Choco OS  V.0.16.9.0
Join to the chocolate world
oc_gpio_lld.c
1 
27 #include <oc_gpio_lld.h>
28 #include <oc_mem_lld.h>
29 #include <oc_bits.h>
30 #include <oc_lld.h>
31 #include <oc_module.h>
32 #include <oc_mcs.h>
33 #include <oc_lsf.h>
34 
40 #define _________________________________________LOCAL_MACROS_SECTION_______________________________________________________________________
41 
42 #define PORT(Pins) oC_Pin_GetPort(Pins)
43 #define PORT_INDEX(Pins) oC_Channel_ToIndex(GPIO , PORT(Pins))
44 #define PINS(Pins) oC_Pin_GetPinsInPort(Pins)
45 #define IsPoweredOn(Pins) oC_Machine_IsChannelPoweredOn(PORT(Pins))
46 #define GPIOx_MODER(Pins) oC_Machine_Register(PORT(Pins),GPIOx_MODER)
47 #define GPIOx_OTYPER(Pins) oC_Machine_Register(PORT(Pins),GPIOx_OTYPER)
48 #define GPIOx_PUPDR(Pins) oC_Machine_Register(PORT(Pins),GPIOx_PUPDR)
49 #define GPIOx_IDR(Pins) oC_Machine_Register(PORT(Pins),GPIOx_IDR)
50 #define GPIOx_ODR(Pins) oC_Machine_Register(PORT(Pins),GPIOx_ODR)
51 #define GPIOx_OSPEEDR(Pins) oC_Machine_Register(PORT(Pins),GPIOx_OSPEEDR)
52 #define GPIOx_LCKR(Pins) oC_Machine_Register(PORT(Pins),GPIOx_LCKR)
53 #define GPIOx_AFRL(Pins) oC_Machine_Register(PORT(Pins),GPIOx_AFRL)
54 #define GPIOx_AFRH(Pins) oC_Machine_Register(PORT(Pins),GPIOx_AFRH)
55 #define SYSCFG_EXTICR1 oC_Register(SYSCFG , SYSCFG_EXTICR1)
56 #define SYSCFG_EXTICR2 oC_Register(SYSCFG , SYSCFG_EXTICR2)
57 #define SYSCFG_EXTICR3 oC_Register(SYSCFG , SYSCFG_EXTICR3)
58 #define SYSCFG_EXTICR4 oC_Register(SYSCFG , SYSCFG_EXTICR4)
59 #define EXTI_IMR oC_Register(EXTI , EXTI_IMR)
60 #define EXTI_EMR oC_Register(EXTI , EXTI_EMR)
61 #define EXTI_RTSR oC_Register(EXTI , EXTI_RTSR)
62 #define EXTI_FTSR oC_Register(EXTI , EXTI_FTSR)
63 #define EXTI_PR oC_Register(EXTI , EXTI_PR)
64 #define IsRam(Address) (oC_LSF_IsRamAddress(Address) || oC_LSF_IsExternalAddress(Address))
65 #define IsRom(Address) oC_LSF_IsRomAddress(Address)
66 #define IsExtiUsed(ExtiLine) (ExtiUsedBits & (1<<ExtiLine))
67 #define SetExtiUsed(ExtiLine) ExtiUsedBits |= (1<<ExtiLine)
68 #define SetExtiUnused(ExtiLine) ExtiUsedBits &= ~(1<<ExtiLine)
69 
70 #undef _________________________________________LOCAL_MACROS_SECTION_______________________________________________________________________
71 
77 #define _________________________________________REDEFINITIONS_SECTION______________________________________________________________________
78 
79 oC_LLD_ConnectToMainDriver(GPIO,IsPortCorrect);
80 oC_LLD_ConnectToMainDriver(GPIO,IsPortIndexCorrect);
81 oC_LLD_ConnectToMainDriver(GPIO,GetPinsMaskOfPins);
82 oC_LLD_ConnectToMainDriver(GPIO,GetPortOfPins);
83 oC_LLD_ConnectToMainDriver(GPIO,PortToPortIndex);
84 oC_LLD_ConnectToMainDriver(GPIO,PortIndexToPort);
85 oC_LLD_ConnectToMainDriver(GPIO,IsPinDefined);
86 oC_LLD_ConnectToMainDriver(GPIO,ArePinsDefined);
87 oC_LLD_ConnectToMainDriver(GPIO,ArePinsCorrect);
88 oC_LLD_ConnectToMainDriver(GPIO,IsSinglePin);
89 oC_LLD_ConnectToMainDriver(GPIO,GetPinsFor);
90 oC_LLD_ConnectToMainDriver(GPIO,GetPortName);
91 oC_LLD_ConnectToMainDriver(GPIO,GetPinName);
92 oC_LLD_ConnectToMainDriver(GPIO,SetPower);
93 oC_LLD_ConnectToMainDriver(GPIO,ReadPower);
94 oC_LLD_ConnectToMainDriver(GPIO,CheckIsPinUsed);
95 oC_LLD_ConnectToMainDriver(GPIO,ArePinsUnused);
96 oC_LLD_ConnectToMainDriver(GPIO,WriteData);
97 oC_LLD_ConnectToMainDriver(GPIO,ReadData);
98 oC_LLD_ConnectToMainDriver(GPIO,ReadDataReference);
99 oC_LLD_ConnectToMainDriver(GPIO,GetHighStatePins);
100 oC_LLD_ConnectToMainDriver(GPIO,GetLowStatePins);
101 oC_LLD_ConnectToMainDriver(GPIO,IsPinsState);
102 oC_LLD_ConnectToMainDriver(GPIO,SetPinsState);
103 oC_LLD_ConnectToMainDriver(GPIO,TogglePinsState);
104 oC_LLD_ConnectToMainDriver(GPIO,GetPinName);
105 
106 #undef _________________________________________REDEFINITIONS_SECTION______________________________________________________________________
107 
113 #define _________________________________________LOCAL_PROTOTYPES_SECTION___________________________________________________________________
114 
115 static void SetConfigurationBitsInRegister( oC_Register_t * outRegister , oC_PinsInPort_t PinsInPort , uint8_t Value );
116 static uint8_t GetConfigurationBitsInRegister( oC_Register_t Register , oC_PinsInPort_t PinsInPort );
117 static oC_ErrorCode_t ConnectPinsToExti ( oC_Pins_t Pins );
118 static oC_ErrorCode_t DisconnectPinsFromExti ( oC_Pins_t Pins );
119 static oC_Port_t GetPortOfExtiLine ( uint8_t ExtiLine );
120 static bool SetExtiLineInterruptState ( uint8_t ExtiLine , bool Enabled );
121 static bool SetInterruptsStateForPins ( oC_Pins_t Pins , bool Enabled );
122 
123 #undef _________________________________________LOCAL_PROTOTYPES_SECTION___________________________________________________________________
124 
125 
131 #define _________________________________________LOCAL_VARIABLES_SECTION____________________________________________________________________
132 
133 static oC_PinsInPort_t UsedPinsArray[oC_ModuleChannel_NumberOfElements(GPIO)];
134 static oC_GPIO_LLD_Interrupt_t InterruptHandler = NULL;
135 static uint16_t ExtiUsedBits = 0;
136 
137 #undef _________________________________________LOCAL_VARIABLES_SECTION____________________________________________________________________
138 
139 
145 #define _________________________________________INTERFACE_FUNCTIONS_SECTION_______________________________________________________________
146 
147 //==========================================================================================================================================
152 //==========================================================================================================================================
153 oC_ErrorCode_t oC_GPIO_LLD_TurnOnDriver( void )
154 {
155  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
156 
158 
159  if(oC_Module_TurnOffVerification(&errorCode , oC_Module_GPIO_LLD))
160  {
161  oC_Module_TurnOn(oC_Module_GPIO_LLD);
162 
163  oC_GPIO_LLD_ForEachPort(port)
164  {
165  UsedPinsArray[PORT_INDEX(port)] = 0;
166  }
167 
169  ExtiUsedBits = 0;
170  errorCode = oC_ErrorCode_None;
171  }
172 
174 
175  return errorCode;
176 }
177 
178 //==========================================================================================================================================
183 //==========================================================================================================================================
184 oC_ErrorCode_t oC_GPIO_LLD_TurnOffDriver( void )
185 {
186  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
187 
189 
190  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
191  {
192  oC_Module_TurnOff(oC_Module_GPIO_LLD);
193 
195  errorCode = oC_ErrorCode_None;
196  }
197 
199 
200  return errorCode;
201 }
202 
203 //==========================================================================================================================================
208 //==========================================================================================================================================
209 bool oC_GPIO_LLD_IsPortCorrect( oC_Port_t Port )
210 {
211  return oC_Channel_IsCorrect(GPIO , Port);
212 }
213 
214 //==========================================================================================================================================
219 //==========================================================================================================================================
220 bool oC_GPIO_LLD_IsPortIndexCorrect( oC_PortIndex_t PortIndex )
221 {
222  return PortIndex < oC_ModuleChannel_NumberOfElements(GPIO);
223 }
224 
225 //==========================================================================================================================================
230 //==========================================================================================================================================
231 oC_PinsMask_t oC_GPIO_LLD_GetPinsMaskOfPins( oC_Pins_t Pins )
232 {
233  return PINS(Pins);
234 }
235 
236 //==========================================================================================================================================
241 //==========================================================================================================================================
242 oC_Port_t oC_GPIO_LLD_GetPortOfPins( oC_Pins_t Pins )
243 {
244  return PORT(Pins);
245 }
246 
247 //==========================================================================================================================================
252 //==========================================================================================================================================
253 oC_PortIndex_t oC_GPIO_LLD_PortToPortIndex( oC_Port_t Port )
254 {
255  return oC_Channel_ToIndex(GPIO,Port);
256 }
257 
258 //==========================================================================================================================================
263 //==========================================================================================================================================
264 oC_Port_t oC_GPIO_LLD_PortIndexToPort( oC_PortIndex_t PortIndex )
265 {
266  return oC_Channel_FromIndex(GPIO,PortIndex);
267 }
268 
269 //==========================================================================================================================================
274 //==========================================================================================================================================
275 bool oC_GPIO_LLD_IsPinDefined( oC_Pin_t Pin )
276 {
277  bool defined = false;
278 
279  oC_Pin_ForeachDefined(pin)
280  {
281  if(pin->Pin == Pin)
282  {
283  defined = true;
284  break;
285  }
286  }
287 
288  return defined;
289 }
290 
291 //==========================================================================================================================================
296 //==========================================================================================================================================
297 bool oC_GPIO_LLD_ArePinsDefined( oC_Pins_t Pins )
298 {
299  bool allDefined = false;
300  oC_Port_t port = PORT(Pins);
301  oC_PinsInPort_t pins = PINS(Pins);
302 
303  if(oC_Channel_IsCorrect(GPIO,port))
304  {
305  allDefined = true;
306 
307  for(uint8_t bitIndex = 0; bitIndex < oC_PORT_WIDTH && allDefined; bitIndex++ )
308  {
309  if(pins & (1<<bitIndex))
310  {
311  allDefined = oC_GPIO_LLD_IsPinDefined(oC_Pins_ToSinglePin(Pins,bitIndex));
312  }
313  }
314  }
315 
316  return allDefined;
317 }
318 
319 //==========================================================================================================================================
324 //==========================================================================================================================================
325 bool oC_GPIO_LLD_ArePinsCorrect( oC_Pins_t Pins )
326 {
327  return oC_Channel_IsCorrect(GPIO,PORT(Pins));
328 }
329 
330 //==========================================================================================================================================
335 //==========================================================================================================================================
336 bool oC_GPIO_LLD_IsSinglePin( oC_Pins_t Pins )
337 {
338  bool isSinglePin = false;
339  oC_PinsInPort_t pins = PINS(Pins);
340 
341  for(uint8_t bitIndex = 0; bitIndex < oC_PORT_WIDTH ; bitIndex++)
342  {
343  if(pins & (1<<bitIndex))
344  {
345  isSinglePin = oC_Pins_ToSinglePin(Pins,bitIndex) == Pins;
346  break;
347  }
348  }
349 
350  return isSinglePin;
351 }
352 
353 //==========================================================================================================================================
358 //==========================================================================================================================================
359 oC_Pins_t oC_GPIO_LLD_GetPinsFor( oC_Port_t Port , oC_PinsMask_t Pins )
360 {
361  return oC_Pin_Make(Port,Pins);
362 }
363 
364 //==========================================================================================================================================
369 //==========================================================================================================================================
370 const char * oC_GPIO_LLD_GetPortName( oC_Port_t Port )
371 {
372  return oC_Channel_GetName(Port);
373 }
374 
375 //==========================================================================================================================================
380 //==========================================================================================================================================
381 const char * oC_GPIO_LLD_GetPinName( oC_Pin_t Pin )
382 {
383  const char * name = "<INCORRECT_PIN>";
384  oC_Port_t port = PORT(Pin);
385 
386  if(oC_Channel_IsCorrect(GPIO,port))
387  {
388  name = "<UNDEFINED_PIN>";
389 
390  oC_Pin_ForeachDefined(pinData)
391  {
392  if(pinData->Pin == Pin)
393  {
394  name = pinData->Name;
395  break;
396  }
397  }
398  }
399 
400  return name;
401 }
402 
403 //==========================================================================================================================================
408 //==========================================================================================================================================
409 oC_ErrorCode_t oC_GPIO_LLD_SetDriverInterruptHandler( oC_GPIO_LLD_Interrupt_t Handler )
410 {
411  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
412 
413  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
414  {
415  if(
416  ErrorCondition( IsRam(Handler) || IsRom(Handler), oC_ErrorCode_WrongEventHandlerAddress) &&
417  ErrorCondition( InterruptHandler == NULL, oC_ErrorCode_InterruptHandlerAlreadySet)
418  )
419  {
420  InterruptHandler = Handler;
421  errorCode = oC_ErrorCode_None;
422  }
423  }
424 
425  return errorCode;
426 }
427 
428 //==========================================================================================================================================
433 //==========================================================================================================================================
434 oC_ErrorCode_t oC_GPIO_LLD_BeginConfiguration( oC_Pins_t Pins )
435 {
436  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
437 
438  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
439  {
440  if(
441  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins) , oC_ErrorCode_WrongChannel) &&
442  ErrorCondition( PINS(Pins) != 0 , oC_ErrorCode_PinNotDefined) &&
443  ErrorCondition( oC_Machine_SetPowerStateForChannel(PORT(Pins),oC_Power_On) , oC_ErrorCode_CannotEnableChannel) &&
444  ErrorCondition( oC_Machine_SetPowerStateForChannel(oC_Channel_SYSCFG , oC_Power_On) , oC_ErrorCode_CannotEnableChannel)
445  )
446  {
447  errorCode = oC_ErrorCode_None;
448  }
449  }
450 
451  return errorCode;
452 }
453 
454 //==========================================================================================================================================
459 //==========================================================================================================================================
460 oC_ErrorCode_t oC_GPIO_LLD_FinishConfiguration( oC_Pins_t Pins )
461 {
462  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
463 
464  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
465  {
466  if(
467  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
468  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined)
469  )
470  {
471  errorCode = oC_ErrorCode_None;
472  }
473  }
474 
475  return errorCode;
476 }
477 
478 //==========================================================================================================================================
483 //==========================================================================================================================================
484 oC_ErrorCode_t oC_GPIO_LLD_SetPower( oC_Pins_t Pins , oC_Power_t Power )
485 {
486  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
487 
488  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
489  {
490  if(
491  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
492  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
493  ErrorCondition( Power == oC_Power_On || Power == oC_Power_Off, oC_ErrorCode_PowerStateNotCorrect)
494  )
495  {
496  if(oC_Machine_SetPowerStateForChannel(PORT(Pins) , Power ) && oC_Machine_SetPowerStateForChannel(oC_Channel_SYSCFG , oC_Power_On))
497  {
498  errorCode = oC_ErrorCode_None;
499  }
500  else
501  {
502  errorCode = oC_ErrorCode_CannotEnableChannel;
503  }
504  }
505  }
506 
507  return errorCode;
508 }
509 
510 //==========================================================================================================================================
515 //==========================================================================================================================================
516 oC_ErrorCode_t oC_GPIO_LLD_ReadPower( oC_Pins_t Pins , oC_Power_t * outPower )
517 {
518  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
519 
520  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
521  {
522  if(
523  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
524  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
525  ErrorCondition( IsRam(outPower), oC_ErrorCode_OutputAddressNotInRAM)
526  )
527  {
528  oC_Power_t powerState = oC_Machine_GetPowerStateForChannel(PORT(Pins));
529 
530  if (powerState == oC_Power_NotHandled)
531  {
532  *outPower = oC_Power_On;
533  errorCode = oC_ErrorCode_None;
534  }
535  else if (powerState == oC_Power_On || powerState == oC_Power_Off)
536  {
537  *outPower = powerState;
538  errorCode = oC_ErrorCode_None;
539  }
540  else
541  {
542  errorCode = oC_ErrorCode_MachineCanBeDamaged;
543  }
544  }
545  }
546 
547  return errorCode;
548 }
549 
550 //==========================================================================================================================================
555 //==========================================================================================================================================
556 bool oC_GPIO_LLD_IsPinProtected( oC_Pins_t Pins )
557 {
558  bool pinProtected = false;
559 
560  if(oC_Module_IsTurnedOn(oC_Module_GPIO_LLD) && IsPoweredOn(Pins))
561  {
562  pinProtected = GPIOx_LCKR(Pins)->Value & PINS(Pins);
563  }
564 
565  return pinProtected;
566 }
567 
568 //==========================================================================================================================================
573 //==========================================================================================================================================
574 oC_ErrorCode_t oC_GPIO_LLD_UnlockProtection( oC_Pins_t Pins , oC_GPIO_LLD_Protection_t Protection )
575 {
576  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
577 
578  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
579  {
580  if(
581  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
582  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
583  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
584  ErrorCondition( Protection == oC_GPIO_LLD_Protection_UnlockProtectedPins, oC_ErrorCode_PinNeedUnlock)
585  )
586  {
588  volatile uint32_t oldValue = GPIOx_LCKR(Pins)->Value;
589  GPIOx_LCKR(Pins)->Value = (1<<16) | ~PINS(Pins) | oldValue;
590  GPIOx_LCKR(Pins)->Value = (0<<16) | ~PINS(Pins) | oldValue;
591  GPIOx_LCKR(Pins)->Value = (1<<16) | ~PINS(Pins) | oldValue;
592 
593  volatile uint32_t Unused(value) = GPIOx_LCKR(Pins)->Value;
594 
595  errorCode = oC_ErrorCode_None;
596 
598  }
599  }
600 
601  return errorCode;
602 }
603 
604 //==========================================================================================================================================
609 //==========================================================================================================================================
610 oC_ErrorCode_t oC_GPIO_LLD_LockProtection( oC_Pins_t Pins )
611 {
612  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
613 
614  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
615  {
616  if(
617  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
618  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
619  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn)
620  )
621  {
623  volatile uint32_t oldValue = GPIOx_LCKR(Pins)->Value;
624  GPIOx_LCKR(Pins)->Value = (1<<16) | PINS(Pins) | oldValue;
625  GPIOx_LCKR(Pins)->Value = (0<<16) | PINS(Pins) | oldValue;
626  GPIOx_LCKR(Pins)->Value = (1<<16) | PINS(Pins) | oldValue;
627 
628  volatile uint32_t Unused(value) = GPIOx_LCKR(Pins)->Value;
629 
630  errorCode = oC_ErrorCode_None;
631 
633  }
634  }
635 
636  return errorCode;
637 }
638 
639 //==========================================================================================================================================
644 //==========================================================================================================================================
645 oC_ErrorCode_t oC_GPIO_LLD_CheckIsPinUnlocked( oC_Pins_t Pins , bool * outPinUnlocked )
646 {
647  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
648 
649  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
650  {
651  if(
652  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
653  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
654  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
655  ErrorCondition( IsRam(outPinUnlocked), oC_ErrorCode_OutputAddressNotInRAM)
656  )
657  {
659  *outPinUnlocked = !(GPIOx_LCKR(Pins)->Value & PINS(Pins));
660  errorCode = oC_ErrorCode_None;
662  }
663  }
664 
665  return errorCode;
666 }
667 
668 //==========================================================================================================================================
673 //==========================================================================================================================================
674 oC_ErrorCode_t oC_GPIO_LLD_SetSpeed( oC_Pins_t Pins , oC_GPIO_LLD_Speed_t Speed )
675 {
676  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
677 
678  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
679  {
680  if(
681  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
682  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
683  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn)
684  )
685  {
687 
688  errorCode = oC_ErrorCode_None;
689 
690  switch(Speed)
691  {
692  case oC_GPIO_LLD_Speed_Minimum:
693  SetConfigurationBitsInRegister(&GPIOx_OSPEEDR(Pins)->Value , PINS(Pins) , 0);
694  break;
695  case oC_GPIO_LLD_Speed_Medium:
696  case oC_GPIO_LLD_Speed_Default:
697  SetConfigurationBitsInRegister(&GPIOx_OSPEEDR(Pins)->Value , PINS(Pins) , 0x1);
698  break;
699  case oC_GPIO_LLD_Speed_Maximum:
700  SetConfigurationBitsInRegister(&GPIOx_OSPEEDR(Pins)->Value , PINS(Pins) , 0x3);
701  break;
702  default:
703  errorCode = oC_ErrorCode_SpeedNotCorrect;
704  break;
705  }
706 
708  }
709  }
710 
711  return errorCode;
712 }
713 
714 //==========================================================================================================================================
719 //==========================================================================================================================================
720 oC_ErrorCode_t oC_GPIO_LLD_ReadSpeed( oC_Pins_t Pins , oC_GPIO_LLD_Speed_t * outSpeed )
721 {
722  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
723 
724  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
725  {
726  if(
727  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
728  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
729  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
730  ErrorCondition( IsRam(outSpeed), oC_ErrorCode_OutputAddressNotInRAM)
731  )
732  {
734 
735  uint8_t value = GetConfigurationBitsInRegister(GPIOx_OSPEEDR(Pins)->Value , PINS(Pins));
736  errorCode = oC_ErrorCode_None;
737 
738  switch(value)
739  {
740  case 0: *outSpeed = oC_GPIO_LLD_Speed_Minimum; break;
741  case 1: *outSpeed = oC_GPIO_LLD_Speed_Medium; break;
742  case 2: *outSpeed = oC_GPIO_LLD_Speed_Medium; break;
743  case 3: *outSpeed = oC_GPIO_LLD_Speed_Maximum; break;
744  default:
745  errorCode = oC_ErrorCode_MachineCanBeDamaged;
746  break;
747  }
748 
750  }
751  }
752 
753  return errorCode;
754 }
755 
756 //==========================================================================================================================================
761 //==========================================================================================================================================
762 oC_ErrorCode_t oC_GPIO_LLD_SetCurrent( oC_Pins_t Pins , oC_GPIO_LLD_Current_t Current )
763 {
764  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
765 
766  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
767  {
768  if(
769  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
770  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
771  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn)
772  )
773  {
774  errorCode = oC_ErrorCode_None;
775  }
776  }
777 
778  return errorCode;
779 }
780 
781 //==========================================================================================================================================
786 //==========================================================================================================================================
787 oC_ErrorCode_t oC_GPIO_LLD_ReadCurrent( oC_Pins_t Pins , oC_GPIO_LLD_Current_t * outCurrent )
788 {
789  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
790 
791  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
792  {
793  if(
794  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
795  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
796  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
797  ErrorCondition( IsRam(outCurrent), oC_ErrorCode_OutputAddressNotInRAM)
798  )
799  {
800  *outCurrent = oC_GPIO_LLD_Current_Maximum;
801  errorCode = oC_ErrorCode_None;
802  }
803  }
804 
805  return errorCode;
806 }
807 
808 //==========================================================================================================================================
813 //==========================================================================================================================================
814 oC_ErrorCode_t oC_GPIO_LLD_SetMode( oC_Pins_t Pins , oC_GPIO_LLD_Mode_t Mode )
815 {
816  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
817 
818  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
819  {
820  if(
821  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
822  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
823  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn)
824  )
825  {
827 
828  errorCode = oC_ErrorCode_None;
829 
830  switch(Mode)
831  {
832  case oC_GPIO_LLD_Mode_Input:
833  SetConfigurationBitsInRegister(&GPIOx_MODER(Pins)->Value , PINS(Pins) , 0);
834  break;
835  case oC_GPIO_LLD_Mode_Output:
836  case oC_GPIO_LLD_Mode_Default:
837  SetConfigurationBitsInRegister(&GPIOx_MODER(Pins)->Value , PINS(Pins) , 0x1);
838  break;
839  case oC_GPIO_LLD_Mode_Alternate:
840  SetConfigurationBitsInRegister(&GPIOx_MODER(Pins)->Value , PINS(Pins) , 0x2);
841  break;
842  default:
843  errorCode = oC_ErrorCode_ModeNotCorrect;
844  break;
845  }
846 
848  }
849  }
850 
851  return errorCode;
852 }
853 
854 //==========================================================================================================================================
859 //==========================================================================================================================================
860 oC_ErrorCode_t oC_GPIO_LLD_ReadMode( oC_Pins_t Pins , oC_GPIO_LLD_Mode_t * outMode )
861 {
862  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
863 
864  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
865  {
866  if(
867  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
868  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
869  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
870  ErrorCondition( IsRam(outMode), oC_ErrorCode_OutputAddressNotInRAM)
871  )
872  {
874 
875  uint8_t value = GetConfigurationBitsInRegister(GPIOx_MODER(Pins)->Value , PINS(Pins));
876  errorCode = oC_ErrorCode_None;
877 
878  switch(value)
879  {
880  case 0: *outMode = oC_GPIO_LLD_Mode_Input; break;
881  case 1: *outMode = oC_GPIO_LLD_Mode_Output; break;
882  case 2: *outMode = oC_GPIO_LLD_Mode_Alternate; break;
883  case 3: *outMode = oC_GPIO_LLD_Mode_Alternate; break;
884  default:
885  errorCode = oC_ErrorCode_MachineCanBeDamaged;
886  break;
887  }
888 
890  }
891  }
892 
893  return errorCode;
894 }
895 
896 //==========================================================================================================================================
901 //==========================================================================================================================================
902 oC_ErrorCode_t oC_GPIO_LLD_SetPull( oC_Pins_t Pins , oC_GPIO_LLD_Pull_t Pull )
903 {
904  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
905 
906  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
907  {
908  if(
909  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
910  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
911  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn)
912  )
913  {
915 
916  errorCode = oC_ErrorCode_None;
917 
918  switch(Pull)
919  {
920  case oC_GPIO_LLD_Pull_Down:
921  SetConfigurationBitsInRegister(&GPIOx_PUPDR(Pins)->Value , PINS(Pins) , 0x2);
922  break;
923  case oC_GPIO_LLD_Pull_Up:
924  SetConfigurationBitsInRegister(&GPIOx_PUPDR(Pins)->Value , PINS(Pins) , 0x1);
925  break;
926  case oC_GPIO_LLD_Mode_Default:
927  SetConfigurationBitsInRegister(&GPIOx_PUPDR(Pins)->Value , PINS(Pins) , 0);
928  break;
929  default:
930  errorCode = oC_ErrorCode_PullNotCorrect;
931  break;
932  }
933 
935  }
936  }
937 
938  return errorCode;
939 }
940 
941 //==========================================================================================================================================
946 //==========================================================================================================================================
947 oC_ErrorCode_t oC_GPIO_LLD_ReadPull( oC_Pins_t Pins , oC_GPIO_LLD_Pull_t * outPull )
948 {
949  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
950 
951  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
952  {
953  if(
954  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
955  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
956  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
957  ErrorCondition( IsRam(outPull), oC_ErrorCode_OutputAddressNotInRAM)
958  )
959  {
961 
962  uint8_t value = GetConfigurationBitsInRegister(GPIOx_PUPDR(Pins)->Value , PINS(Pins));
963  errorCode = oC_ErrorCode_None;
964 
965  switch(value)
966  {
967  case 0: *outPull = oC_GPIO_LLD_Pull_Default; break;
968  case 1: *outPull = oC_GPIO_LLD_Pull_Up; break;
969  case 2: *outPull = oC_GPIO_LLD_Pull_Down; break;
970  default:
971  errorCode = oC_ErrorCode_MachineCanBeDamaged;
972  break;
973  }
974 
976  }
977  }
978 
979  return errorCode;
980 }
981 
982 //==========================================================================================================================================
987 //==========================================================================================================================================
988 oC_ErrorCode_t oC_GPIO_LLD_SetOutputCircuit( oC_Pins_t Pins , oC_GPIO_LLD_OutputCircuit_t OutputCircuit )
989 {
990  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
991 
992  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
993  {
994  if(
995  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
996  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
997  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn)
998  )
999  {
1001 
1002  if(OutputCircuit == oC_GPIO_LLD_OutputCircuit_OpenDrain)
1003  {
1004  GPIOx_OTYPER(Pins)->Value |= PINS(Pins);
1005  errorCode = oC_ErrorCode_None;
1006  }
1007  else if (OutputCircuit == oC_GPIO_LLD_OutputCircuit_PushPull || OutputCircuit == oC_GPIO_LLD_OutputCircuit_Default)
1008  {
1009  GPIOx_OTYPER(Pins)->Value &= ~(PINS(Pins));
1010  errorCode = oC_ErrorCode_None;
1011  }
1012  else
1013  {
1014  errorCode = oC_ErrorCode_OutputCircuitNotCorrect;
1015  }
1016 
1018  }
1019  }
1020 
1021  return errorCode;
1022 }
1023 
1024 //==========================================================================================================================================
1029 //==========================================================================================================================================
1030 oC_ErrorCode_t oC_GPIO_LLD_ReadOutputCircuit( oC_Pins_t Pins , oC_GPIO_LLD_OutputCircuit_t * outOutputCircuit )
1031 {
1032  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1033 
1034  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
1035  {
1036  if(
1037  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1038  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
1039  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
1040  ErrorCondition( IsRam(outOutputCircuit), oC_ErrorCode_OutputAddressNotInRAM)
1041  )
1042  {
1044 
1045  oC_PinsInPort_t pinsInPort = PINS(Pins);
1046  uint32_t value = GPIOx_OTYPER(Pins)->Value & pinsInPort;
1047 
1048  if(value == pinsInPort)
1049  {
1050  errorCode = oC_ErrorCode_None;
1051  *outOutputCircuit = oC_GPIO_LLD_OutputCircuit_OpenDrain;
1052  }
1053  else if(value == 0)
1054  {
1055  errorCode = oC_ErrorCode_None;
1056  *outOutputCircuit = oC_GPIO_LLD_OutputCircuit_PushPull;
1057  }
1058  else
1059  {
1060  errorCode = oC_ErrorCode_NotAllPinsInTheSameState;
1061  }
1062 
1064  }
1065  }
1066 
1067  return errorCode;
1068 }
1069 
1070 //==========================================================================================================================================
1075 //==========================================================================================================================================
1076 oC_ErrorCode_t oC_GPIO_LLD_SetInterruptTrigger( oC_Pins_t Pins , oC_GPIO_LLD_IntTrigger_t InterruptTrigger )
1077 {
1078  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1079 
1080  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
1081  {
1082  if(
1083  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1084  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
1085  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn)
1086  )
1087  {
1088  if(InterruptTrigger == oC_GPIO_LLD_IntTrigger_Off)
1089  {
1090  if(ErrorCondition(SetInterruptsStateForPins(Pins,false) , oC_ErrorCode_CannotDisableInterrupt))
1091  {
1092  errorCode = DisconnectPinsFromExti(Pins);
1093  }
1094  }
1095  else if(oC_AssignErrorCode(&errorCode , ConnectPinsToExti(Pins)))
1096  {
1097  oC_PinsInPort_t pinsInPort = oC_Pin_GetPinsInPort(Pins);
1098 
1099  if(InterruptTrigger & oC_GPIO_LLD_IntTrigger_FallingEdge)
1100  {
1101  EXTI_IMR->Value |= ((uint32_t)pinsInPort);
1102  EXTI_FTSR->Value |= ((uint32_t)pinsInPort);
1103 
1104  if(ErrorCondition(SetInterruptsStateForPins(Pins,true) , oC_ErrorCode_CannotEnableInterrupt))
1105  {
1106  errorCode = oC_ErrorCode_None;
1107  }
1108  }
1109  if(InterruptTrigger & oC_GPIO_LLD_IntTrigger_RisingEdge)
1110  {
1111  EXTI_IMR->Value |= ((uint32_t)pinsInPort);
1112  EXTI_RTSR->Value |= ((uint32_t)pinsInPort);
1113 
1114  if(ErrorCondition(SetInterruptsStateForPins(Pins,true) , oC_ErrorCode_CannotEnableInterrupt))
1115  {
1116  errorCode = oC_ErrorCode_None;
1117  }
1118  }
1119 
1120  if(InterruptTrigger & oC_GPIO_LLD_IntTrigger_HighLevel)
1121  {
1122  errorCode = oC_ErrorCode_NotSupportedOnTargetMachine;
1123  }
1124 
1125  if(InterruptTrigger & oC_GPIO_LLD_IntTrigger_LowLevel)
1126  {
1127  errorCode = oC_ErrorCode_NotSupportedOnTargetMachine;
1128  }
1129  }
1130 
1131  }
1132  }
1133 
1134  return errorCode;
1135 }
1136 
1137 //==========================================================================================================================================
1142 //==========================================================================================================================================
1143 oC_ErrorCode_t oC_GPIO_LLD_ReadInterruptTrigger( oC_Pins_t Pins , oC_GPIO_LLD_IntTrigger_t * outInterruptTrigger )
1144 {
1145  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1146 
1147  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
1148  {
1150  if(
1151  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1152  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
1153  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
1154  ErrorCondition( IsRam(outInterruptTrigger), oC_ErrorCode_OutputAddressNotInRAM)
1155  )
1156  {
1157  errorCode = oC_ErrorCode_NotImplemented;
1158  }
1160  }
1161 
1162  return errorCode;
1163 }
1164 
1165 //==========================================================================================================================================
1170 //==========================================================================================================================================
1171 oC_ErrorCode_t oC_GPIO_LLD_SetPinsUsed( oC_Pins_t Pins )
1172 {
1173  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1174 
1175  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
1176  {
1178  if(
1179  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel ) &&
1180  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined )
1181  )
1182  {
1183  oC_Bits_SetBitsU16(&UsedPinsArray[PORT_INDEX(Pins)],PINS(Pins));
1184  errorCode = oC_ErrorCode_None;
1185  }
1187  }
1188 
1189  return errorCode;
1190 }
1191 
1192 //==========================================================================================================================================
1197 //==========================================================================================================================================
1198 oC_ErrorCode_t oC_GPIO_LLD_SetPinsUnused( oC_Pins_t Pins )
1199 {
1200  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1201 
1202  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
1203  {
1205  if(
1206  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1207  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined)
1208  )
1209  {
1210  oC_Bits_ClearBitsU16(&UsedPinsArray[PORT_INDEX(Pins)],PINS(Pins));
1211  DisconnectPinsFromExti(Pins);
1212 
1213  errorCode = oC_ErrorCode_None;
1214  }
1216  }
1217 
1218  return errorCode;
1219 }
1220 
1221 //==========================================================================================================================================
1226 //==========================================================================================================================================
1227 oC_ErrorCode_t oC_GPIO_LLD_CheckIsPinUsed( oC_Pins_t Pins , bool * outPinUsed )
1228 {
1229  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1230 
1231  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
1232  {
1234  if(
1235  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1236  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
1237  ErrorCondition( oC_GPIO_LLD_IsSinglePin(Pins), oC_ErrorCode_NotSinglePin) &&
1238  ErrorCondition( IsRam(outPinUsed), oC_ErrorCode_OutputAddressNotInRAM)
1239  )
1240  {
1241  if(oC_Bits_AreBitsSetU16(UsedPinsArray[PORT_INDEX(Pins)],PINS(Pins)))
1242  {
1243  *outPinUsed = true;
1244  errorCode = oC_ErrorCode_None;
1245  }
1246  else if(oC_Bits_AreBitsClearU16(UsedPinsArray[PORT_INDEX(Pins)],PINS(Pins)))
1247  {
1248  *outPinUsed = false;
1249  errorCode = oC_ErrorCode_None;
1250  }
1251  else
1252  {
1253  errorCode = oC_ErrorCode_NotAllPinsInTheSameState;
1254  }
1255  }
1257  }
1258 
1259  return errorCode;
1260 }
1261 
1262 //==========================================================================================================================================
1267 //==========================================================================================================================================
1268 oC_ErrorCode_t oC_GPIO_LLD_ArePinsUnused( oC_Pins_t Pins , bool * outPinsUnused )
1269 {
1270  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1271 
1272  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
1273  {
1275  if(
1276  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1277  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
1278  ErrorCondition( IsRam(outPinsUnused), oC_ErrorCode_OutputAddressNotInRAM)
1279  )
1280  {
1281  if(oC_Bits_AreBitsSetU16(UsedPinsArray[PORT_INDEX(Pins)],PINS(Pins)))
1282  {
1283  *outPinsUnused = false;
1284  errorCode = oC_ErrorCode_None;
1285  }
1286  else if(oC_Bits_AreBitsClearU16(UsedPinsArray[PORT_INDEX(Pins)],PINS(Pins)))
1287  {
1288  *outPinsUnused = true;
1289  errorCode = oC_ErrorCode_None;
1290  }
1291  else
1292  {
1293  errorCode = oC_ErrorCode_NotAllPinsInTheSameState;
1294  }
1295  }
1297  }
1298 
1299  return errorCode;
1300 }
1301 
1302 //=========================================================================================================================================
1307 //==========================================================================================================================================
1308 oC_ErrorCode_t oC_GPIO_LLD_WriteData( oC_Pins_t Pins , oC_PinsMask_t Data )
1309 {
1310  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1311 
1312  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
1313  {
1315  if(
1316  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1317  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
1318  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined)
1319  )
1320  {
1321  oC_PinsInPort_t pinsInPort = PINS(Pins);
1322  GPIOx_ODR(Pins)->Value = (GPIOx_ODR(Pins)->Value & ~pinsInPort) | (GPIOx_ODR(Pins)->Value & pinsInPort & Data);
1323  errorCode = oC_ErrorCode_None;
1324  }
1326  }
1327 
1328  return errorCode;
1329 }
1330 
1331 //==========================================================================================================================================
1336 //==========================================================================================================================================
1337 oC_ErrorCode_t oC_GPIO_LLD_ReadData( oC_Pins_t Pins , oC_PinsMask_t * outData )
1338 {
1339  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1340 
1341  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
1342  {
1344  if(
1345  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1346  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
1347  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
1348  ErrorCondition( IsRam(outData), oC_ErrorCode_OutputAddressNotInRAM)
1349  )
1350  {
1351  *outData = GPIOx_IDR(Pins)->Value & PINS(Pins);
1352  errorCode= oC_ErrorCode_None;
1353  }
1355  }
1356 
1357  return errorCode;
1358 }
1359 
1360 //==========================================================================================================================================
1365 //==========================================================================================================================================
1366 oC_ErrorCode_t oC_GPIO_LLD_ReadDataReference( oC_Pins_t Pins , oC_UInt_t ** outDataReference )
1367 {
1368  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1369 
1370  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
1371  {
1373  if(
1374  ErrorCondition( oC_GPIO_LLD_ArePinsCorrect(Pins), oC_ErrorCode_WrongChannel) &&
1375  ErrorCondition( IsPoweredOn(Pins), oC_ErrorCode_ChannelNotPoweredOn) &&
1376  ErrorCondition( PINS(Pins) != 0, oC_ErrorCode_PinNotDefined) &&
1377  ErrorCondition( IsRam(outDataReference), oC_ErrorCode_OutputAddressNotInRAM)
1378  )
1379  {
1380  *outDataReference = (oC_UInt_t*)&GPIOx_IDR(Pins)->Value;
1381  errorCode = oC_ErrorCode_None;
1382  }
1384  }
1385 
1386 
1387  return errorCode;
1388 }
1389 
1390 //==========================================================================================================================================
1395 //==========================================================================================================================================
1396 oC_Pins_t oC_GPIO_LLD_GetHighStatePins( oC_Pins_t Pins )
1397 {
1398  return oC_Pin_Make(PORT(Pins),(GPIOx_IDR(Pins)->Value & PINS(Pins)));
1399 }
1400 
1401 //==========================================================================================================================================
1406 //==========================================================================================================================================
1407 oC_Pins_t oC_GPIO_LLD_GetLowStatePins( oC_Pins_t Pins )
1408 {
1409  return oC_Pin_Make(PORT(Pins),(~GPIOx_IDR(Pins)->Value & PINS(Pins)));
1410 }
1411 
1412 //==========================================================================================================================================
1417 //==========================================================================================================================================
1418 bool oC_GPIO_LLD_IsPinsState( oC_Pins_t Pins , oC_GPIO_LLD_PinsState_t ExpectedPinsState )
1419 {
1420  return oC_Bits_AreBitsSetU16(PINS(Pins),ExpectedPinsState);
1421 }
1422 
1423 //==========================================================================================================================================
1428 //==========================================================================================================================================
1429 void oC_GPIO_LLD_SetPinsState( oC_Pins_t Pins , oC_GPIO_LLD_PinsState_t PinsState )
1430 {
1431  oC_Bits_SetValueU32((uint32_t*)&GPIOx_ODR(Pins)->Value, PinsState & PINS(Pins) , 0 , 16);
1432 }
1433 
1434 //==========================================================================================================================================
1439 //==========================================================================================================================================
1440 void oC_GPIO_LLD_TogglePinsState( oC_Pins_t Pins )
1441 {
1442  GPIOx_ODR(Pins)->Value = (GPIOx_ODR(Pins)->Value & (~PINS(Pins))) | ((GPIOx_ODR(Pins)->Value ^ PINS(Pins)) & PINS(Pins));
1443 }
1444 
1445 
1446 #undef _________________________________________INTERFACE_FUNCTIONS_SECTION_______________________________________________________________
1447 
1453 #define _________________________________________MSLLD_INTERFACE_FUNCTIONS_SECTION__________________________________________________________
1454 
1455 //==========================================================================================================================================
1460 //==========================================================================================================================================
1461 oC_ErrorCode_t oC_GPIO_MSLLD_SetAlternateNumber( oC_Pin_t Pin , oC_PinAlternateNumber_t Function )
1462 {
1463  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1464 
1465  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
1466  {
1467  if(
1468  ErrorCondition(oC_GPIO_LLD_IsSinglePin(Pin) , oC_ErrorCode_NotSinglePin) &&
1469  ErrorCondition(oC_GPIO_LLD_IsPinDefined(Pin) , oC_ErrorCode_PinNotDefined) &&
1470  ErrorCondition( IsPoweredOn(Pin), oC_ErrorCode_ChannelNotPoweredOn) &&
1471  ErrorCondition(Function <= oC_PinAlternateNumberMask , oC_ErrorCode_ValueTooBig)
1472  )
1473  {
1474  oC_PinsInPort_t pinsInPort = oC_Pin_GetPinsInPort(Pin);
1475  uint8_t bitIndex = oC_Bits_GetBitNumberU32(pinsInPort);
1476  oC_Register_t * regPointer = (bitIndex < 8) ? &GPIOx_AFRL(Pin)->Value : &GPIOx_AFRH(Pin)->Value;
1477 
1478  bitIndex = (bitIndex >= 8) ? bitIndex - 8 : bitIndex;
1479 
1481  oC_Bits_SetValueU32((uint32_t*)regPointer , Function , bitIndex * 4 , (bitIndex * 4) + 3);
1483 
1484  errorCode = oC_ErrorCode_None;
1485  }
1486  }
1487 
1488  return errorCode;
1489 }
1490 
1491 //==========================================================================================================================================
1496 //==========================================================================================================================================
1497 oC_ErrorCode_t oC_GPIO_MSLLD_ConnectPin( oC_Pin_t Pin , oC_PinAlternateNumber_t Function )
1498 {
1499  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1500 
1501  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
1502  {
1504  if(
1505  ErrorCondition(oC_GPIO_LLD_IsSinglePin(Pin) , oC_ErrorCode_NotSinglePin) &&
1506  ErrorCondition(oC_GPIO_LLD_IsPinDefined(Pin) , oC_ErrorCode_PinNotDefined) &&
1507  ErrorCondition(Function <= oC_PinAlternateNumberMask , oC_ErrorCode_ValueTooBig)
1508  )
1509  {
1510 
1511  if(
1512  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_BeginConfiguration(Pin)) &&
1513  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_SetMode(Pin , oC_GPIO_LLD_Mode_Alternate)) &&
1514  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_SetSpeed(Pin , oC_GPIO_LLD_Speed_Maximum)) &&
1515  oC_AssignErrorCode(&errorCode , oC_GPIO_MSLLD_SetAlternateNumber(Pin , Function )) &&
1516  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_FinishConfiguration(Pin))
1517  )
1518  {
1519  errorCode = oC_ErrorCode_None;
1520  }
1521 
1522  }
1524  }
1525 
1526  return errorCode;
1527 }
1528 
1529 //==========================================================================================================================================
1534 //==========================================================================================================================================
1535 oC_ErrorCode_t oC_GPIO_MSLLD_DisconnectPin( oC_Pin_t Pin , oC_PinAlternateNumber_t Function )
1536 {
1537  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1538 
1539  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
1540  {
1541  if(
1542  ErrorCondition(oC_GPIO_LLD_IsSinglePin(Pin) , oC_ErrorCode_NotSinglePin) &&
1543  ErrorCondition(oC_GPIO_LLD_IsPinDefined(Pin) , oC_ErrorCode_PinNotDefined) &&
1544  ErrorCondition(Function <= oC_PinAlternateNumberMask , oC_ErrorCode_ValueTooBig)
1545  )
1546  {
1548  if(
1549  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_BeginConfiguration(Pin)) &&
1550  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_SetMode(Pin , oC_GPIO_LLD_Mode_Default)) &&
1551  oC_AssignErrorCode(&errorCode , oC_GPIO_MSLLD_SetAlternateNumber(Pin , 0)) &&
1552  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_FinishConfiguration(Pin))
1553  )
1554  {
1555  errorCode = oC_ErrorCode_None;
1556  }
1558  }
1559  }
1560 
1561  return errorCode;
1562 }
1563 
1564 //==========================================================================================================================================
1569 //==========================================================================================================================================
1570 oC_ErrorCode_t oC_GPIO_MSLLD_FindModulePin( oC_Pin_t Pin , oC_Channel_t Channel , oC_PinFunction_t PinFunction , oC_ModulePinIndex_t * outModulePinIndex )
1571 {
1572  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1573 
1574  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_GPIO_LLD))
1575  {
1576  if(
1577  ErrorCondition(oC_GPIO_LLD_IsSinglePin(Pin) , oC_ErrorCode_NotSinglePin ) &&
1578  ErrorCondition(oC_GPIO_LLD_IsPinDefined(Pin) , oC_ErrorCode_PinNotDefined ) &&
1579  ErrorCondition(IsRam(outModulePinIndex) , oC_ErrorCode_OutputAddressNotInRAM )
1580  )
1581  {
1582  errorCode = oC_ErrorCode_NoneOfModulePinAssigned;
1583 
1584  oC_ModulePin_ForeachDefined(pinDefinition)
1585  {
1586  if(pinDefinition->Pin == Pin && pinDefinition->PinFunction == PinFunction && pinDefinition->Channel == Channel)
1587  {
1588  *outModulePinIndex = pinDefinition->ModulePinIndex;
1589  errorCode = oC_ErrorCode_None;
1590  break;
1591  }
1592  }
1593  }
1594  }
1595 
1596  return errorCode;
1597 }
1598 
1599 #undef _________________________________________MSLLD_INTERFACE_FUNCTIONS_SECTION__________________________________________________________
1600 
1606 #define _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________
1607 
1608 //==========================================================================================================================================
1621 //==========================================================================================================================================
1622 static void SetConfigurationBitsInRegister( oC_Register_t * outRegister , oC_PinsInPort_t PinsInPort , uint8_t Value )
1623 {
1624  const uint8_t fieldWidth = 2;
1625 
1626  for(uint8_t bitIndex = 0; bitIndex < oC_PORT_WIDTH ; bitIndex++ )
1627  {
1628  if(PinsInPort & (1<<bitIndex))
1629  {
1630  oC_Bits_SetValueU32((uint32_t*)outRegister,Value,bitIndex*fieldWidth,(bitIndex+1)*fieldWidth-1);
1631  }
1632  }
1633 }
1634 
1635 //==========================================================================================================================================
1651 //==========================================================================================================================================
1652 static uint8_t GetConfigurationBitsInRegister( oC_Register_t Register , oC_PinsInPort_t PinsInPort )
1653 {
1654  uint8_t value = 0;
1655  const uint8_t fieldWidth = 2;
1656 
1657  for(uint8_t bitIndex = 0; bitIndex < oC_PORT_WIDTH ; bitIndex++ )
1658  {
1659  if(PinsInPort & (1<<bitIndex))
1660  {
1661  value = oC_Bits_GetValueU32((uint32_t)Register,bitIndex*fieldWidth,(bitIndex+1)*fieldWidth-1);
1662  break;
1663  }
1664  }
1665 
1666  return value;
1667 }
1668 
1669 //==========================================================================================================================================
1673 //==========================================================================================================================================
1674 static oC_ErrorCode_t ConnectPinsToExti( oC_Pins_t Pins )
1675 {
1676  oC_ErrorCode_t errorCode = oC_ErrorCode_None;
1677  oC_PinsInPort_t pinsInPort = oC_Pin_GetPinsInPort(Pins);
1678 
1680 
1681  for(uint8_t bitIndex = 0; bitIndex < oC_PORT_WIDTH ; bitIndex++ )
1682  {
1683  if(pinsInPort & (1<<bitIndex))
1684  {
1685  if(ErrorCondition(!IsExtiUsed(bitIndex) , oC_ErrorCode_ExtiLineIsUsed))
1686  {
1687  SetExtiUsed(bitIndex);
1688 
1689  if(bitIndex <= 3)
1690  {
1691  oC_Bits_SetValueU32((uint32_t*)&SYSCFG_EXTICR1->Value , oC_Channel_ToIndex(GPIO,PORT(Pins)) , bitIndex * 4 , bitIndex * 4 + 3 );
1692  }
1693  else if(bitIndex <= 7)
1694  {
1695  oC_Bits_SetValueU32((uint32_t*)&SYSCFG_EXTICR2->Value , oC_Channel_ToIndex(GPIO,PORT(Pins)) , (bitIndex - 4) * 4 , (bitIndex - 4) * 4 + 3 );
1696  }
1697  else if(bitIndex <= 11)
1698  {
1699  oC_Bits_SetValueU32((uint32_t*)&SYSCFG_EXTICR3->Value , oC_Channel_ToIndex(GPIO,PORT(Pins)) , (bitIndex - 8) * 4 , (bitIndex - 8) * 4 + 3 );
1700  }
1701  else
1702  {
1703  oC_Bits_SetValueU32((uint32_t*)&SYSCFG_EXTICR4->Value , oC_Channel_ToIndex(GPIO,PORT(Pins)) , (bitIndex - 12) * 4 , (bitIndex - 12) * 4 + 3 );
1704  }
1705  }
1706  }
1707  }
1708 
1710  return errorCode;
1711 }
1712 
1713 //==========================================================================================================================================
1717 //==========================================================================================================================================
1718 static oC_ErrorCode_t DisconnectPinsFromExti( oC_Pins_t Pins )
1719 {
1720  oC_ErrorCode_t errorCode = oC_ErrorCode_None;
1721  oC_PinsInPort_t pinsInPort = oC_Pin_GetPinsInPort(Pins);
1722 
1723  for(uint8_t bitIndex = 0; bitIndex < oC_PORT_WIDTH ; bitIndex++ )
1724  {
1725  if(pinsInPort & (1<<bitIndex))
1726  {
1727  uint8_t startBit = 0;
1728  uint8_t endBit = 0;
1729  oC_Register_t * SYSCFG_EXTICR = NULL;
1730 
1731  if(bitIndex <= 3)
1732  {
1733  startBit = bitIndex * 4;
1734  endBit = bitIndex * 4 + 3;
1735  SYSCFG_EXTICR = &SYSCFG_EXTICR1->Value;
1736  }
1737  else if(bitIndex <= 7)
1738  {
1739  startBit = (bitIndex - 4) * 4;
1740  endBit = (bitIndex - 4) * 4 + 3;
1741  SYSCFG_EXTICR = &SYSCFG_EXTICR2->Value;
1742  }
1743  else if(bitIndex <= 11)
1744  {
1745  startBit = (bitIndex - 8) * 4;
1746  endBit = (bitIndex - 8) * 4 + 3;
1747  SYSCFG_EXTICR = &SYSCFG_EXTICR3->Value;
1748  }
1749  else
1750  {
1751  startBit = (bitIndex - 12) * 4;
1752  endBit = (bitIndex - 12) * 4 + 3;
1753  SYSCFG_EXTICR = &SYSCFG_EXTICR4->Value;
1754  }
1755 
1756  oC_ChannelIndex_t channelIndex = oC_Bits_GetValueU32(*SYSCFG_EXTICR,startBit,endBit);
1757 
1758  if(channelIndex == oC_Channel_ToIndex(GPIO,PORT(Pins)))
1759  {
1760  SetExtiUnused(bitIndex);
1761  oC_Bits_SetValueU32((uint32_t*)SYSCFG_EXTICR , oC_ModuleChannel_NumberOfElements(GPIO) , startBit , endBit );
1762  }
1763 
1764  }
1765  }
1766 
1767  return errorCode;
1768 }
1769 
1770 //==========================================================================================================================================
1774 //==========================================================================================================================================
1775 static oC_Port_t GetPortOfExtiLine( uint8_t ExtiLine )
1776 {
1777  uint8_t startBit = 0;
1778  uint8_t endBit = 0;
1779  oC_Register_t * SYSCFG_EXTICR = NULL;
1780 
1781  if(ExtiLine <= 3)
1782  {
1783  startBit = ExtiLine * 4;
1784  endBit = ExtiLine * 4 + 3;
1785  SYSCFG_EXTICR = &SYSCFG_EXTICR1->Value;
1786  }
1787  else if(ExtiLine <= 7)
1788  {
1789  startBit = (ExtiLine - 4) * 4;
1790  endBit = (ExtiLine - 4) * 4 + 3;
1791  SYSCFG_EXTICR = &SYSCFG_EXTICR2->Value;
1792  }
1793  else if(ExtiLine <= 11)
1794  {
1795  startBit = (ExtiLine - 8) * 4;
1796  endBit = (ExtiLine - 8) * 4 + 3;
1797  SYSCFG_EXTICR = &SYSCFG_EXTICR3->Value;
1798  }
1799  else
1800  {
1801  startBit = (ExtiLine - 12) * 4;
1802  endBit = (ExtiLine - 12) * 4 + 3;
1803  SYSCFG_EXTICR = &SYSCFG_EXTICR4->Value;
1804  }
1805 
1806  oC_ChannelIndex_t channelIndex = oC_Bits_GetValueU32(*SYSCFG_EXTICR,startBit,endBit);
1807 
1808  return oC_Channel_FromIndex(GPIO,channelIndex);
1809 }
1810 
1811 //==========================================================================================================================================
1815 //==========================================================================================================================================
1816 static bool SetExtiLineInterruptState( uint8_t ExtiLine , bool Enabled )
1817 {
1818  static const IRQn_Type irqns[] = {
1819  EXTI0EXTI_IRQn ,
1820  EXTI1EXTI_IRQn ,
1821  EXTI2EXTI_IRQn ,
1822  EXTI3EXTI_IRQn ,
1823  EXTI4EXTI_IRQn ,
1824  EXTI5_9EXTI_IRQn ,
1825  EXTI5_9EXTI_IRQn ,
1826  EXTI5_9EXTI_IRQn ,
1827  EXTI5_9EXTI_IRQn ,
1828  EXTI5_9EXTI_IRQn ,
1829  EXTI10_15EXTI_IRQn ,
1830  EXTI10_15EXTI_IRQn ,
1831  EXTI10_15EXTI_IRQn ,
1832  EXTI10_15EXTI_IRQn ,
1833  EXTI10_15EXTI_IRQn ,
1834  EXTI10_15EXTI_IRQn
1835  };
1836 
1837  oC_ASSERT( ExtiLine < oC_ARRAY_SIZE(irqns) );
1838 
1839  return Enabled ? oC_MCS_EnableInterrupt(irqns[ExtiLine]) : oC_MCS_DisableInterrupt(irqns[ExtiLine]);
1840 }
1841 
1842 //==========================================================================================================================================
1846 //==========================================================================================================================================
1847 static bool SetInterruptsStateForPins( oC_Pins_t Pins , bool Enabled )
1848 {
1849  oC_PinsInPort_t pinsInPort = oC_Pin_GetPinsInPort(Pins);
1850  oC_Port_t port = oC_Pin_GetPort(Pins);
1851  bool allEnabled = true;
1852 
1853  for(uint8_t bitIndex = 0; bitIndex < oC_PORT_WIDTH ; bitIndex++ )
1854  {
1855  if(pinsInPort & (1<<bitIndex))
1856  {
1857  oC_Port_t extiPort = GetPortOfExtiLine(bitIndex);
1858 
1859  if(port == extiPort)
1860  {
1861  allEnabled = allEnabled && SetExtiLineInterruptState(bitIndex , Enabled);
1862  }
1863  else
1864  {
1865  allEnabled = false;
1866  }
1867  }
1868  }
1869 
1870  return allEnabled;
1871 }
1872 
1873 
1874 #undef _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________
1875 
1876 
1882 #define _________________________________________INTERRUPTS_SECTION________________________________________________________________________
1883 
1884 //==========================================================================================================================================
1888 //==========================================================================================================================================
1889 oC_InterruptHandler(EXTI,EXTI0)
1890 {
1891  oC_Port_t port = GetPortOfExtiLine(0);
1892 
1893  if((IsRam(InterruptHandler) || IsRom(InterruptHandler)) && oC_Channel_IsCorrect(GPIO,port))
1894  {
1895  InterruptHandler( oC_Pin_Make( port , EXTI_PR->Value ) );
1896  }
1897 
1898  EXTI_PR->Value |= (1<<0);
1899 }
1900 
1901 //==========================================================================================================================================
1905 //==========================================================================================================================================
1906 oC_InterruptHandler(EXTI,EXTI1)
1907 {
1908  oC_Port_t port = GetPortOfExtiLine(1);
1909 
1910  if((IsRam(InterruptHandler) || IsRom(InterruptHandler)) && oC_Channel_IsCorrect(GPIO,port))
1911  {
1912  InterruptHandler( oC_Pin_Make( port , EXTI_PR->Value ) );
1913  }
1914 
1915  EXTI_PR->Value |= (1<<1);
1916 }
1917 
1918 //==========================================================================================================================================
1922 //==========================================================================================================================================
1923 oC_InterruptHandler(EXTI,EXTI2)
1924 {
1925  oC_Port_t port = GetPortOfExtiLine(2);
1926 
1927  if((IsRam(InterruptHandler) || IsRom(InterruptHandler)) && oC_Channel_IsCorrect(GPIO,port))
1928  {
1929  InterruptHandler( oC_Pin_Make( port , EXTI_PR->Value ) );
1930  }
1931 
1932  EXTI_PR->Value |= (1<<2);
1933 }
1934 
1935 //==========================================================================================================================================
1939 //==========================================================================================================================================
1940 oC_InterruptHandler(EXTI,EXTI3)
1941 {
1942  oC_Port_t port = GetPortOfExtiLine(3);
1943 
1944  if((IsRam(InterruptHandler) || IsRom(InterruptHandler)) && oC_Channel_IsCorrect(GPIO,port))
1945  {
1946  InterruptHandler( oC_Pin_Make( port , EXTI_PR->Value ) );
1947  }
1948 
1949  EXTI_PR->Value |= (1<<3);
1950 }
1951 
1952 //==========================================================================================================================================
1956 //==========================================================================================================================================
1957 oC_InterruptHandler(EXTI,EXTI4)
1958 {
1959  oC_Port_t port = GetPortOfExtiLine(4);
1960 
1961  if((IsRam(InterruptHandler) || IsRom(InterruptHandler)) && oC_Channel_IsCorrect(GPIO,port))
1962  {
1963  InterruptHandler( oC_Pin_Make( port , EXTI_PR->Value ) );
1964  }
1965 
1966  EXTI_PR->Value |= (1<<4);
1967 }
1968 
1969 //==========================================================================================================================================
1973 //==========================================================================================================================================
1974 oC_InterruptHandler(EXTI,EXTI5_9)
1975 {
1976  if((IsRam(InterruptHandler) || IsRom(InterruptHandler)))
1977  {
1978  for(uint8_t extiLine = 5; extiLine < 10 ; extiLine++)
1979  {
1980  oC_Port_t port = GetPortOfExtiLine(extiLine);
1981 
1982  if(oC_Channel_IsCorrect(GPIO,port) && oC_Bits_IsBitSetU32(EXTI_PR->Value,extiLine))
1983  {
1984  InterruptHandler( oC_Pin_Make( port , 1<<extiLine ) );
1985  }
1986 
1987  }
1988 
1989  }
1990 
1991  EXTI_PR->Value |= oC_Bits_Mask_U32(5,9);
1992 }
1993 
1994 //==========================================================================================================================================
1998 //==========================================================================================================================================
1999 oC_InterruptHandler(EXTI,EXTI10_15)
2000 {
2001  if((IsRam(InterruptHandler) || IsRom(InterruptHandler)))
2002  {
2003  for(uint8_t extiLine = 10; extiLine < 16 ; extiLine++)
2004  {
2005  oC_Port_t port = GetPortOfExtiLine(extiLine);
2006 
2007  if(oC_Channel_IsCorrect(GPIO,port) && oC_Bits_IsBitSetU32(EXTI_PR->Value,extiLine))
2008  {
2009  InterruptHandler( oC_Pin_Make( port , 1<<extiLine ) );
2010  }
2011  }
2012 
2013  }
2014 
2015  EXTI_PR->Value |= oC_Bits_Mask_U32(10,15);
2016 }
2017 
2018 #undef _________________________________________INTERRUPTS_SECTION________________________________________________________________________
2019 
#define oC_InterruptHandler(BASE_NAME, TYPE_NAME)
Define handler for interrupt.
Something is powered on.
Definition: oc_stdtypes.h:252
The file with interface for LLD layer.
static bool oC_Bits_AreBitsSetU16(uint16_t BitMask, uint16_t BitsToCheck)
checks if all bits in field are set
Definition: oc_bits.h:867
#define oC_ARRAY_SIZE(ARRAY)
returns size of static array
Definition: oc_array.h:36
static uint16_t oC_Bits_SetBitsU16(uint16_t *outVariable, uint16_t Mask)
Definition: oc_bits.h:137
static bool oC_Bits_AreBitsClearU16(uint16_t BitMask, uint16_t BitsToCheck)
checks if all bits in field are clear
Definition: oc_bits.h:935
Something power is not handled.
Definition: oc_stdtypes.h:253
#define oC_Bits_Mask_U32(FROM, TO)
Definition: oc_bits.h:73
volatile oC_UInt_t oC_Register_t
type for storing registers
Definition: oc_registers.h:136
static uint32_t oC_Bits_SetValueU32(uint32_t *outVariable, uint32_t Value, uint8_t StartBitNr, uint8_t EndBitNr)
Definition: oc_bits.h:308
static uint32_t oC_Bits_GetValueU32(uint32_t Variable, uint8_t StartBitNr, uint8_t EndBitNr)
Definition: oc_bits.h:395
The file with interface for LSF module.
#define oC_Channel_GetName(Channel)
returns name of channel
Definition: oc_channels.h:391
The file with LLD interface for the MEM driver.
The file with LLD interface for the GPIO driver.
bool oC_MCS_EnableInterrupt(IRQn_Type InterruptNumber)
enables interrupt with specified number
Definition: oc_mcs.c:368
The file with interface for the module library.
static bool oC_Module_IsTurnedOn(oC_Module_t Module)
checks if the module is turned on
Definition: oc_module.h:121
Something is powered off.
Definition: oc_stdtypes.h:251
static oC_ErrorCode_t ReadData(oC_FMC_Context_t Context, char *outData)
Reads one byte from the configured buffer.
Definition: oc_fmc.c:624
oC_Channel_t
stores machine channel
Definition: oc_channels.h:573
static int8_t oC_Bits_GetBitNumberU32(uint32_t BitMask)
Definition: oc_bits.h:585
#define oC_Channel_IsCorrect(MODULE_NAME, Channel)
checks if channel is correct
Definition: oc_channels.h:283
#define oC_Channel_FromIndex(MODULE_NAME, ChannelIndex)
returns channel according to index in module
Definition: oc_channels.h:313
#define oC_ModuleChannel_NumberOfElements(MODULE_NAME)
Number of elements in module channel.
Definition: oc_channels.h:465
static void oC_Module_TurnOn(oC_Module_t Module)
sets module as turned on
Definition: oc_module.h:170
Contains machine core specific functions.
The file with functions for the bits operation.
IRQn_Type
type for the CMSIS library, that contains definitions of interrupts
Definition: oc_mcs.h:149
static void oC_MCS_EnterCriticalSection(void)
Enters to critical section.
Definition: oc_mcs.h:755
static bool oC_Bits_IsBitSetU32(uint32_t BitMask, uint8_t BitIndex)
checks if bit is set
Definition: oc_bits.h:679
static oC_Power_t oC_Machine_GetPowerStateForChannel(oC_Channel_t Channel)
returns power state for channel
Definition: oc_machine.h:550
static uint16_t oC_Bits_ClearBitsU16(uint16_t *outVariable, uint16_t Mask)
Definition: oc_bits.h:205
static oC_ErrorCode_t WriteData(oC_FMC_Context_t Context, char Data)
Writes one byte to the configured buffer.
Definition: oc_fmc.c:646
static bool oC_Module_TurnOffVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned off
Definition: oc_module.h:155
static bool oC_MCS_ExitCriticalSection(void)
Exits from critical section.
Definition: oc_mcs.h:784
static bool oC_Module_TurnOnVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned on
Definition: oc_module.h:138
#define oC_Channel_ToIndex(MODULE_NAME, Channel)
returns index in module according to channel
Definition: oc_channels.h:298
static void InterruptHandler(oC_ETH_LLD_InterruptSource_t Source)
handler for interrupts
Definition: oc_eth.c:1124
bool oC_MCS_DisableInterrupt(IRQn_Type InterruptNumber)
disables interrupt with specified number
Definition: oc_mcs.c:379
static bool oC_Machine_SetPowerStateForChannel(oC_Channel_t Channel, oC_Power_t Power)
configures power state for machine channel
Definition: oc_machine.h:593
oC_Power_t
stores registers power state
Definition: oc_stdtypes.h:249
#define NULL
pointer to a zero
Definition: oc_null.h:37
static void oC_Module_TurnOff(oC_Module_t Module)
sets module as turned off
Definition: oc_module.h:185