EFM32 Giant Gecko Software Documentation  efm32gg-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 
76 #endif
78 
80 typedef enum
81 {
88 #if defined(LCD_DISPCTRL_BIAS_ONEFOURTH)
89 
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_BIAS_ONETHIRD
Definition: efm32gg_lcd.h:134
LCD_ConConf_TypeDef contrast
Definition: em_lcd.h:261
#define LCD_BACTRL_FCEN
Definition: efm32gg_lcd.h:256
#define LCD_DISPCTRL_BIAS_ONEFOURTH
Definition: efm32gg_lcd.h:135
__STATIC_INLINE uint32_t LCD_SyncBusyGet(void)
Returns SYNCBUSY bits, indicating which registers have pending updates.
Definition: em_lcd.h:455
#define LCD
void LCD_VBoostSet(LCD_VBoostLevel_TypeDef vboost)
Configure voltage booster.
Definition: em_lcd.c:610
#define LCD_CTRL_DSC
Definition: efm32gg_lcd.h:103
LCD_Wave_TypeDef wave
Definition: em_lcd.h:257
#define LCD_DISPCTRL_CONCONF_GND
Definition: efm32gg_lcd.h:161
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_MUX_TRIPLEX
Definition: efm32gg_lcd.h:122
void LCD_BiasComSet(int com, int biasLevel)
Configure bias level for a specific segment line.
Definition: em_lcd.c:755
LCD_AnimShift_TypeDef
Definition: em_lcd.h:191
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
#define LCD_DISPCTRL_VBLEV_LEVEL7
Definition: efm32gg_lcd.h:190
#define _LCD_BACTRL_AREGASC_SHIFTLEFT
Definition: efm32gg_lcd.h:231
void LCD_FrameCountInit(const LCD_FrameCountInit_TypeDef *fcInit)
Initialize LCD Frame Counter.
Definition: em_lcd.c:154
#define _LCD_SEGD0H_MASK
Definition: efm32gg_lcd.h:386
void LCD_SegmentSet(int com, int bit, bool enable)
Turn on or clear a segment.
Definition: em_lcd.c:265
#define LCD_BACTRL_BLANK
Definition: efm32gg_lcd.h:217
void LCD_VLCDSelect(LCD_VLCDSel_TypeDef vlcd)
Select source for VLCD.
Definition: em_lcd.c:112
#define LCD_DISPCTRL_VBLEV_LEVEL0
Definition: efm32gg_lcd.h:182
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
#define LCD_DISPCTRL_MUX_DUPLEX
Definition: efm32gg_lcd.h:121
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_BACTRL_BLINKEN
Definition: efm32gg_lcd.h:212
#define LCD_BACTRL_FCPRESC_DIV4
Definition: efm32gg_lcd.h:271
#define _LCD_STATUS_BLINK_SHIFT
Definition: efm32gg_lcd.h:295
__STATIC_INLINE void LCD_IntSet(uint32_t flags)
Set one or more pending LCD interrupts from SW.
Definition: em_lcd.h:529
#define LCD_BACTRL_ALOGSEL_OR
Definition: efm32gg_lcd.h:255
#define LCD_DISPCTRL_VBLEV_LEVEL3
Definition: efm32gg_lcd.h:186
#define LCD_BACTRL_ALOGSEL_AND
Definition: efm32gg_lcd.h:254
#define LCD_DISPCTRL_BIAS_STATIC
Definition: efm32gg_lcd.h:132
#define LCD_CTRL_UDCTRL_FCEVENT
Definition: efm32gg_lcd.h:101
#define _LCD_BACTRL_AREGASC_SHIFTRIGHT
Definition: efm32gg_lcd.h:232
#define LCD_DISPCTRL_VBLEV_LEVEL2
Definition: efm32gg_lcd.h:184
#define LCD_DISPCTRL_BIAS_ONEHALF
Definition: efm32gg_lcd.h:133
#define LCD_DISPCTRL_VBLEV_LEVEL6
Definition: efm32gg_lcd.h:189
__STATIC_INLINE int LCD_BlinkState(void)
Returns current blink state.
Definition: em_lcd.h:421
#define LCD_DISPCTRL_MUX_QUADRUPLEX
Definition: efm32gg_lcd.h:123
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_VBLEV_LEVEL1
Definition: efm32gg_lcd.h:183
#define LCD_BACTRL_AEN
Definition: efm32gg_lcd.h:222
#define _LCD_STATUS_BLINK_MASK
Definition: efm32gg_lcd.h:296
LCD_AnimLogic_TypeDef
Definition: em_lcd.h:202
__STATIC_INLINE void LCD_IntClear(uint32_t flags)
Clear one or more interrupt flags.
Definition: em_lcd.h:574
#define _LCD_STATUS_ASTATE_SHIFT
Definition: efm32gg_lcd.h:290
__STATIC_INLINE int LCD_AnimState(void)
Returns current animation state.
Definition: em_lcd.h:408
#define LCD_DISPCTRL_VLCDSEL_VEXTBOOST
Definition: efm32gg_lcd.h:170
LCD_Bias_TypeDef
Definition: em_lcd.h:80
#define LCD_DISPCTRL_VLCDSEL_VDD
Definition: efm32gg_lcd.h:169
#define LCD_CTRL_EN
Definition: efm32gg_lcd.h:88
#define _LCD_BACTRL_AREGASC_NOSHIFT
Definition: efm32gg_lcd.h:230
#define _LCD_STATUS_ASTATE_MASK
Definition: efm32gg_lcd.h:291
#define LCD_CTRL_UDCTRL_FRAMESTART
Definition: efm32gg_lcd.h:102
LCD_AnimShift_TypeDef AShift
Definition: em_lcd.h:223
void LCD_ContrastSet(int level)
Configure contrast level on LCD panel.
Definition: em_lcd.c:592
#define LCD_FREEZE_REGFREEZE_FREEZE
Definition: efm32gg_lcd.h:427
#define LCD_BACTRL_FCPRESC_DIV1
Definition: efm32gg_lcd.h:269
#define LCD_BACTRL_FCPRESC_DIV8
Definition: efm32gg_lcd.h:272
#define LCD_DISPCTRL_MUX_STATIC
Definition: efm32gg_lcd.h:120
__STATIC_INLINE void LCD_FreezeEnable(bool enable)
When set, LCD registers will not be updated until cleared,.
Definition: em_lcd.h:435
__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
void LCD_BiasSegmentSet(int segment, int biasLevel)
Configure bias level for a specific segment line for Direct Segment Control.
Definition: em_lcd.c:637
LCD_Mux_TypeDef mux
Definition: em_lcd.h:253
#define LCD_DISPCTRL_WAVE_LOWPOWER
Definition: efm32gg_lcd.h:143
__STATIC_INLINE void LCD_DSCEnable(bool enable)
Enable or disable LCD Direct Segment Control.
Definition: em_lcd.h:590
#define LCD_CTRL_UDCTRL_REGULAR
Definition: efm32gg_lcd.h:100
#define LCD_DISPCTRL_CONCONF_VLCD
Definition: efm32gg_lcd.h:160
#define LCD_FREEZE_REGFREEZE_UPDATE
Definition: efm32gg_lcd.h:426
__STATIC_INLINE void LCD_BlankEnable(bool enable)
Disables all segments, while keeping segment state.
Definition: em_lcd.h:368
LCD_UpdateCtrl_TypeDef
Definition: em_lcd.h:180
LCD_Mux_TypeDef
Definition: em_lcd.h:61
LCD_FCPreScale_TypeDef
Definition: em_lcd.h:135
__STATIC_INLINE void LCD_SyncBusyDelay(uint32_t flags)
Polls LCD SYNCBUSY flags, until flag has been cleared.
Definition: em_lcd.h:468
__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
#define LCD_DISPCTRL_VBLEV_LEVEL5
Definition: efm32gg_lcd.h:188
__STATIC_INLINE void LCD_IntDisable(uint32_t flags)
Disable LCD interrupts.
Definition: em_lcd.h:559
#define LCD_DISPCTRL_MUXE_MUXE
Definition: efm32gg_lcd.h:199
LCD_ConConf_TypeDef
Definition: em_lcd.h:113
LCD_VLCDSel_TypeDef
Definition: em_lcd.h:104
#define LCD_DISPCTRL_WAVE_NORMAL
Definition: efm32gg_lcd.h:144
void LCD_AnimInit(const LCD_AnimInit_TypeDef *animInit)
Configures LCD controller Animation feature.
Definition: em_lcd.c:183
#define LCD_BACTRL_FCPRESC_DIV2
Definition: efm32gg_lcd.h:270
__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
__STATIC_INLINE void LCD_AnimEnable(bool enable)
Enables or disables LCD Animation feature.
Definition: em_lcd.h:328
#define LCD_DISPCTRL_VBLEV_LEVEL4
Definition: efm32gg_lcd.h:187