otm8009a.c
Go to the documentation of this file.
1 
21 /* Includes ------------------------------------------------------------------*/
22 #include "otm8009a.h"
23 #include <stddef.h>
24 
43 {
63 };
64 
74 /*
75  * @brief Constant tables of register settings used to transmit DSI
76  * command packets as power up initialization sequence of the KoD LCD (OTM8009A LCD Driver)
77  */
78 
79 /*
80  * CASET value (Column Address Set) : X direction LCD GRAM boundaries
81  * depending on LCD orientation mode and PASET value (Page Address Set) : Y direction
82  * LCD GRAM boundaries depending on LCD orientation mode
83  * XS[15:0] = 0x000 = 0, XE[15:0] = 0x31F = 799 for landscape mode : apply to CASET
84  * YS[15:0] = 0x000 = 0, YE[15:0] = 0x31F = 799 for portrait mode : apply to PASET
85  */
86 static const uint8_t LcdRegData27[] = {0x00, 0x00, 0x03, 0x1F};
87 /*
88  * XS[15:0] = 0x000 = 0, XE[15:0] = 0x1DF = 479 for portrait mode : apply to CASET
89  * YS[15:0] = 0x000 = 0, YE[15:0] = 0x1DF = 479 for landscape mode : apply to PASET
90  */
91 static const uint8_t LcdRegData28[] = {0x00, 0x00, 0x01, 0xDF};
92 
97 /* Private macros ------------------------------------------------------------*/
98 /* Private functions ---------------------------------------------------------*/
102 static int32_t OTM8009A_ReadRegWrap(void *Handle, uint16_t Reg, uint8_t* Data, uint16_t Length);
103 static int32_t OTM8009A_WriteRegWrap(void *Handle, uint16_t Reg, uint8_t *pData, uint16_t Length);
104 static int32_t OTM8009A_IO_Delay(OTM8009A_Object_t *pObj, uint32_t Delay);
117 /* Exported functions ---------------------------------------------------------*/
128 {
129  int32_t ret = OTM8009A_OK;
130 
131  if(pObj == NULL)
132  {
133  ret = OTM8009A_ERROR;
134  }
135  else
136  {
137  pObj->IO.WriteReg = pIO->WriteReg;
138  pObj->IO.ReadReg = pIO->ReadReg;
139  pObj->IO.GetTick = pIO->GetTick;
140 
143  pObj->Ctx.handle = pObj;
144  }
145 
146  return ret;
147 }
148 
157 int32_t OTM8009A_Init(OTM8009A_Object_t *pObj, uint32_t ColorCoding, uint32_t Orientation)
158 {
159  int32_t ret;
160  static const uint8_t lcd_reg_data1[] = {0x80,0x09,0x01};
161  static const uint8_t lcd_reg_data2[] = {0x80,0x09};
162  static const uint8_t lcd_reg_data3[] = {0x00,0x09,0x0F,0x0E,0x07,0x10,0x0B,0x0A,0x04,0x07,0x0B,0x08,0x0F,0x10,0x0A,0x01};
163  static const uint8_t lcd_reg_data4[] = {0x00,0x09,0x0F,0x0E,0x07,0x10,0x0B,0x0A,0x04,0x07,0x0B,0x08,0x0F,0x10,0x0A,0x01};
164  static const uint8_t lcd_reg_data5[] = {0x79,0x79};
165  static const uint8_t lcd_reg_data6[] = {0x00,0x01};
166  static const uint8_t lcd_reg_data7[] = {0x85,0x01,0x00,0x84,0x01,0x00};
167  static const uint8_t lcd_reg_data8[] = {0x18,0x04,0x03,0x39,0x00,0x00,0x00,0x18,0x03,0x03,0x3A,0x00,0x00,0x00};
168  static const uint8_t lcd_reg_data9[] = {0x18,0x02,0x03,0x3B,0x00,0x00,0x00,0x18,0x01,0x03,0x3C,0x00,0x00,0x00};
169  static const uint8_t lcd_reg_data10[] = {0x01,0x01,0x20,0x20,0x00,0x00,0x01,0x02,0x00,0x00};
170  static const uint8_t lcd_reg_data11[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
171  static const uint8_t lcd_reg_data12[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
172  static const uint8_t lcd_reg_data13[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
173  static const uint8_t lcd_reg_data14[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
174  static const uint8_t lcd_reg_data15[] = {0x00,0x04,0x04,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
175  static const uint8_t lcd_reg_data16[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x00,0x00,0x00,0x00};
176  static const uint8_t lcd_reg_data17[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
177  static const uint8_t lcd_reg_data18[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
178  static const uint8_t lcd_reg_data19[] = {0x00,0x26,0x09,0x0B,0x01,0x25,0x00,0x00,0x00,0x00};
179  static const uint8_t lcd_reg_data20[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x26,0x0A,0x0C,0x02};
180  static const uint8_t lcd_reg_data21[] = {0x25,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
181  static const uint8_t lcd_reg_data22[] = {0x00,0x25,0x0C,0x0A,0x02,0x26,0x00,0x00,0x00,0x00};
182  static const uint8_t lcd_reg_data23[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x0B,0x09,0x01};
183  static const uint8_t lcd_reg_data24[] = {0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
184  static const uint8_t lcd_reg_data25[] = {0xFF,0xFF,0xFF};
185 
186  static const uint8_t short_reg_data[] = {
187  0x00,0x00,0x80,0x30,0x8A,0x40,0xB1,0xA9,0x91,0x34,0xB4,0x50,0x4E,0x81,0x66,0xA1,0x08,
188  0x92,0x01,0x95,0x94,0x33,0xA3,0x1B,0x82,0x83,0x83,0x0E,0xA6,0xA0,0xB0,0xC0,0xD0,0x90,
189  0xE0,0xF0,0x00,OTM8009A_COLMOD_RGB565,OTM8009A_COLMOD_RGB888,0x7F,0x2C,0x02,0xFF,0x00,
190  0x00,0x00,0x66,0xB6,0x06,0xB1,0x06};
191 
192  /* Enable CMD2 to access vendor specific commands */
193  /* Enter in command 2 mode and set EXTC to enable address shift function (0x00) */
194  ret = otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[1], 0);
195 
196  ret += otm8009a_write_reg(&pObj->Ctx, 0xFF, lcd_reg_data1, 3);
197 
198  /* Enter ORISE Command 2 */
199  /* Shift address to 0x80 */
200  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[2], 0);
201 
202  ret += otm8009a_write_reg(&pObj->Ctx, 0xFF, lcd_reg_data2, 2);
203 
205  /* SD_PCH_CTRL - 0xC480h - 129th parameter - Default 0x00 */
206  /* Set SD_PT */
207  /* -> Source output level during porch and non-display area to GND */
208  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[2], 0);
209  ret += otm8009a_write_reg(&pObj->Ctx, 0xC4, &short_reg_data[3], 0);
210 
211  (void)OTM8009A_IO_Delay(pObj, 10);
212  /* Not documented */
213  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[4], 0);
214  ret += otm8009a_write_reg(&pObj->Ctx, 0xC4, &short_reg_data[5], 0);
215  (void)OTM8009A_IO_Delay(pObj, 10);
217 
218  /* PWR_CTRL4 - 0xC4B0h - 178th parameter - Default 0xA8 */
219  /* Set gvdd_en_test */
220  /* -> enable GVDD test mode !!! */
221  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[6], 0);
222  ret += otm8009a_write_reg(&pObj->Ctx, 0xC5, &short_reg_data[7], 0);
223 
224  /* PWR_CTRL2 - 0xC590h - 146th parameter - Default 0x79 */
225  /* Set pump 4 vgh voltage */
226  /* -> from 15.0v down to 13.0v */
227  /* Set pump 5 vgh voltage */
228  /* -> from -12.0v downto -9.0v */
229  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[8], 0);
230  ret += otm8009a_write_reg(&pObj->Ctx, 0xC5, &short_reg_data[9], 0);
231 
232  /* P_DRV_M - 0xC0B4h - 181th parameter - Default 0x00 */
233  /* -> Column inversion */
234  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[10], 0);
235  ret += otm8009a_write_reg(&pObj->Ctx, 0xC0, &short_reg_data[11], 0);
236 
237  /* VCOMDC - 0xD900h - 1st parameter - Default 0x39h */
238  /* VCOM Voltage settings */
239  /* -> from -1.0000v downto -1.2625v */
240  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[1], 0);
241  ret += otm8009a_write_reg(&pObj->Ctx, 0xD9, &short_reg_data[12], 0);
242 
243  /* Oscillator adjustment for Idle/Normal mode (LPDT only) set to 65Hz (default is 60Hz) */
244  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[13], 0);
245  ret += otm8009a_write_reg(&pObj->Ctx, 0xC1, &short_reg_data[14], 0);
246 
247  /* Video mode internal */
248  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[15], 0);
249  ret += otm8009a_write_reg(&pObj->Ctx, 0xC1, &short_reg_data[16], 0);
250 
251  /* PWR_CTRL2 - 0xC590h - 147h parameter - Default 0x00 */
252  /* Set pump 4&5 x6 */
253  /* -> ONLY VALID when PUMP4_EN_ASDM_HV = "0" */
254  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[17], 0);
255  ret += otm8009a_write_reg(&pObj->Ctx, 0xC5, &short_reg_data[18], 0);
256 
257  /* PWR_CTRL2 - 0xC590h - 150th parameter - Default 0x33h */
258  /* Change pump4 clock ratio */
259  /* -> from 1 line to 1/2 line */
260  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[19], 0);
261  ret += otm8009a_write_reg(&pObj->Ctx, 0xC5, &short_reg_data[9], 0);
262 
263  /* GVDD/NGVDD settings */
264  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[1], 0);
265  ret += otm8009a_write_reg(&pObj->Ctx, 0xD8, lcd_reg_data5, 2);
266 
267  /* PWR_CTRL2 - 0xC590h - 149th parameter - Default 0x33h */
268  /* Rewrite the default value ! */
269  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[20], 0);
270  ret += otm8009a_write_reg(&pObj->Ctx, 0xC5, &short_reg_data[21], 0);
271 
272  /* Panel display timing Setting 3 */
273  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[22], 0);
274  ret += otm8009a_write_reg(&pObj->Ctx, 0xC0, &short_reg_data[23], 0);
275 
276  /* Power control 1 */
277  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[24], 0);
278  ret += otm8009a_write_reg(&pObj->Ctx, 0xC5, &short_reg_data[25], 0);
279 
280  /* Source driver precharge */
281  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[13], 0);
282  ret += otm8009a_write_reg(&pObj->Ctx, 0xC4, &short_reg_data[26], 0);
283 
284  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[15], 0);
285  ret += otm8009a_write_reg(&pObj->Ctx, 0xC1, &short_reg_data[27], 0);
286 
287  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[28], 0);
288  ret += otm8009a_write_reg(&pObj->Ctx, 0xB3, lcd_reg_data6, 2);
289 
290  /* GOAVST */
291  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[2], 0);
292  ret += otm8009a_write_reg(&pObj->Ctx, 0xCE, lcd_reg_data7, 6);
293 
294  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[29], 0);
295  ret += otm8009a_write_reg(&pObj->Ctx, 0xCE, lcd_reg_data8, 14);
296 
297  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[30], 0);
298  ret += otm8009a_write_reg(&pObj->Ctx, 0xCE, lcd_reg_data9, 14);
299 
300  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[31], 0);
301  ret += otm8009a_write_reg(&pObj->Ctx, 0xCF, lcd_reg_data10, 10);
302 
303  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[32], 0);
304  ret += otm8009a_write_reg(&pObj->Ctx, 0xCF, &short_reg_data[45], 0);
305 
306  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[2], 0);
307  ret += otm8009a_write_reg(&pObj->Ctx, 0xCB, lcd_reg_data11, 10);
308 
309  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[33], 0);
310  ret += otm8009a_write_reg(&pObj->Ctx, 0xCB, lcd_reg_data12, 15);
311 
312  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[29], 0);
313  ret += otm8009a_write_reg(&pObj->Ctx, 0xCB, lcd_reg_data13, 15);
314 
315  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[30], 0);
316  ret += otm8009a_write_reg(&pObj->Ctx, 0xCB, lcd_reg_data14, 10);
317 
318  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[31], 0);
319  ret += otm8009a_write_reg(&pObj->Ctx, 0xCB, lcd_reg_data15, 15);
320 
321  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[32], 0);
322  ret += otm8009a_write_reg(&pObj->Ctx, 0xCB, lcd_reg_data16, 15);
323 
324  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[34], 0);
325  ret += otm8009a_write_reg(&pObj->Ctx, 0xCB, lcd_reg_data17, 10);
326 
327  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[35], 0);
328  ret += otm8009a_write_reg(&pObj->Ctx, 0xCB, lcd_reg_data18, 10);
329 
330  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[2], 0);
331  ret += otm8009a_write_reg(&pObj->Ctx, 0xCC, lcd_reg_data19, 10);
332 
333  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[33], 0);
334  ret += otm8009a_write_reg(&pObj->Ctx, 0xCC, lcd_reg_data20, 15);
335 
336  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[29], 0);
337  ret += otm8009a_write_reg(&pObj->Ctx, 0xCC, lcd_reg_data21, 15);
338 
339  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[30], 0);
340  ret += otm8009a_write_reg(&pObj->Ctx, 0xCC, lcd_reg_data22, 10);
341 
342  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[31], 0);
343  ret += otm8009a_write_reg(&pObj->Ctx, 0xCC, lcd_reg_data23, 15);
344 
345  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[32], 0);
346  ret += otm8009a_write_reg(&pObj->Ctx, 0xCC, lcd_reg_data24, 15);
347 
349  /* PWR_CTRL1 - 0xc580h - 130th parameter - default 0x00 */
350  /* Pump 1 min and max DM */
351  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[13], 0);
352  ret += otm8009a_write_reg(&pObj->Ctx, 0xC5, &short_reg_data[46], 0);
353  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[47], 0);
354  ret += otm8009a_write_reg(&pObj->Ctx, 0xF5, &short_reg_data[48], 0);
356 
357  /* CABC LEDPWM frequency adjusted to 19,5kHz */
358  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[49], 0);
359  ret += otm8009a_write_reg(&pObj->Ctx, 0xC6, &short_reg_data[50], 0);
360 
361  /* Exit CMD2 mode */
362  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[1], 0);
363  ret += otm8009a_write_reg(&pObj->Ctx, 0xFF, lcd_reg_data25, 3);
364 
365  /*************************************************************************** */
366  /* Standard DCS Initialization TO KEEP CAN BE DONE IN HSDT */
367  /*************************************************************************** */
368 
369  /* NOP - goes back to DCS std command ? */
370  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[1], 0);
371 
372  /* Gamma correction 2.2+ table (HSDT possible) */
373  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[1], 0);
374  ret += otm8009a_write_reg(&pObj->Ctx, 0xE1, lcd_reg_data3, 16);
375 
376  /* Gamma correction 2.2- table (HSDT possible) */
377  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[1], 0);
378  ret += otm8009a_write_reg(&pObj->Ctx, 0xE2, lcd_reg_data4, 16);
379 
380  /* Send Sleep Out command to display : no parameter */
381  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_SLPOUT, &short_reg_data[36], 0);
382 
383  /* Wait for sleep out exit */
384  (void)OTM8009A_IO_Delay(pObj, 120);
385 
386  switch(ColorCoding)
387  {
389  /* Set Pixel color format to RGB565 */
390  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_COLMOD, &short_reg_data[37], 0);
392  break;
394  /* Set Pixel color format to RGB888 */
395  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_COLMOD, &short_reg_data[38], 0);
397  break;
398  default :
399  break;
400  }
401 
402  /* Send command to configure display in landscape orientation mode. By default
403  the orientation mode is portrait */
404  if(Orientation == OTM8009A_ORIENTATION_LANDSCAPE)
405  {
406  uint8_t tmp = OTM8009A_MADCTR_MODE_LANDSCAPE;
407  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_MADCTR, &tmp, 0);
410 
412  }
413  else
414  {
416  }
417 
419  /* Note : defaut is 0 (lowest Brightness], 0xFF is highest Brightness, try 0x7F : intermediate value */
420  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_WRDISBV, &short_reg_data[39], 0);
421  /* Store default brightness */
422  OTM8009ACtx.Brightness = ((uint32_t)short_reg_data[39] / 0xFFU) * 100U;
423 
424  /* defaut is 0, try 0x2C - Brightness Control Block, Display Dimming & BackLight on */
425  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_WRCTRLD, &short_reg_data[40], 0);
426 
427  /* defaut is 0, try 0x02 - image Content based Adaptive Brightness [Still Picture] */
428  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_WRCABC, &short_reg_data[41], 0);
429 
430  /* defaut is 0 (lowest Brightness], 0xFF is highest Brightness */
431  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_WRCABCMB, &short_reg_data[42], 0);
432 
435  /* Send Command Display On */
436  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_DISPON, &short_reg_data[43], 0);
437 
438  /* NOP command */
439  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_NOP, &short_reg_data[1], 0);
440 
441  /* Send Command GRAM memory write (no parameters) : this initiates frame write via other DSI commands sent by */
442  /* DSI host from LTDC incoming pixels in video mode */
443  ret += otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_RAMWR, &short_reg_data[44], 0);
444 
445  if(ret != OTM8009A_OK)
446  {
447  ret = OTM8009A_ERROR;
448  }
449 
450  return ret;
451 }
452 
459 {
460  return OTM8009A_ERROR;
461 }
462 
469 int32_t OTM8009A_ReadID(OTM8009A_Object_t *pObj, uint32_t *Id)
470 {
471  int32_t ret;
472 
473  if(otm8009a_read_reg(&pObj->Ctx, OTM8009A_CMD_ID1, (uint8_t *)Id, 0)!= OTM8009A_OK)
474  {
475  ret = OTM8009A_ERROR;
476  }
477  else
478  {
479  ret = OTM8009A_OK;
480  }
481 
482  return ret;
483 }
484 
491 int32_t OTM8009A_SetBrightness(OTM8009A_Object_t *pObj, uint32_t Brightness)
492 {
493  int32_t ret;
494  uint8_t brightness = (uint8_t)((Brightness * 255U)/100U);
495 
496  /* Send Display on DCS command to display */
497  if(otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_WRDISBV, &brightness, 0) != OTM8009A_OK)
498  {
499  ret = OTM8009A_ERROR;
500  }
501  else
502  {
503  OTM8009ACtx.Brightness = Brightness;
504  ret = OTM8009A_OK;
505  }
506 
507  return ret;
508 }
509 
516 int32_t OTM8009A_GetBrightness(OTM8009A_Object_t *pObj, uint32_t *Brightness)
517 {
518  *Brightness = OTM8009ACtx.Brightness;
519  return OTM8009A_OK;
520 }
521 
528 {
529  int32_t ret;
530  uint8_t display = 0;
531 
532  /* Send Display on DCS command to display */
533  if(otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_DISPON, &display, 0) != OTM8009A_OK)
534  {
535  ret = OTM8009A_ERROR;
536  }
537  else
538  {
539  ret = OTM8009A_OK;
540  }
541 
542  return ret;
543 }
544 
551 {
552  int32_t ret;
553  uint8_t display = 0;
554 
555  /* Send Display on DCS command to display */
556  if(otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_DISPOFF, &display, 0) != OTM8009A_OK)
557  {
558  ret = OTM8009A_ERROR;
559  }
560  else
561  {
562  ret = OTM8009A_OK;
563  }
564 
565  return ret;
566 }
567 
574 int32_t OTM8009A_SetOrientation(OTM8009A_Object_t *pObj, uint32_t Orientation)
575 {
576  int32_t ret;
577  uint8_t tmp = OTM8009A_MADCTR_MODE_LANDSCAPE;
578  uint8_t tmp1 = OTM8009A_MADCTR_MODE_PORTRAIT;
579 
580  if((Orientation != OTM8009A_ORIENTATION_LANDSCAPE) && (Orientation != OTM8009A_ORIENTATION_PORTRAIT))
581  {
582  ret = OTM8009A_ERROR;
583  }/* Send command to configure display orientation mode */
584  else if(Orientation == OTM8009A_ORIENTATION_LANDSCAPE)
585  {
586  ret = otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_MADCTR, &tmp, 0);
589 
591  }
592  else
593  {
594  ret = otm8009a_write_reg(&pObj->Ctx, OTM8009A_CMD_MADCTR, &tmp1, 0);
597 
599  }
600 
601  if(ret != OTM8009A_OK)
602  {
603  ret = OTM8009A_ERROR;
604  }
605 
606  return ret;
607 }
608 
615 int32_t OTM8009A_GetOrientation(OTM8009A_Object_t *pObj, uint32_t *Orientation)
616 {
617  /* Prevent unused argument(s) compilation warning */
618  (void)(pObj);
619 
620  *Orientation = OTM8009ACtx.Orientation;
621 
622  return OTM8009A_OK;
623 }
624 
631 int32_t OTM8009A_GetXSize(OTM8009A_Object_t *pObj, uint32_t *Xsize)
632 {
633  /* Prevent unused argument(s) compilation warning */
634  (void)(pObj);
635 
636  switch(OTM8009ACtx.Orientation)
637  {
639  *Xsize = OTM8009A_480X800_WIDTH;
640  break;
642  *Xsize = OTM8009A_800X480_WIDTH;
643  break;
644  default:
645  *Xsize = OTM8009A_800X480_WIDTH;
646  break;
647  }
648 
649  return OTM8009A_OK;
650 }
651 
658 int32_t OTM8009A_GetYSize(OTM8009A_Object_t *pObj, uint32_t *Ysize)
659 {
660  /* Prevent unused argument(s) compilation warning */
661  (void)(pObj);
662 
663  switch(OTM8009ACtx.Orientation)
664  {
666  *Ysize = OTM8009A_480X800_HEIGHT;
667  break;
669  *Ysize = OTM8009A_800X480_HEIGHT;
670  break;
671  default:
672  *Ysize = OTM8009A_800X480_HEIGHT;
673  break;
674  }
675 
676  return OTM8009A_OK;
677 }
678 
686 int32_t OTM8009A_SetCursor(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos)
687 {
688  /* Prevent unused argument(s) compilation warning */
689  (void)(pObj);
690 
691  return OTM8009A_ERROR;
692 }
693 
702 int32_t OTM8009A_DrawBitmap(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint8_t *pBmp)
703 {
704  /* Prevent unused argument(s) compilation warning */
705  (void)(pObj);
706 
707  return OTM8009A_ERROR;
708 }
709 
710 int32_t OTM8009A_FillRGBRect(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint8_t *pData, uint32_t Width, uint32_t Height)
711 {
712  /* Prevent unused argument(s) compilation warning */
713  (void)(pObj);
714 
715  return OTM8009A_ERROR;
716 }
726 int32_t OTM8009A_DrawHLine(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Length, uint32_t Color)
727 {
728  /* Prevent unused argument(s) compilation warning */
729  (void)(pObj);
730 
731  return OTM8009A_ERROR;
732 }
733 
743 int32_t OTM8009A_DrawVLine(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Length, uint32_t Color)
744 {
745  /* Prevent unused argument(s) compilation warning */
746  (void)(pObj);
747 
748  return OTM8009A_ERROR;
749 }
750 
761 int32_t OTM8009A_FillRect(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Width, uint32_t Height, uint32_t Color)
762 {
763  /* Prevent unused argument(s) compilation warning */
764  (void)(pObj);
765 
766  return OTM8009A_ERROR;
767 }
768 
777 int32_t OTM8009A_GetPixel(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t *Color)
778 {
779  /* Prevent unused argument(s) compilation warning */
780  (void)(pObj);
781 
782  return OTM8009A_ERROR;
783 }
784 
793 int32_t OTM8009A_SetPixel(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Color)
794 {
795  /* Prevent unused argument(s) compilation warning */
796  (void)(pObj);
797 
798  return OTM8009A_ERROR;
799 }
800 
816 static int32_t OTM8009A_ReadRegWrap(void *Handle, uint16_t Reg, uint8_t* pData, uint16_t Length)
817 {
818  OTM8009A_Object_t *pObj = (OTM8009A_Object_t *)Handle;
819 
820  return pObj->IO.ReadReg(pObj->IO.Address, Reg, pData, Length);
821 }
822 
831 static int32_t OTM8009A_WriteRegWrap(void *Handle, uint16_t Reg, uint8_t *pData, uint16_t Length)
832 {
833  OTM8009A_Object_t *pObj = (OTM8009A_Object_t *)Handle;
834 
835  return pObj->IO.WriteReg(pObj->IO.Address, Reg, pData, Length);
836 }
837 
842 static int32_t OTM8009A_IO_Delay(OTM8009A_Object_t *pObj, uint32_t Delay)
843 {
844  uint32_t tickstart;
845  tickstart = pObj->IO.GetTick();
846  while((pObj->IO.GetTick() - tickstart) < Delay)
847  {
848  }
849  return OTM8009A_OK;
850 }
868 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
OTM8009A_SetBrightness
int32_t OTM8009A_SetBrightness(OTM8009A_Object_t *pObj, uint32_t Brightness)
Set the display brightness.
Definition: otm8009a.c:491
OTM8009A_CMD_ID1
#define OTM8009A_CMD_ID1
Definition: otm8009a_reg.h:106
OTM8009A_DrawBitmap
int32_t OTM8009A_DrawBitmap(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint8_t *pBmp)
Draw Bitmap image.
Definition: otm8009a.c:702
OTM8009A_ERROR
#define OTM8009A_ERROR
Definition: otm8009a.h:112
OTM8009A_IO_t::ReadReg
OTM8009A_ReadReg_Func ReadReg
Definition: otm8009a.h:69
OTM8009A_CMD_WRCABCMB
#define OTM8009A_CMD_WRCABCMB
Definition: otm8009a_reg.h:104
otm8009a_write_reg
int32_t otm8009a_write_reg(otm8009a_ctx_t *ctx, uint16_t reg, const uint8_t *pdata, uint16_t length)
Definition: otm8009a_reg.c:70
OTM8009A_ORIENTATION_LANDSCAPE
#define OTM8009A_ORIENTATION_LANDSCAPE
Definition: otm8009a.h:121
OTM8009A_ReadID
int32_t OTM8009A_ReadID(OTM8009A_Object_t *pObj, uint32_t *Id)
Read the component ID.
Definition: otm8009a.c:469
otm8009a.h
This file contains all the constants parameters for the OTM8009A which is the LCD Driver for KoD KM-0...
OTM8009A_CMD_MADCTR
#define OTM8009A_CMD_MADCTR
Definition: otm8009a_reg.h:79
NULL
#define NULL
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/extras/speex_resampler/thirdparty/resample.c:92
OTM8009A_COLMOD_RGB888
#define OTM8009A_COLMOD_RGB888
Definition: otm8009a_reg.h:92
OTM8009A_Object_t::Ctx
otm8009a_ctx_t Ctx
Definition: otm8009a.h:76
OTM8009A_480X800_WIDTH
#define OTM8009A_480X800_WIDTH
otm8009a_480x800 Size
Definition: otm8009a.h:135
OTM8009A_FORMAT_RBG565
#define OTM8009A_FORMAT_RBG565
Definition: otm8009a.h:128
OTM8009A_LCD_Ctx_t
Definition: otm8009a.h:58
OTM8009A_SetOrientation
int32_t OTM8009A_SetOrientation(OTM8009A_Object_t *pObj, uint32_t Orientation)
Set the display Orientation.
Definition: otm8009a.c:574
OTM8009A_FillRect
int32_t OTM8009A_FillRect(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Width, uint32_t Height, uint32_t Color)
Fill rectangle.
Definition: otm8009a.c:761
OTM8009A_CMD_DISPOFF
#define OTM8009A_CMD_DISPOFF
Definition: otm8009a_reg.h:60
OTM8009A_LCD_Ctx_t::ColorCode
uint32_t ColorCode
Definition: otm8009a.h:61
OTM8009A_SetPixel
int32_t OTM8009A_SetPixel(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Color)
Set pixel color.
Definition: otm8009a.c:793
OTM8009A_GetPixel
int32_t OTM8009A_GetPixel(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t *Color)
Get pixel color.
Definition: otm8009a.c:777
OTM8009A_DrawVLine
int32_t OTM8009A_DrawVLine(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Length, uint32_t Color)
Draw Vertical line.
Definition: otm8009a.c:743
OTM8009A_Init
int32_t OTM8009A_Init(OTM8009A_Object_t *pObj, uint32_t ColorCoding, uint32_t Orientation)
Initializes the LCD KoD display part by communication in DSI mode in Video Mode with IC Display Drive...
Definition: otm8009a.c:157
OTM8009A_MADCTR_MODE_PORTRAIT
#define OTM8009A_MADCTR_MODE_PORTRAIT
Definition: otm8009a_reg.h:82
OTM8009A_GetYSize
int32_t OTM8009A_GetYSize(OTM8009A_Object_t *pObj, uint32_t *Ysize)
Set the display Height.
Definition: otm8009a.c:658
OTM8009A_FORMAT_RGB888
#define OTM8009A_FORMAT_RGB888
Possible values of pixel data format (ie color coding) transmitted on DSI Data lane in DSI packets.
Definition: otm8009a.h:127
OTM8009A_GetOrientation
int32_t OTM8009A_GetOrientation(OTM8009A_Object_t *pObj, uint32_t *Orientation)
Set the display Orientation.
Definition: otm8009a.c:615
otm8009a_ctx_t::handle
void * handle
Definition: otm8009a_reg.h:137
OTM8009A_LCD_Ctx_t::Brightness
uint32_t Brightness
Definition: otm8009a.h:62
OTM8009A_GetXSize
int32_t OTM8009A_GetXSize(OTM8009A_Object_t *pObj, uint32_t *Xsize)
Set the display Width.
Definition: otm8009a.c:631
OTM8009A_DisplayOn
int32_t OTM8009A_DisplayOn(OTM8009A_Object_t *pObj)
Set the display On.
Definition: otm8009a.c:527
OTM8009A_RegisterBusIO
int32_t OTM8009A_RegisterBusIO(OTM8009A_Object_t *pObj, OTM8009A_IO_t *pIO)
Register component IO bus.
Definition: otm8009a.c:127
OTM8009A_IO_Delay
static int32_t OTM8009A_IO_Delay(OTM8009A_Object_t *pObj, uint32_t Delay)
OTM8009A delay.
Definition: otm8009a.c:842
OTM8009A_IO_t::Address
uint16_t Address
Definition: otm8009a.h:67
OTM8009A_CMD_PASET
#define OTM8009A_CMD_PASET
Definition: otm8009a_reg.h:64
OTM8009A_COLMOD_RGB565
#define OTM8009A_COLMOD_RGB565
Definition: otm8009a_reg.h:91
OTM8009A_MADCTR_MODE_LANDSCAPE
#define OTM8009A_MADCTR_MODE_LANDSCAPE
Definition: otm8009a_reg.h:83
OTM8009A_CMD_COLMOD
#define OTM8009A_CMD_COLMOD
Definition: otm8009a_reg.h:88
OTM8009A_Object_t
Definition: otm8009a.h:73
OTM8009A_SetCursor
int32_t OTM8009A_SetCursor(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos)
Set the display cursor.
Definition: otm8009a.c:686
OTM8009A_800X480_HEIGHT
#define OTM8009A_800X480_HEIGHT
Definition: otm8009a.h:140
OTM8009A_IO_t
Definition: otm8009a.h:65
OTM8009A_DrawHLine
int32_t OTM8009A_DrawHLine(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Length, uint32_t Color)
Draw Horizontal Line.
Definition: otm8009a.c:726
OTM8009A_GetBrightness
int32_t OTM8009A_GetBrightness(OTM8009A_Object_t *pObj, uint32_t *Brightness)
Get the display brightness.
Definition: otm8009a.c:516
OTM8009A_FillRGBRect
int32_t OTM8009A_FillRGBRect(OTM8009A_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint8_t *pData, uint32_t Width, uint32_t Height)
Definition: otm8009a.c:710
otm8009a_ctx_t::WriteReg
OTM8009A_Write_Func WriteReg
Definition: otm8009a_reg.h:135
OTM8009A_LCD_Drv_t
Definition: otm8009a.h:80
OTM8009A_CMD_RAMWR
#define OTM8009A_CMD_RAMWR
Definition: otm8009a_reg.h:66
OTM8009A_CMD_WRCTRLD
#define OTM8009A_CMD_WRCTRLD
Definition: otm8009a_reg.h:102
OTM8009A_DisplayOff
int32_t OTM8009A_DisplayOff(OTM8009A_Object_t *pObj)
Set the display Off.
Definition: otm8009a.c:550
OTM8009A_CMD_SLPOUT
#define OTM8009A_CMD_SLPOUT
Definition: otm8009a_reg.h:57
OTM8009A_LCD_Ctx_t::Orientation
uint32_t Orientation
Definition: otm8009a.h:60
OTM8009A_480X800_HEIGHT
#define OTM8009A_480X800_HEIGHT
Definition: otm8009a.h:136
OTM8009A_IO_t::GetTick
OTM8009A_GetTick_Func GetTick
Definition: otm8009a.h:70
OTM8009A_CMD_DISPON
#define OTM8009A_CMD_DISPON
Definition: otm8009a_reg.h:61
OTM8009A_CMD_CASET
#define OTM8009A_CMD_CASET
Definition: otm8009a_reg.h:63
LcdRegData27
static const uint8_t LcdRegData27[]
Definition: otm8009a.c:86
OTM8009A_800X480_WIDTH
#define OTM8009A_800X480_WIDTH
Definition: otm8009a.h:139
OTM8009A_OK
#define OTM8009A_OK
Definition: otm8009a.h:111
OTM8009A_Object_t::IO
OTM8009A_IO_t IO
Definition: otm8009a.h:75
LcdRegData28
static const uint8_t LcdRegData28[]
Definition: otm8009a.c:91
OTM8009A_IO_t::WriteReg
OTM8009A_WriteReg_Func WriteReg
Definition: otm8009a.h:68
OTM8009A_LCD_Driver
OTM8009A_LCD_Drv_t OTM8009A_LCD_Driver
Definition: otm8009a.c:42
otm8009a_ctx_t::ReadReg
OTM8009A_Read_Func ReadReg
Definition: otm8009a_reg.h:136
OTM8009ACtx
static OTM8009A_LCD_Ctx_t OTM8009ACtx
Definition: otm8009a.c:65
OTM8009A_ReadRegWrap
static int32_t OTM8009A_ReadRegWrap(void *Handle, uint16_t Reg, uint8_t *Data, uint16_t Length)
Wrap component ReadReg to Bus Read function.
Definition: otm8009a.c:816
Length
Length
otm8009a_read_reg
int32_t otm8009a_read_reg(otm8009a_ctx_t *ctx, uint16_t reg, uint8_t *pdata, uint16_t length)
Definition: otm8009a_reg.c:58
OTM8009A_DeInit
int32_t OTM8009A_DeInit(OTM8009A_Object_t *pObj)
De-Initializes the component.
Definition: otm8009a.c:458
OTM8009A_CMD_NOP
#define OTM8009A_CMD_NOP
Definition: otm8009a_reg.h:52
OTM8009A_CMD_WRDISBV
#define OTM8009A_CMD_WRDISBV
Definition: otm8009a_reg.h:101
OTM8009A_CMD_WRCABC
#define OTM8009A_CMD_WRCABC
Definition: otm8009a_reg.h:103
OTM8009A_WriteRegWrap
static int32_t OTM8009A_WriteRegWrap(void *Handle, uint16_t Reg, uint8_t *pData, uint16_t Length)
Wrap component WriteReg to Bus Write function.
Definition: otm8009a.c:831
OTM8009A_ORIENTATION_PORTRAIT
#define OTM8009A_ORIENTATION_PORTRAIT
Definition: otm8009a.h:120


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:50