42 #define _________________________________________LOCAL_MACROS_SECTION_______________________________________________________________________ 44 #define PORT(Pins) oC_Pin_GetPort(Pins) 45 #define PORT_INDEX(Pins) oC_Channel_ToIndex(GPIO , PORT(Pins)) 46 #define PINS(Pins) oC_Pin_GetPinsInPort(Pins) 47 #define IsPoweredOn(Pins) oC_Machine_IsChannelPoweredOn(PORT(Pins)) 48 #define GPIODATA(Pins) oC_Machine_Register(PORT(Pins),GPIODATA) 49 #define GPIOCR(Pins) oC_Machine_Register(PORT(Pins),GPIOCR) 50 #define GPIODEN(Pins) oC_Machine_Register(PORT(Pins),GPIODEN) 51 #define GPIODR2R(Pins) oC_Machine_Register(PORT(Pins),GPIODR2R) 52 #define GPIODR4R(Pins) oC_Machine_Register(PORT(Pins),GPIODR4R) 53 #define GPIODR8R(Pins) oC_Machine_Register(PORT(Pins),GPIODR8R) 54 #define GPIODIR(Pins) oC_Machine_Register(PORT(Pins),GPIODIR) 55 #define GPIOAFSEL(Pins) oC_Machine_Register(PORT(Pins),GPIOAFSEL) 56 #define GPIOPUR(Pins) oC_Machine_Register(PORT(Pins),GPIOPUR) 57 #define GPIOPDR(Pins) oC_Machine_Register(PORT(Pins),GPIOPDR) 58 #define GPIOPCTL(Pins) oC_Machine_Register(PORT(Pins),GPIOPCTL) 59 #define GPIOODR(Pins) oC_Machine_Register(PORT(Pins),GPIOODR) 60 #define GPIOIM(Pins) oC_Machine_Register(PORT(Pins),GPIOIM) 61 #define GPIOIS(Pins) oC_Machine_Register(PORT(Pins),GPIOIS) 62 #define GPIOIBE(Pins) oC_Machine_Register(PORT(Pins),GPIOIBE) 63 #define GPIOIEV(Pins) oC_Machine_Register(PORT(Pins),GPIOIEV) 64 #define IsRam(Address) oC_LSF_IsRamAddress(Address) 65 #define IsRom(Address) oC_LSF_IsRomAddress(Address) 67 #undef _________________________________________LOCAL_MACROS_SECTION_______________________________________________________________________ 74 #define _________________________________________MAIN_DRIVER_CONNECTIONS_SECTION____________________________________________________________ 76 oC_LLD_ConnectToMainDriver(GPIO,IsPortCorrect);
77 oC_LLD_ConnectToMainDriver(GPIO,IsPortIndexCorrect);
78 oC_LLD_ConnectToMainDriver(GPIO,GetPinsMaskOfPins);
79 oC_LLD_ConnectToMainDriver(GPIO,GetPortOfPins);
80 oC_LLD_ConnectToMainDriver(GPIO,PortToPortIndex);
81 oC_LLD_ConnectToMainDriver(GPIO,PortIndexToPort);
82 oC_LLD_ConnectToMainDriver(GPIO,IsPinDefined);
83 oC_LLD_ConnectToMainDriver(GPIO,ArePinsDefined);
84 oC_LLD_ConnectToMainDriver(GPIO,ArePinsCorrect);
85 oC_LLD_ConnectToMainDriver(GPIO,IsSinglePin);
86 oC_LLD_ConnectToMainDriver(GPIO,GetPinsFor);
87 oC_LLD_ConnectToMainDriver(GPIO,GetPortName);
88 oC_LLD_ConnectToMainDriver(GPIO,GetPinName);
89 oC_LLD_ConnectToMainDriver(GPIO,SetPower);
90 oC_LLD_ConnectToMainDriver(GPIO,ReadPower);
91 oC_LLD_ConnectToMainDriver(GPIO,CheckIsPinUsed);
92 oC_LLD_ConnectToMainDriver(GPIO,ArePinsUnused);
93 oC_LLD_ConnectToMainDriver(GPIO,
WriteData);
94 oC_LLD_ConnectToMainDriver(GPIO,
ReadData);
95 oC_LLD_ConnectToMainDriver(GPIO,ReadDataReference);
96 oC_LLD_ConnectToMainDriver(GPIO,GetHighStatePins);
97 oC_LLD_ConnectToMainDriver(GPIO,GetLowStatePins);
98 oC_LLD_ConnectToMainDriver(GPIO,IsPinsState);
99 oC_LLD_ConnectToMainDriver(GPIO,SetPinsState);
100 oC_LLD_ConnectToMainDriver(GPIO,TogglePinsState);
101 oC_LLD_ConnectToMainDriver(GPIO,GetPinName);
103 #undef _________________________________________MAIN_DRIVER_CONNECTIONS_SECTION____________________________________________________________ 110 #define _________________________________________LOCAL_VARIABLES_SECTION____________________________________________________________________ 115 #undef _________________________________________LOCAL_VARIABLES_SECTION____________________________________________________________________ 123 #define _________________________________________INTERFACE_FUNCTIONS_SECTION_______________________________________________________________ 131 oC_ErrorCode_t oC_GPIO_LLD_TurnOnDriver(
void )
133 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
141 oC_GPIO_LLD_ForEachPort(port)
147 errorCode = oC_ErrorCode_None;
161 oC_ErrorCode_t oC_GPIO_LLD_TurnOffDriver(
void )
163 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
172 errorCode = oC_ErrorCode_None;
186 bool oC_GPIO_LLD_IsPortCorrect( oC_Port_t Port )
197 bool oC_GPIO_LLD_IsPortIndexCorrect( oC_PortIndex_t PortIndex )
208 oC_PinsMask_t oC_GPIO_LLD_GetPinsMaskOfPins( oC_Pins_t Pins )
219 oC_Port_t oC_GPIO_LLD_GetPortOfPins( oC_Pins_t Pins )
230 oC_PortIndex_t oC_GPIO_LLD_PortToPortIndex( oC_Port_t Port )
241 oC_Port_t oC_GPIO_LLD_PortIndexToPort( oC_PortIndex_t PortIndex )
252 bool oC_GPIO_LLD_IsPinDefined( oC_Pins_t Pin )
254 bool defined =
false;
256 oC_Pin_ForeachDefined(pin)
274 bool oC_GPIO_LLD_ArePinsDefined( oC_Pins_t Pins )
276 bool allDefined =
false;
277 oC_Port_t port = PORT(Pins);
278 oC_PinsInPort_t pins = PINS(Pins);
284 for(uint8_t bitIndex = 0; bitIndex < oC_PORT_WIDTH && allDefined; bitIndex++ )
286 if(pins & (1<<bitIndex))
288 allDefined = oC_GPIO_LLD_IsPinDefined(oC_Pins_ToSinglePin(Pins,bitIndex));
302 bool oC_GPIO_LLD_ArePinsCorrect( oC_Pins_t Pins )
313 bool oC_GPIO_LLD_IsSinglePin( oC_Pins_t Pins )
315 bool isSinglePin =
false;
316 oC_PinsInPort_t pins = PINS(Pins);
318 for(uint8_t bitIndex = 0; bitIndex < oC_PORT_WIDTH ; bitIndex++)
320 if(pins & (1<<bitIndex))
322 isSinglePin = oC_Pins_ToSinglePin(Pins,bitIndex) == Pins;
336 oC_Pins_t oC_GPIO_LLD_GetPinsFor( oC_Port_t Port , oC_PinsMask_t Pins )
338 return oC_Pin_Make(Port,Pins);
347 const char * oC_GPIO_LLD_GetPortName( oC_Port_t Port )
358 const char * oC_GPIO_LLD_GetPinName( oC_Pins_t Pin )
360 const char * name =
"<INCORRECT_PIN>";
361 oC_Port_t port = PORT(Pin);
365 name =
"<UNDEFINED_PIN>";
367 oC_Pin_ForeachDefined(pinData)
369 if(pinData->Pin == Pin)
371 name = pinData->Name;
386 oC_ErrorCode_t oC_GPIO_LLD_SetDriverInterruptHandler( oC_GPIO_LLD_Interrupt_t Handler )
388 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
393 ErrorCondition( IsRam(Handler) || IsRom(Handler), oC_ErrorCode_WrongEventHandlerAddress) &&
398 errorCode = oC_ErrorCode_None;
411 oC_ErrorCode_t oC_GPIO_LLD_BeginConfiguration( oC_Pins_t Pins )
413 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
418 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins) , oC_ErrorCode_WrongChannel) &&
419 ErrorCondition( PINS(Pins) != 0 , oC_ErrorCode_PinNotDefined) &&
424 errorCode = oC_ErrorCode_None;
437 oC_ErrorCode_t oC_GPIO_LLD_FinishConfiguration( oC_Pins_t Pins )
439 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
444 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
445 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined)
448 errorCode = oC_ErrorCode_None;
461 oC_ErrorCode_t oC_GPIO_LLD_SetPower( oC_Pins_t Pins ,
oC_Power_t Power )
463 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
468 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
469 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
475 errorCode = oC_ErrorCode_None;
479 errorCode = oC_ErrorCode_CannotEnableChannel;
493 oC_ErrorCode_t oC_GPIO_LLD_ReadPower( oC_Pins_t Pins ,
oC_Power_t * outPower )
495 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
500 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
501 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
502 ErrorCondition( IsRam(outPower), oC_ErrorCode_OutputAddressNotInRAM)
510 errorCode = oC_ErrorCode_None;
514 *outPower = powerState;
515 errorCode = oC_ErrorCode_None;
519 errorCode = oC_ErrorCode_MachineCanBeDamaged;
533 bool oC_GPIO_LLD_IsPinProtected( oC_Pins_t Pins )
535 bool pinProtected =
false;
539 pinProtected = (~GPIOCR(Pins)->Value) & PINS(Pins);;
551 oC_ErrorCode_t oC_GPIO_LLD_UnlockProtection( oC_Pins_t Pins , oC_GPIO_LLD_Protection_t Protection )
553 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
558 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
559 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
560 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
561 ErrorCondition( Protection == oC_GPIO_LLD_Protection_UnlockProtectedPins, oC_ErrorCode_PinNeedUnlock)
567 GPIOCR(Pins)->Value |= PINS(Pins);
568 GPIODEN(Pins)->Value |= PINS(Pins);
572 errorCode = oC_ErrorCode_None;
587 oC_ErrorCode_t oC_GPIO_LLD_LockProtection( oC_Pins_t Pins )
589 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
594 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
595 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
596 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn)
603 GPIOCR(Pins)->Value &= ~PINS(Pins);
604 GPIODEN(Pins)->Value &= ~PINS(Pins);
608 errorCode = oC_ErrorCode_None;
623 oC_ErrorCode_t oC_GPIO_LLD_CheckIsPinUnlocked( oC_Pins_t Pins ,
bool * outPinUnlocked )
625 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
630 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
631 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
632 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
633 ErrorCondition( IsRam(outPinUnlocked), oC_ErrorCode_OutputAddressNotInRAM)
640 *outPinUnlocked = (GPIOCR(Pins)->Value & PINS(Pins)) == PINS(Pins);
644 errorCode = oC_ErrorCode_None;
659 oC_ErrorCode_t oC_GPIO_LLD_SetSpeed( oC_Pins_t Pins , oC_GPIO_LLD_Speed_t Speed )
661 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
666 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel ) &&
667 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined ) &&
668 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn ) &&
669 ErrorCondition( Speed == oC_GPIO_LLD_Speed_Default, oC_ErrorCode_NotSupportedOnTargetMachine)
672 errorCode = oC_ErrorCode_None;
685 oC_ErrorCode_t oC_GPIO_LLD_ReadSpeed( oC_Pins_t Pins , oC_GPIO_LLD_Speed_t * outSpeed )
687 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
692 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
693 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
694 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
695 ErrorCondition( IsRam(outSpeed), oC_ErrorCode_OutputAddressNotInRAM)
698 *outSpeed = oC_GPIO_LLD_Speed_Maximum;
699 errorCode = oC_ErrorCode_None;
713 oC_ErrorCode_t oC_GPIO_LLD_SetCurrent( oC_Pins_t Pins , oC_GPIO_LLD_Current_t Current )
715 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
720 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
721 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
722 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn)
725 errorCode = oC_ErrorCode_None;
729 case oC_GPIO_LLD_Current_Default:
730 case oC_GPIO_LLD_Current_Minimum:
731 GPIODR2R(Pins)->Value |= PINS(Pins);
733 case oC_GPIO_LLD_Current_Medium:
734 GPIODR4R(Pins)->Value |= PINS(Pins);
736 case oC_GPIO_LLD_Current_Maximum:
737 GPIODR8R(Pins)->Value |= PINS(Pins);
740 errorCode = oC_ErrorCode_GPIOCurrentNotCorrect;
755 oC_ErrorCode_t oC_GPIO_LLD_ReadCurrent( oC_Pins_t Pins , oC_GPIO_LLD_Current_t * outCurrent )
757 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
762 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
763 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
764 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
765 ErrorCondition( IsRam(outCurrent), oC_ErrorCode_OutputAddressNotInRAM)
768 errorCode = oC_ErrorCode_None;
770 if(GPIODR2R(Pins)->Value & PINS(Pins))
772 *outCurrent = oC_GPIO_LLD_Current_Minimum;
774 else if(GPIODR4R(Pins)->Value & PINS(Pins))
776 *outCurrent = oC_GPIO_LLD_Current_Medium;
778 else if(GPIODR4R(Pins)->Value & PINS(Pins))
780 *outCurrent = oC_GPIO_LLD_Current_Maximum;
784 errorCode = oC_ErrorCode_MachineCanBeDamaged;
798 oC_ErrorCode_t oC_GPIO_LLD_SetMode( oC_Pins_t Pins , oC_GPIO_LLD_Mode_t Mode )
800 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
805 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
806 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
807 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn)
811 errorCode = oC_ErrorCode_None;
815 case oC_GPIO_LLD_Mode_Output:
820 case oC_GPIO_LLD_Mode_Default:
821 case oC_GPIO_LLD_Mode_Input:
826 case oC_GPIO_LLD_Mode_Alternate:
831 errorCode = oC_ErrorCode_GPIOModeNotCorrect;
848 oC_ErrorCode_t oC_GPIO_LLD_ReadMode( oC_Pins_t Pins , oC_GPIO_LLD_Mode_t * outMode )
850 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
855 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
856 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
857 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
858 ErrorCondition( IsRam(outMode), oC_ErrorCode_OutputAddressNotInRAM)
862 errorCode = oC_ErrorCode_None;
869 *outMode = oC_GPIO_LLD_Mode_Output;
876 *outMode = oC_GPIO_LLD_Mode_Input;
883 *outMode = oC_GPIO_LLD_Mode_Alternate;
887 errorCode = oC_ErrorCode_MachineCanBeDamaged;
903 oC_ErrorCode_t oC_GPIO_LLD_SetPull( oC_Pins_t Pins , oC_GPIO_LLD_Pull_t Pull )
905 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
910 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
911 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
912 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn)
916 errorCode = oC_ErrorCode_None;
920 case oC_GPIO_LLD_Pull_Default:
926 case oC_GPIO_LLD_Pull_Up:
929 case oC_GPIO_LLD_Pull_Down:
933 errorCode = oC_ErrorCode_PullNotCorrect;
951 oC_ErrorCode_t oC_GPIO_LLD_ReadPull( oC_Pins_t Pins , oC_GPIO_LLD_Pull_t * outPull )
953 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
958 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
959 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
960 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
961 ErrorCondition( IsRam(outPull), oC_ErrorCode_OutputAddressNotInRAM)
966 errorCode = oC_ErrorCode_None;
972 *outPull = oC_GPIO_LLD_Pull_Up;
978 *outPull = oC_GPIO_LLD_Pull_Down;
982 errorCode = oC_ErrorCode_MachineCanBeDamaged;
998 oC_ErrorCode_t oC_GPIO_LLD_SetOutputCircuit( oC_Pins_t Pins , oC_GPIO_LLD_OutputCircuit_t OutputCircuit )
1000 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1005 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1006 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
1007 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn)
1011 errorCode = oC_ErrorCode_None;
1013 switch(OutputCircuit)
1015 case oC_GPIO_LLD_OutputCircuit_Default:
1016 case oC_GPIO_LLD_OutputCircuit_PushPull:
1019 case oC_GPIO_LLD_OutputCircuit_OpenDrain:
1023 errorCode = oC_ErrorCode_OutputCircuitNotCorrect;
1039 oC_ErrorCode_t oC_GPIO_LLD_ReadOutputCircuit( oC_Pins_t Pins , oC_GPIO_LLD_OutputCircuit_t * outOutputCircuit )
1041 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1046 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1047 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
1048 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
1049 ErrorCondition( IsRam(outOutputCircuit), oC_ErrorCode_OutputAddressNotInRAM)
1053 errorCode = oC_ErrorCode_None;
1059 *outOutputCircuit = oC_GPIO_LLD_OutputCircuit_PushPull;
1065 *outOutputCircuit = oC_GPIO_LLD_OutputCircuit_OpenDrain;
1069 errorCode = oC_ErrorCode_MachineCanBeDamaged;
1084 oC_ErrorCode_t oC_GPIO_LLD_SetInterruptTrigger( oC_Pins_t Pins , oC_GPIO_LLD_IntTrigger_t InterruptTrigger )
1086 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1091 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1092 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
1093 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
1094 ErrorCondition( InterruptTrigger == oC_GPIO_LLD_IntTrigger_Off, oC_ErrorCode_NotSupportedOnTargetMachine)
1098 errorCode = oC_ErrorCode_None;
1100 switch(InterruptTrigger)
1102 case oC_GPIO_LLD_IntTrigger_Off:
1105 case oC_GPIO_LLD_IntTrigger_BothEdges:
1106 oC_Channel_EnableInterrupt(PORT(Pins) , PeripheralInterrupt);
1114 case oC_GPIO_LLD_IntTrigger_BothLevels:
1115 oC_Channel_EnableInterrupt(PORT(Pins) , PeripheralInterrupt);
1122 case oC_GPIO_LLD_IntTrigger_FallingEdge:
1123 oC_Channel_EnableInterrupt(PORT(Pins) , PeripheralInterrupt);
1132 case oC_GPIO_LLD_IntTrigger_RisingEdge:
1133 oC_Channel_EnableInterrupt(PORT(Pins) , PeripheralInterrupt);
1141 case oC_GPIO_LLD_IntTrigger_HighLevel:
1142 oC_Channel_EnableInterrupt(PORT(Pins) , PeripheralInterrupt);
1150 case oC_GPIO_LLD_IntTrigger_LowLevel:
1151 oC_Channel_EnableInterrupt(PORT(Pins) , PeripheralInterrupt);
1160 errorCode = oC_ErrorCode_GPIOIntTriggerNotCorrect;
1176 oC_ErrorCode_t oC_GPIO_LLD_ReadInterruptTrigger( oC_Pins_t Pins , oC_GPIO_LLD_IntTrigger_t * outInterruptTrigger )
1178 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1184 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1185 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
1186 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
1187 ErrorCondition( IsRam(outInterruptTrigger), oC_ErrorCode_OutputAddressNotInRAM)
1190 errorCode = oC_ErrorCode_None;
1193 (oC_Channel_IsInterruptEnabled( PORT(Pins) , PeripheralInterrupt ) ==
false)
1196 *outInterruptTrigger = oC_GPIO_LLD_IntTrigger_Off;
1203 *outInterruptTrigger = oC_GPIO_LLD_IntTrigger_BothEdges;
1210 *outInterruptTrigger = oC_GPIO_LLD_IntTrigger_BothLevels;
1218 *outInterruptTrigger = oC_GPIO_LLD_IntTrigger_FallingEdge;
1226 *outInterruptTrigger = oC_GPIO_LLD_IntTrigger_RisingEdge;
1234 *outInterruptTrigger = oC_GPIO_LLD_IntTrigger_HighLevel;
1242 *outInterruptTrigger = oC_GPIO_LLD_IntTrigger_LowLevel;
1246 errorCode = oC_ErrorCode_MachineCanBeDamaged;
1261 oC_ErrorCode_t oC_GPIO_LLD_SetPinsUsed( oC_Pins_t Pins )
1263 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1269 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1270 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined)
1274 errorCode = oC_ErrorCode_None;
1288 oC_ErrorCode_t oC_GPIO_LLD_SetPinsUnused( oC_Pins_t Pins )
1290 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1296 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1297 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined)
1301 errorCode = oC_ErrorCode_None;
1315 oC_ErrorCode_t oC_GPIO_LLD_CheckIsPinUsed( oC_Pins_t Pins ,
bool * outPinUsed )
1317 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1323 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1324 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
1325 ErrorCondition( oC_GPIO_LLD_IsSinglePin(Pins), oC_ErrorCode_NotSinglePin) &&
1326 ErrorCondition( IsRam(outPinUsed), oC_ErrorCode_OutputAddressNotInRAM)
1331 errorCode = oC_ErrorCode_None;
1345 oC_ErrorCode_t oC_GPIO_LLD_ArePinsUnused( oC_Pins_t Pins ,
bool * outPinsUnused )
1347 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1353 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1354 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
1355 ErrorCondition( IsRam(outPinsUnused), oC_ErrorCode_OutputAddressNotInRAM)
1359 errorCode = oC_ErrorCode_None;
1373 oC_ErrorCode_t oC_GPIO_LLD_WriteData( oC_Pins_t Pins , oC_PinsMask_t Data )
1375 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1381 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1382 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
1383 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined)
1386 GPIODATA(Pins)->Value &= ~PINS(Pins);
1387 GPIODATA(Pins)->Value |= Data & PINS(Pins);
1388 errorCode = oC_ErrorCode_None;
1402 oC_ErrorCode_t oC_GPIO_LLD_ReadData( oC_Pins_t Pins , oC_PinsMask_t * outData )
1404 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1410 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1411 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
1412 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
1413 ErrorCondition( IsRam(outData), oC_ErrorCode_OutputAddressNotInRAM)
1416 *outData = GPIODATA(Pins)->Value & PINS(Pins);
1417 errorCode = oC_ErrorCode_None;
1431 oC_ErrorCode_t oC_GPIO_LLD_ReadDataReference( oC_Pins_t Pins , oC_UInt_t ** outDataReference )
1433 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1439 ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1440 ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
1441 ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
1442 ErrorCondition( IsRam(outDataReference), oC_ErrorCode_OutputAddressNotInRAM)
1445 *outDataReference = (oC_UInt_t*)&GPIODATA(Pins)->Value;
1446 errorCode = oC_ErrorCode_None;
1460 oC_Pins_t oC_GPIO_LLD_GetHighStatePins( oC_Pins_t Pins )
1462 return oC_GPIO_LLD_GetPinsFor(PORT(Pins) , (oC_PinsMask_t)(GPIODATA(Pins)->Value & Pins));
1471 oC_Pins_t oC_GPIO_LLD_GetLowStatePins( oC_Pins_t Pins )
1473 return oC_GPIO_LLD_GetPinsFor(PORT(Pins) , (oC_PinsMask_t)(~GPIODATA(Pins)->Value) & Pins);
1482 bool oC_GPIO_LLD_IsPinsState( oC_Pins_t Pins , oC_GPIO_LLD_PinsState_t ExpectedPinsState )
1484 return (GPIODATA(Pins)->Value & PINS(Pins)) == (ExpectedPinsState & PINS(Pins));
1493 void oC_GPIO_LLD_SetPinsState( oC_Pins_t Pins , oC_GPIO_LLD_PinsState_t PinsState )
1495 GPIODATA(Pins)->Value = (GPIODATA(Pins)->Value & (~PINS(Pins))) | (PinsState & PINS(Pins) );
1504 void oC_GPIO_LLD_TogglePinsState( oC_Pins_t Pins )
1506 GPIODATA(Pins)->Value ^= PINS(Pins);
1510 #undef _________________________________________INTERFACE_FUNCTIONS_SECTION_______________________________________________________________ 1517 #define _________________________________________MSLLD_INTERFACE_FUNCTIONS_SECTION__________________________________________________________ 1525 oC_ErrorCode_t oC_GPIO_MSLLD_SetAlternateNumber( oC_Pin_t Pin , oC_PinAlternateNumber_t Function )
1527 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1532 ErrorCondition(oC_GPIO_LLD_IsSinglePin(Pin) , oC_ErrorCode_NotSinglePin) &&
1533 ErrorCondition(oC_GPIO_LLD_IsPinDefined(Pin) , oC_ErrorCode_PinNotDefined) &&
1534 ErrorCondition( IsPoweredOn(Pin), oC_ErrorCode_ChannelNotPoweredOn) &&
1535 ErrorCondition(Function <= oC_PinAlternateNumberMask , oC_ErrorCode_ValueTooBig)
1547 errorCode = oC_ErrorCode_None;
1561 oC_ErrorCode_t oC_GPIO_MSLLD_ConnectPin( oC_Pin_t Pin , oC_PinAlternateNumber_t Function )
1563 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1569 ErrorCondition(oC_GPIO_LLD_IsSinglePin(Pin) , oC_ErrorCode_NotSinglePin) &&
1570 ErrorCondition(oC_GPIO_LLD_IsPinDefined(Pin) , oC_ErrorCode_PinNotDefined) &&
1571 ErrorCondition(Function <= oC_PinAlternateNumberMask , oC_ErrorCode_ValueTooBig)
1576 oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_BeginConfiguration(Pin)) &&
1577 oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_SetMode(Pin , oC_GPIO_LLD_Mode_Alternate)) &&
1578 oC_AssignErrorCode(&errorCode , oC_GPIO_MSLLD_SetAlternateNumber(Pin , Function)) &&
1579 oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_FinishConfiguration(Pin))
1582 errorCode = oC_ErrorCode_None;
1592 #undef _________________________________________MSLLD_INTERFACE_FUNCTIONS_SECTION__________________________________________________________ 1600 #define _________________________________________INTERRUPTS_SECTION________________________________________________________________________ 1604 #define MODULE_NAME GPIO 1605 #define INTERRUPT_TYPE_NAME PeripheralInterrupt 1616 oC_Pins_t pins = oC_GPIO_LLD_GetPinsFor(
1623 #undef INTERRUPT_TYPE_NAME 1626 #undef _________________________________________INTERRUPTS_SECTION________________________________________________________________________
The file with interface for LLD layer.
static bool oC_Bits_AreBitsSetU32(uint32_t BitMask, uint32_t BitsToCheck)
checks if all bits in field are set
Something power is not handled.
uint32_t oC_uint32_t
type for 32 bit unsigned integer
static bool oC_Bits_IsAtLeastOneBitClearU32(uint32_t BitMask, uint32_t BitsToCheck)
checks if at least one of bits in field is set
static uint32_t oC_Bits_SetValueU32(uint32_t *outVariable, uint32_t Value, uint8_t StartBitNr, uint8_t EndBitNr)
static uint8_t oC_Bits_SetBitsU8(uint8_t *outVariable, uint8_t Mask)
The file with interface for LSF module.
#define oC_Channel_GetName(Channel)
returns name of channel
The file with LLD interface for the MEM driver.
The file with LLD interface for the GPIO driver.
#define oC_Machine_WriteRegister(Channel, REGISTER_NAME, Value)
redefinition of oC_Machine_WriteRegisterDirectStaticOffset
static bool oC_Bits_IsAtLeastOneBitSetU32(uint32_t BitMask, uint32_t BitsToCheck)
checks if at least one of bits in field is set
static uint32_t oC_Bits_SetBitsU32(uint32_t *outVariable, uint32_t Mask)
#define oC_Machine_RegisterIndirectDynamic(BaseAddress, RegisterOffset)
allows for accessing registers in dynamic mode
The file with interface for the module library.
static bool oC_Module_IsTurnedOn(oC_Module_t Module)
checks if the module is turned on
Something is powered off.
static oC_ErrorCode_t ReadData(oC_FMC_Context_t Context, char *outData)
Reads one byte from the configured buffer.
static int8_t oC_Bits_GetBitNumberU32(uint32_t BitMask)
#define oC_Channel_IsCorrect(MODULE_NAME, Channel)
checks if channel is correct
static bool oC_Bits_AreBitsClearU32(uint32_t BitMask, uint32_t BitsToCheck)
checks if all bits in field are clear
#define oC_Channel_FromIndex(MODULE_NAME, ChannelIndex)
returns channel according to index in module
#define oC_ModuleChannel_NumberOfElements(MODULE_NAME)
Number of elements in module channel.
static void oC_Module_TurnOn(oC_Module_t Module)
sets module as turned on
Contains machine core specific functions.
The file with functions for the bits operation.
static void oC_MCS_EnterCriticalSection(void)
Enters to critical section.
static uint32_t oC_Bits_ClearBitsU32(uint32_t *outVariable, uint32_t Mask)
The file with interface interrupt module.
static oC_Power_t oC_Machine_GetPowerStateForChannel(oC_Channel_t Channel)
returns power state for channel
static oC_ErrorCode_t WriteData(oC_FMC_Context_t Context, char Data)
Writes one byte to the configured buffer.
static bool oC_Module_TurnOffVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned off
static bool oC_MCS_ExitCriticalSection(void)
Exits from critical section.
static bool oC_Module_TurnOnVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned on
#define oC_Channel_ToIndex(MODULE_NAME, Channel)
returns index in module according to channel
static void InterruptHandler(oC_ETH_LLD_InterruptSource_t Source)
handler for interrupts
#define oC_Machine_Register(Channel, REGISTER_NAME)
allows for accessing registers using channel and offset name
#define oC_Channel_InterruptHandler(ChannelVariableName)
creates common interrupt handler for channel
static bool oC_Machine_SetPowerStateForChannel(oC_Channel_t Channel, oC_Power_t Power)
configures power state for machine channel
The file with interface for Channel module.
oC_Power_t
stores registers power state
static uint8_t oC_Bits_ClearBitsU8(uint8_t *outVariable, uint8_t Mask)
#define NULL
pointer to a zero
static void oC_Module_TurnOff(oC_Module_t Module)
sets module as turned off