]> rtime.felk.cvut.cz Git - arc.git/blobdiff - arch/arm/arm_cr4/drivers/Port.c
LED Blinker example made running for the RPP Board.
[arc.git] / arch / arm / arm_cr4 / drivers / Port.c
index 67446fbeac69a6a4a79b7409128a6c624fcc34f4..f44ca374333b4f0fb12ba392b8366c2423ad6784 100644 (file)
@@ -46,10 +46,10 @@ 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_0_BASE ((Port_RegisterType *)0xFFF7BC30)                  // GIO Port A\r
+#define PORT_1_BASE ((Port_RegisterType *)0xFFF7BC50)                  // GIO Port B\r
 #define PORT_2_BASE ((Port_RegisterType *)0xFFF7B848)                  // N2HET1 Base\r
-#define PORT_3_BASE ((Port_RegisterType *)PORT_NOT_CONFIGURED)\r
+#define PORT_3_BASE ((Port_RegisterType *)0xFFFFF76C)                  // DMM used as a GIO\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
@@ -187,9 +187,9 @@ static Std_VersionInfoType _Port_VersionInfo =
 #endif\r
 \r
 void Port_RefreshPin(uint16 pinNumber) {\r
-       uint8 port = GET_PIN_PORT(_configPtr->pins[pinNumber].pin);\r
+       uint32 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
+       uint32 conf = _configPtr->pins[pinNumber].conf;\r
 \r
        uint32 pinmux = _configPtr->pins[pinNumber].pinmux;\r
        uint8 pinmuxFunctionNum = _configPtr->pins[pinNumber].pinmuxFunctionNum;\r
@@ -243,7 +243,7 @@ void Port_RefreshPin(uint16 pinNumber) {
 }\r
 \r
 \r
-void Port_Init(const Port_ConfigType *configType) {\r
+void Port_Init(const Port_ConfigType *configType) {            // note: HalCoGen: gioInit\r
        VALIDATE_PARAM_CONFIG(configType, PORT_INIT_ID);\r
 \r
        _configPtr = (Port_ConfigType *)configType;\r
@@ -256,12 +256,42 @@ void Port_Init(const Port_ConfigType *configType) {
        for (uint16 i = 0; i < PORT_NUMBER_OF_PINS; i++) {\r
                Port_RefreshPin(i);\r
        }\r
+       if (DMM_USED) {\r
+               for (uint16 i = 0; i < PORT_NUMBER_OF_PINS; i++) {\r
+                       Dmm_Init(i);\r
+               }\r
+       }\r
 \r
        _portState = PORT_INITIALIZED;\r
 \r
        return;\r
 }\r
 \r
+void Dmm_Init(uint16 pinNumber) {\r
+\r
+       dmmReg->GLBCTRL= 0x00000605; /* DMM switched ON, set 32 bit length */\r
+       //dmmReg->GLBCTRL = 0x5; // don't use DMM_Reset\r
+\r
+       uint32 port = GET_PIN_PORT(_configPtr->pins[pinNumber].pin);\r
+       uint32 mask = GET_PIN_MASK(_configPtr->pins[pinNumber].pin);\r
+\r
+       Port_Base[port]->FUN |= ~mask;                  // pin usage: 1 - functional, 0 - GIO\r
+       //Port_Base[port]->FUN = 0x00000000;\r
+       //Port_Base[port]->DIR = 0x00000001;\r
+       Port_Base[port]->DIR = 0x7FFFF;                 // I/O selection: 0 - input, 1 - output (not necessary but assures that all DMM GIO pins are used as outputs in our example)\r
+       Port_Base[port]->PSL &= ~mask;                  // pull-up/pull-down selection: 0 - pull-down, 1 - pull-up\r
+}\r
+\r
+void Dmm_Reset(const Port_ConfigType *configType) {\r
+       VALIDATE_PARAM_CONFIG(configType, PORT_INIT_ID);\r
+\r
+       _configPtr = (Port_ConfigType *)configType;\r
+\r
+       uint32 mask = GET_PIN_MASK(_configPtr->pins[0].pin);\r
+       dmmReg->GLBCTRL |= mask;\r
+       dmmReg->GLBCTRL &= ~mask;\r
+}\r
+\r
 #if ( PORT_SET_PIN_DIRECTION_API == STD_ON )\r
 void Port_SetPinDirection( Port_PinType pin, Port_PinDirectionType direction )\r
 {\r