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 PAL_GpioPinModeSet(LCD_PORT_EXTCOMIN,LCD_PIN_EXTCOMIN,palGpioModePushPull,0);
183 #ifdef PAL_TIMER_REPEAT_FUNCTION
189 PAL_TimerRepeat((
void(*)(
void*)) DisplayPolarityInverse, 0,
190 LS013B7DH03_POLARITY_INVERSION_FREQUENCY);
191 #elif defined POLARITY_INVERSION_EXTCOMIN_PAL_AUTO_TOGGLE
193 status = PAL_GpioPinAutoToggle(LCD_PORT_EXTCOMIN, LCD_PIN_EXTCOMIN,
194 LS013B7DH03_POLARITY_INVERSION_FREQUENCY);
205 display.
name = SHARP_MEMLCD_DEVICE_NAME;
215 #ifdef PIXEL_MATRIX_ALLOC_SUPPORT
231 DisplayEnable(&display,
true);
286 #if defined( LCD_PORT_DISP_SEL )
288 PAL_GpioPinOutSet(LCD_PORT_DISP_SEL, LCD_PIN_DISP_SEL);
291 #if defined( LCD_PORT_DISP_PWR )
293 PAL_GpioPinOutSet(LCD_PORT_DISP_PWR, LCD_PIN_DISP_PWR);
298 #if defined( LCD_PORT_DISP_PWR )
300 PAL_GpioPinOutClear(LCD_PORT_DISP_PWR, LCD_PIN_DISP_PWR);
303 #if defined( LCD_PORT_DISP_SEL )
305 PAL_GpioPinOutClear(LCD_PORT_DISP_SEL, LCD_PIN_DISP_SEL);
320 static EMSTATUS DisplayClear (
void )
325 PAL_GpioPinOutSet( LCD_PORT_SCS, LCD_PIN_SCS );
328 PAL_TimerMicroSecondsDelay(6);
331 cmd = LS013B7DH03_CMD_ALL_CLEAR | lcdPolarity;
332 PAL_SpiTransmit ((uint8_t*) &cmd, 2 );
335 PAL_TimerMicroSecondsDelay(2);
338 PAL_GpioPinOutClear( LCD_PORT_SCS, LCD_PIN_SCS );
344 #ifdef PAL_TIMER_REPEAT_FUNCTION
354 static EMSTATUS DisplayPolarityInverse (
void)
356 #ifdef POLARITY_INVERSION_EXTCOMIN
359 PAL_GpioPinOutToggle( LCD_PORT_EXTCOMIN, LCD_PIN_EXTCOMIN );
364 PAL_GpioPinOutSet( LCD_PORT_SCS, LCD_PIN_SCS );
367 PAL_TimerMicroSecondsDelay(6);
370 PAL_SpiTransmit ((uint8_t*) &lcdPolarity, 2 );
373 PAL_TimerMicroSecondsDelay(2);
375 PAL_GpioPinOutClear( LCD_PORT_SCS, LCD_PIN_SCS );
378 if (lcdPolarity == 0x00)
395 #ifdef PIXEL_MATRIX_ALLOC_SUPPORT
416 #ifdef EMWIN_WORKAROUND
417 unsigned int userStride,
422 #ifdef EMWIN_WORKAROUND
423 unsigned int allocSize = (userStride/8 + LS013B7DH03_CONTROL_BYTES) * height;
425 unsigned int allocSize = (width/8 + LS013B7DH03_CONTROL_BYTES) * height;
430 if (width != LS013B7DH03_WIDTH)
432 #ifdef EMWIN_WORKAROUND
433 if (userStride < width)
442 if (NULL == *pixelMatrix)
449 #ifdef USE_STATIC_PIXEL_MATRIX_POOL
451 if (((uint8_t*)pixelMatrixPool) + allocSize >
452 ((uint8_t*)pixelMatrixPoolBase) + PIXEL_MATRIX_POOL_SIZE)
459 *pixelMatrix = pixelMatrixPool;
460 pixelMatrixPool += allocSize /
sizeof(PixelMatrixAlign_t) +
461 ((allocSize %
sizeof(PixelMatrixAlign_t))? 1 : 0);
471 #ifdef PIXEL_MATRIX_ALLOC_SUPPORT
492 #ifdef USE_STATIC_PIXEL_MATRIX_POOL
527 uint8_t* pByte = (uint8_t*) pixelMatrix;
533 for (i=0; i<height; i++)
536 memset(pByte, 0, LS013B7DH03_WIDTH/8);
537 pByte += LS013B7DH03_WIDTH/8;
539 #ifdef USE_CONTROL_BYTES
551 #ifdef USE_CONTROL_BYTES
564 unsigned int startRow,
566 #ifdef EMWIN_WORKAROUND
568 unsigned int userStride
573 uint8_t* pByte = (uint8_t*) pixelMatrix;
574 #ifdef EMWIN_WORKAROUND
576 (userStride-LS013B7DH03_WIDTH-(LS013B7DH03_CONTROL_BYTES*8)) /
578 if ((userStride-LS013B7DH03_WIDTH) %
sizeof(uint16_t))
584 pByte += LS013B7DH03_WIDTH/8;
596 *pByte++ = startRow + (++i);
598 #ifdef EMWIN_WORKAROUND
628 unsigned int startColumn,
630 #ifdef EMWIN_WORKAROUND
631 unsigned int userStride,
633 unsigned int startRow,
634 unsigned int height )
637 uint16_t* p = (uint16_t *)pixelMatrix;
639 #ifdef EMWIN_WORKAROUND
641 (userStride-width-(LS013B7DH03_CONTROL_BYTES*8)) / 8 /
sizeof(uint16_t);
642 if ((userStride-width) %
sizeof(uint16_t))
654 #ifdef USE_CONTROL_BYTES
656 pixelMatrixSetup(pixelMatrix, startRow, height
657 #ifdef EMWIN_WORKAROUND
664 PAL_GpioPinOutSet( LCD_PORT_SCS, LCD_PIN_SCS );
667 PAL_TimerMicroSecondsDelay(6);
670 cmd = LS013B7DH03_CMD_UPDATE | (startRow << 8);
671 PAL_SpiTransmit((uint8_t*) &cmd, 2 );
674 for ( i=0; i<height; i++ ) {
677 PAL_SpiTransmit((uint8_t*) p,
678 LS013B7DH03_WIDTH/8 + LS013B7DH03_CONTROL_BYTES);
679 p+=(LS013B7DH03_WIDTH/8 + LS013B7DH03_CONTROL_BYTES) /
sizeof(uint16_t);
681 #ifndef USE_CONTROL_BYTES
688 cmd = 0xff | ((startRow+i+1) << 8);
690 PAL_SpiTransmit((uint8_t*) &cmd, 2 );
693 #ifdef EMWIN_WORKAROUND
700 PAL_TimerMicroSecondsDelay(2);
703 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