From: Leos Mikulka Date: Fri, 3 May 2013 08:23:17 +0000 (+0200) Subject: LED Blinker example made running for the RPP Board. X-Git-Url: http://rtime.felk.cvut.cz/gitweb/arc.git/commitdiff_plain/79cf0308001e35225531aa542b87fda205b0ffaa?hp=60966c493db6916acb0f8d9beaa9c1e77c206ef2 LED Blinker example made running for the RPP Board. --- diff --git a/arch/arm/arm_cr4/drivers/Dio.c b/arch/arm/arm_cr4/drivers/Dio.c index 69130922..26b915b5 100644 --- a/arch/arm/arm_cr4/drivers/Dio.c +++ b/arch/arm/arm_cr4/drivers/Dio.c @@ -21,7 +21,7 @@ #include #include "../kernel/core_cr4.h" -GIO_RegisterType *GPIO_ports[] = { GIO_PORTA_BASE, GIO_PORTB_BASE, GIO_HET_PORT1_BASE }; +GIO_RegisterType *GPIO_ports[] = { GIO_PORTA_BASE, GIO_PORTB_BASE, GIO_HET_PORT1_BASE, GIO_DMM_PORT_BASE }; #define DIO_GET_PORT_FROM_CHANNEL_ID(_channelId) (_channelId >> 8) #define DIO_GET_BIT_FROM_CHANNEL_ID(_channelId) (1 << (_channelId & 0x1F)) @@ -113,7 +113,7 @@ void Dio_WritePort(Dio_PortType portId, Dio_PortLevelType level) { VALIDATE_PORT(portId, DIO_WRITEPORT_ID); - GPIO_ports[portId]->DOUT = (uint32)level; + GPIO_ports[portId]->DOUT = (uint16)level; // uint32 for TMS570LS3137HDK, uint16 for RPP #if ( DIO_DEV_ERROR_DETECT == STD_ON ) cleanup: diff --git a/arch/arm/arm_cr4/drivers/Port.c b/arch/arm/arm_cr4/drivers/Port.c index 67446fbe..f44ca374 100644 --- a/arch/arm/arm_cr4/drivers/Port.c +++ b/arch/arm/arm_cr4/drivers/Port.c @@ -46,10 +46,10 @@ typedef volatile struct #define PORT_NOT_CONFIGURED 0x00000000 -#define PORT_0_BASE ((Port_RegisterType *)0xFFF7BC30) -#define PORT_1_BASE ((Port_RegisterType *)0xFFF7BC50) +#define PORT_0_BASE ((Port_RegisterType *)0xFFF7BC30) // GIO Port A +#define PORT_1_BASE ((Port_RegisterType *)0xFFF7BC50) // GIO Port B #define PORT_2_BASE ((Port_RegisterType *)0xFFF7B848) // N2HET1 Base -#define PORT_3_BASE ((Port_RegisterType *)PORT_NOT_CONFIGURED) +#define PORT_3_BASE ((Port_RegisterType *)0xFFFFF76C) // DMM used as a GIO #define PORT_4_BASE ((Port_RegisterType *)PORT_NOT_CONFIGURED) #define PORT_5_BASE ((Port_RegisterType *)PORT_NOT_CONFIGURED) #define PORT_6_BASE ((Port_RegisterType *)PORT_NOT_CONFIGURED) @@ -187,9 +187,9 @@ static Std_VersionInfoType _Port_VersionInfo = #endif void Port_RefreshPin(uint16 pinNumber) { - uint8 port = GET_PIN_PORT(_configPtr->pins[pinNumber].pin); + uint32 port = GET_PIN_PORT(_configPtr->pins[pinNumber].pin); uint32 mask = GET_PIN_MASK(_configPtr->pins[pinNumber].pin); - uint16 conf = _configPtr->pins[pinNumber].conf; + uint32 conf = _configPtr->pins[pinNumber].conf; uint32 pinmux = _configPtr->pins[pinNumber].pinmux; uint8 pinmuxFunctionNum = _configPtr->pins[pinNumber].pinmuxFunctionNum; @@ -243,7 +243,7 @@ void Port_RefreshPin(uint16 pinNumber) { } -void Port_Init(const Port_ConfigType *configType) { +void Port_Init(const Port_ConfigType *configType) { // note: HalCoGen: gioInit VALIDATE_PARAM_CONFIG(configType, PORT_INIT_ID); _configPtr = (Port_ConfigType *)configType; @@ -256,12 +256,42 @@ void Port_Init(const Port_ConfigType *configType) { for (uint16 i = 0; i < PORT_NUMBER_OF_PINS; i++) { Port_RefreshPin(i); } + if (DMM_USED) { + for (uint16 i = 0; i < PORT_NUMBER_OF_PINS; i++) { + Dmm_Init(i); + } + } _portState = PORT_INITIALIZED; return; } +void Dmm_Init(uint16 pinNumber) { + + dmmReg->GLBCTRL= 0x00000605; /* DMM switched ON, set 32 bit length */ + //dmmReg->GLBCTRL = 0x5; // don't use DMM_Reset + + uint32 port = GET_PIN_PORT(_configPtr->pins[pinNumber].pin); + uint32 mask = GET_PIN_MASK(_configPtr->pins[pinNumber].pin); + + Port_Base[port]->FUN |= ~mask; // pin usage: 1 - functional, 0 - GIO + //Port_Base[port]->FUN = 0x00000000; + //Port_Base[port]->DIR = 0x00000001; + 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) + Port_Base[port]->PSL &= ~mask; // pull-up/pull-down selection: 0 - pull-down, 1 - pull-up +} + +void Dmm_Reset(const Port_ConfigType *configType) { + VALIDATE_PARAM_CONFIG(configType, PORT_INIT_ID); + + _configPtr = (Port_ConfigType *)configType; + + uint32 mask = GET_PIN_MASK(_configPtr->pins[0].pin); + dmmReg->GLBCTRL |= mask; + dmmReg->GLBCTRL &= ~mask; +} + #if ( PORT_SET_PIN_DIRECTION_API == STD_ON ) void Port_SetPinDirection( Port_PinType pin, Port_PinDirectionType direction ) { diff --git a/communication/CanIf/CanIf.c b/communication/CanIf/CanIf.c index 14bc8d20..7f27d792 100644 --- a/communication/CanIf/CanIf.c +++ b/communication/CanIf/CanIf.c @@ -463,7 +463,7 @@ Std_ReturnType CanIf_Transmit(PduIdType CanTxPduId, canPdu.length = PduInfoPtr->SduLength; canPdu.sdu = PduInfoPtr->SduDataPtr; - canPdu.swPduHandle = CanTxPduId; + canPdu.swPduHandle = CanTxPduId; // e.g. ARC_PDUR_CANIF Can_ReturnType rVal = Can_Write(txEntry->CanIfCanTxPduHthRef->CanIfHthIdSymRef, &canPdu); diff --git a/include/Port.h b/include/Port.h index a5fa82d9..b393437e 100644 --- a/include/Port.h +++ b/include/Port.h @@ -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