Choco OS  V.0.16.9.0
Join to the chocolate world
oc_uart_lld.c
1 
27 #include <oc_uart_lld.h>
28 #include <oc_mem_lld.h>
29 #include <oc_bits.h>
30 #include <oc_gpio_mslld.h>
31 #include <oc_array.h>
32 #include <oc_clock_lld.h>
33 #include <oc_dma_lld.h>
34 #include <oc_module.h>
35 #include <oc_lsf.h>
36 #include <oc_stdtypes.h>
37 #include <string.h>
38 #include <oc_compiler.h>
39 
45 #define _________________________________________MACROS_SECTION_____________________________________________________________________________
46 
47 #define USE_INTERRUPTS_FOR_TX false
48 #define SOFTWARE_RING_COUNT 10
49 #define IsRam(Address) (oC_LSF_IsRamAddress(Address) || oC_LSF_IsExternalAddress(Address))
50 #define IsRom(Address) oC_LSF_IsRomAddress(Address)
51 #define IsChannelCorrect(Channel) oC_Channel_IsCorrect(UART,Channel)
52 #define IsChannelPoweredOn(Channel) (oC_Machine_GetPowerStateForChannel(Channel) == oC_Power_On)
53 #define AreOperationsDisabled(Channel) (USARTx_CR1(Channel)->UE == 0)
54 #define AreOperationsEnabled(Channel) (USARTx_CR1(Channel)->UE == 1)
55 #define USARTx_CR1(Channel) oC_Machine_Register(Channel , USARTx_CR1)
56 #define USARTx_CR2(Channel) oC_Machine_Register(Channel , USARTx_CR2)
57 #define USARTx_CR3(Channel) oC_Machine_Register(Channel , USARTx_CR3)
58 #define USARTx_BRR(Channel) oC_Machine_Register(Channel , USARTx_BRR)
59 #define USARTx_SR(Channel) oC_Machine_Register(Channel , USARTx_SR)
60 #define USARTx_DR(Channel) oC_Machine_Register(Channel , USARTx_DR)
61 #define USARTx_GPTR(Channel) oC_Machine_Register(Channel , USARTx_GPTR)
62 #define TransmitDataMovedToFifo(Channel) (USARTx_SR(Channel)->TXE == 1)
63 #define ReceiveDataAvailable(Channel) (USARTx_SR(Channel)->RXNE == 1)
64 #define RCC_DCKCFGR oC_Register(RCC,RCC_DCKCFGR)
65 #define RxRing(Channel) SoftwareRxRings[oC_Channel_ToIndex(UART,Channel)]
66 #define IsSoftwareRxRingEmpty(Channel) (RxRing(Channel).Counter == 0)
67 #define IsSoftwareRxRingFull(Channel) (RxRing(Channel).Counter == SOFTWARE_RING_COUNT)
68 #define TxRing(Channel) SoftwareTxRings[oC_Channel_ToIndex(UART,Channel)]
69 #define IsSoftwareTxRingEmpty(Channel) (TxRing(Channel).Counter == 0)
70 #define IsSoftwareTxRingFull(Channel) (TxRing(Channel).Counter == SOFTWARE_RING_COUNT)
71 
72 
73 #undef _________________________________________MACROS_SECTION_____________________________________________________________________________
74 
80 #define _________________________________________TYPES_SECTION______________________________________________________________________________
81 
82 typedef struct
83 {
84  uint16_t Buffer[SOFTWARE_RING_COUNT];
85  uint16_t PutIndex;
86  uint16_t GetIndex;
87  uint16_t Counter;
89 
90 #undef _________________________________________TYPES_SECTION______________________________________________________________________________
91 
97 #define _________________________________________LOCAL_PROTOTYPES_SECTION___________________________________________________________________
98 
99 static inline void PutToSoftwareRing ( SoftwareRing_t * Ring , uint16_t Data );
100 static inline uint16_t GetFromSoftwareRing( SoftwareRing_t * Ring );
101 static inline void ClearSoftwareRing ( SoftwareRing_t * Ring );
102 
103 #undef _________________________________________LOCAL_PROTOTYPES_SECTION___________________________________________________________________
104 
105 
111 #define _________________________________________VARIABLES_SECTION__________________________________________________________________________
112 
113 static oC_UART_LLD_Interrupt_t RxNotEmptyHandler = NULL;
114 static oC_UART_LLD_Interrupt_t TxNotFullHandler = NULL;
115 static SoftwareRing_t SoftwareRxRings[oC_ModuleChannel_NumberOfElements(UART)];
116 static SoftwareRing_t SoftwareTxRings[oC_ModuleChannel_NumberOfElements(UART)];
117 #if oC_ModuleChannel_NumberOfElements(UART) <= 8
118 static uint8_t UsedChannels = 0;
119 #elif oC_ModuleChannel_NumberOfElements(UART) <= 16
120 static uint16_t UsedChannels = 0;
121 #elif oC_ModuleChannel_NumberOfElements(UART) <= 32
122 static uint32_t UsedChannels = 0;
123 #elif oC_ModuleChannel_NumberOfElements(UART) <= 64
124 static uint64_t UsedChannels = 0;
125 #else
126 # error Number of UART channels is too big (max 64)
127 #endif
128 
129 #undef _________________________________________VARIABLES_SECTION__________________________________________________________________________
130 
136 #define _________________________________________FUNCTIONS_SECTION__________________________________________________________________________
137 
138 //==========================================================================================================================================
143 //==========================================================================================================================================
144 bool oC_UART_LLD_IsChannelCorrect( oC_UART_Channel_t Channel )
145 {
146  return oC_Channel_IsCorrect(UART,Channel);
147 }
148 
149 //==========================================================================================================================================
154 //==========================================================================================================================================
155 bool oC_UART_LLD_IsChannelIndexCorrect( oC_UART_LLD_ChannelIndex_t ChannelIndex )
156 {
157  return ChannelIndex < oC_ModuleChannel_NumberOfElements(UART);
158 }
159 
160 //==========================================================================================================================================
165 //==========================================================================================================================================
166 oC_UART_LLD_ChannelIndex_t oC_UART_LLD_ChannelToChannelIndex( oC_UART_Channel_t Channel )
167 {
168  return oC_Channel_ToIndex(UART,Channel);
169 }
170 
171 //==========================================================================================================================================
176 //==========================================================================================================================================
177 oC_UART_Channel_t oC_UART_LLD_ChannelIndexToChannel( oC_UART_LLD_ChannelIndex_t Channel )
178 {
179  return oC_Channel_FromIndex(UART,Channel);
180 }
181 
182 //==========================================================================================================================================
187 //==========================================================================================================================================
188 oC_UART_Channel_t oC_UART_LLD_GetChannelOfModulePin( oC_UART_Pin_t ModulePin )
189 {
190  return oC_ModulePin_GetChannel(ModulePin);
191 }
192 
193 //==========================================================================================================================================
198 //==========================================================================================================================================
199 oC_ErrorCode_t oC_UART_LLD_TurnOnDriver( void )
200 {
201  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
202 
204 
205  if(oC_Module_TurnOffVerification(&errorCode , oC_Module_UART_LLD))
206  {
207  oC_Module_TurnOn(oC_Module_UART_LLD);
208  errorCode = oC_ErrorCode_None;
209  RxNotEmptyHandler = NULL;
210  TxNotFullHandler = NULL;
211  UsedChannels = 0;
212 
213  memset(SoftwareRxRings,0,sizeof(SoftwareRxRings));
214  memset(SoftwareTxRings,0,sizeof(SoftwareTxRings));
215  }
216 
218 
219  return errorCode;
220 }
221 
222 //==========================================================================================================================================
227 //==========================================================================================================================================
228 oC_ErrorCode_t oC_UART_LLD_TurnOffDriver( void )
229 {
230  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
231 
233 
234  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
235  {
236  oC_Module_TurnOff(oC_Module_UART_LLD);
237  errorCode = oC_ErrorCode_None;
238  }
239 
241 
242  return errorCode;
243 }
244 
245 //==========================================================================================================================================
250 //==========================================================================================================================================
251 oC_ErrorCode_t oC_UART_LLD_SetDriverInterruptHandlers( oC_UART_LLD_Interrupt_t RxNotEmpty , oC_UART_LLD_Interrupt_t TxNotFull)
252 {
253  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
254 
256 
257  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
258  {
259  if(
260  ErrorCondition( IsRam(RxNotEmpty) || IsRom(RxNotEmpty) , oC_ErrorCode_WrongEventHandlerAddress) &&
261  ErrorCondition( RxNotEmptyHandler == NULL , oC_ErrorCode_InterruptHandlerAlreadySet) &&
262  ErrorCondition( IsRam(TxNotFull) || IsRom(TxNotFull) , oC_ErrorCode_WrongEventHandlerAddress) &&
263  ErrorCondition( TxNotFullHandler == NULL , oC_ErrorCode_InterruptHandlerAlreadySet)
264  )
265  {
266  RxNotEmptyHandler = RxNotEmpty;
267  TxNotFullHandler = TxNotFull;
268  errorCode = oC_ErrorCode_None;
269  }
270  }
271 
273 
274  return errorCode;
275 }
276 
277 //==========================================================================================================================================
282 //==========================================================================================================================================
283 oC_ErrorCode_t oC_UART_LLD_SetPower( oC_UART_Channel_t Channel , oC_Power_t Power )
284 {
285  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
286 
288 
289  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
290  {
291  if(
292  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
293  ErrorCondition( Power == oC_Power_On || Power == oC_Power_Off , oC_ErrorCode_PowerStateNotCorrect) &&
294  ErrorCondition( oC_Machine_SetPowerStateForChannel(Channel,Power) , oC_ErrorCode_CannotEnableChannel) &&
295  ErrorCondition( oC_Channel_EnableInterrupt(Channel,PeripheralInterrupt) , oC_ErrorCode_CannotEnableInterrupt)
296  )
297  {
298  oC_ChannelIndex_t channelIndex = oC_Channel_ToIndex(UART,Channel);
299 
300  oC_ASSERT(channelIndex < oC_ModuleChannel_NumberOfElements(UART));
301 
302  oC_Channel_SetInterruptPriority(Channel,PeripheralInterrupt,oC_InterruptPriority_Maximum);
303 
304  errorCode = oC_ErrorCode_None;
305  }
306  }
307 
309 
310  return errorCode;
311 }
312 
313 //==========================================================================================================================================
318 //==========================================================================================================================================
319 oC_ErrorCode_t oC_UART_LLD_ReadPower( oC_UART_Channel_t Channel , oC_Power_t * outPower )
320 {
321  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
322 
324 
325  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
326  {
327  if(
328  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
329  ErrorCondition( IsRam(outPower) , oC_ErrorCode_OutputAddressNotInRAM)
330  )
331  {
332  *outPower = oC_Machine_GetPowerStateForChannel(Channel);
333  errorCode = oC_ErrorCode_None;
334  }
335  }
336 
338 
339  return errorCode;
340 }
341 //==========================================================================================================================================
346 //==========================================================================================================================================
347 oC_ErrorCode_t oC_UART_LLD_DisableOperations( oC_UART_Channel_t Channel )
348 {
349  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
350 
352 
353  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
354  {
355  if(
356  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
357  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn)
358  )
359  {
360  USARTx_CR1(Channel)->UE = 0;
361  errorCode = oC_ErrorCode_None;
362  }
363  }
364 
366 
367  return errorCode;
368 }
369 
370 //==========================================================================================================================================
375 //==========================================================================================================================================
376 oC_ErrorCode_t oC_UART_LLD_EnableOperations( oC_UART_Channel_t Channel )
377 {
378  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
379 
381 
382  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
383  {
384  if(
385  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
386  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn)
387  )
388  {
389  USARTx_CR1(Channel)->UE = 1;
390  USARTx_CR1(Channel)->TE = 1;
391  USARTx_CR1(Channel)->RE = 1;
392  USARTx_CR1(Channel)->RXNEIE = 1;
393  errorCode = oC_ErrorCode_None;
394  }
395  }
396 
398 
399  return errorCode;
400 }
401 
402 //==========================================================================================================================================
407 //==========================================================================================================================================
408 oC_ErrorCode_t oC_UART_LLD_RestoreDefaultStateOnChannel( oC_UART_Channel_t Channel )
409 {
410  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
411 
413 
414  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
415  {
416  if(
417  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
418  ErrorCondition( oC_Machine_SetPowerStateForChannel(Channel,oC_Power_Off) , oC_ErrorCode_CannotRestoreDefaultState)
419  )
420  {
421  errorCode = oC_ErrorCode_None;
422  }
423  }
424 
426 
427  return errorCode;
428 }
429 
430 //==========================================================================================================================================
435 //==========================================================================================================================================
436 oC_ErrorCode_t oC_UART_LLD_SetWordLength( oC_UART_Channel_t Channel , oC_UART_LLD_WordLength_t WordLength )
437 {
438  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
439 
441 
442  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
443  {
444  if(
445  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
446  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
447  ErrorCondition( AreOperationsDisabled(Channel) , oC_ErrorCode_ChannelOperationsNotDisabled)
448  )
449  {
450  switch(WordLength)
451  {
452  case oC_UART_LLD_WordLength_5Bits:
453  errorCode = oC_ErrorCode_NotSupportedOnTargetMachine;
454  break;
455  case oC_UART_LLD_WordLength_6Bits:
456  errorCode = oC_ErrorCode_NotSupportedOnTargetMachine;
457  break;
458  case oC_UART_LLD_WordLength_7Bits:
459  errorCode = oC_ErrorCode_NotSupportedOnTargetMachine;
460  break;
461  case oC_UART_LLD_WordLength_8Bits:
462  USARTx_CR1(Channel)->M = 0;
463  errorCode = oC_ErrorCode_None;
464  break;
465  case oC_UART_LLD_WordLength_9Bits:
466  USARTx_CR1(Channel)->M = 1;
467 
468  /* ***************************************************************** **
469  * Data in UART transmit/receive functions are given by char (uint8),
470  * Thanks to that transmission functions is quite simple. We will keep
471  * this until it is not very important. If you need 9bits transmission,
472  * please tell us with explanation, and we will try to fix this problem.
473  * ***************************************************************** */
474  errorCode = oC_ErrorCode_ProhibitedByArchitecture;
475  break;
476  default:
477  errorCode = oC_ErrorCode_WordLengthNotCorrect;
478  break;
479  }
480  }
481  }
482 
484 
485  return errorCode;
486 }
487 
488 //==========================================================================================================================================
493 //==========================================================================================================================================
494 oC_ErrorCode_t oC_UART_LLD_ReadWordLength( oC_UART_Channel_t Channel , oC_UART_LLD_WordLength_t * outWordLength )
495 {
496  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
497 
498  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
499  {
500  if(
501  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
502  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
503  ErrorCondition( IsRam(outWordLength) , oC_ErrorCode_OutputAddressNotInRAM)
504  )
505  {
506  if( USARTx_CR1(Channel)->M == 0 )
507  {
508  *outWordLength = oC_UART_LLD_WordLength_8Bits;
509  errorCode = oC_ErrorCode_None;
510  }
511  else if( USARTx_CR1(Channel)->M == 1 )
512  {
513  *outWordLength = oC_UART_LLD_WordLength_9Bits;
514  errorCode = oC_ErrorCode_None;
515  }
516  else
517  {
518  errorCode = oC_ErrorCode_MachineCanBeDamaged;
519  }
520  }
521  }
522 
523  return errorCode;
524 }
525 
526 //==========================================================================================================================================
531 //==========================================================================================================================================
532 oC_ErrorCode_t oC_UART_LLD_SetBitRate( oC_UART_Channel_t Channel , uint32_t BitRate )
533 {
534  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
535 
537 
538  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
539  {
540  if(
541  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
542  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
543  ErrorCondition( AreOperationsDisabled(Channel) , oC_ErrorCode_ChannelOperationsNotDisabled) &&
544  ErrorCondition( BitRate > 0 , oC_ErrorCode_BitRateNotCorrect)
545  )
546  {
548  uint32_t usartDiv = (clockFrequency / BitRate);
549 
550  if(usartDiv <= UINT16_MAX)
551  {
552  USARTx_CR1(Channel)->OVER8 = 0;
553  USARTx_BRR(Channel)->BRR = usartDiv;
554  errorCode = oC_ErrorCode_None;
555  }
556  else
557  {
558  errorCode = oC_ErrorCode_BitRateNotSupported;
559  }
560  }
561  }
562 
564 
565  return errorCode;
566 }
567 
568 //==========================================================================================================================================
573 //==========================================================================================================================================
574 oC_ErrorCode_t oC_UART_LLD_ReadBitRate( oC_UART_Channel_t Channel , uint32_t * outBitRate )
575 {
576  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
577 
578  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
579  {
580  if(
581  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
582  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
583  ErrorCondition( IsRam(outBitRate) , oC_ErrorCode_OutputAddressNotInRAM)
584  )
585  {
587  uint32_t usartDiv = USARTx_BRR(Channel)->BRR;
588 
589  if(usartDiv > 0)
590  {
591  *outBitRate = clockFrequency / usartDiv;
592  }
593  else
594  {
595  *outBitRate = 0;
596  }
597 
598  errorCode = oC_ErrorCode_None;
599  }
600  }
601 
602  return errorCode;
603 }
604 
605 //==========================================================================================================================================
610 //==========================================================================================================================================
611 oC_ErrorCode_t oC_UART_LLD_SetParity( oC_UART_Channel_t Channel , oC_UART_LLD_Parity_t Parity )
612 {
613  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
614 
616 
617  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
618  {
619  if(
620  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
621  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
622  ErrorCondition( AreOperationsDisabled(Channel) , oC_ErrorCode_ChannelOperationsNotDisabled)
623  )
624  {
625  switch(Parity)
626  {
627  case oC_UART_LLD_Parity_None:
628  USARTx_CR1(Channel)->PCE = 0;
629  errorCode = oC_ErrorCode_None;
630  break;
631  case oC_UART_LLD_Parity_Even:
632  USARTx_CR1(Channel)->PCE = 1;
633  USARTx_CR1(Channel)->PS = 0;
634  errorCode = oC_ErrorCode_None;
635  break;
636  case oC_UART_LLD_Parity_Odd:
637  USARTx_CR1(Channel)->PCE = 1;
638  USARTx_CR1(Channel)->PS = 1;
639  errorCode = oC_ErrorCode_None;
640  break;
641  default:
642  errorCode = oC_ErrorCode_ParityNotCorrect;
643  break;
644  }
645  }
646  }
647 
649 
650  return errorCode;
651 }
652 
653 //==========================================================================================================================================
658 //==========================================================================================================================================
659 oC_ErrorCode_t oC_UART_LLD_ReadParity( oC_UART_Channel_t Channel , oC_UART_LLD_Parity_t * outParity )
660 {
661  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
662 
663  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
664  {
665  if(
666  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
667  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
668  ErrorCondition( IsRam(outParity) , oC_ErrorCode_OutputAddressNotInRAM)
669  )
670  {
671  if(USARTx_CR1(Channel)->PCE == 0)
672  {
673  *outParity = oC_UART_LLD_Parity_None;
674  errorCode = oC_ErrorCode_None;
675  }
676  else if(USARTx_CR1(Channel)->PS == 0)
677  {
678  *outParity = oC_UART_LLD_Parity_Even;
679  errorCode = oC_ErrorCode_None;
680  }
681  else if(USARTx_CR1(Channel)->PS == 1)
682  {
683  *outParity = oC_UART_LLD_Parity_Odd;
684  errorCode = oC_ErrorCode_None;
685  }
686  else
687  {
688  errorCode = oC_ErrorCode_MachineCanBeDamaged;
689  }
690  }
691  }
692 
693  return errorCode;
694 }
695 
696 //==========================================================================================================================================
701 //==========================================================================================================================================
702 oC_ErrorCode_t oC_UART_LLD_SetStopBit( oC_UART_Channel_t Channel , oC_UART_LLD_StopBit_t StopBit )
703 {
704  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
705 
707 
708  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
709  {
710  if(
711  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
712  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
713  ErrorCondition( AreOperationsDisabled(Channel) , oC_ErrorCode_ChannelOperationsNotDisabled)
714  )
715  {
716  //TODO: 0.5,1.5 bit are not avaible for UART4 i UART5
717  switch(StopBit)
718  {
719  case oC_UART_LLD_StopBit_0p5Bit:
720  USARTx_CR2(Channel)->STOP = 1;
721  errorCode = oC_ErrorCode_None;
722  break;
723  case oC_UART_LLD_StopBit_1Bit:
724  USARTx_CR2(Channel)->STOP = 0;
725  errorCode = oC_ErrorCode_None;
726  break;
727  case oC_UART_LLD_StopBit_1p5Bits:
728  USARTx_CR2(Channel)->STOP = 3;
729  errorCode = oC_ErrorCode_None;
730  break;
731  case oC_UART_LLD_StopBit_2Bits:
732  USARTx_CR2(Channel)->STOP = 2;
733  errorCode = oC_ErrorCode_None;
734  break;
735  default:
736  errorCode = oC_ErrorCode_StopBitNotSupported;
737  break;
738  }
739  }
740  }
741 
743 
744 
745  return errorCode;
746 }
747 
748 //==========================================================================================================================================
753 //==========================================================================================================================================
754 oC_ErrorCode_t oC_UART_LLD_ReadStopBit( oC_UART_Channel_t Channel , oC_UART_LLD_StopBit_t * outStopBit )
755 {
756  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
757 
758  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
759  {
760  if(
761  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
762  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
763  ErrorCondition( IsRam(outStopBit) , oC_ErrorCode_OutputAddressNotInRAM)
764  )
765  {
766  if(USARTx_CR2(Channel)->STOP == 1)
767  {
768  *outStopBit = oC_UART_LLD_StopBit_0p5Bit;
769  errorCode = oC_ErrorCode_None;
770  }
771  else if(USARTx_CR2(Channel)->STOP == 0)
772  {
773  *outStopBit = oC_UART_LLD_StopBit_1Bit;
774  errorCode = oC_ErrorCode_None;
775  }
776  else if(USARTx_CR2(Channel)->STOP == 3)
777  {
778  *outStopBit = oC_UART_LLD_StopBit_1p5Bits;
779  errorCode = oC_ErrorCode_None;
780  }
781  else if(USARTx_CR2(Channel)->STOP == 2)
782  {
783  *outStopBit = oC_UART_LLD_StopBit_2Bits;
784  errorCode = oC_ErrorCode_None;
785  }
786  else
787  {
788  errorCode = oC_ErrorCode_MachineCanBeDamaged;
789  }
790  }
791  }
792 
793  return errorCode;
794 }
795 
796 //==========================================================================================================================================
801 //==========================================================================================================================================
802 oC_ErrorCode_t oC_UART_LLD_SetBitOrder( oC_UART_Channel_t Channel , oC_UART_LLD_BitOrder_t BitOrder )
803 {
804  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
805 
807 
808  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
809  {
810  if(
811  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
812  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
813  ErrorCondition( AreOperationsDisabled(Channel) , oC_ErrorCode_ChannelOperationsNotDisabled)
814  )
815  {
816  //TODO: check which bit order is supported
817  errorCode = oC_ErrorCode_None;;
818  }
819  }
820 
822 
823  return errorCode;
824 }
825 
826 //==========================================================================================================================================
831 //==========================================================================================================================================
832 oC_ErrorCode_t oC_UART_LLD_ReadBitOrder( oC_UART_Channel_t Channel , oC_UART_LLD_BitOrder_t * outBitOrder )
833 {
834  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
835 
836  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
837  {
838  if(
839  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
840  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
841  ErrorCondition( IsRam(outBitOrder) , oC_ErrorCode_OutputAddressNotInRAM)
842  )
843  {
844  *outBitOrder= oC_UART_LLD_BitOrder_LSBFirst;
845  }
846  }
847 
848  return errorCode;
849 }
850 
851 //==========================================================================================================================================
856 //==========================================================================================================================================
857 oC_ErrorCode_t oC_UART_LLD_SetInvert( oC_UART_Channel_t Channel , oC_UART_LLD_Invert_t Invert )
858 {
859  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
860 
862 
863  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
864  {
865  if(
866  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
867  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
868  ErrorCondition( AreOperationsDisabled(Channel) , oC_ErrorCode_ChannelOperationsNotDisabled)&&
869  ErrorCondition( Invert == oC_UART_LLD_Invert_NotInverted , oC_ErrorCode_InvertNotSupported)
870  )
871  {
872  errorCode = oC_ErrorCode_None;
873  }
874  }
875 
877 
878  return errorCode;
879 }
880 
881 //==========================================================================================================================================
886 //==========================================================================================================================================
887 oC_ErrorCode_t oC_UART_LLD_ReadInvert( oC_UART_Channel_t Channel , oC_UART_LLD_Invert_t * outInvert )
888 {
889  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
890 
891  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
892  {
893  if(
894  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
895  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
896  ErrorCondition( IsRam(outInvert) , oC_ErrorCode_OutputAddressNotInRAM)
897  )
898  {
899  *outInvert = oC_UART_LLD_Invert_NotInverted;
900  errorCode = oC_ErrorCode_None;
901  }
902  }
903 
904  return errorCode;
905 }
906 
907 //==========================================================================================================================================
912 //==========================================================================================================================================
913 oC_ErrorCode_t oC_UART_LLD_SetLoopback( oC_UART_Channel_t Channel , bool Loopback )
914 {
915  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
916 
918 
919  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
920  {
921  if(
922  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
923  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
924  ErrorCondition( AreOperationsDisabled(Channel) , oC_ErrorCode_ChannelOperationsNotDisabled)
925  )
926  {
927  if(!Loopback)
928  {
929  errorCode = oC_ErrorCode_None;
930  }
931  else
932  {
933  errorCode = oC_ErrorCode_LoopbackNotSupported;
934  }
935  }
936  }
937 
939 
940  return errorCode;
941 }
942 
943 //==========================================================================================================================================
948 //==========================================================================================================================================
949 oC_ErrorCode_t oC_UART_LLD_ReadLoopback( oC_UART_Channel_t Channel , bool * outLoopback )
950 {
951  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
952 
953  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
954  {
955  if(
956  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
957  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
958  ErrorCondition( IsRam(outLoopback) , oC_ErrorCode_OutputAddressNotInRAM)
959  )
960  {
961  *outLoopback = false;
962  errorCode = oC_ErrorCode_None;
963  }
964  }
965 
966  return errorCode;
967 }
968 
969 //==========================================================================================================================================
974 //==========================================================================================================================================
975 oC_ErrorCode_t oC_UART_LLD_ConnectModulePin( oC_UART_Pin_t ModulePin )
976 {
977  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
978 
979  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
980  {
981  oC_UART_Channel_t channel = oC_ModulePin_GetChannel(ModulePin);
982  oC_Pin_t pin = oC_ModulePin_GetPin(ModulePin);
983 
984  if(
985  ErrorCondition( IsChannelCorrect(channel) , oC_ErrorCode_WrongChannel ) &&
986  ErrorCondition( oC_GPIO_LLD_IsPinDefined(pin) , oC_ErrorCode_PinNotDefined )
987  )
988  {
989  bool unused = false;
990 
992 
993  if(
994  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_ArePinsUnused(pin,&unused) ) &&
995  ErrorCondition( unused , oC_ErrorCode_PinIsUsed ) &&
996  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_SetPinsUsed(pin) ) &&
997  oC_AssignErrorCode(&errorCode , oC_GPIO_MSLLD_ConnectModulePin(ModulePin) )
998  )
999  {
1000  errorCode = oC_ErrorCode_None;
1001  }
1002  else
1003  {
1004  oC_GPIO_LLD_SetPinsUnused(pin);
1005  }
1006 
1008  }
1009  }
1010 
1011  return errorCode;
1012 }
1013 
1014 //==========================================================================================================================================
1019 //==========================================================================================================================================
1020 oC_ErrorCode_t oC_UART_LLD_DisconnectModulePin( oC_UART_Pin_t ModulePin )
1021 {
1022  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1023 
1024  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
1025  {
1026  oC_UART_Channel_t channel = oC_ModulePin_GetChannel(ModulePin);
1027  oC_Pin_t pin = oC_ModulePin_GetPin(ModulePin);
1028 
1029  if(
1030  ErrorCondition( IsChannelCorrect(channel) , oC_ErrorCode_WrongChannel ) &&
1031  ErrorCondition( oC_GPIO_LLD_IsPinDefined(pin) , oC_ErrorCode_PinNotDefined )
1032  )
1033  {
1035 
1036  if(
1037  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_SetPinsUnused(pin) ) &&
1038  oC_AssignErrorCode(&errorCode , oC_GPIO_MSLLD_DisconnectModulePin(ModulePin) )
1039  )
1040  {
1041  errorCode = oC_ErrorCode_None;
1042  }
1043 
1045  }
1046  }
1047 
1048  return errorCode;
1049 }
1050 
1051 //==========================================================================================================================================
1056 //==========================================================================================================================================
1057 oC_ErrorCode_t oC_UART_LLD_SetChannelUsed( oC_UART_Channel_t Channel )
1058 {
1059  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1060 
1061  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
1062  {
1064 
1065  if( ErrorCondition(IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) )
1066  {
1067  UsedChannels |= (1<<oC_Channel_ToIndex(UART,Channel));
1068  errorCode = oC_ErrorCode_None;
1069  }
1070 
1072  }
1073 
1074  return errorCode;
1075 }
1076 
1077 //==========================================================================================================================================
1082 //==========================================================================================================================================
1083 oC_ErrorCode_t oC_UART_LLD_SetChannelUnused( oC_UART_Channel_t Channel )
1084 {
1085  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1086 
1087  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
1088  {
1090 
1091  if( ErrorCondition(IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) )
1092  {
1093  UsedChannels &= ~(1<<oC_Channel_ToIndex(UART,Channel));
1094  errorCode = oC_ErrorCode_None;
1095  }
1096 
1098  }
1099 
1100  return errorCode;
1101 }
1102 
1103 //==========================================================================================================================================
1108 //==========================================================================================================================================
1109 bool oC_UART_LLD_IsChannelUsed( oC_UART_Channel_t Channel )
1110 {
1111  bool used = false;
1112 
1113  if(oC_Module_IsTurnedOn(oC_Module_UART_LLD))
1114  {
1115  if(IsChannelCorrect(Channel))
1116  {
1117  used = (UsedChannels & (1<<oC_Channel_ToIndex(UART,Channel))) == (1<<oC_Channel_ToIndex(UART,Channel));
1118  }
1119  }
1120 
1121  return used;
1122 }
1123 
1124 //==========================================================================================================================================
1129 //==========================================================================================================================================
1130 oC_ErrorCode_t oC_UART_LLD_ReadModulePinsOfPin( oC_Pin_t Pin , oC_UART_Pin_t * outModulePinsArray , uint32_t * ArraySize , oC_UART_PinFunction_t PinFunction )
1131 {
1132  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1133 
1134  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
1135  {
1136 
1137  if(
1138  ErrorCondition( oC_GPIO_LLD_IsPinDefined(Pin) , oC_ErrorCode_PinNotDefined) &&
1139  ErrorCondition( IsRam(ArraySize) , oC_ErrorCode_OutputAddressNotInRAM) &&
1140  ErrorCondition(outModulePinsArray == NULL || IsRam(outModulePinsArray) , oC_ErrorCode_OutputAddressNotInRAM)
1141  )
1142  {
1143  uint32_t foundPins = 0;
1144 
1145  errorCode = oC_ErrorCode_None;
1146 
1147  oC_ModulePin_ForeachDefined(modulePin)
1148  {
1149  if(modulePin->Pin == Pin && oC_Channel_IsCorrect(UART,modulePin->Channel) && modulePin->PinFunction == PinFunction)
1150  {
1151  if(outModulePinsArray != NULL)
1152  {
1153  if(foundPins < *ArraySize)
1154  {
1155  outModulePinsArray[foundPins] = modulePin->ModulePinIndex;
1156  }
1157  else
1158  {
1159  errorCode = oC_ErrorCode_OutputArrayToSmall;
1160  }
1161  }
1162  foundPins++;
1163  }
1164  }
1165 
1166  *ArraySize = foundPins;
1167  }
1168  }
1169 
1170  return errorCode;
1171 }
1172 
1173 //==========================================================================================================================================
1174 //==========================================================================================================================================
1175 oC_ErrorCode_t oC_UART_LLD_ClearRxFifo( oC_UART_Channel_t Channel )
1176 {
1177  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1178 
1179  if(ErrorCondition(oC_Channel_IsCorrect(UART,Channel) , oC_ErrorCode_WrongChannel ))
1180  {
1181  ClearSoftwareRing(&RxRing(Channel));
1182  errorCode = oC_ErrorCode_None;
1183  }
1184 
1185  return errorCode;
1186 }
1187 
1188 //==========================================================================================================================================
1193 //==========================================================================================================================================
1194 bool oC_UART_LLD_IsTxFifoFull( oC_UART_Channel_t Channel )
1195 {
1196 #if USE_INTERRUPTS_FOR_TX
1197  return IsSoftwareTxRingFull(Channel);
1198 #else
1199  return false;
1200 #endif
1201 }
1202 
1203 //==========================================================================================================================================
1208 //==========================================================================================================================================
1209 bool oC_UART_LLD_IsRxFifoEmpty( oC_UART_Channel_t Channel )
1210 {
1211  return IsSoftwareRxRingEmpty(Channel);
1212 }
1213 
1214 //==========================================================================================================================================
1219 //==========================================================================================================================================
1220 void oC_UART_LLD_PutData( oC_UART_Channel_t Channel , char Data )
1221 {
1222 #if USE_INTERRUPTS_FOR_TX
1224  USARTx_CR1(Channel)->TCIE = 1;
1225 
1226  if(IsSoftwareTxRingEmpty(Channel) && TransmitDataMovedToFifo(Channel))
1227  {
1228  USARTx_DR(Channel)->DR = Data;
1229  }
1230  else
1231  {
1232  PutToSoftwareRing(&TxRing(Channel),Data);
1233  }
1235 #else
1236  while(TransmitDataMovedToFifo(Channel) != true);
1237  USARTx_DR(Channel)->DR = Data;
1238 #endif
1239 }
1240 
1241 //==========================================================================================================================================
1246 //==========================================================================================================================================
1247 char oC_UART_LLD_GetData( oC_UART_Channel_t Channel )
1248 {
1249  return (char)GetFromSoftwareRing(&RxRing(Channel));
1250 }
1251 
1252 //==========================================================================================================================================
1257 //==========================================================================================================================================
1258 oC_ErrorCode_t oC_UART_LLD_WriteWithDma( oC_UART_Channel_t Channel , const char * Buffer , oC_UInt_t Size )
1259 {
1260  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1261 
1262  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
1263  {
1264  if(
1265  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
1266  ErrorCondition( IsRam(Buffer) || IsRom(Buffer) , oC_ErrorCode_WrongAddress) &&
1267  ErrorCondition( Size > 0 , oC_ErrorCode_SizeNotCorrect) &&
1268  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
1269  ErrorCondition( AreOperationsEnabled(Channel) , oC_ErrorCode_ChannelOperationsNotEnabled)
1270  )
1271  {
1272  errorCode = oC_ErrorCode_NotImplemented;
1273  }
1274  }
1275 
1276  return errorCode;
1277 }
1278 
1279 //==========================================================================================================================================
1284 //==========================================================================================================================================
1285 oC_ErrorCode_t oC_UART_LLD_ReadWithDma( oC_UART_Channel_t Channel , char * outBuffer , oC_UInt_t Size )
1286 {
1287  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1288 
1289  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_UART_LLD))
1290  {
1291  if(
1292  ErrorCondition( IsChannelCorrect(Channel) , oC_ErrorCode_WrongChannel) &&
1293  ErrorCondition( IsRam(outBuffer) , oC_ErrorCode_OutputAddressNotInRAM) &&
1294  ErrorCondition( Size > 0 , oC_ErrorCode_SizeNotCorrect) &&
1295  ErrorCondition( IsChannelPoweredOn(Channel) , oC_ErrorCode_ChannelNotPoweredOn) &&
1296  ErrorCondition( AreOperationsEnabled(Channel) , oC_ErrorCode_ChannelOperationsNotEnabled)
1297  )
1298  {
1299  errorCode = oC_ErrorCode_NotImplemented;
1300  }
1301  }
1302 
1303  return errorCode;
1304 }
1305 
1306 #undef _________________________________________FUNCTIONS_SECTION__________________________________________________________________________
1307 
1313 #define _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________
1314 
1315 //==========================================================================================================================================
1319 //==========================================================================================================================================
1320 static inline void PutToSoftwareRing( SoftwareRing_t * Ring , uint16_t Data )
1321 {
1322  if(Ring->Counter >= SOFTWARE_RING_COUNT)
1323  {
1324  /* If ring is full, take the oldest data */
1325  GetFromSoftwareRing(Ring);
1326  }
1327 
1328  Ring->Buffer[Ring->PutIndex++] = Data;
1329  Ring->Counter++;
1330 
1331  if(Ring->PutIndex >= SOFTWARE_RING_COUNT)
1332  {
1333  Ring->PutIndex = 0;
1334  }
1335 }
1336 
1337 //==========================================================================================================================================
1341 //==========================================================================================================================================
1342 static inline uint16_t GetFromSoftwareRing( SoftwareRing_t * Ring )
1343 {
1344  uint16_t data = 0xFFFF;
1345 
1346  if(Ring->Counter > 0)
1347  {
1348  Ring->Counter--;
1349  data = Ring->Buffer[Ring->GetIndex++];
1350  if(Ring->GetIndex >= SOFTWARE_RING_COUNT)
1351  {
1352  Ring->GetIndex = 0;
1353  }
1354  }
1355 
1356  return data;
1357 }
1358 
1359 //==========================================================================================================================================
1363 //==========================================================================================================================================
1364 static inline void ClearSoftwareRing( SoftwareRing_t * Ring )
1365 {
1366  memset(Ring,0,sizeof(SoftwareRing_t));
1367 }
1368 
1369 #undef _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________
1370 
1371 
1377 #define _________________________________________INTERRUPTS_SECTION_________________________________________________________________________
1378 
1379 #define MODULE_NAME UART
1380 #define INTERRUPT_TYPE_NAME PeripheralInterrupt
1381 
1382 //==========================================================================================================================================
1386 //==========================================================================================================================================
1388 {
1389  if(USARTx_SR(Channel)->TC == 1)
1390  {
1391  while(IsSoftwareTxRingEmpty(Channel) == false && (TransmitDataMovedToFifo(Channel)))
1392  {
1393  USARTx_DR(Channel)->DR = GetFromSoftwareRing(&TxRing(Channel));
1394  }
1395 
1396  if(TxNotFullHandler)
1397  {
1398  TxNotFullHandler(Channel);
1399  }
1400 
1401  if(IsSoftwareTxRingEmpty(Channel))
1402  {
1403  USARTx_CR1(Channel)->TCIE = 0;
1404  }
1405  }
1406 
1407  if(USARTx_SR(Channel)->RXNE == 1)
1408  {
1409  while(ReceiveDataAvailable(Channel))
1410  {
1411  PutToSoftwareRing(&RxRing(Channel),USARTx_DR(Channel)->DR);
1412  }
1413 
1414  if(RxNotEmptyHandler)
1415  {
1416  RxNotEmptyHandler(Channel);
1417  }
1418  }
1419 
1420  USARTx_SR(Channel)->Value = 0x864;
1421 }
1422 
1423 #undef _________________________________________INTERRUPTS_SECTION_________________________________________________________________________
1424 
Something is powered on.
Definition: oc_stdtypes.h:252
double oC_Frequency_t
type to store frequency
Definition: oc_frequency.h:76
The file contains definitions for the compiler, that helps to manage errors, etc. ...
The file with interface for LSF module.
The file with LLD interface for the MEM driver.
The file with interface for the module library.
oC_Frequency_t oC_CLOCK_LLD_GetClockFrequency(void)
returns frequency of the system clock
Definition: oc_clock_lld.c:237
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
The file with LLD interface for the CLOCK driver.
oC_Channel_t
stores machine channel
Definition: oc_channels.h:573
#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
The file with functions for the bits operation.
static void oC_MCS_EnterCriticalSection(void)
Enters to critical section.
Definition: oc_mcs.h:755
Static array definitions.
static void PutToSoftwareRing(SoftwareRing_t *SoftwareRing, oC_Netif_t Netif, oC_Net_Packet_t *Packet)
puts packet to the software ring
Definition: oc_netifman.c:951
static oC_Power_t oC_Machine_GetPowerStateForChannel(oC_Channel_t Channel)
returns power state for channel
Definition: oc_machine.h:550
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
The file with LLD interface for the DMA driver.
static bool GetFromSoftwareRing(SoftwareRing_t *SoftwareRing, const oC_Net_Address_t *Address, oC_Net_Packet_t *outPacket, oC_Netif_t *outNetif, oC_NetifMan_PacketFilterFunction_t FilterFunction, const void *Parameter)
reads packet from the software ring
Definition: oc_netifman.c:987
#define oC_Channel_InterruptHandler(ChannelVariableName)
creates common interrupt handler for channel
Definition: oc_channels.h:514
static bool oC_Machine_SetPowerStateForChannel(oC_Channel_t Channel, oC_Power_t Power)
configures power state for machine channel
Definition: oc_machine.h:593
FILE__DESCRIPTION
oC_Power_t
stores registers power state
Definition: oc_stdtypes.h:249
The most important interrupt priority, that is possible in the machine.
Definition: oc_mcs.h:178
#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