39 #define LS013B7DH03_CMD_UPDATE (0x01)
40 #define LS013B7DH03_CMD_ALL_CLEAR (0x04)
43 #ifndef LS013B7DH03_POLARITY_INVERSION_FREQUENCY
44 #define LS013B7DH03_POLARITY_INVERSION_FREQUENCY (128)
47 #ifdef USE_CONTROL_BYTES
48 #define LS013B7DH03_CONTROL_BYTES (2)
50 #define LS013B7DH03_CONTROL_BYTES (0)
53 #ifdef PIXEL_MATRIX_ALLOC_SUPPORT
55 #ifdef USE_STATIC_PIXEL_MATRIX_POOL
64 #undef USE_STATIC_PIXEL_MATRIX_POOL
74 #ifdef PIXEL_MATRIX_ALLOC_SUPPORT
75 #ifndef PIXEL_MATRIX_ALIGNMENT
76 typedef uint8_t PixelMatrixAlign_t;
78 #if (1 == PIXEL_MATRIX_ALIGNMENT)
79 typedef uint8_t PixelMatrixAlign_t;
80 #elif (2 == PIXEL_MATRIX_ALIGNMENT)
81 typedef uint16_t PixelMatrixAlign_t;
82 #elif (4 == PIXEL_MATRIX_ALIGNMENT)
83 typedef uint32_t PixelMatrixAlign_t;
85 #error Unsupported PIXEL_MATRIX_ALIGNMENT.
96 static uint8_t lcdPolarity = 0;
98 #ifdef PIXEL_MATRIX_ALLOC_SUPPORT
99 #ifdef USE_STATIC_PIXEL_MATRIX_POOL
100 #define PIXEL_MATRIX_POOL_ELEMENTS \
101 (PIXEL_MATRIX_POOL_SIZE/sizeof(PixelMatrixAlign_t) + \
102 ((PIXEL_MATRIX_POOL_SIZE%sizeof(PixelMatrixAlign_t))? 1 : 0))
103 static PixelMatrixAlign_t pixelMatrixPoolBase[PIXEL_MATRIX_POOL_ELEMENTS];
104 static PixelMatrixAlign_t* pixelMatrixPool = pixelMatrixPoolBase;
115 static EMSTATUS DisplayClear(
void);
116 #ifndef POLARITY_INVERSION_EXTCOMIN_PAL_AUTO_TOGGLE
117 static EMSTATUS DisplayPolarityInverse (
void);
120 #ifdef PIXEL_MATRIX_ALLOC_SUPPORT
123 #ifdef EMWIN_WORKAROUND
124 unsigned int userStride,
133 unsigned int startColumn,
135 #ifdef EMWIN_WORKAROUND
136 unsigned int userStride,
138 unsigned int startRow,
139 unsigned int height );
143 unsigned int height);
156 EMSTATUS DISPLAY_Ls013b7dh03Init(
void)
167 PAL_GpioPinModeSet(LCD_PORT_SCLK, LCD_PIN_SCLK, palGpioModePushPull,0);
168 PAL_GpioPinModeSet(LCD_PORT_SI, LCD_PIN_SI, palGpioModePushPull,0);
169 PAL_GpioPinModeSet(LCD_PORT_SCS, LCD_PIN_SCS, palGpioModePushPull,0);
170 #if defined( LCD_PORT_DISP_SEL )
171 PAL_GpioPinModeSet(LCD_PORT_DISP_SEL,LCD_PIN_DISP_SEL,palGpioModePushPull,0);
174 #if defined( LCD_PORT_DISP_PWR )
175 PAL_GpioPinModeSet(LCD_PORT_DISP_PWR,LCD_PIN_DISP_PWR,palGpioModePushPull,0);
178 #if defined( LCD_PORT_EXTMODE )
179 PAL_GpioPinModeSet(LCD_PORT_EXTMODE, LCD_PIN_EXTMODE, palGpioModePushPull,0);
181 #if defined (LCD_PORT_EXTCOMIN)
182 PAL_GpioPinModeSet(LCD_PORT_EXTCOMIN,LCD_PIN_EXTCOMIN,palGpioModePushPull,0);
184 #ifdef PAL_TIMER_REPEAT_FUNCTION
190 PAL_TimerRepeat((
void(*)(
void*)) DisplayPolarityInverse, 0,
191 LS013B7DH03_POLARITY_INVERSION_FREQUENCY);
192 #elif defined POLARITY_INVERSION_EXTCOMIN_MANUAL
195 #elif defined POLARITY_INVERSION_EXTCOMIN_PAL_AUTO_TOGGLE
197 status = PAL_GpioPinAutoToggle(LCD_PORT_EXTCOMIN, LCD_PIN_EXTCOMIN,
198 LS013B7DH03_POLARITY_INVERSION_FREQUENCY);
209 display.
name = SHARP_MEMLCD_DEVICE_NAME;
219 #ifdef PIXEL_MATRIX_ALLOC_SUPPORT
235 DisplayEnable(&display,
true);
290 #if defined( LCD_PORT_DISP_SEL )
292 PAL_GpioPinOutSet(LCD_PORT_DISP_SEL, LCD_PIN_DISP_SEL);
295 #if defined( LCD_PORT_DISP_PWR )
297 PAL_GpioPinOutSet(LCD_PORT_DISP_PWR, LCD_PIN_DISP_PWR);
302 #if defined( LCD_PORT_DISP_PWR )
304 PAL_GpioPinOutClear(LCD_PORT_DISP_PWR, LCD_PIN_DISP_PWR);
307 #if defined( LCD_PORT_DISP_SEL )
309 PAL_GpioPinOutClear(LCD_PORT_DISP_SEL, LCD_PIN_DISP_SEL);
324 static EMSTATUS DisplayClear (
void )
329 PAL_GpioPinOutSet( LCD_PORT_SCS, LCD_PIN_SCS );
332 PAL_TimerMicroSecondsDelay(6);
335 cmd = LS013B7DH03_CMD_ALL_CLEAR | lcdPolarity;
336 PAL_SpiTransmit ((uint8_t*) &cmd, 2 );
339 PAL_TimerMicroSecondsDelay(2);
342 PAL_GpioPinOutClear( LCD_PORT_SCS, LCD_PIN_SCS );
348 #ifdef PAL_TIMER_REPEAT_FUNCTION
358 static EMSTATUS DisplayPolarityInverse (
void)
360 #ifdef POLARITY_INVERSION_EXTCOMIN
362 #if defined(LCD_PORT_EXTCOMIN)
364 PAL_GpioPinOutToggle( LCD_PORT_EXTCOMIN, LCD_PIN_EXTCOMIN );
369 PAL_GpioPinOutSet( LCD_PORT_SCS, LCD_PIN_SCS );
372 PAL_TimerMicroSecondsDelay(6);
375 PAL_SpiTransmit ((uint8_t*) &lcdPolarity, 2 );
378 PAL_TimerMicroSecondsDelay(2);
380 PAL_GpioPinOutClear( LCD_PORT_SCS, LCD_PIN_SCS );
383 if (lcdPolarity == 0x00)
400 #ifdef PIXEL_MATRIX_ALLOC_SUPPORT
421 #ifdef EMWIN_WORKAROUND
422 unsigned int userStride,
427 #ifdef EMWIN_WORKAROUND
428 unsigned int allocSize = (userStride/8 + LS013B7DH03_CONTROL_BYTES) * height;
430 unsigned int allocSize = (width/8 + LS013B7DH03_CONTROL_BYTES) * height;
435 if (width != LS013B7DH03_WIDTH)
437 #ifdef EMWIN_WORKAROUND
438 if (userStride < width)
447 if (NULL == *pixelMatrix)
454 #ifdef USE_STATIC_PIXEL_MATRIX_POOL
456 if (((uint8_t*)pixelMatrixPool) + allocSize >
457 ((uint8_t*)pixelMatrixPoolBase) + PIXEL_MATRIX_POOL_SIZE)
464 *pixelMatrix = pixelMatrixPool;
465 pixelMatrixPool += allocSize /
sizeof(PixelMatrixAlign_t) +
466 ((allocSize %
sizeof(PixelMatrixAlign_t))? 1 : 0);
476 #ifdef PIXEL_MATRIX_ALLOC_SUPPORT
497 #ifdef USE_STATIC_PIXEL_MATRIX_POOL
532 uint8_t* pByte = (uint8_t*) pixelMatrix;
538 for (i=0; i<height; i++)
541 memset(pByte, 0, LS013B7DH03_WIDTH/8);
542 pByte += LS013B7DH03_WIDTH/8;
544 #ifdef USE_CONTROL_BYTES
556 #ifdef USE_CONTROL_BYTES
569 unsigned int startRow,
571 #ifdef EMWIN_WORKAROUND
573 unsigned int userStride
578 uint8_t* pByte = (uint8_t*) pixelMatrix;
579 #ifdef EMWIN_WORKAROUND
581 (userStride-LS013B7DH03_WIDTH-(LS013B7DH03_CONTROL_BYTES*8)) /
583 if ((userStride-LS013B7DH03_WIDTH) %
sizeof(uint16_t))
589 pByte += LS013B7DH03_WIDTH/8;
601 *pByte++ = startRow + (++i);
603 #ifdef EMWIN_WORKAROUND
633 unsigned int startColumn,
635 #ifdef EMWIN_WORKAROUND
636 unsigned int userStride,
638 unsigned int startRow,
639 unsigned int height )
642 uint16_t* p = (uint16_t *)pixelMatrix;
644 #ifdef EMWIN_WORKAROUND
646 (userStride-width-(LS013B7DH03_CONTROL_BYTES*8)) / 8 /
sizeof(uint16_t);
647 if ((userStride-width) %
sizeof(uint16_t))
659 #ifdef USE_CONTROL_BYTES
661 pixelMatrixSetup(pixelMatrix, startRow, height
662 #ifdef EMWIN_WORKAROUND
669 PAL_GpioPinOutSet( LCD_PORT_SCS, LCD_PIN_SCS );
672 PAL_TimerMicroSecondsDelay(6);
675 cmd = LS013B7DH03_CMD_UPDATE | (startRow << 8);
676 PAL_SpiTransmit((uint8_t*) &cmd, 2 );
679 for ( i=0; i<height; i++ ) {
682 PAL_SpiTransmit((uint8_t*) p,
683 LS013B7DH03_WIDTH/8 + LS013B7DH03_CONTROL_BYTES);
684 p+=(LS013B7DH03_WIDTH/8 + LS013B7DH03_CONTROL_BYTES) /
sizeof(uint16_t);
686 #ifndef USE_CONTROL_BYTES
693 cmd = 0xff | ((startRow+i+1) << 8);
695 PAL_SpiTransmit((uint8_t*) &cmd, 2 );
698 #ifdef EMWIN_WORKAROUND
705 PAL_TimerMicroSecondsDelay(2);
708 PAL_GpioPinOutClear( LCD_PORT_SCS, LCD_PIN_SCS );
DISPLAY_ColourMode_t colourMode
EMSTATUS(* pPixelMatrixClear)(struct DISPLAY_Device_t *device, DISPLAY_PixelMatrix_t pixelMatrix, unsigned int width, unsigned int height)
#define DISPLAY_EMSTATUS_INVALID_PARAMETER
#define DISPLAY_EMSTATUS_NOT_ENOUGH_MEMORY
EMSTATUS DISPLAY_DeviceRegister(DISPLAY_Device_t *device)
Register a display device.
Display device backend interface.
EMSTATUS(* pDriverRefresh)(struct DISPLAY_Device_t *device)
EMSTATUS(* pPixelMatrixDraw)(struct DISPLAY_Device_t *device, DISPLAY_PixelMatrix_t pixelMatrix, unsigned int startColumn, unsigned int width, unsigned int startRow, unsigned int height)
EMSTATUS(* pDisplayPowerOn)(struct DISPLAY_Device_t *device, bool on)
EMSTATUS(* pPixelMatrixFree)(struct DISPLAY_Device_t *device, DISPLAY_PixelMatrix_t pixelMatrix)
Platform Abstraction Layer (PAL) interface for DISPLAY driver.
General Purpose IO (GPIO) peripheral API.
#define DISPLAY_EMSTATUS_OK
Main configuration file for the DISPLAY driver software stack.
#define DISPLAY_EMSTATUS_OUT_OF_RANGE
DISPLAY_Geometry_t geometry
Configuration for the display driver for the Sharp Memory LCD LS013B7DH03.
#define DISPLAY_EMSTATUS_NOT_SUPPORTED
EMSTATUS(* pPixelMatrixAllocate)(struct DISPLAY_Device_t *device, unsigned int width, unsigned int height, DISPLAY_PixelMatrix_t *pixelMatrix)
void * DISPLAY_PixelMatrix_t
DISPLAY_AddressMode_t addressMode