]> rtime.felk.cvut.cz Git - arc.git/commitdiff
LED Blinker example made running for the RPP Board.
authorLeos Mikulka <mikulleo@fel.cvut.cz>
Fri, 3 May 2013 08:23:17 +0000 (10:23 +0200)
committerLeos Mikulka <mikulleo@fel.cvut.cz>
Fri, 3 May 2013 08:23:17 +0000 (10:23 +0200)
arch/arm/arm_cr4/drivers/Dio.c
arch/arm/arm_cr4/drivers/Port.c
communication/CanIf/CanIf.c
include/Port.h

index 6913092231bf343879235d1dff4de86b42a323ae..26b915b57ed1e32d65f1d7636ced7319c0ed6a06 100644 (file)
@@ -21,7 +21,7 @@
 #include <string.h>\r
 #include "../kernel/core_cr4.h"\r
 \r
-GIO_RegisterType *GPIO_ports[] = { GIO_PORTA_BASE, GIO_PORTB_BASE, GIO_HET_PORT1_BASE };\r
+GIO_RegisterType *GPIO_ports[] = { GIO_PORTA_BASE, GIO_PORTB_BASE, GIO_HET_PORT1_BASE, GIO_DMM_PORT_BASE };\r
 \r
 #define DIO_GET_PORT_FROM_CHANNEL_ID(_channelId) (_channelId >> 8)\r
 #define DIO_GET_BIT_FROM_CHANNEL_ID(_channelId) (1 << (_channelId & 0x1F))\r
@@ -113,7 +113,7 @@ void Dio_WritePort(Dio_PortType portId, Dio_PortLevelType level)
 {\r
     VALIDATE_PORT(portId, DIO_WRITEPORT_ID);\r
 \r
-       GPIO_ports[portId]->DOUT = (uint32)level;\r
+       GPIO_ports[portId]->DOUT = (uint16)level;       // uint32 for TMS570LS3137HDK, uint16 for RPP\r
 \r
 #if ( DIO_DEV_ERROR_DETECT == STD_ON )\r
        cleanup:\r
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
index 14bc8d2031683e026e3aec50999e66f6c0593d4e..7f27d79299b517ec977af4baf2f8abea6c088db7 100644 (file)
@@ -463,7 +463,7 @@ Std_ReturnType CanIf_Transmit(PduIdType CanTxPduId,
 \r
   canPdu.length = PduInfoPtr->SduLength;\r
   canPdu.sdu = PduInfoPtr->SduDataPtr;\r
-  canPdu.swPduHandle = CanTxPduId;\r
+  canPdu.swPduHandle = CanTxPduId;             // e.g. ARC_PDUR_CANIF\r
 \r
   Can_ReturnType rVal = Can_Write(txEntry->CanIfCanTxPduHthRef->CanIfHthIdSymRef, &canPdu);\r
 \r
index a5fa82d9f8a5e63bdb2d82ea99816ffc678066df..b393437e37948eaae071e3787270bf927239364e 100644 (file)
@@ -60,6 +60,27 @@ void Port_GetVersionInfo(Std_VersionInfoType *versionInfo);
 #define PORT_SET_PIN_MODE_ID            0x04
 //@}
 
+/** @name DMM defines */
+#define DMM_SYNC               0
+#define DMM_CLK                        1
+#define DMM_DATA0              2
+#define DMM_DATA1              3
+#define DMM_DATA2              4
+#define DMM_DATA3              5
+#define DMM_DATA4              6
+#define DMM_DATA5              7
+#define DMM_DATA6              8
+#define DMM_DATA7              9
+#define DMM_DATA8              10
+#define DMM_DATA9              11
+#define DMM_DATA10             12
+#define DMM_DATA11             13
+#define DMM_DATA12             14
+#define DMM_DATA13             15
+#define DMM_DATA14             16
+#define DMM_DATA15             17
+#define DMM_ENA                        18
+
 /** @req PORT046
  * The type Port_PinDirectionType is a type for defining the direction of a Port Pin.
  * PORT_PIN_IN Sets port pin as input. 
@@ -79,6 +100,9 @@ typedef uint32 Port_PinModeType;
 
 void Port_Init(const Port_ConfigType *configType);
 
+void Dmm_Init(uint16 pinNumber);       // Dmm will be used as a GIO
+void Dmm_Reset(const Port_ConfigType *configType);
+
 #if ( PORT_SET_PIN_DIRECTION_API == STD_ON )
 void Port_SetPinDirection(Port_PinType pin, Port_PinDirectionType direction);
 #endif