EFM32 Gecko Software Documentation  efm32g-doc-5.1.2
em_lcd.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef EM_LCD_H
34 #define EM_LCD_H
35 
36 #include "em_device.h"
37 
38 #if defined(LCD_COUNT) && (LCD_COUNT > 0)
39 #include <stdint.h>
40 #include <stdbool.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /***************************************************************************/
51 /***************************************************************************/
56 /*******************************************************************************
57  ******************************** ENUMS ************************************
58  ******************************************************************************/
59 
61 typedef enum
62 {
71 #if defined(LCD_DISPCTRL_MUXE_MUXE)
72 
73  lcdMuxSextaplex = LCD_DISPCTRL_MUXE_MUXE | LCD_DISPCTRL_MUX_DUPLEX,
75  lcdMuxOctaplex = LCD_DISPCTRL_MUXE_MUXE | LCD_DISPCTRL_MUX_QUADRUPLEX
76 #endif
78 
80 typedef enum
81 {
88 #if defined(LCD_DISPCTRL_BIAS_ONEFOURTH)
89 
90  lcdBiasOneFourth = LCD_DISPCTRL_BIAS_ONEFOURTH,
91 #endif
93 
95 typedef enum
96 {
102 
104 typedef enum
105 {
111 
113 typedef enum
114 {
120 
122 typedef enum
123 {
133 
135 typedef enum
136 {
146 
148 typedef enum
149 {
151  lcdSegment0_3 = (1 << 0),
153  lcdSegment4_7 = (1 << 1),
155  lcdSegment8_11 = (1 << 2),
157  lcdSegment12_15 = (1 << 3),
159  lcdSegment16_19 = (1 << 4),
161  lcdSegment20_23 = (1 << 5),
162 #if defined(_LCD_SEGD0L_MASK) && (_LCD_SEGD0L_MASK == 0x00FFFFFFUL)
163 
164  lcdSegmentAll = (0x003f)
165 #elif defined(_LCD_SEGD0H_MASK) && (_LCD_SEGD0H_MASK == 0x000000FFUL)
167  lcdSegment24_27 = (1 << 6),
169  lcdSegment28_31 = (1 << 7),
171  lcdSegment32_35 = (1 << 8),
173  lcdSegment36_39 = (1 << 9),
175  lcdSegmentAll = (0x03ff)
176 #endif
178 
180 typedef enum
181 {
189 
191 typedef enum
192 {
200 
202 typedef enum
203 {
209 
210 
211 /*******************************************************************************
212  ******************************* STRUCTS ***********************************
213  ******************************************************************************/
214 
216 typedef struct
217 {
219  bool enable;
221  uint32_t AReg;
225  uint32_t BReg;
230 #if defined(LCD_BACTRL_ALOC)
231 
232  int startSeg;
233 #endif
235 
237 typedef struct
238 {
240  bool enable;
242  uint32_t top;
246 
248 typedef struct
249 {
251  bool enable;
263 
265 #define LCD_INIT_DEFAULT \
266 { \
267  true, \
268  lcdMuxQuadruplex, \
269  lcdBiasOneThird, \
270  lcdWaveLowPower, \
271  lcdVLCDSelVDD, \
272  lcdConConfVLCD \
273 }
274 
275 /*******************************************************************************
276  ***************************** PROTOTYPES **********************************
277  ******************************************************************************/
278 
279 void LCD_Init(const LCD_Init_TypeDef *lcdInit);
283 void LCD_AnimInit(const LCD_AnimInit_TypeDef *animInit);
284 
285 void LCD_SegmentRangeEnable(LCD_SegmentRange_TypeDef segment, bool enable);
286 void LCD_SegmentSet(int com, int bit, bool enable);
287 void LCD_SegmentSetLow(int com, uint32_t mask, uint32_t bits);
288 #if defined(_LCD_SEGD0H_MASK)
289 void LCD_SegmentSetHigh(int com, uint32_t mask, uint32_t bits);
290 #endif
291 void LCD_ContrastSet(int level);
293 
294 #if defined(LCD_CTRL_DSC)
295 void LCD_BiasSegmentSet(int segment, int biasLevel);
296 void LCD_BiasComSet(int com, int biasLevel);
297 #endif
298 
299 /***************************************************************************/
308 __STATIC_INLINE void LCD_Enable(bool enable)
309 {
310  if (enable)
311  {
312  LCD->CTRL |= LCD_CTRL_EN;
313  }
314  else
315  {
316  LCD->CTRL &= ~LCD_CTRL_EN;
317  }
318 }
319 
320 
321 /***************************************************************************/
328 __STATIC_INLINE void LCD_AnimEnable(bool enable)
329 {
330  if (enable)
331  {
332  LCD->BACTRL |= LCD_BACTRL_AEN;
333  }
334  else
335  {
336  LCD->BACTRL &= ~LCD_BACTRL_AEN;
337  }
338 }
339 
340 
341 /***************************************************************************/
348 __STATIC_INLINE void LCD_BlinkEnable(bool enable)
349 {
350  if (enable)
351  {
352  LCD->BACTRL |= LCD_BACTRL_BLINKEN;
353  }
354  else
355  {
356  LCD->BACTRL &= ~LCD_BACTRL_BLINKEN;
357  }
358 }
359 
360 
361 /***************************************************************************/
368 __STATIC_INLINE void LCD_BlankEnable(bool enable)
369 {
370  if (enable)
371  {
372  LCD->BACTRL |= LCD_BACTRL_BLANK;
373  }
374  else
375  {
376  LCD->BACTRL &= ~LCD_BACTRL_BLANK;
377  }
378 }
379 
380 
381 /***************************************************************************/
388 __STATIC_INLINE void LCD_FrameCountEnable(bool enable)
389 {
390  if (enable)
391  {
392  LCD->BACTRL |= LCD_BACTRL_FCEN;
393  }
394  else
395  {
396  LCD->BACTRL &= ~LCD_BACTRL_FCEN;
397  }
398 }
399 
400 
401 /***************************************************************************/
408 __STATIC_INLINE int LCD_AnimState(void)
409 {
410  return (int)(LCD->STATUS & _LCD_STATUS_ASTATE_MASK) >> _LCD_STATUS_ASTATE_SHIFT;
411 }
412 
413 
414 /***************************************************************************/
421 __STATIC_INLINE int LCD_BlinkState(void)
422 {
423  return (int)(LCD->STATUS & _LCD_STATUS_BLINK_MASK) >> _LCD_STATUS_BLINK_SHIFT;
424 }
425 
426 
427 /***************************************************************************/
435 __STATIC_INLINE void LCD_FreezeEnable(bool enable)
436 {
437  if (enable)
438  {
440  }
441  else
442  {
444  }
445 }
446 
447 
448 /***************************************************************************/
455 __STATIC_INLINE uint32_t LCD_SyncBusyGet(void)
456 {
457  return LCD->SYNCBUSY;
458 }
459 
460 
461 /***************************************************************************/
468 __STATIC_INLINE void LCD_SyncBusyDelay(uint32_t flags)
469 {
470  while (LCD->SYNCBUSY & flags)
471  ;
472 }
473 
474 
475 /***************************************************************************/
483 __STATIC_INLINE uint32_t LCD_IntGet(void)
484 {
485  return LCD->IF;
486 }
487 
488 
489 /***************************************************************************/
507 __STATIC_INLINE uint32_t LCD_IntGetEnabled(void)
508 {
509  uint32_t ien;
510 
511  /* Store LCD->IEN in temporary variable in order to define explicit order
512  * of volatile accesses. */
513  ien = LCD->IEN;
514 
515  /* Bitwise AND of pending and enabled interrupts */
516  return LCD->IF & ien;
517 }
518 
519 
520 /***************************************************************************/
529 __STATIC_INLINE void LCD_IntSet(uint32_t flags)
530 {
531  LCD->IFS = flags;
532 }
533 
534 
535 /***************************************************************************/
544 __STATIC_INLINE void LCD_IntEnable(uint32_t flags)
545 {
546  LCD->IEN |= flags;
547 }
548 
549 
550 /***************************************************************************/
559 __STATIC_INLINE void LCD_IntDisable(uint32_t flags)
560 {
561  LCD->IEN &= ~flags;
562 }
563 
564 
565 /***************************************************************************/
574 __STATIC_INLINE void LCD_IntClear(uint32_t flags)
575 {
576  LCD->IFC = flags;
577 }
578 
579 
580 #if defined(LCD_CTRL_DSC)
581 /***************************************************************************/
590 __STATIC_INLINE void LCD_DSCEnable(bool enable)
591 {
592  if (enable)
593  {
594  LCD->CTRL |= LCD_CTRL_DSC;
595  }
596  else
597  {
598  LCD->CTRL &= ~LCD_CTRL_DSC;
599  }
600 }
601 #endif
602 
606 #ifdef __cplusplus
607 }
608 #endif
609 
610 #endif /* defined(LCD_COUNT) && (LCD_COUNT > 0) */
611 
612 #endif /* EM_LCD_H */
__STATIC_INLINE uint32_t LCD_IntGet(void)
Get pending LCD interrupt flags.
Definition: em_lcd.h:483
#define LCD_DISPCTRL_VBLEV_LEVEL5
Definition: efm32g_lcd.h:169
LCD_ConConf_TypeDef contrast
Definition: em_lcd.h:261
#define _LCD_BACTRL_AREGASC_SHIFTLEFT
Definition: efm32g_lcd.h:203
#define LCD_DISPCTRL_VBLEV_LEVEL7
Definition: efm32g_lcd.h:171
#define LCD_FREEZE_REGFREEZE_UPDATE
Definition: efm32g_lcd.h:389
__STATIC_INLINE uint32_t LCD_SyncBusyGet(void)
Returns SYNCBUSY bits, indicating which registers have pending updates.
Definition: em_lcd.h:455
#define _LCD_BACTRL_AREGASC_SHIFTRIGHT
Definition: efm32g_lcd.h:204
void LCD_VBoostSet(LCD_VBoostLevel_TypeDef vboost)
Configure voltage booster.
Definition: em_lcd.c:610
#define LCD_DISPCTRL_MUX_TRIPLEX
Definition: efm32g_lcd.h:105
#define LCD
LCD_Wave_TypeDef wave
Definition: em_lcd.h:257
#define LCD_DISPCTRL_VBLEV_LEVEL3
Definition: efm32g_lcd.h:167
#define _LCD_STATUS_ASTATE_MASK
Definition: efm32g_lcd.h:254
void LCD_SegmentSetLow(int com, uint32_t mask, uint32_t bits)
Updates the 0-31 lowest segments on a given COM-line in one operation, according to bit mask...
Definition: em_lcd.c:419
void LCD_SegmentRangeEnable(LCD_SegmentRange_TypeDef segment, bool enable)
Enables update of this range of LCD segment lines.
Definition: em_lcd.c:234
#define LCD_DISPCTRL_BIAS_STATIC
Definition: efm32g_lcd.h:114
#define LCD_DISPCTRL_CONCONF_VLCD
Definition: efm32g_lcd.h:141
LCD_AnimShift_TypeDef
Definition: em_lcd.h:191
#define LCD_DISPCTRL_VLCDSEL_VDD
Definition: efm32g_lcd.h:150
LCD_AnimShift_TypeDef BShift
Definition: em_lcd.h:227
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
LCD_Bias_TypeDef bias
Definition: em_lcd.h:255
LCD_VLCDSel_TypeDef vlcd
Definition: em_lcd.h:259
void LCD_FrameCountInit(const LCD_FrameCountInit_TypeDef *fcInit)
Initialize LCD Frame Counter.
Definition: em_lcd.c:154
void LCD_SegmentSet(int com, int bit, bool enable)
Turn on or clear a segment.
Definition: em_lcd.c:265
#define LCD_BACTRL_FCPRESC_DIV2
Definition: efm32g_lcd.h:242
void LCD_VLCDSelect(LCD_VLCDSel_TypeDef vlcd)
Select source for VLCD.
Definition: em_lcd.c:112
LCD_VBoostLevel_TypeDef
Definition: em_lcd.h:122
__STATIC_INLINE void LCD_FrameCountEnable(bool enable)
Enables or disables LCD Frame Control.
Definition: em_lcd.h:388
void LCD_UpdateCtrl(LCD_UpdateCtrl_TypeDef ud)
Configure Update Control.
Definition: em_lcd.c:141
LCD_FCPreScale_TypeDef prescale
Definition: em_lcd.h:244
#define LCD_DISPCTRL_VBLEV_LEVEL1
Definition: efm32g_lcd.h:164
#define LCD_BACTRL_BLANK
Definition: efm32g_lcd.h:189
__STATIC_INLINE void LCD_IntSet(uint32_t flags)
Set one or more pending LCD interrupts from SW.
Definition: em_lcd.h:529
#define LCD_DISPCTRL_VLCDSEL_VEXTBOOST
Definition: efm32g_lcd.h:151
#define LCD_BACTRL_FCEN
Definition: efm32g_lcd.h:228
#define LCD_CTRL_EN
Definition: efm32g_lcd.h:76
#define LCD_CTRL_UDCTRL_REGULAR
Definition: efm32g_lcd.h:88
__STATIC_INLINE int LCD_BlinkState(void)
Returns current blink state.
Definition: em_lcd.h:421
#define LCD_DISPCTRL_MUX_STATIC
Definition: efm32g_lcd.h:103
void LCD_SegmentSetHigh(int com, uint32_t mask, uint32_t bits)
Updated the high (32-39) segments on a given COM-line in one operation.
Definition: em_lcd.c:510
#define LCD_DISPCTRL_MUX_DUPLEX
Definition: efm32g_lcd.h:104
#define LCD_CTRL_UDCTRL_FRAMESTART
Definition: efm32g_lcd.h:90
#define _LCD_STATUS_ASTATE_SHIFT
Definition: efm32g_lcd.h:253
LCD_AnimLogic_TypeDef
Definition: em_lcd.h:202
#define LCD_BACTRL_BLINKEN
Definition: efm32g_lcd.h:184
__STATIC_INLINE void LCD_IntClear(uint32_t flags)
Clear one or more interrupt flags.
Definition: em_lcd.h:574
__STATIC_INLINE int LCD_AnimState(void)
Returns current animation state.
Definition: em_lcd.h:408
#define LCD_DISPCTRL_BIAS_ONETHIRD
Definition: efm32g_lcd.h:116
LCD_Bias_TypeDef
Definition: em_lcd.h:80
#define _LCD_STATUS_BLINK_MASK
Definition: efm32g_lcd.h:259
#define LCD_DISPCTRL_MUX_QUADRUPLEX
Definition: efm32g_lcd.h:106
#define _LCD_BACTRL_AREGASC_NOSHIFT
Definition: efm32g_lcd.h:202
LCD_AnimShift_TypeDef AShift
Definition: em_lcd.h:223
#define LCD_DISPCTRL_VBLEV_LEVEL4
Definition: efm32g_lcd.h:168
#define LCD_BACTRL_FCPRESC_DIV8
Definition: efm32g_lcd.h:244
void LCD_ContrastSet(int level)
Configure contrast level on LCD panel.
Definition: em_lcd.c:592
__STATIC_INLINE void LCD_FreezeEnable(bool enable)
When set, LCD registers will not be updated until cleared,.
Definition: em_lcd.h:435
#define LCD_BACTRL_AEN
Definition: efm32g_lcd.h:194
__STATIC_INLINE void LCD_IntEnable(uint32_t flags)
Enable LCD interrupts.
Definition: em_lcd.h:544
LCD_AnimLogic_TypeDef animLogic
Definition: em_lcd.h:229
#define LCD_CTRL_UDCTRL_FCEVENT
Definition: efm32g_lcd.h:89
#define LCD_DISPCTRL_BIAS_ONEHALF
Definition: efm32g_lcd.h:115
LCD_Mux_TypeDef mux
Definition: em_lcd.h:253
#define LCD_BACTRL_ALOGSEL_AND
Definition: efm32g_lcd.h:226
#define LCD_DISPCTRL_VBLEV_LEVEL6
Definition: efm32g_lcd.h:170
__STATIC_INLINE void LCD_BlankEnable(bool enable)
Disables all segments, while keeping segment state.
Definition: em_lcd.h:368
#define LCD_BACTRL_FCPRESC_DIV1
Definition: efm32g_lcd.h:241
LCD_UpdateCtrl_TypeDef
Definition: em_lcd.h:180
#define LCD_DISPCTRL_VBLEV_LEVEL2
Definition: efm32g_lcd.h:165
LCD_Mux_TypeDef
Definition: em_lcd.h:61
#define LCD_DISPCTRL_WAVE_LOWPOWER
Definition: efm32g_lcd.h:124
#define LCD_BACTRL_FCPRESC_DIV4
Definition: efm32g_lcd.h:243
#define LCD_DISPCTRL_CONCONF_GND
Definition: efm32g_lcd.h:142
LCD_FCPreScale_TypeDef
Definition: em_lcd.h:135
#define LCD_FREEZE_REGFREEZE_FREEZE
Definition: efm32g_lcd.h:390
__STATIC_INLINE void LCD_SyncBusyDelay(uint32_t flags)
Polls LCD SYNCBUSY flags, until flag has been cleared.
Definition: em_lcd.h:468
#define _LCD_STATUS_BLINK_SHIFT
Definition: efm32g_lcd.h:258
__STATIC_INLINE void LCD_BlinkEnable(bool enable)
Enables or disables LCD blink.
Definition: em_lcd.h:348
LCD_Wave_TypeDef
Definition: em_lcd.h:95
__STATIC_INLINE void LCD_IntDisable(uint32_t flags)
Disable LCD interrupts.
Definition: em_lcd.h:559
LCD_ConConf_TypeDef
Definition: em_lcd.h:113
LCD_VLCDSel_TypeDef
Definition: em_lcd.h:104
#define _LCD_SEGD0H_MASK
Definition: efm32g_lcd.h:349
void LCD_AnimInit(const LCD_AnimInit_TypeDef *animInit)
Configures LCD controller Animation feature.
Definition: em_lcd.c:183
__STATIC_INLINE void LCD_Enable(bool enable)
Enable or disable LCD controller.
Definition: em_lcd.h:308
LCD_SegmentRange_TypeDef
Definition: em_lcd.h:148
void LCD_Init(const LCD_Init_TypeDef *lcdInit)
Initalize Liquid Crystal Display (LCD) controller.
Definition: em_lcd.c:67
__STATIC_INLINE uint32_t LCD_IntGetEnabled(void)
Get enabled and pending LCD interrupt flags.
Definition: em_lcd.h:507
#define LCD_BACTRL_ALOGSEL_OR
Definition: efm32g_lcd.h:227
#define LCD_DISPCTRL_WAVE_NORMAL
Definition: efm32g_lcd.h:125
__STATIC_INLINE void LCD_AnimEnable(bool enable)
Enables or disables LCD Animation feature.
Definition: em_lcd.h:328
#define LCD_DISPCTRL_VBLEV_LEVEL0
Definition: efm32g_lcd.h:163