]> rtime.felk.cvut.cz Git - arc.git/commitdiff
More work on PORT driver for Cortex R4.
authormaek <devnull@localhost>
Fri, 10 Dec 2010 09:05:36 +0000 (10:05 +0100)
committermaek <devnull@localhost>
Fri, 10 Dec 2010 09:05:36 +0000 (10:05 +0100)
arch/arm/arm_cr4/drivers/Port.c
boards/ti_tms570ls/config/Port_Cfg.c
boards/ti_tms570ls/config/Port_Cfg.h

index 1232fcbcf68e3db2bbe69849f7e0a0844aa09add..ac7467e23671626189a5babd82d6b1b264065982 100644 (file)
@@ -119,60 +119,81 @@ static Std_VersionInfoType _Port_VersionInfo =
 };\r
 #endif\r
 \r
-void Port_Init(const Port_ConfigType *configType) {\r
-       VALIDATE_PARAM_CONFIG(configType, PORT_INIT_ID);\r
+void Port_RefreshPin(uint16 pinNumber) {\r
+       uint8 port = GET_PIN_PORT(_configPtr->pins[pinNumber].pin);\r
+       uint32 mask = GET_PIN_MASK(_configPtr->pins[pinNumber].pin);\r
+       uint16 conf = _configPtr->pins[pinNumber].conf;\r
+\r
+       if (conf & PORT_FUNC) {\r
+               // Don't do anything, let each driver configure???\r
+               return;\r
+       }\r
 \r
-       // Bring GIO register out of reset.\r
-       gioREG->GCR0 = 1;\r
+       // Set pin direction\r
+       if (conf & PORT_PIN_IN) {\r
+               Port_Base[port]->DIR &= ~mask;\r
 \r
-       for (uint16 i = 0; i < PORT_NUMBER_OF_PINS; i++) {\r
-               uint8 port = GET_PIN_PORT(configType->pins[i].pin);\r
-               uint32 mask = GET_PIN_MASK(configType->pins[i].pin);\r
-               uint16 conf = configType->pins[i].conf;\r
+       } else {\r
+               Port_Base[port]->DIR |= mask;\r
 \r
-               if (conf & PORT_FUNC) {\r
-                       // Don't do anything, let each driver configure???\r
-                       continue;\r
+               // Set open drain\r
+               if (conf & PORT_ODE_ENABLE) {\r
+                       Port_Base[port]->PDR |= mask;\r
+               } else {\r
+                       Port_Base[port]->PDR &= ~mask;\r
                }\r
+       }\r
+\r
+       // Set pull up or down or nothing.\r
+       if (conf & PORT_PULL_NONE) {\r
+               Port_Base[port]->PULDIS |= mask;\r
 \r
-               // Set pin direction\r
-               if (conf & PORT_PIN_IN) {\r
-                       Port_Base[port]->DIR &= ~mask;\r
+       } else {\r
+               Port_Base[port]->PULDIS &= ~mask;\r
+               if (conf & PORT_PULL_UP) {\r
+                       Port_Base[port]->PSL |= mask;\r
 \r
                } else {\r
-                       Port_Base[port]->DIR |= mask;\r
-\r
-                       // Set open drain\r
-                       if (conf & PORT_ODE_ENABLE) {\r
-                               Port_Base[port]->PDR |= mask;\r
-                       } else {\r
-                               Port_Base[port]->PDR &= ~mask;\r
-                       }\r
+                       Port_Base[port]->PSL &= ~mask;\r
                }\r
+       }\r
+}\r
 \r
-               // Set pull up or down or nothing.\r
-               if (conf & PORT_PULL_NONE) {\r
-                       Port_Base[port]->PULDIS |= mask;\r
 \r
-               } else {\r
-                       Port_Base[port]->PULDIS &= ~mask;\r
-                       if (conf & PORT_PULL_UP) {\r
-                               Port_Base[port]->PSL |= mask;\r
 \r
-                       } else {\r
-                               Port_Base[port]->PSL &= ~mask;\r
-                       }\r
-               }\r
+void Port_Init(const Port_ConfigType *configType) {\r
+       VALIDATE_PARAM_CONFIG(configType, PORT_INIT_ID);\r
+\r
+       _configPtr = (Port_ConfigType *)configType;\r
+\r
+       // Bring GIO register out of reset.\r
+       gioREG->GCR0 = 1;\r
+\r
+       for (uint16 i = 0; i < PORT_NUMBER_OF_PINS; i++) {\r
+               Port_RefreshPin(i);\r
        }\r
+\r
+       _portState = PORT_INITIALIZED;\r
+\r
        cleanup:return;\r
 }\r
 \r
 #if ( PORT_SET_PIN_DIRECTION_API == STD_ON )\r
 void Port_SetPinDirection( Port_PinType pin, Port_PinDirectionType direction )\r
 {\r
-  VALIDATE_STATE_INIT(PORT_SET_PIN_DIRECTION_ID);\r
-  VALIDATE_PARAM_PIN(pin, PORT_SET_PIN_DIRECTION_ID);\r
-  // TODO IMPLEMENT!\r
+       VALIDATE_STATE_INIT(PORT_SET_PIN_DIRECTION_ID);\r
+       VALIDATE_PARAM_PIN(pin, PORT_SET_PIN_DIRECTION_ID);\r
+\r
+       uint8 port = GET_PIN_PORT(pin);\r
+       uint32 mask = GET_PIN_MASK(pin);\r
+\r
+       if (direction & PORT_PIN_IN) {\r
+               Port_Base[port]->DIR &= ~mask;\r
+\r
+       } else {\r
+               Port_Base[port]->DIR |= mask;\r
+\r
+       }\r
 \r
 cleanup:return;\r
 }\r
@@ -180,9 +201,14 @@ cleanup:return;
 \r
 void Port_RefreshPortDirection( void )\r
 {\r
-       // TODO IMPLEMENT!\r
+       for (uint16 i = 0; i < PORT_NUMBER_OF_PINS; i++) {\r
+               if (!(_configPtr->pins[i].conf & PORT_DIRECTION_CHANGEABLE)) {\r
+                       Port_RefreshPin(i);\r
+               }\r
+       }\r
 }\r
 \r
+\r
 #if PORT_VERSION_INFO_API == STD_ON\r
 void Port_GetVersionInfo(Std_VersionInfoType* versionInfo)\r
 {\r
@@ -197,11 +223,7 @@ void Port_SetPinMode(Port_PinType Pin, Port_PinModeType Mode) {
        uint8 port = GET_PIN_PORT(Pin);\r
        uint8 pin = GET_PIN_PIN(Pin);\r
        uint32 mask = GET_PIN_MASK(Pin);\r
-/*\r
-    Port_PinType pin  = Pin & 0x1F;\r
-    Port_PinType port = Pin >> 8;\r
-    Port_PinType mask = 1 << pin;\r
-*/\r
+\r
     Port_Base[port]->FUN &= ~mask;\r
     Port_Base[port]->FUN |= ((Mode & 1) << pin);\r
 }\r
index f0f4307914e140c642d5097967dd79c8768a94ee..acae5bb7a63e19d7d216dd571533b1240f7e57df 100644 (file)
@@ -9,7 +9,7 @@
  *\r
  * \r
  * Generated by Arctic Studio (http://arccore.com) \r
- *           on Fri Dec 10 07:52:22 CET 2010\r
+ *           on Fri Dec 10 08:23:08 CET 2010\r
  */\r
 \r
        \r
@@ -23,7 +23,7 @@ const Port_ConfigType PortConfigData =
     .pins = {\r
        {\r
                        .pin = PORT_PIN_DCAN1_TX,\r
-                       .conf = ( PORT_PIN_OUT | PORT_FUNC | PORT_PULL_NONE ),\r
+                       .conf = ( PORT_PIN_OUT | PORT_FUNC | PORT_PULL_NONE | PORT_DIRECTION_CHANGEABLE ),\r
                },                       \r
        {\r
                        .pin = PORT_PIN_DCAN1_RX,\r
index 57454ddd97dff8b59ed98faedcb02f39bad3b4f9..e53e368b8539ac1489681965f225895802d0d146 100644 (file)
@@ -9,7 +9,7 @@
  *\r
  * \r
  * Generated by Arctic Studio (http://arccore.com) \r
- *           on Fri Dec 10 07:52:22 CET 2010\r
+ *           on Fri Dec 10 08:23:08 CET 2010\r
  */\r
 \r
 
@@ -41,6 +41,7 @@
 #define PORT_PULL_UP   (1 << 3)\r
 #define PORT_PULL_DOWN (0 << 3)\r
 #define PORT_ODE_ENABLE        (1 << 4)\r
+#define PORT_DIRECTION_CHANGEABLE (1 << 5)\r
 \r
 /** HW specific symbolic names of pins */\r
 /** @req PORT013 */\r