Choco OS  V.0.16.9.0
Join to the chocolate world
oc_lcdtft_lld.c
1 
29 #include <oc_lcdtft_lld.h>
30 #include <oc_mem_lld.h>
31 #include <oc_bits.h>
32 #include <oc_module.h>
33 #include <oc_lsf.h>
34 #include <oc_stdtypes.h>
35 #include <oc_saipll.h>
36 #include <oc_gpio_lld.h>
37 #include <oc_gpio_mslld.h>
38 
44 #define _________________________________________MACROS_SECTION_____________________________________________________________________________
45 
46 #define IsRam(Address) (oC_LSF_IsRamAddress(Address) || oC_LSF_IsExternalAddress(Address))
47 #define IsRom(Address) oC_LSF_IsRomAddress(Address)
48 #define LTDC_Channel oC_Channel_LCD
49 #define LTDC_Layer 1
50 #define IsLayerCorrect(Layer) ( (Layer) < 2 && (Layer) >= 0 )
51 #define IsPolarityCorrect(Polarity) ( (Polarity) == oC_LCDTFT_LLD_Polarity_ActiveLow || (Polarity) == oC_LCDTFT_LLD_Polarity_ActiveHigh )
52 #define IsChannelPoweredOn() (oC_Machine_GetPowerStateForChannel(LTDC_Channel) == oC_Power_On)
53 #define SetPolarity(Bit , Polarity) Bit = (Polarity == oC_LCDTFT_LLD_Polarity_ActiveHigh) ? 1 : 0
54 #define GetPolarity(Bit) ((Bit) == 1) ? oC_LCDTFT_LLD_Polarity_ActiveHigh : oC_LCDTFT_LLD_Polarity_ActiveHigh
55 #define AreOperationsEnabled() (LTDC_GCR->LTDCEN == 1)
56 #define AreOperationsDisabled() (LTDC_GCR->LTDCEN == 0)
57 #define LTDC_GCR oC_Register(LCD_TFT , LTDC_GCR )
58 #define LTDC_SSCR oC_Register(LCD_TFT , LTDC_SSCR )
59 #define LTDC_SRCR oC_Register(LCD_TFT , LTDC_SRCR )
60 #define LTDC_BCCR oC_Register(LCD_TFT , LTDC_BCCR )
61 #define LTDC_IER oC_Register(LCD_TFT , LTDC_IER )
62 #define LTDC_TWCR oC_Register(LCD_TFT , LTDC_TWCR )
63 #define LTDC_BPCR oC_Register(LCD_TFT , LTDC_BPCR )
64 #define LTDC_AWCR oC_Register(LCD_TFT , LTDC_AWCR )
65 #define LTDC_L1CFBAR oC_Register(LCD_TFT , LTDC_L1CFBAR )
66 #define LTDC_L1CFBLR oC_Register(LCD_TFT , LTDC_L1CFBLR )
67 #define LTDC_L1CFBLNR oC_Register(LCD_TFT , LTDC_L1CFBLNR )
68 #define LTDC_L1CR oC_Register(LCD_TFT , LTDC_L1CR )
69 #define LTDC_L1PFCR oC_Register(LCD_TFT , LTDC_L1PFCR )
70 #define LTDC_L1WHPCR oC_Register(LCD_TFT , LTDC_L1WHPCR )
71 #define LTDC_L1WVPCR oC_Register(LCD_TFT , LTDC_L1WVPCR )
72 #define LTDC_L1DCCR oC_Register(LCD_TFT , LTDC_L1DCCR )
73 #define LTDC_L1CACR oC_Register(LCD_TFT , LTDC_L1CACR )
74 #define LTDC_L1BFCR oC_Register(LCD_TFT , LTDC_L1BFCR )
75 #define RCC_CR oC_Register(RCC , RCC_CR)
76 #define RCC_PLLSAICFGR oC_Register(RCC , RCC_PLLSAICFGR)
77 #define RCC_DCKCFGR1 oC_Register(RCC , RCC_DCKCFGR1)
78 #define RCC_APB2RSTR oC_Register(RCC , RCC_APB2RSTR)
79 #define MAX_WIDTH 1024
80 #define MAX_HEIGHT 768
81 #define MAX_HSW 0xFFF
82 #define MAX_VSW 0x7FF
83 #define MAX_AHBP 0xFFF
84 #define MAX_AVBP 0x7FF
85 #define MAX_AAH 0xFFF
86 #define MAX_AAW 0x7FF
87 #define MAX_TOTALH 0xFFF
88 #define MAX_TOTALW 0x7FF
89 #define MAX_COLOR_VALUE(PixelSize) ( \
90  ((PixelSize) == 1 ) ? 0x000000FF : \
91  ((PixelSize) == 2 ) ? 0x0000FFFF : \
92  ((PixelSize) == 3 ) ? 0x00FFFFFF : \
93  ((PixelSize) == 4 ) ? 0xFFFFFFFF : 0 \
94  )
95 
96 #undef _________________________________________MACROS_SECTION_____________________________________________________________________________
97 
103 #define _________________________________________TYPES_SECTION______________________________________________________________________________
104 
105 
106 #undef _________________________________________TYPES_SECTION______________________________________________________________________________
107 
113 #define _________________________________________PROTOTYPES_SECTION_________________________________________________________________________
114 
115 static bool FindModulePin ( oC_Pin_t Pin , oC_LCDTFT_PinFunction_t Function , oC_LCDTFT_Pin_t * outModulePin );
116 static oC_ErrorCode_t ConnectModulePin ( oC_LCDTFT_Pin_t ModulePin );
117 static oC_ErrorCode_t ConnectPin ( oC_Pin_t Pin , oC_GPIO_LLD_Mode_t PinMode );
118 static oC_ColorFormat_t GetPixelFormat ( void );
119 static oC_UInt_t GetPixelSize ( void );
120 static oC_ErrorCode_t SetPixelFormat ( oC_ColorFormat_t PixelFormat );
121 static oC_ErrorCode_t SetTimingParameters ( const oC_LCDTFT_LLD_TimingParameters_t * TimingParameters );
122 static oC_ErrorCode_t ReadTimingParameters ( oC_LCDTFT_LLD_TimingParameters_t * outTimingParameters );
123 
124 #undef _________________________________________PROTOTYPES_SECTION_________________________________________________________________________
125 
126 
132 #define _________________________________________VARIABLES_SECTION__________________________________________________________________________
133 
134 static oC_Frequency_t ConfiguredFrequency = 0;
135 static oC_Pixel_ResolutionUInt_t ConfiguredWidth = 0;
136 static oC_Pixel_ResolutionUInt_t ConfiguredHeight = 0;
137 static oC_Pin_t ConfiguredDispPin = 0;
138 static oC_Pin_t ConfiguredBlCtrlPin = 0;
139 static oC_ColorFormat_t ConfiguredColorFormat = oC_ColorFormat_Unknown;
140 static const oC_LCDTFT_PinFunction_t PinFunctions [oC_LCDTFT_LLD_PinIndex_NumberOfPins] = {
141  [ oC_LCDTFT_LLD_PinIndex_R0 ] = oC_LCDTFT_PinFunction_LCD_R0 ,
142  [ oC_LCDTFT_LLD_PinIndex_R1 ] = oC_LCDTFT_PinFunction_LCD_R1 ,
143  [ oC_LCDTFT_LLD_PinIndex_R2 ] = oC_LCDTFT_PinFunction_LCD_R2 ,
144  [ oC_LCDTFT_LLD_PinIndex_R3 ] = oC_LCDTFT_PinFunction_LCD_R3 ,
145  [ oC_LCDTFT_LLD_PinIndex_R4 ] = oC_LCDTFT_PinFunction_LCD_R4 ,
146  [ oC_LCDTFT_LLD_PinIndex_R5 ] = oC_LCDTFT_PinFunction_LCD_R5 ,
147  [ oC_LCDTFT_LLD_PinIndex_R6 ] = oC_LCDTFT_PinFunction_LCD_R6 ,
148  [ oC_LCDTFT_LLD_PinIndex_R7 ] = oC_LCDTFT_PinFunction_LCD_R7 ,
149  [ oC_LCDTFT_LLD_PinIndex_G0 ] = oC_LCDTFT_PinFunction_LCD_G0 ,
150  [ oC_LCDTFT_LLD_PinIndex_G1 ] = oC_LCDTFT_PinFunction_LCD_G1 ,
151  [ oC_LCDTFT_LLD_PinIndex_G2 ] = oC_LCDTFT_PinFunction_LCD_G2 ,
152  [ oC_LCDTFT_LLD_PinIndex_G3 ] = oC_LCDTFT_PinFunction_LCD_G3 ,
153  [ oC_LCDTFT_LLD_PinIndex_G4 ] = oC_LCDTFT_PinFunction_LCD_G4 ,
154  [ oC_LCDTFT_LLD_PinIndex_G5 ] = oC_LCDTFT_PinFunction_LCD_G5 ,
155  [ oC_LCDTFT_LLD_PinIndex_G6 ] = oC_LCDTFT_PinFunction_LCD_G6 ,
156  [ oC_LCDTFT_LLD_PinIndex_G7 ] = oC_LCDTFT_PinFunction_LCD_G7 ,
157  [ oC_LCDTFT_LLD_PinIndex_B0 ] = oC_LCDTFT_PinFunction_LCD_B0 ,
158  [ oC_LCDTFT_LLD_PinIndex_B1 ] = oC_LCDTFT_PinFunction_LCD_B1 ,
159  [ oC_LCDTFT_LLD_PinIndex_B2 ] = oC_LCDTFT_PinFunction_LCD_B2 ,
160  [ oC_LCDTFT_LLD_PinIndex_B3 ] = oC_LCDTFT_PinFunction_LCD_B3 ,
161  [ oC_LCDTFT_LLD_PinIndex_B4 ] = oC_LCDTFT_PinFunction_LCD_B4 ,
162  [ oC_LCDTFT_LLD_PinIndex_B5 ] = oC_LCDTFT_PinFunction_LCD_B5 ,
163  [ oC_LCDTFT_LLD_PinIndex_B6 ] = oC_LCDTFT_PinFunction_LCD_B6 ,
164  [ oC_LCDTFT_LLD_PinIndex_B7 ] = oC_LCDTFT_PinFunction_LCD_B7 ,
165  [ oC_LCDTFT_LLD_PinIndex_VSYNC ] = oC_LCDTFT_PinFunction_LCD_VSYNC ,
166  [ oC_LCDTFT_LLD_PinIndex_HSYNC ] = oC_LCDTFT_PinFunction_LCD_HSYNC ,
167  [ oC_LCDTFT_LLD_PinIndex_CLK ] = oC_LCDTFT_PinFunction_LCD_CLK ,
168  [ oC_LCDTFT_LLD_PinIndex_DE ] = oC_LCDTFT_PinFunction_LCD_DE ,
169  [ oC_LCDTFT_LLD_PinIndex_DISP ] = 0 ,
170  [ oC_LCDTFT_LLD_PinIndex_BL_CTRL ] = 0 ,
171  [ oC_LCDTFT_LLD_PinIndex_LED_K ] = 0 ,
172  [ oC_LCDTFT_LLD_PinIndex_LED_A ] = 0 ,
173  [ oC_LCDTFT_LLD_PinIndex_NC_XR ] = 0 ,
174  [ oC_LCDTFT_LLD_PinIndex_NC_YD ] = 0 ,
175  [ oC_LCDTFT_LLD_PinIndex_NC_XL ] = 0 ,
176  [ oC_LCDTFT_LLD_PinIndex_NC_YU ] = 0
177 };
178 
179 #undef _________________________________________VARIABLES_SECTION__________________________________________________________________________
180 
186 #define _________________________________________FUNCTIONS_SECTION__________________________________________________________________________
187 
188 //==========================================================================================================================================
193 //==========================================================================================================================================
194 oC_ErrorCode_t oC_LCDTFT_LLD_TurnOnDriver( void )
195 {
196  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
197 
199 
200  if(oC_Module_TurnOffVerification(&errorCode , oC_Module_LCDTFT_LLD))
201  {
202  oC_Module_TurnOn(oC_Module_LCDTFT_LLD);
203  ConfiguredFrequency = 0;
204  ConfiguredHeight = 0;
205  ConfiguredWidth = 0;
206  ConfiguredDispPin = 0;
207  ConfiguredBlCtrlPin = 0;
208  ConfiguredColorFormat = 0;
209  errorCode = oC_ErrorCode_None;
210  }
211 
213 
214  return errorCode;
215 }
216 
217 //==========================================================================================================================================
222 //==========================================================================================================================================
223 oC_ErrorCode_t oC_LCDTFT_LLD_TurnOffDriver( void )
224 {
225  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
226 
228 
229  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
230  {
231  oC_Module_TurnOff(oC_Module_LCDTFT_LLD);
232  errorCode = oC_ErrorCode_None;
233  }
234 
236 
237  return errorCode;
238 }
239 
240 //==========================================================================================================================================
245 //==========================================================================================================================================
246 oC_ErrorCode_t oC_LCDTFT_LLD_SetPower( oC_Power_t Power )
247 {
248  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
249 
251 
252  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
253  {
254  if(
255  ErrorCondition( Power == oC_Power_On || Power == oC_Power_Off , oC_ErrorCode_PowerStateNotCorrect) &&
256  ErrorCondition( oC_Machine_SetPowerStateForChannel(LTDC_Channel,Power) , oC_ErrorCode_CannotEnableChannel)
257  )
258  {
259  errorCode = oC_ErrorCode_None;
260  }
261  }
262 
264 
265  return errorCode;
266 }
267 
268 //==========================================================================================================================================
273 //==========================================================================================================================================
274 oC_ErrorCode_t oC_LCDTFT_LLD_ReadPower( oC_Power_t * outPower )
275 {
276  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
277 
279 
280  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
281  {
282  if(ErrorCondition( IsRam(outPower) , oC_ErrorCode_OutputAddressNotInRAM))
283  {
284  *outPower = oC_Machine_GetPowerStateForChannel(LTDC_Channel);
285  errorCode = oC_ErrorCode_None;
286  }
287  }
288 
290 
291  return errorCode;
292 }
293 
294 //==========================================================================================================================================
299 //==========================================================================================================================================
300 oC_ErrorCode_t oC_LCDTFT_LLD_EnableOperations( void )
301 {
302  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
303 
304  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
305  {
306  if(
307  ErrorCondition( IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn ) &&
308  ErrorCondition( ConfiguredBlCtrlPin != 0 , oC_ErrorCode_ChannelNotConfigured) &&
309  ErrorCondition( ConfiguredDispPin != 0 , oC_ErrorCode_ChannelNotConfigured) &&
310  ErrorCondition( ConfiguredFrequency != 0 , oC_ErrorCode_ChannelNotConfigured) &&
311  ErrorCondition( ConfiguredHeight != 0 , oC_ErrorCode_ChannelNotConfigured) &&
312  ErrorCondition( ConfiguredWidth != 0 , oC_ErrorCode_ChannelNotConfigured)
313  )
314  {
315  LTDC_IER->TERRIE = 1;
316  LTDC_IER->FUIE = 1;
317  LTDC_SRCR->IMR = 1;
318  LTDC_L1CR->LEN = 1;
319  LTDC_GCR->LTDCEN = 1;
320 
321  oC_GPIO_LLD_SetPinsState(ConfiguredBlCtrlPin , oC_GPIO_LLD_PinsState_AllHigh);
322  oC_GPIO_LLD_SetPinsState(ConfiguredDispPin , oC_GPIO_LLD_PinsState_AllHigh);
323 
324  errorCode = oC_ErrorCode_None;
325 
326  }
327  }
328 
329  return errorCode;
330 }
331 
332 //==========================================================================================================================================
337 //==========================================================================================================================================
338 oC_ErrorCode_t oC_LCDTFT_LLD_DisableOperations( void )
339 {
340  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
341 
342  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
343  {
344  if(ErrorCondition( IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn))
345  {
346  LTDC_GCR->LTDCEN = 0;
347  errorCode = oC_ErrorCode_None;
348  }
349  }
350 
351  return errorCode;
352 }
353 
354 //==========================================================================================================================================
359 //==========================================================================================================================================
360 oC_ErrorCode_t oC_LCDTFT_LLD_SetFrequency( oC_Frequency_t Frequency , oC_Frequency_t PermissibleDifference )
361 {
362  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
363 
364  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
365  {
366  if(
367  ErrorCondition( Frequency > 0 , oC_ErrorCode_WrongFrequency ) &&
368  ErrorCondition( PermissibleDifference >= 0 , oC_ErrorCode_WrongFrequency )
369  )
370  {
371  errorCode = oC_SaiPll_Configure( oC_SaiPll_OutputLine_LTDC , Frequency , PermissibleDifference , &ConfiguredFrequency );
372  }
373  }
374 
375  return errorCode;
376 }
377 
378 //==========================================================================================================================================
383 //==========================================================================================================================================
384 oC_ErrorCode_t oC_LCDTFT_LLD_ReadFrequency( oC_Frequency_t * outFrequency )
385 {
386  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
387 
388  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
389  {
390  if(
391  ErrorCondition( IsRam(outFrequency) , oC_ErrorCode_OutputAddressNotInRAM ) &&
392  ErrorCondition( ConfiguredFrequency != 0 , oC_ErrorCode_ChannelNotConfigured )
393  )
394  {
395  *outFrequency = ConfiguredFrequency;
396  errorCode = oC_ErrorCode_None;
397  }
398  }
399 
400  return errorCode;
401 }
402 
403 //==========================================================================================================================================
408 //==========================================================================================================================================
409 oC_ErrorCode_t oC_LCDTFT_LLD_SetPixelClockPolarity( oC_LCDTFT_LLD_PixelClockPolarity_t PixelPolarity )
410 {
411  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
412 
413  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
414  {
415  if(
416  ErrorCondition( IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn ) &&
417  ErrorCondition( AreOperationsDisabled() , oC_ErrorCode_ChannelOperationsNotDisabled )
418  )
419  {
420  switch(PixelPolarity)
421  {
422  case oC_LCDTFT_LLD_PixelClockPolarity_InputPixelClock:
423  LTDC_GCR->PCPOL = 0;
424  errorCode = oC_ErrorCode_None;
425  break;
426  case oC_LCDTFT_LLD_PixelClockPolarity_InvertedInputPixelClock:
427  LTDC_GCR->PCPOL = 1;
428  errorCode = oC_ErrorCode_None;
429  break;
430  default:
431  errorCode = oC_ErrorCode_PolarityNotCorrect;
432  break;
433  }
434  }
435  }
436 
437  return errorCode;
438 }
439 
440 //==========================================================================================================================================
445 //==========================================================================================================================================
446 oC_ErrorCode_t oC_LCDTFT_LLD_ReadPixelClockPolarity( oC_LCDTFT_LLD_PixelClockPolarity_t * outPixelPolarity )
447 {
448  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
449 
450  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
451  {
452  if(
453  ErrorCondition( IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn ) &&
454  ErrorCondition( IsRam(outPixelPolarity) , oC_ErrorCode_OutputAddressNotInRAM )
455  )
456  {
457  if(LTDC_GCR->PCPOL == 0)
458  {
459  *outPixelPolarity = oC_LCDTFT_LLD_PixelClockPolarity_InputPixelClock;
460  }
461  else
462  {
463  *outPixelPolarity = oC_LCDTFT_LLD_PixelClockPolarity_InvertedInputPixelClock;
464  }
465  errorCode = oC_ErrorCode_None;
466  }
467  }
468 
469  return errorCode;
470 }
471 
472 //==========================================================================================================================================
477 //==========================================================================================================================================
478 oC_ErrorCode_t oC_LCDTFT_LLD_SetPolarities( oC_LCDTFT_LLD_Polarity_t HSyncPolarity , oC_LCDTFT_LLD_Polarity_t VSyncPolarity , oC_LCDTFT_LLD_Polarity_t DataEnablePolarity )
479 {
480  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
481 
482  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
483  {
484  if(
485  ErrorCondition( IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn ) &&
486  ErrorCondition( AreOperationsDisabled() , oC_ErrorCode_ChannelOperationsNotDisabled ) &&
487  ErrorCondition( IsPolarityCorrect(HSyncPolarity) , oC_ErrorCode_PolarityNotCorrect ) &&
488  ErrorCondition( IsPolarityCorrect(VSyncPolarity) , oC_ErrorCode_PolarityNotCorrect ) &&
489  ErrorCondition( IsPolarityCorrect(DataEnablePolarity) , oC_ErrorCode_PolarityNotCorrect )
490  )
491  {
492  SetPolarity( LTDC_GCR->HSPOL , HSyncPolarity );
493  SetPolarity( LTDC_GCR->VSPOL , VSyncPolarity );
494  SetPolarity( LTDC_GCR->DEPOL , DataEnablePolarity );
495  errorCode = oC_ErrorCode_None;
496  }
497  }
498 
499  return errorCode;
500 }
501 
502 //==========================================================================================================================================
507 //==========================================================================================================================================
508 oC_ErrorCode_t oC_LCDTFT_LLD_ReadPolarities( oC_LCDTFT_LLD_Polarity_t * outHSyncPolarity , oC_LCDTFT_LLD_Polarity_t * outVSyncPolarity , oC_LCDTFT_LLD_Polarity_t * outDataEnablePolarity )
509 {
510  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
511 
512  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
513  {
514  if(
515  ErrorCondition( IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn ) &&
516  ErrorCondition( IsRam(outHSyncPolarity) , oC_ErrorCode_OutputAddressNotInRAM ) &&
517  ErrorCondition( IsRam(outVSyncPolarity) , oC_ErrorCode_OutputAddressNotInRAM ) &&
518  ErrorCondition( IsRam(outDataEnablePolarity) , oC_ErrorCode_OutputAddressNotInRAM )
519  )
520  {
521  *outHSyncPolarity = GetPolarity(LTDC_GCR->HSPOL);
522  *outVSyncPolarity = GetPolarity(LTDC_GCR->VSPOL);
523  *outDataEnablePolarity = GetPolarity(LTDC_GCR->DEPOL);
524  errorCode = oC_ErrorCode_None;
525  }
526  }
527 
528  return errorCode;
529 }
530 
531 //==========================================================================================================================================
536 //==========================================================================================================================================
537 oC_ErrorCode_t oC_LCDTFT_LLD_SetResolution( oC_Pixel_ResolutionUInt_t Width , oC_Pixel_ResolutionUInt_t Height )
538 {
539  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
540 
541  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
542  {
543  if(
544  ErrorCondition( IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn ) &&
545  ErrorCondition( AreOperationsDisabled() , oC_ErrorCode_ChannelOperationsNotDisabled ) &&
546  ErrorCondition( Width <= MAX_WIDTH , oC_ErrorCode_WidthTooBig ) &&
547  ErrorCondition( Height <= MAX_HEIGHT , oC_ErrorCode_HeightTooBig )
548  )
549  {
550  ConfiguredWidth = Width;
551  ConfiguredHeight = Height;
552  errorCode = oC_ErrorCode_None;
553  }
554  }
555 
556  return errorCode;
557 }
558 
559 //==========================================================================================================================================
564 //==========================================================================================================================================
565 oC_ErrorCode_t oC_LCDTFT_LLD_ReadResolution( oC_Pixel_ResolutionUInt_t * outWidth , oC_Pixel_ResolutionUInt_t * outHeight )
566 {
567  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
568 
569  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
570  {
571  if(
572  ErrorCondition( IsRam(outWidth) , oC_ErrorCode_OutputAddressNotInRAM ) &&
573  ErrorCondition( IsRam(outHeight) , oC_ErrorCode_OutputAddressNotInRAM ) &&
574  ErrorCondition( IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn ) &&
575  ErrorCondition( ConfiguredWidth > 0 , oC_ErrorCode_ChannelNotConfigured ) &&
576  ErrorCondition( ConfiguredHeight > 0 , oC_ErrorCode_ChannelNotConfigured )
577  )
578  {
579  *outWidth = ConfiguredWidth;
580  *outHeight = ConfiguredHeight;
581  errorCode = oC_ErrorCode_None;
582  }
583  }
584 
585  return errorCode;
586 }
587 
588 //==========================================================================================================================================
593 //==========================================================================================================================================
594 oC_ErrorCode_t oC_LCDTFT_LLD_RestoreDefaultState( void )
595 {
596  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
597 
598  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
599  {
600  RCC_APB2RSTR->LTDCRST = 1;
601  errorCode = oC_ErrorCode_None;
602  }
603 
604  return errorCode;
605 }
606 
607 //==========================================================================================================================================
612 //==========================================================================================================================================
613 oC_ErrorCode_t oC_LCDTFT_LLD_ConnectPins( const oC_LCDTFT_LLD_Pins_t * Pins )
614 {
615  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
616 
617  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
618  {
619  if(
620  ErrorCondition( IsRam(Pins) || IsRom(Pins) , oC_ErrorCode_WrongAddress ) &&
621  ErrorCondition( IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn )
622  )
623  {
624 #define IS_PIN_REQUIRED(PinIndex) \
625  ( (PinIndex >= oC_LCDTFT_LLD_PinIndex_R0 && PinIndex <= oC_LCDTFT_LLD_PinIndex_R7) ? (PinIndex - oC_LCDTFT_LLD_PinIndex_R0) < requiredRed :\
626  (PinIndex >= oC_LCDTFT_LLD_PinIndex_G0 && PinIndex <= oC_LCDTFT_LLD_PinIndex_G7) ? (PinIndex - oC_LCDTFT_LLD_PinIndex_G0) < requiredGreen :\
627  (PinIndex >= oC_LCDTFT_LLD_PinIndex_B0 && PinIndex <= oC_LCDTFT_LLD_PinIndex_B7) ? (PinIndex - oC_LCDTFT_LLD_PinIndex_B0) < requiredBlue : true\
628  )
629  oC_ColorFormat_t pixelFormat = GetPixelFormat();
630  uint8_t requiredRed = oC_ColorFormat_GetNoRedBits(pixelFormat);
631  uint8_t requiredGreen = oC_ColorFormat_GetNoGreenBits(pixelFormat);
632  uint8_t requiredBlue = oC_ColorFormat_GetNoBlueBits(pixelFormat);
633 
634  errorCode = (pixelFormat != oC_ColorFormat_Unknown) ? oC_ErrorCode_None : oC_ErrorCode_PixelFormatNotConfigured;
635 
636  for(oC_LCDTFT_LLD_PinIndex_t pinIndex = 0 ; !oC_ErrorOccur(errorCode ) && pinIndex < oC_LCDTFT_LLD_PinIndex_NumberOfPins ; pinIndex++ )
637  {
638  if(PinFunctions[pinIndex])
639  {
640  if(oC_GPIO_LLD_IsPinDefined(Pins->PinsArray[pinIndex]))
641  {
642  oC_LCDTFT_Pin_t modulePin = 0;
643 
644  if(FindModulePin(Pins->PinsArray[pinIndex],PinFunctions[pinIndex],&modulePin))
645  {
646  errorCode = ConnectModulePin(modulePin);
647  }
648  else
649  {
650  errorCode = oC_ErrorCode_NoneOfModulePinAssigned;
651  }
652  }
653  else if(IS_PIN_REQUIRED(pinIndex))
654  {
655  errorCode = oC_ErrorCode_PinNotDefined;
656  }
657  }
658  }
659 
660  if(
661  !oC_ErrorOccur(errorCode) &&
662  oC_AssignErrorCode( &errorCode , ConnectPin(Pins->PinsArray[oC_LCDTFT_LLD_PinIndex_DISP] , oC_GPIO_LLD_Mode_Output ) ) &&
663  oC_AssignErrorCode( &errorCode , ConnectPin(Pins->PinsArray[oC_LCDTFT_LLD_PinIndex_BL_CTRL], oC_GPIO_LLD_Mode_Output ) )
664  )
665  {
666  ConfiguredDispPin = Pins->PinsArray[oC_LCDTFT_LLD_PinIndex_DISP];
667  ConfiguredBlCtrlPin = Pins->PinsArray[oC_LCDTFT_LLD_PinIndex_BL_CTRL];
668  errorCode = oC_ErrorCode_None;
669  }
670  else
671  {
672  oC_SaveIfErrorOccur("LCDTFT-LLD - Disconnecting pins error: " , oC_LCDTFT_LLD_DisconnectPins(Pins));
673  }
674  }
675  }
676 
677  return errorCode;
678 }
679 
680 //==========================================================================================================================================
685 //==========================================================================================================================================
687 {
688  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
689 
690  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
691  {
692  if(
693  ErrorCondition( IsRam(Pins) || IsRom(Pins) , oC_ErrorCode_WrongAddress )
694  )
695  {
696  errorCode = oC_ErrorCode_None;
697 
698  for(oC_LCDTFT_LLD_PinIndex_t pinIndex = 0 ; pinIndex < oC_LCDTFT_LLD_PinIndex_NumberOfPins ; pinIndex++ )
699  {
700  if(Pins->PinsArray[pinIndex] != oC_Pin_NotUsed)
701  {
702  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_SetPinsUnused(Pins->PinsArray[pinIndex]) );
703  oC_AssignErrorCode(&errorCode , oC_GPIO_MSLLD_DisconnectPin( Pins->PinsArray[pinIndex] , 0 ) );
704  }
705  }
706  }
707  }
708 
709  return errorCode;
710 }
711 
712 //==========================================================================================================================================
717 //==========================================================================================================================================
718 oC_ErrorCode_t oC_LCDTFT_LLD_SetColormapBuffer( const void * Buffer )
719 {
720  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
721 
722  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
723  {
724  oC_UInt_t pixelSize = GetPixelSize();
725  oC_UInt_t requiredBufferSize = pixelSize * ConfiguredWidth * ConfiguredHeight;
726  const void * bufferEnd = (const void * )(((oC_UInt_t)Buffer) + requiredBufferSize - 1);
727 
728  if(
729  ErrorCondition( IsRam(Buffer) || IsRom(Buffer) , oC_ErrorCode_WrongAddress ) &&
730  ErrorCondition( GetPixelFormat() != oC_ColorFormat_Unknown , oC_ErrorCode_PixelFormatNotConfigured ) &&
731  ErrorCondition( pixelSize > 0 && pixelSize <= 4 , oC_ErrorCode_MachineCanBeDamaged ) &&
732  ErrorCondition( ConfiguredWidth > 0 , oC_ErrorCode_ResolutionNotSet ) &&
733  ErrorCondition( ConfiguredHeight> 0 , oC_ErrorCode_ResolutionNotSet ) &&
734  ErrorCondition( IsRam(bufferEnd) || IsRom(bufferEnd) , oC_ErrorCode_WrongBufferEndAddress ) &&
735  ErrorCondition( IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn ) &&
736  ErrorCondition( AreOperationsDisabled() , oC_ErrorCode_ChannelOperationsNotDisabled )
737  )
738  {
739  LTDC_L1CFBAR->Value = (uint32_t)Buffer;
740  errorCode = oC_ErrorCode_None;
741  }
742  }
743 
744  return errorCode;
745 }
746 
747 //==========================================================================================================================================
752 //==========================================================================================================================================
753 oC_ErrorCode_t oC_LCDTFT_LLD_SetPixelFormat( oC_ColorFormat_t PixelFormat )
754 {
755  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
756 
757  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
758  {
759  if(
760  ErrorCondition(IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn ) &&
761  ErrorCondition(AreOperationsDisabled() , oC_ErrorCode_ChannelOperationsNotDisabled )
762  )
763  {
764  errorCode = SetPixelFormat( PixelFormat );
765  }
766  }
767 
768  return errorCode;
769 }
770 
771 //==========================================================================================================================================
776 //==========================================================================================================================================
777 oC_ErrorCode_t oC_LCDTFT_LLD_ReadPixelFormat( oC_ColorFormat_t * outPixelFormat )
778 {
779  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
780 
781  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
782  {
783  if(
784  ErrorCondition(IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn ) &&
785  ErrorCondition(IsRam(outPixelFormat) , oC_ErrorCode_OutputAddressNotInRAM )
786  )
787  {
788  *outPixelFormat = GetPixelFormat();
789  errorCode = oC_ErrorCode_None;
790  }
791  }
792 
793  return errorCode;
794 }
795 
796 //==========================================================================================================================================
801 //==========================================================================================================================================
802 oC_ErrorCode_t oC_LCDTFT_LLD_SetTimingParameters( const oC_LCDTFT_LLD_TimingParameters_t * TimingParameters )
803 {
804  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
805 
806  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
807  {
808  if(
809  ErrorCondition( IsRam(TimingParameters) || IsRom(TimingParameters) , oC_ErrorCode_WrongAddress ) &&
810  ErrorCondition( IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn ) &&
811  ErrorCondition( AreOperationsDisabled() , oC_ErrorCode_ChannelOperationsNotDisabled ) &&
812  ErrorCondition( ConfiguredWidth > 0 , oC_ErrorCode_ResolutionNotSet ) &&
813  ErrorCondition( ConfiguredHeight> 0 , oC_ErrorCode_ResolutionNotSet )
814  )
815  {
816  errorCode = SetTimingParameters( TimingParameters );
817  }
818  }
819 
820  return errorCode;
821 }
822 
823 //==========================================================================================================================================
828 //==========================================================================================================================================
830 {
831  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
832 
833  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
834  {
835  if(
836  ErrorCondition( IsRam(outTimingParameters) , oC_ErrorCode_OutputAddressNotInRAM ) &&
837  ErrorCondition( IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn )
838  )
839  {
840  errorCode = ReadTimingParameters( outTimingParameters );
841  }
842  }
843 
844  return errorCode;
845 }
846 
847 //==========================================================================================================================================
852 //==========================================================================================================================================
853 oC_ErrorCode_t oC_LCDTFT_LLD_SetBackgroundColor( oC_Color_t Color , oC_ColorFormat_t ColorFormat )
854 {
855  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
856 
857  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
858  {
859  if(
860  ErrorCondition( IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn ) &&
861  ErrorCondition( AreOperationsDisabled() , oC_ErrorCode_ChannelOperationsNotDisabled ) &&
862  ErrorCondition( oC_Color_IsCorrect(Color) , oC_ErrorCode_ColorNotCorrect ) &&
863  ErrorCondition( ColorFormat != oC_ColorFormat_Unknown , oC_ErrorCode_ColorFormatNotSupported )
864  )
865  {
866  oC_Color_t converted = oC_Color_ConvertToFormat(Color,ColorFormat,oC_ColorFormat_RGB888);
867  LTDC_BCCR->Value = (uint32_t)converted;
868  LTDC_L1DCCR->Value = (uint32_t)converted;
869  LTDC_L1CACR->Value = 0xFF;
870  errorCode = oC_ErrorCode_None;
871  }
872  }
873 
874  return errorCode;
875 }
876 
877 //==========================================================================================================================================
882 //==========================================================================================================================================
883 oC_ErrorCode_t oC_LCDTFT_LLD_ReadBackgroundColor( oC_Color_t * outColor , oC_ColorFormat_t ColorFormat )
884 {
885  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
886 
887  if(oC_Module_TurnOnVerification(&errorCode , oC_Module_LCDTFT_LLD))
888  {
889  if(
890  ErrorCondition( IsChannelPoweredOn() , oC_ErrorCode_ChannelNotPoweredOn ) &&
891  ErrorCondition( IsRam(outColor) , oC_ErrorCode_OutputAddressNotInRAM ) &&
892  ErrorCondition( ColorFormat != oC_ColorFormat_Unknown , oC_ErrorCode_ColorFormatNotSupported )
893  )
894  {
895  *outColor = oC_Color_ConvertToFormat((oC_Color_t)LTDC_BCCR->Value,oC_ColorFormat_RGB888,ColorFormat);
896  errorCode = oC_ErrorCode_None;
897  }
898  }
899 
900  return errorCode;
901 }
902 
903 
904 #undef _________________________________________FUNCTIONS_SECTION__________________________________________________________________________
905 
911 #define _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________
912 
913 //==========================================================================================================================================
917 //==========================================================================================================================================
918 static bool FindModulePin( oC_Pin_t Pin , oC_LCDTFT_PinFunction_t Function , oC_LCDTFT_Pin_t * outModulePin )
919 {
920  bool success = false;
921 
922  oC_ModulePin_ForeachDefined(modulePin)
923  {
924  if((modulePin->Channel == LTDC_Channel) && modulePin->PinFunction == Function && modulePin->Pin == Pin)
925  {
926  *outModulePin = modulePin->ModulePinIndex;
927  success = true;
928  break;
929  }
930  }
931 
932  return success;
933 }
934 
935 //==========================================================================================================================================
939 //==========================================================================================================================================
940 static oC_ErrorCode_t ConnectModulePin( oC_LCDTFT_Pin_t ModulePin )
941 {
942  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
943  oC_Pin_t pin = oC_ModulePin_GetPin(ModulePin);
944  bool unused = false;
945  if(
946  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_ArePinsUnused(pin,&unused) ) &&
947  ErrorCondition( unused , oC_ErrorCode_PinIsUsed) &&
948  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_SetPinsUsed(pin) ) &&
949  oC_AssignErrorCode(&errorCode , oC_GPIO_MSLLD_ConnectModulePin(ModulePin) )
950  )
951  {
952  errorCode = oC_ErrorCode_None;
953  }
954  return errorCode;
955 }
956 //==========================================================================================================================================
960 //==========================================================================================================================================
961 static oC_ErrorCode_t ConnectPin( oC_Pin_t Pin , oC_GPIO_LLD_Mode_t PinMode )
962 {
963  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
964  bool unused = false;
965 
966  if(
967  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_ArePinsUnused(Pin,&unused) ) &&
968  ErrorCondition( unused , oC_ErrorCode_PinIsUsed ) &&
969  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_SetPinsUsed(Pin) ) &&
970  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_BeginConfiguration(Pin) ) &&
971  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_SetMode(Pin , PinMode) ) &&
972  oC_AssignErrorCode(&errorCode , oC_GPIO_LLD_FinishConfiguration(Pin) )
973  )
974  {
975  errorCode = oC_ErrorCode_None;
976  }
977 
978  return errorCode;
979 }
980 
981 //==========================================================================================================================================
985 //==========================================================================================================================================
986 static oC_ColorFormat_t GetPixelFormat( void )
987 {
988  /* This is not read from register, because it always returns 0 */
989  return ConfiguredColorFormat;
990 }
991 
992 //==========================================================================================================================================
996 //==========================================================================================================================================
997 static oC_UInt_t GetPixelSize( void )
998 {
999  oC_ColorFormat_t pixelFormat = GetPixelFormat();
1000  return oC_Color_GetFormatSize(pixelFormat);
1001 }
1002 
1003 //==========================================================================================================================================
1007 //==========================================================================================================================================
1008 static oC_ErrorCode_t SetPixelFormat( oC_ColorFormat_t PixelFormat )
1009 {
1010  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1011 
1012  switch(PixelFormat)
1013  {
1014  case oC_ColorFormat_RGB888: LTDC_L1PFCR->PF = 1; errorCode = oC_ErrorCode_None; ConfiguredColorFormat = PixelFormat; break;
1015  case oC_ColorFormat_RGB565: LTDC_L1PFCR->PF = 2; errorCode = oC_ErrorCode_None; ConfiguredColorFormat = PixelFormat; break;
1016  default: errorCode = oC_ErrorCode_ColorFormatNotSupported; break;
1017  }
1018 
1019  return errorCode;
1020 }
1021 
1022 //==========================================================================================================================================
1026 //==========================================================================================================================================
1027 static oC_ErrorCode_t SetTimingParameters( const oC_LCDTFT_LLD_TimingParameters_t * TimingParameters )
1028 {
1029  oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
1030  uint32_t TOTAL_HEIGHT;
1031  uint32_t TOTAL_WIDTH;
1032  uint32_t ACTIVE_HEIGHT;
1033  uint32_t ACTIVE_WIDTH;
1034  oC_UInt_t pixelSize = GetPixelSize();
1035 
1036  ACTIVE_WIDTH = TimingParameters->HSYNC.PulseWidth + ConfiguredWidth + TimingParameters->HSYNC.BackPorch - 1;
1037  ACTIVE_HEIGHT= TimingParameters->VSYNC.PulseWidth + ConfiguredHeight + TimingParameters->VSYNC.BackPorch - 1;
1038 
1039  TOTAL_WIDTH = TimingParameters->HSYNC.PulseWidth + TimingParameters->HSYNC.BackPorch + ACTIVE_WIDTH + TimingParameters->HSYNC.FrontPorch;
1040  TOTAL_HEIGHT = TimingParameters->VSYNC.PulseWidth + TimingParameters->VSYNC.BackPorch + ACTIVE_HEIGHT+ TimingParameters->VSYNC.FrontPorch;
1041 
1042  if(
1043  ErrorCondition( TimingParameters->HSYNC.PulseWidth <= MAX_HSW , oC_ErrorCode_TimingParametersNotSupported ) &&
1044  ErrorCondition( TimingParameters->VSYNC.PulseWidth <= MAX_VSW , oC_ErrorCode_TimingParametersNotSupported ) &&
1045  ErrorCondition( TimingParameters->HSYNC.BackPorch <= MAX_AHBP , oC_ErrorCode_TimingParametersNotSupported ) &&
1046  ErrorCondition( TimingParameters->VSYNC.BackPorch <= MAX_AVBP , oC_ErrorCode_TimingParametersNotSupported ) &&
1047  ErrorCondition( TimingParameters->HSYNC.PulseWidth > 0 , oC_ErrorCode_TimingParametersNotFilled ) &&
1048  ErrorCondition( TimingParameters->VSYNC.PulseWidth > 0 , oC_ErrorCode_TimingParametersNotFilled ) &&
1049  ErrorCondition( TimingParameters->HSYNC.BackPorch > 0 , oC_ErrorCode_TimingParametersNotFilled ) &&
1050  ErrorCondition( TimingParameters->VSYNC.BackPorch > 0 , oC_ErrorCode_TimingParametersNotFilled ) &&
1051  ErrorCondition( ACTIVE_HEIGHT <= MAX_AAH , oC_ErrorCode_TimingParametersNotSupported ) &&
1052  ErrorCondition( ACTIVE_WIDTH <= MAX_AAW , oC_ErrorCode_TimingParametersNotSupported ) &&
1053  ErrorCondition( TOTAL_HEIGHT <= MAX_TOTALH , oC_ErrorCode_TimingParametersNotSupported ) &&
1054  ErrorCondition( TOTAL_WIDTH <= MAX_TOTALW , oC_ErrorCode_TimingParametersNotSupported )
1055  )
1056  {
1057  LTDC_L1CR->LEN = 1;
1058 
1059  SetPixelFormat(ConfiguredColorFormat);
1060 
1061  LTDC_SSCR->HSW = TimingParameters->HSYNC.PulseWidth - 1;
1062  LTDC_SSCR->VSH = TimingParameters->VSYNC.PulseWidth - 1;
1063 
1064  LTDC_BPCR->AHBP = TimingParameters->HSYNC.BackPorch - 1;
1065  LTDC_BPCR->AVBP = TimingParameters->VSYNC.BackPorch - 1;
1066 
1067  LTDC_AWCR->AAH = ACTIVE_HEIGHT;
1068  LTDC_AWCR->AAW = ACTIVE_WIDTH;
1069 
1070  LTDC_TWCR->TOTALH = TOTAL_HEIGHT;
1071  LTDC_TWCR->TOTALW = TOTAL_WIDTH;
1072 
1073  LTDC_L1WHPCR->Value = TimingParameters->HSYNC.BackPorch | ((TimingParameters->HSYNC.BackPorch + ConfiguredWidth - 1) << 16);
1074 
1075  LTDC_L1WVPCR->WVSPPOS = TimingParameters->VSYNC.BackPorch + ConfiguredHeight - 1;
1076  LTDC_L1WVPCR->WVSTPOS = TimingParameters->VSYNC.BackPorch;
1077 
1078  LTDC_L1CFBLR->Value = ((ConfiguredWidth * pixelSize) << 16) | ((ConfiguredWidth * pixelSize) + 3);
1079 
1080  LTDC_L1CFBLNR->Value = ConfiguredHeight;
1081 
1082  LTDC_L1BFCR->BF1 = 4;
1083  LTDC_L1BFCR->BF2 = 5;
1084 
1085  errorCode = oC_ErrorCode_None;
1086  }
1087 
1088  return errorCode;
1089 }
1090 
1091 //==========================================================================================================================================
1095 //==========================================================================================================================================
1096 static oC_ErrorCode_t ReadTimingParameters( oC_LCDTFT_LLD_TimingParameters_t * outTimingParameters )
1097 {
1098  return oC_ErrorCode_NotImplemented;
1099 }
1100 
1101 
1102 #undef _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________
1103 
oC_ErrorCode_t oC_LCDTFT_LLD_SetTimingParameters(const oC_LCDTFT_LLD_TimingParameters_t *TimingParameters)
oC_ErrorCode_t oC_LCDTFT_LLD_SetBackgroundColor(oC_Color_t Color, oC_ColorFormat_t ColorFormat)
Something is powered on.
Definition: oc_stdtypes.h:252
oC_ErrorCode_t oC_LCDTFT_LLD_RestoreDefaultState(void)
oC_ErrorCode_t oC_LCDTFT_LLD_EnableOperations(void)
oC_ErrorCode_t oC_LCDTFT_LLD_SetPixelFormat(oC_ColorFormat_t PixelFormat)
double oC_Frequency_t
type to store frequency
Definition: oc_frequency.h:76
oC_ErrorCode_t oC_LCDTFT_LLD_SetResolution(oC_Pixel_ResolutionUInt_t Width, oC_Pixel_ResolutionUInt_t Height)
oC_ErrorCode_t oC_LCDTFT_LLD_SetPower(oC_Power_t Power)
oC_ErrorCode_t oC_LCDTFT_LLD_SetColormapBuffer(const void *Buffer)
oC_ErrorCode_t oC_LCDTFT_LLD_SetPolarities(oC_LCDTFT_LLD_Polarity_t HSyncPolarity, oC_LCDTFT_LLD_Polarity_t VSyncPolarity, oC_LCDTFT_LLD_Polarity_t DataEnablePolarity)
The file with interface for LSF module.
oC_ErrorCode_t oC_LCDTFT_LLD_ReadPixelClockPolarity(oC_LCDTFT_LLD_PixelClockPolarity_t *outPixelPolarity)
The file with LLD interface for the MEM driver.
The file with LLD interface for the GPIO driver.
oC_ErrorCode_t oC_LCDTFT_LLD_ReadPower(oC_Power_t *outPower)
oC_ErrorCode_t oC_LCDTFT_LLD_ReadTimingParameters(oC_LCDTFT_LLD_TimingParameters_t *outTimingParameters)
The file with interface for the module library.
Output of the PLL connected to the LTDC module (LTDC Clock)
Definition: oc_saipll.h:57
Something is powered off.
Definition: oc_stdtypes.h:251
oC_ErrorCode_t oC_LCDTFT_LLD_ReadResolution(oC_Pixel_ResolutionUInt_t *outWidth, oC_Pixel_ResolutionUInt_t *outHeight)
oC_ErrorCode_t oC_LCDTFT_LLD_TurnOffDriver(void)
oC_ErrorCode_t oC_LCDTFT_LLD_TurnOnDriver(void)
oC_ErrorCode_t oC_LCDTFT_LLD_DisconnectPins(const oC_LCDTFT_LLD_Pins_t *Pins)
oC_ErrorCode_t oC_LCDTFT_LLD_ConnectPins(const oC_LCDTFT_LLD_Pins_t *Pins)
oC_ErrorCode_t oC_LCDTFT_LLD_ReadPolarities(oC_LCDTFT_LLD_Polarity_t *outHSyncPolarity, oC_LCDTFT_LLD_Polarity_t *outVSyncPolarity, oC_LCDTFT_LLD_Polarity_t *outDataEnablePolarity)
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.
oC_ErrorCode_t oC_LCDTFT_LLD_ReadPixelFormat(oC_ColorFormat_t *outPixelFormat)
static void oC_MCS_EnterCriticalSection(void)
Enters to critical section.
Definition: oc_mcs.h:755
oC_ErrorCode_t oC_LCDTFT_LLD_ReadFrequency(oC_Frequency_t *outFrequency)
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
oC_ErrorCode_t oC_LCDTFT_LLD_SetPixelClockPolarity(oC_LCDTFT_LLD_PixelClockPolarity_t PixelPolarity)
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
oC_ErrorCode_t oC_SaiPll_Configure(oC_SaiPll_OutputLine_t OutputLine, oC_Frequency_t Frequency, oC_Frequency_t PermissibleDifference, oC_Frequency_t *outRealFrequency)
Configures SAI PLL.
Definition: oc_saipll.c:201
oC_ErrorCode_t oC_LCDTFT_LLD_SetFrequency(oC_Frequency_t Frequency, oC_Frequency_t PermissibleDifference)
oC_ErrorCode_t oC_LCDTFT_LLD_ReadBackgroundColor(oC_Color_t *outColor, oC_ColorFormat_t ColorFormat)
The file with LLD interface for the LCDTFT driver.
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
oC_ErrorCode_t oC_LCDTFT_LLD_DisableOperations(void)
static void oC_Module_TurnOff(oC_Module_t Module)
sets module as turned off
Definition: oc_module.h:185