]> rtime.felk.cvut.cz Git - arc.git/blobdiff - arch/arm/arm_cr4/drivers/Port.c
LED Blinker running on TMS570LS31x Hercules Development Kit (HDK) (TMS570LS3137ZWT)
[arc.git] / arch / arm / arm_cr4 / drivers / Port.c
index 456ae1a73ccb26019f1a8579f755bfb57f2897bc..fb764f08186c81bcc556c576f17a122a3a78daf4 100644 (file)
@@ -46,17 +46,17 @@ typedef volatile struct
 \r
 #define PORT_NOT_CONFIGURED 0x00000000\r
 \r
-#define PORT_0_BASE ((Port_RegisterType *)0xFFF7BC30)\r
-#define PORT_1_BASE ((Port_RegisterType *)0xFFF7BC50)\r
-#define PORT_2_BASE ((Port_RegisterType *)PORT_NOT_CONFIGURED)\r
+#define PORT_0_BASE ((Port_RegisterType *)0xFFF7BC30)                  // GIO Emulation B register\r
+#define PORT_1_BASE ((Port_RegisterType *)0xFFF7BC50)                  // GIO Pull Select Register A ??\r
+#define PORT_2_BASE ((Port_RegisterType *)0xFFF7B848)                  // N2HET1\r
 #define PORT_3_BASE ((Port_RegisterType *)PORT_NOT_CONFIGURED)\r
 #define PORT_4_BASE ((Port_RegisterType *)PORT_NOT_CONFIGURED)\r
 #define PORT_5_BASE ((Port_RegisterType *)PORT_NOT_CONFIGURED)\r
 #define PORT_6_BASE ((Port_RegisterType *)PORT_NOT_CONFIGURED)\r
 #define PORT_7_BASE ((Port_RegisterType *)PORT_NOT_CONFIGURED)\r
-#define PORT_8_BASE ((Port_RegisterType *)0xFFF7DDE0)\r
-#define PORT_9_BASE ((Port_RegisterType *)0xFFF7DFE0)\r
-#define PORT_10_BASE ((Port_RegisterType *)0xFFF7E1E0)\r
+#define PORT_8_BASE ((Port_RegisterType *)0xFFF7DDE0)                  // DCAN1 TX IO Control Register\r
+#define PORT_9_BASE ((Port_RegisterType *)0xFFF7DFE0)                  // DCAN2 TX IO Control Register\r
+#define PORT_10_BASE ((Port_RegisterType *)0xFFF7E1E0)                 // DCAN3 TX IO Control Register\r
 #define PORT_NUMBER_OF_PORTS 11\r
 \r
 static Port_RegisterType * const Port_Base[] =\r
@@ -83,19 +83,19 @@ static const Port_ConfigType * _configPtr = &PortConfigData;
 #define VALIDATE_PARAM_CONFIG(_ptr,_api) \\r
        if( (_ptr)==((void *)0) ) { \\r
                Det_ReportError(MODULE_ID_PORT, 0, _api, PORT_E_PARAM_CONFIG ); \\r
-               goto cleanup; \\r
+               return; \\r
        }\r
 \r
 #define VALIDATE_STATE_INIT(_api)\\r
        if(PORT_INITIALIZED!=_portState){\\r
                Det_ReportError(MODULE_ID_PORT, 0, _api, PORT_E_UNINIT ); \\r
-               goto cleanup; \\r
+               return; \\r
        }\r
 \r
 #define VALIDATE_PARAM_PIN(_pin, _api)\\r
        if(GET_PIN_PORT(_pin) >= PORT_NUMBER_OF_PORTS || Port_Base[GET_PIN_PORT(_pin)] == PORT_NOT_CONFIGURED || GET_PIN_PIN(_pin) > 7 ){\\r
                Det_ReportError(MODULE_ID_PORT, 0, _api, PORT_E_PARAM_PIN ); \\r
-               goto cleanup; \\r
+               return; \\r
        }\r
 \r
 #else\r
@@ -130,10 +130,7 @@ void Port_RefreshPin(uint16 pinNumber) {
        }\r
 \r
        // Set pin direction\r
-       if (conf & PORT_PIN_IN) {\r
-               Port_Base[port]->DIR &= ~mask;\r
-\r
-       } else {\r
+       if (conf & PORT_PIN_OUT) {\r
                Port_Base[port]->DIR |= mask;\r
 \r
                // Set open drain\r
@@ -142,6 +139,9 @@ void Port_RefreshPin(uint16 pinNumber) {
                } else {\r
                        Port_Base[port]->PDR &= ~mask;\r
                }\r
+\r
+       } else {\r
+               Port_Base[port]->DIR &= ~mask;\r
        }\r
 \r
        // Set pull up or down or nothing.\r
@@ -169,13 +169,17 @@ void Port_Init(const Port_ConfigType *configType) {
        // Bring GIO register out of reset.\r
        gioREG->GCR0 = 1;\r
 \r
+       /* Hack to connect N2HET1[27] (function 2) to pin A9 */\r
+       *(volatile uint32*)0xFFFFEB10 &= ~0xFF000000;\r
+       *(volatile uint32*)0xFFFFEB10 |= ~0x04000000;\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
+       return;\r
 }\r
 \r
 #if ( PORT_SET_PIN_DIRECTION_API == STD_ON )\r
@@ -195,7 +199,7 @@ void Port_SetPinDirection( Port_PinType pin, Port_PinDirectionType direction )
 \r
        }\r
 \r
-cleanup:return;\r
+       return;\r
 }\r
 #endif\r
 \r
@@ -207,7 +211,7 @@ void Port_RefreshPortDirection( void )
                        Port_RefreshPin(i);\r
                }\r
        }\r
-cleanup:return;\r
+       return;\r
 }\r
 \r
 \r
@@ -216,7 +220,7 @@ void Port_GetVersionInfo(Std_VersionInfoType* versionInfo)
 {\r
   VALIDATE_STATE_INIT(PORT_GET_VERSION_INFO_ID);\r
   memcpy(versionInfo, &_Port_VersionInfo, sizeof(Std_VersionInfoType));\r
-  cleanup: return;\r
+  return;\r
 }\r
 #endif\r
 \r
@@ -231,6 +235,6 @@ void Port_SetPinMode(Port_PinType Pin, Port_PinModeType Mode) {
 \r
     Port_Base[port]->FUN &= ~mask;\r
     Port_Base[port]->FUN |= ((Mode & 1) << pin);\r
-    cleanup: return;\r
+    return;\r
 }\r
 #endif\r