Choco OS  V.0.16.9.0
Join to the chocolate world
oc_spi_lld.h
Go to the documentation of this file.
1 
32 #ifndef SPITEM_PORTABLE_INC_LLD_OC_SPI_LLD_H_
33 #define SPITEM_PORTABLE_INC_LLD_OC_SPI_LLD_H_
34 
35 #include <oc_machine.h>
36 #include <oc_frequency.h>
37 #include <oc_errors.h>
38 #include <oc_clock_lld.h>
39 
40 #if oC_Channel_IsModuleDefined(SPI) == false
41 #error SPI module channels are not defined
42 #elif oC_ModulePinFunctions_IsModuleDefined(SPI) == false
43 #error SPI module pin functions are not defined
44 #elif oC_ModulePin_IsModuleDefined(SPI) == false
45 #error SPI module pins are not defined
46 #else
47 
53 #define _________________________________________TYPES_SECTION______________________________________________________________________________
54 #define MODULE_NAME SPI
57 
58 
59 //==========================================================================================================================================
66 //==========================================================================================================================================
68 
69 //==========================================================================================================================================
76 //==========================================================================================================================================
77 oC_ModulePinFunction_DefineType;
78 
79 //==========================================================================================================================================
86 //==========================================================================================================================================
87 oC_ModulePin_DefineType;
88 
89 //==========================================================================================================================================
95 //==========================================================================================================================================
96 typedef oC_ChannelIndex_t oC_SPI_LLD_ChannelIndex_t;
97 //==========================================================================================================================================
103 //==========================================================================================================================================
104 typedef enum
105 {
106  oC_SPI_LLD_BitOrder_MSBFirst ,
107  oC_SPI_LLD_BitOrder_LSBFirst
108 } oC_SPI_LLD_BitOrder_t;
109 
110 //==========================================================================================================================================
116 //==========================================================================================================================================
117 typedef enum
118 {
119  oC_SPI_LLD_FrameWidth_NotConfigured,
120  oC_SPI_LLD_FrameWidth_1Bit,
121  oC_SPI_LLD_FrameWidth_2Bits,
122  oC_SPI_LLD_FrameWidth_3Bits,
123  oC_SPI_LLD_FrameWidth_4Bits,
124  oC_SPI_LLD_FrameWidth_5Bits,
125  oC_SPI_LLD_FrameWidth_6Bits,
126  oC_SPI_LLD_FrameWidth_7Bits,
127  oC_SPI_LLD_FrameWidth_8Bits,
128  oC_SPI_LLD_FrameWidth_9Bits,
129  oC_SPI_LLD_FrameWidth_10Bits,
130  oC_SPI_LLD_FrameWidth_11Bits,
131  oC_SPI_LLD_FrameWidth_12Bits,
132  oC_SPI_LLD_FrameWidth_13Bits,
133  oC_SPI_LLD_FrameWidth_14Bits,
134  oC_SPI_LLD_FrameWidth_15Bits,
135  oC_SPI_LLD_FrameWidth_16Bits,
136  oC_SPI_LLD_FrameWidth_32Bits
137 } oC_SPI_LLD_FrameWidth_t;
138 
139 //==========================================================================================================================================
145 //==========================================================================================================================================
146 typedef enum
147 {
148  oC_SPI_LLD_Phase_FirstEdge ,
149  oC_SPI_LLD_Phase_SecondEdge
150 } oC_SPI_LLD_Phase_t;
151 
152 //==========================================================================================================================================
158 //==========================================================================================================================================
159 typedef enum
160 {
161  oC_SPI_LLD_Polarity_HighWhenActive ,
162  oC_SPI_LLD_Polarity_LowWhenActive
163 } oC_SPI_LLD_Polarity_t;
164 
165 //==========================================================================================================================================
169 //==========================================================================================================================================
170 typedef enum
171 {
172  oC_SPI_LLD_State_Active ,
173  oC_SPI_LLD_State_NotActive
174 } oC_SPI_LLD_State_t;
175 
176 //==========================================================================================================================================
182 //==========================================================================================================================================
183 typedef enum
184 {
185  oC_SPI_LLD_Mode_Master,
186  oC_SPI_LLD_Mode_SlaveEnabledOutput,
187  oC_SPI_LLD_Mode_SlaveDisabledOutput
188 } oC_SPI_LLD_Mode_t;
189 
190 //==========================================================================================================================================
200 //==========================================================================================================================================
201 typedef bool (*oC_SPI_LLD_Interrupt_t)( oC_SPI_Channel_t Channel );
202 
203 #undef MODULE_NAME
204 #undef _________________________________________TYPES_SECTION______________________________________________________________________________
205 
211 #define _________________________________________MACROS_SECTION_____________________________________________________________________________
212 
213 //==========================================================================================================================================
231 //==========================================================================================================================================
232 #define oC_SPI_LLD_ForEachChannel( Channel ) oC_Channel_Foreach( SPI , Channel )
233 
234 #undef _________________________________________MACROS_SECTION_____________________________________________________________________________
235 
241 #define _________________________________________FUNCTIONS_SECTION__________________________________________________________________________
242 
245 //==========================================================================================================================================
255 //==========================================================================================================================================
256 extern bool oC_SPI_LLD_IsChannelCorrect( oC_SPI_Channel_t Channel );
257 //==========================================================================================================================================
267 //==========================================================================================================================================
268 extern bool oC_SPI_LLD_IsChannelIndexCorrect( oC_ChannelIndex_t ChannelIndex );
269 //==========================================================================================================================================
279 //==========================================================================================================================================
280 extern bool oC_SPI_LLD_IsModulePinDefined( oC_SPI_Pin_t ModulePin );
281 //==========================================================================================================================================
291 //==========================================================================================================================================
292 extern oC_ChannelIndex_t oC_SPI_LLD_ChannelToChannelIndex( oC_SPI_Channel_t Channel );
293 //==========================================================================================================================================
303 //==========================================================================================================================================
304 extern oC_SPI_Channel_t oC_SPI_LLD_ChannelIndexToChannel( oC_ChannelIndex_t Channel );
305 //==========================================================================================================================================
316 //==========================================================================================================================================
317 extern oC_SPI_Channel_t oC_SPI_LLD_GetChannelOfModulePin( oC_SPI_Pin_t ModulePin );
318 //==========================================================================================================================================
336 //==========================================================================================================================================
337 extern oC_ErrorCode_t oC_SPI_LLD_TurnOnDriver( void );
338 //==========================================================================================================================================
357 //==========================================================================================================================================
358 extern oC_ErrorCode_t oC_SPI_LLD_TurnOffDriver( void );
359 //==========================================================================================================================================
382 //==========================================================================================================================================
383 extern oC_ErrorCode_t oC_SPI_LLD_SetDriverInterruptHandlers( oC_SPI_LLD_Interrupt_t RxFull , oC_SPI_LLD_Interrupt_t TxEmpty );
384 //==========================================================================================================================================
408 //==========================================================================================================================================
409 extern oC_ErrorCode_t oC_SPI_LLD_SetPower( oC_SPI_Channel_t Channel , oC_Power_t Power );
410 
411 //==========================================================================================================================================
423 //==========================================================================================================================================
424 extern oC_ErrorCode_t oC_SPI_LLD_ReadModulePinsOfPin( oC_Pins_t Pin , oC_SPI_Pin_t * outPeripheralPinsArray , uint32_t * ArraySize);
425 
426 //==========================================================================================================================================
450 //==========================================================================================================================================
451 extern oC_ErrorCode_t oC_SPI_LLD_ReadPower( oC_SPI_Channel_t Channel , oC_Power_t * outPower );
452 //==========================================================================================================================================
473 //==========================================================================================================================================
474 extern oC_ErrorCode_t oC_SPI_LLD_DisableOperations( oC_SPI_Channel_t Channel );
475 //==========================================================================================================================================
497 //==========================================================================================================================================
498 extern oC_ErrorCode_t oC_SPI_LLD_EnableOperations( oC_SPI_Channel_t Channel );
499 //==========================================================================================================================================
518 //==========================================================================================================================================
519 extern oC_ErrorCode_t oC_SPI_LLD_RestoreDefaultStateOnChannel( oC_SPI_Channel_t Channel );
520 //==========================================================================================================================================
548 //==========================================================================================================================================
549 extern oC_ErrorCode_t oC_SPI_LLD_SetBitOrder( oC_SPI_Channel_t Channel , oC_SPI_LLD_BitOrder_t BitOrder );
550 //==========================================================================================================================================
573 //==========================================================================================================================================
574 extern oC_ErrorCode_t oC_SPI_LLD_ReadBitOrder( oC_SPI_Channel_t Channel , oC_SPI_LLD_BitOrder_t * outBitOrder );
575 //==========================================================================================================================================
603 //==========================================================================================================================================
604 extern oC_ErrorCode_t oC_SPI_LLD_SetFrameWidth( oC_SPI_Channel_t Channel , oC_SPI_LLD_FrameWidth_t FrameWidth );
605 //==========================================================================================================================================
630 //==========================================================================================================================================
631 extern oC_ErrorCode_t oC_SPI_LLD_ReadFrameWidth( oC_SPI_Channel_t Channel , oC_SPI_LLD_FrameWidth_t * outFrameWidth );
632 //==========================================================================================================================================
660 //==========================================================================================================================================
661 extern oC_ErrorCode_t oC_SPI_LLD_SetClockPhase( oC_SPI_Channel_t Channel , oC_SPI_LLD_Phase_t Phase );
662 //==========================================================================================================================================
685 //==========================================================================================================================================
686 extern oC_ErrorCode_t oC_SPI_LLD_ReadClockPhase( oC_SPI_Channel_t Channel , oC_SPI_LLD_Phase_t * outPhase );
687 //==========================================================================================================================================
715 //==========================================================================================================================================
716 extern oC_ErrorCode_t oC_SPI_LLD_SetClockPolarity( oC_SPI_Channel_t Channel , oC_SPI_LLD_Polarity_t Polarity );
717 //==========================================================================================================================================
740 //==========================================================================================================================================
741 extern oC_ErrorCode_t oC_SPI_LLD_ReadClockPolarity( oC_SPI_Channel_t Channel , oC_SPI_LLD_Polarity_t * outPolarity );
742 //==========================================================================================================================================
770 //==========================================================================================================================================
771 extern oC_ErrorCode_t oC_SPI_LLD_SetChipSelectPolarity( oC_SPI_Channel_t Channel , oC_SPI_LLD_Polarity_t Polarity );
772 //==========================================================================================================================================
795 //==========================================================================================================================================
796 extern oC_ErrorCode_t oC_SPI_LLD_ReadChipSelectPolarity( oC_SPI_Channel_t Channel , oC_SPI_LLD_Polarity_t * outPolarity );
797 //==========================================================================================================================================
824 //==========================================================================================================================================
825 oC_ErrorCode_t oC_SPI_LLD_SetLoopback( oC_SPI_Channel_t Channel , bool Loopback );
826 //==========================================================================================================================================
849 //==========================================================================================================================================
850 oC_ErrorCode_t oC_SPI_LLD_ReadLoopback( oC_SPI_Channel_t Channel , bool* outLoopback);
851 //==========================================================================================================================================
881 //==========================================================================================================================================
882 extern oC_ErrorCode_t oC_SPI_LLD_SetFrequency( oC_SPI_Channel_t Channel , oC_Frequency_t Frequency , oC_Frequency_t AcceptableDifference );
883 //==========================================================================================================================================
907 //==========================================================================================================================================
908 extern oC_ErrorCode_t oC_SPI_LLD_ReadFrequency( oC_SPI_Channel_t Channel , oC_Frequency_t * outFrequency );
909 //==========================================================================================================================================
929 //==========================================================================================================================================
930 extern oC_ErrorCode_t oC_SPI_LLD_SetChannelUsed( oC_SPI_Channel_t Channel );
931 //==========================================================================================================================================
951 //==========================================================================================================================================
952 extern oC_ErrorCode_t oC_SPI_LLD_SetChannelUnused( oC_SPI_Channel_t Channel );
953 //==========================================================================================================================================
964 //==========================================================================================================================================
965 extern bool oC_SPI_LLD_IsChannelUsed( oC_SPI_Channel_t Channel );
966 //==========================================================================================================================================
990 //==========================================================================================================================================
991 extern oC_ErrorCode_t oC_SPI_LLD_ConnectModulePin( oC_SPI_Pin_t ModulePin );
992 //==========================================================================================================================================
1016 //==========================================================================================================================================
1017 extern oC_ErrorCode_t oC_SPI_LLD_SetMode( oC_SPI_Channel_t Channel, oC_SPI_LLD_Mode_t Mode );
1018 //==========================================================================================================================================
1041 //==========================================================================================================================================
1042 extern oC_ErrorCode_t oC_SPI_LLD_ReadMode( oC_SPI_Channel_t Channel, oC_SPI_LLD_Mode_t * outMode );
1043 //==========================================================================================================================================
1044 
1069 //==========================================================================================================================================
1070 extern oC_ErrorCode_t oC_SPI_LLD_ConfigureGeneralChipSelectPin( oC_SPI_Channel_t Channel , oC_Pins_t Pin );
1071 //==========================================================================================================================================
1093 //==========================================================================================================================================
1094 extern oC_ErrorCode_t oC_SPI_LLD_UnconfigureGeneralChipSelectPin( oC_SPI_Channel_t Channel , oC_Pins_t Pin );
1095 //==========================================================================================================================================
1118 //==========================================================================================================================================
1119 extern oC_ErrorCode_t oC_SPI_LLD_SetGeneralChipSelectState( oC_SPI_Channel_t Channel , oC_Pins_t Pin , oC_SPI_LLD_State_t State );
1120 //==========================================================================================================================================
1131 //==========================================================================================================================================
1132 extern bool oC_SPI_LLD_IsDmaSupportPossible( oC_SPI_Channel_t Channel );
1133 //==========================================================================================================================================
1154 //==========================================================================================================================================
1155 extern oC_ErrorCode_t oC_SPI_LLD_ConfigureDma( oC_SPI_Channel_t Channel , void * RxBuffer , uint32_t RxSize , void * TxBuffer , uint32_t TxSize );
1156 //==========================================================================================================================================
1176 //==========================================================================================================================================
1177 extern oC_ErrorCode_t oC_SPI_LLD_UnconfigureDma( oC_SPI_Channel_t Channel );
1178 //==========================================================================================================================================
1207 //==========================================================================================================================================
1208 extern oC_ErrorCode_t oC_SPI_LLD_Write( oC_SPI_Channel_t Channel , void * Buffer , oC_UInt_t BufferSize , oC_UInt_t ElementSize , oC_IoFlags_t IoFlags );
1209 //==========================================================================================================================================
1210 //==========================================================================================================================================
1239 //==========================================================================================================================================
1240 extern oC_ErrorCode_t oC_SPI_LLD_Read( oC_SPI_Channel_t Channel , void * Buffer , oC_UInt_t BufferSize , oC_UInt_t ElementSize , oC_IoFlags_t IoFlags );
1241 //==========================================================================================================================================
1270 //==========================================================================================================================================
1271 extern oC_ErrorCode_t oC_SPI_LLD_WriteWithDma( oC_SPI_Channel_t Channel , void * Buffer , oC_UInt_t Size , oC_UInt_t ElementSize , oC_IoFlags_t IoFlags );
1272 //==========================================================================================================================================
1301 //==========================================================================================================================================
1302 extern oC_ErrorCode_t oC_SPI_LLD_ReadWithDma( oC_SPI_Channel_t Channel , void * outBuffer , oC_UInt_t Size , oC_UInt_t ElementSize , oC_IoFlags_t IoFlags );
1303 
1304 #undef _________________________________________FUNCTIONS_SECTION__________________________________________________________________________
1305 
1307 #endif
1308 #endif /* SPITEM_PORTABLE_INC_LLD_OC_SPI_LLD_H_ */
The file with frequency definitions.
double oC_Frequency_t
type to store frequency
Definition: oc_frequency.h:76
#define oC_ModuleChannel_DefineType
defines module channel type
Definition: oc_channels.h:541
The file with LLD interface for the CLOCK driver.
oC_Channel_t
stores machine channel
Definition: oc_channels.h:573
The file with interface for the machine module.
oC_Power_t
stores registers power state
Definition: oc_stdtypes.h:249