EFM32 Happy Gecko Software Documentation  efm32hg-doc-5.1.2
display.c
Go to the documentation of this file.
1 /***************************************************************************/
18 #include <stdint.h>
19 #include <stdbool.h>
20 #include <string.h>
21 
22 #include "displayconfigall.h"
23 #include "display.h"
24 #include "displaybackend.h"
25 
26 
29 /*******************************************************************************
30  ******************************** STATICS ************************************
31  ******************************************************************************/
32 
33 /* Table of display devices. */
34 static DISPLAY_Device_t deviceTable[DISPLAY_DEVICES_MAX];
35 
36 /* This variable keeps track of whether the DISPLAY module is initialized
37  or not. */
38 static bool moduleInitialized = false;
39 
40 /* This variable keeps track of the number of devices that have been
41  registered. */
42 static int devicesRegistered=0;
43 
44 /*
45  * Table of display device driver initialization functions to be called in
46  * DISPLAY_Init, the DISPLAY module init function.
47  */
48 static pDisplayDeviceDriverInitFunction_t pDisplayDeviceDriverInitFunctions[] =
49  DISPLAY_DEVICE_DRIVER_INIT_FUNCTIONS;
50 
54 /*******************************************************************************
55  ************************** GLOBAL FUNCTIONS **************************
56  ******************************************************************************/
57 
58 /***************************************************************************/
64 EMSTATUS DISPLAY_Init (void)
65 {
66  EMSTATUS status;
67 
68  pDisplayDeviceDriverInitFunction_t* pDisplayDeviceDriverInitFunction =
69  pDisplayDeviceDriverInitFunctions;
70 
71  if (false == moduleInitialized)
72  {
73  moduleInitialized = true;
74  for (; *pDisplayDeviceDriverInitFunction; pDisplayDeviceDriverInitFunction++)
75  {
76  status = (*pDisplayDeviceDriverInitFunction)();
77  if (DISPLAY_EMSTATUS_OK != status)
78  return status;
79  }
80  }
81 
82  return DISPLAY_EMSTATUS_OK;
83 }
84 
85 
86 /***************************************************************************/
97 EMSTATUS DISPLAY_DriverRefresh (void)
98 {
99  int i;
100  EMSTATUS status = DISPLAY_EMSTATUS_OK;
101 
102  if (false == moduleInitialized)
103  {
105  }
106  else
107  {
108  for (i=0; i<devicesRegistered; i++)
109  {
110  if (deviceTable[i].pDriverRefresh)
111  {
112  status = (*deviceTable[i].pDriverRefresh)(&deviceTable[i]);
113  if (DISPLAY_EMSTATUS_OK != status)
114  {
115  return status;
116  }
117  }
118  }
119  }
120 
121  return status;
122 }
123 
124 
125 /***************************************************************************/
139 EMSTATUS DISPLAY_DeviceGet(int displayDeviceNo,
140  DISPLAY_Device_t* device)
141 {
142  EMSTATUS status;
143 
144  if (false == moduleInitialized)
145  {
147  }
148  else
149  {
150  if (displayDeviceNo < DISPLAY_DEVICES_MAX)
151  {
152  memcpy(device, &deviceTable[displayDeviceNo], sizeof(DISPLAY_Device_t));
153  status = DISPLAY_EMSTATUS_OK;
154  }
155  else
156  {
158  }
159  }
160  return status;
161 }
162 
163 
164 /**************************************************************************/
173 {
174  EMSTATUS status;
175 
176  if (false == moduleInitialized)
177  {
179  }
180  else
181  {
182  if (devicesRegistered < DISPLAY_DEVICES_MAX)
183  {
184  memcpy(&deviceTable[devicesRegistered++], device, sizeof(DISPLAY_Device_t));
185  status = DISPLAY_EMSTATUS_OK;
186  }
187  else
188  {
190  }
191  }
192  return status;
193 }
194 
195 
196 /*************** THE REST OF THE FILE IS DOCUMENTATION ONLY ! ***************/
197 
198 /*******************************************************************************
199  ************************** DOCUMENTATION **************************
200  ******************************************************************************/
201 
202 /***************************************************************************/
EMSTATUS DISPLAY_Init(void)
Initialize the DISPLAY module.
Definition: display.c:64
#define DISPLAY_EMSTATUS_NOT_ENOUGH_MEMORY
Definition: display.h:46
EMSTATUS DISPLAY_DeviceRegister(DISPLAY_Device_t *device)
Register a display device.
Definition: display.c:172
Display device backend interface.
EMSTATUS(* pDriverRefresh)(struct DISPLAY_Device_t *device)
Definition: display.h:153
Display device interface.
EMSTATUS DISPLAY_DriverRefresh(void)
Refresh all DISPLAY devices.
Definition: display.c:97
EMSTATUS(* pDisplayDeviceDriverInitFunction_t)(void)
Definition: display.h:163
#define DISPLAY_EMSTATUS_OK
Definition: display.h:45
Main configuration file for the DISPLAY driver software stack.
#define DISPLAY_EMSTATUS_OUT_OF_RANGE
Definition: display.h:47
EMSTATUS DISPLAY_DeviceGet(int displayDeviceNo, DISPLAY_Device_t *device)
Get the display device data structure corresponding to the device number.
Definition: display.c:139
#define DISPLAY_EMSTATUS_NOT_INITIALIZED
Definition: display.h:50