Convert ILI9325 driver to new format
This commit is contained in:
parent
313956b215
commit
668afded53
7 changed files with 428 additions and 396 deletions
117
drivers/gdisp/ILI9325/board_ILI9325_hy_stm32_100p.h
Normal file
117
drivers/gdisp/ILI9325/board_ILI9325_hy_stm32_100p.h
Normal file
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* This file is subject to the terms of the GFX License. If a copy of
|
||||
* the license was not distributed with this file, you can obtain one at:
|
||||
*
|
||||
* http://ugfx.org/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
driver quickly hacked together from a chinese sourcecode that came
|
||||
with the board and existing ili9320 code by Chris van Dongen (sjaak)
|
||||
(sjaak2002 at msn.com)
|
||||
|
||||
Also added rotation for 180 and 270 degrees and minor tweaks to
|
||||
setcursor
|
||||
|
||||
Added code comes without warranty and free bugs. Feel free to use
|
||||
or misuse the added code :D
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @file drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h
|
||||
* @brief GDISP Graphic Driver subsystem board interface for the ILI9325 display.
|
||||
*/
|
||||
|
||||
#ifndef GDISP_LLD_BOARD_H
|
||||
#define GDISP_LLD_BOARD_H
|
||||
|
||||
// For a multiple display configuration we would put all this in a structure and then
|
||||
// set g->priv to that structure.
|
||||
#define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */
|
||||
#define GDISP_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */
|
||||
|
||||
static inline void init_board(GDisplay *g, unsigned display) {
|
||||
|
||||
// As we are not using multiple displays we set g->priv to NULL as we don't use it.
|
||||
g->priv = 0;
|
||||
|
||||
if (display == 0) {
|
||||
|
||||
/**
|
||||
* Set up for Display 0
|
||||
*/
|
||||
|
||||
/* FSMC setup for F1 */
|
||||
rccEnableAHB(RCC_AHBENR_FSMCEN, 0);
|
||||
|
||||
/* set pin modes */
|
||||
/* IOBus busD = {GPIOD, PAL_WHOLE_PORT, 0};
|
||||
IOBus busE = {GPIOE, PAL_WHOLE_PORT, 0};
|
||||
palSetBusMode(&busD, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
|
||||
palSetBusMode(&busE, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
|
||||
palSetPadMode(GPIOE, GPIOE_TFT_RST, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOD, GPIOD_TFT_LIGHT, PAL_MODE_OUTPUT_PUSHPULL); */
|
||||
|
||||
const unsigned char FSMC_Bank = 0;
|
||||
|
||||
/* FSMC timing */
|
||||
FSMC_Bank1->BTCR[FSMC_Bank+1] = (6) | (10 << 8) | (10 << 16);
|
||||
|
||||
/* Bank1 NOR/SRAM control register configuration
|
||||
* This is actually not needed as already set by default after reset */
|
||||
FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void post_init_board(GDisplay *g) {
|
||||
(void) g;
|
||||
}
|
||||
|
||||
static inline void setpin_reset(GDisplay *g, bool_t state) {
|
||||
(void) g;
|
||||
if(state)
|
||||
palClearPad(GPIOE, GPIOE_TFT_RST);
|
||||
else
|
||||
palSetPad(GPIOE, GPIOE_TFT_RST);
|
||||
}
|
||||
|
||||
static inline void set_backlight(GDisplay *g, uint8_t percent) {
|
||||
(void) g;
|
||||
(void)percent;
|
||||
}
|
||||
|
||||
static inline void acquire_bus(GDisplay *g) {
|
||||
(void) g;
|
||||
}
|
||||
|
||||
static inline void release_bus(GDisplay *g) {
|
||||
(void) g;
|
||||
}
|
||||
|
||||
static inline void write_index(GDisplay *g, uint16_t index) {
|
||||
(void) g;
|
||||
GDISP_REG = index;
|
||||
}
|
||||
|
||||
static inline void write_data(GDisplay *g, uint16_t data) {
|
||||
(void) g;
|
||||
GDISP_RAM = data;
|
||||
}
|
||||
|
||||
static inline void setreadmode(GDisplay *g) {
|
||||
(void) g;
|
||||
}
|
||||
|
||||
static inline void setwritemode(GDisplay *g) {
|
||||
(void) g;
|
||||
}
|
||||
|
||||
static inline uint16_t read_data(GDisplay *g) {
|
||||
(void) g;
|
||||
return GDISP_RAM;
|
||||
}
|
||||
|
||||
#endif /* GDISP_LLD_BOARD_H */
|
||||
/** @} */
|
||||
|
157
drivers/gdisp/ILI9325/board_ILI9325_template.h
Normal file
157
drivers/gdisp/ILI9325/board_ILI9325_template.h
Normal file
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* This file is subject to the terms of the GFX License. If a copy of
|
||||
* the license was not distributed with this file, you can obtain one at:
|
||||
*
|
||||
* http://ugfx.org/license.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file drivers/gdisp/ILI9325/gdisp_lld_board_template.h
|
||||
* @brief GDISP Graphic Driver subsystem board interface for the ILI9325 display.
|
||||
*
|
||||
* @addtogroup GDISP
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef GDISP_LLD_BOARD_H
|
||||
#define GDISP_LLD_BOARD_H
|
||||
|
||||
/**
|
||||
* @brief Initialise the board for the display.
|
||||
*
|
||||
* @param[in] g The GDisplay structure
|
||||
* @param[in] display The display number on this controller (0..n)
|
||||
*
|
||||
* @note Set the g->priv member to whatever is appropriate. For multiple
|
||||
* displays this might be a pointer to the appropriate register set.
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void init_board(GDisplay *g, unsigned display) {
|
||||
(void) g;
|
||||
(void) display;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief After the initialisation.
|
||||
*
|
||||
* @param[in] g The GDisplay structure
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void post_init_board(GDisplay *g) {
|
||||
(void) g;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set or clear the lcd reset pin.
|
||||
*
|
||||
* @param[in] g The GDisplay structure
|
||||
* @param[in] state TRUE = lcd in reset, FALSE = normal operation
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void setpin_reset(GDisplay *g, bool_t state) {
|
||||
(void) g;
|
||||
(void) state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the lcd back-light level.
|
||||
*
|
||||
* @param[in] g The GDisplay structure
|
||||
* @param[in] percent 0 to 100%
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void set_backlight(GDisplay *g, uint8_t percent) {
|
||||
(void) g;
|
||||
(void) percent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Take exclusive control of the bus
|
||||
*
|
||||
* @param[in] g The GDisplay structure
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void acquire_bus(GDisplay *g) {
|
||||
(void) g;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release exclusive control of the bus
|
||||
*
|
||||
* @param[in] g The GDisplay structure
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void release_bus(GDisplay *g) {
|
||||
(void) g;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Send data to the index register.
|
||||
*
|
||||
* @param[in] g The GDisplay structure
|
||||
* @param[in] index The index register to set
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void write_index(GDisplay *g, uint16_t index) {
|
||||
(void) g;
|
||||
(void) index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Send data to the lcd.
|
||||
*
|
||||
* @param[in] g The GDisplay structure
|
||||
* @param[in] data The data to send
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void write_data(GDisplay *g, uint16_t data) {
|
||||
(void) g;
|
||||
(void) data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the bus in read mode
|
||||
*
|
||||
* @param[in] g The GDisplay structure
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void setreadmode(GDisplay *g) {
|
||||
(void) g;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the bus back into write mode
|
||||
*
|
||||
* @param[in] g The GDisplay structure
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void setwritemode(GDisplay *g) {
|
||||
(void) g;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read data from the lcd.
|
||||
* @return The data from the lcd
|
||||
*
|
||||
* @param[in] g The GDisplay structure
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline uint16_t read_data(GDisplay *g) {
|
||||
(void) g;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* GDISP_LLD_BOARD_H */
|
||||
/** @} */
|
||||
|
|
@ -8,9 +8,6 @@
|
|||
/**
|
||||
* @file drivers/gdisp/ILI9325/gdisp_lld.c
|
||||
* @brief GDISP Graphics Driver subsystem low level driver source for the ILI9325 display.
|
||||
*
|
||||
* @addtogroup GDISP
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "gfx.h"
|
||||
|
@ -27,9 +24,11 @@
|
|||
#undef GDISP_SCREEN_WIDTH
|
||||
#endif
|
||||
|
||||
#define GDISP_LLD_DECLARATIONS
|
||||
#define GDISP_DRIVER_VMT GDISPVMT_ILI9325
|
||||
#include "../drivers/gdisp/ILI9325/gdisp_lld_config.h"
|
||||
#include "gdisp/lld/gdisp_lld.h"
|
||||
#include "gdisp_lld_board.h"
|
||||
|
||||
#include "board_ILI9325.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local definitions. */
|
||||
|
@ -51,126 +50,135 @@
|
|||
/*===========================================================================*/
|
||||
/* Driver local variables. */
|
||||
/*===========================================================================*/
|
||||
uint32_t DISPLAY_CODE;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
// Some common routines and macros
|
||||
#define dummy_read() { volatile uint16_t dummy; dummy = read_data(); (void) dummy; }
|
||||
#define write_reg(reg, data) { write_index(reg); write_data(data); }
|
||||
#define dummy_read(g) { volatile uint16_t dummy; dummy = read_data(g); (void) dummy; }
|
||||
#define write_reg(g, reg, data) { write_index(g, reg); write_data(g, data); }
|
||||
|
||||
static void set_cursor(GDISPDriver *g) {
|
||||
static void set_cursor(GDisplay *g) {
|
||||
switch(g->g.Orientation) {
|
||||
case GDISP_ROTATE_0:
|
||||
case GDISP_ROTATE_180:
|
||||
write_reg(0x0020, g->p.x);
|
||||
write_reg(0x0021, g->p.y);
|
||||
write_reg(g, 0x20, g->p.x);
|
||||
write_reg(g, 0x21, g->p.y);
|
||||
break;
|
||||
|
||||
case GDISP_ROTATE_90:
|
||||
case GDISP_ROTATE_270:
|
||||
write_reg(0x0020, g->p.y);
|
||||
write_reg(0x0021, g->p.x);
|
||||
write_reg(g, 0x20, g->p.y);
|
||||
write_reg(g, 0x21, g->p.x);
|
||||
break;
|
||||
}
|
||||
write_index(0x0022);
|
||||
write_index(g, 0x22);
|
||||
}
|
||||
|
||||
static void set_viewport(GDISPDriver* g) {
|
||||
static void set_viewport(GDisplay* g) {
|
||||
switch(g->g.Orientation) {
|
||||
case GDISP_ROTATE_0:
|
||||
case GDISP_ROTATE_180:
|
||||
write_reg(0x0050, g->p.x);
|
||||
write_reg(0x0051, g->p.x + g->p.cx - 1);
|
||||
write_reg(0x0052, g->p.y);
|
||||
write_reg(0x0053, g->p.y + g->p.cy - 1);
|
||||
write_reg(g, 0x50, g->p.x);
|
||||
write_reg(g, 0x51, g->p.x + g->p.cx - 1);
|
||||
write_reg(g, 0x52, g->p.y);
|
||||
write_reg(g, 0x53, g->p.y + g->p.cy - 1);
|
||||
break;
|
||||
|
||||
case GDISP_ROTATE_90:
|
||||
case GDISP_ROTATE_270:
|
||||
write_reg(0x0050, g->p.y);
|
||||
write_reg(0x0051, g->p.y + g->p.cy - 1);
|
||||
write_reg(0x0052, g->p.x);
|
||||
write_reg(0x0053, g->p.x + g->p.cx - 1);
|
||||
write_reg(g, 0x50, g->p.y);
|
||||
write_reg(g, 0x51, g->p.y + g->p.cy - 1);
|
||||
write_reg(g, 0x52, g->p.x);
|
||||
write_reg(g, 0x53, g->p.x + g->p.cx - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LLDSPEC bool_t gdisp_lld_init(GDISPDriver *g) {
|
||||
LLDSPEC bool_t gdisp_lld_init(GDisplay *g, unsigned display) {
|
||||
uint16_t cver;
|
||||
|
||||
/* Initialise your display */
|
||||
init_board();
|
||||
init_board(g, display);
|
||||
|
||||
/* Hardware reset */
|
||||
setpin_reset(TRUE);
|
||||
setpin_reset(g, TRUE);
|
||||
gfxSleepMicroseconds(1000);
|
||||
setpin_reset(FALSE);
|
||||
setpin_reset(g, FALSE);
|
||||
gfxSleepMicroseconds(1000);
|
||||
|
||||
acquire_bus();
|
||||
write_index(0); // Get controller version
|
||||
dummy_read();
|
||||
DISPLAY_CODE = read_data();
|
||||
acquire_bus(g);
|
||||
write_index(g, 0); // Get controller version
|
||||
setreadmode(g);
|
||||
dummy_read(g);
|
||||
cver = read_data(g);
|
||||
setwritemode(g);
|
||||
|
||||
// chinese code starts here
|
||||
write_reg(0x0000,0x0001);
|
||||
write_reg(g, 0x00, 0x0001);
|
||||
gfxSleepMilliseconds(10);
|
||||
|
||||
write_reg(0x0015,0x0030);
|
||||
write_reg(0x0011,0x0040);
|
||||
write_reg(0x0010,0x1628);
|
||||
write_reg(0x0012,0x0000);
|
||||
write_reg(0x0013,0x104d);
|
||||
write_reg(g, 0x15, 0x0030);
|
||||
write_reg(g, 0x11, 0x0040);
|
||||
write_reg(g, 0x10, 0x1628);
|
||||
write_reg(g, 0x12, 0x0000);
|
||||
write_reg(g, 0x13, 0x104d);
|
||||
gfxSleepMilliseconds(10);
|
||||
write_reg(0x0012,0x0010);
|
||||
write_reg(g, 0x12, 0x0010);
|
||||
gfxSleepMilliseconds(10);
|
||||
write_reg(0x0010,0x2620);
|
||||
write_reg(0x0013,0x344d); //304d
|
||||
write_reg(g, 0x10, 0x2620);
|
||||
write_reg(g, 0x13, 0x344d); //304d
|
||||
gfxSleepMilliseconds(10);
|
||||
|
||||
write_reg(0x0001,0x0100);
|
||||
write_reg(0x0002,0x0300);
|
||||
write_reg(0x0003,0x1038);//0x1030
|
||||
write_reg(0x0008,0x0604);
|
||||
write_reg(0x0009,0x0000);
|
||||
write_reg(0x000A,0x0008);
|
||||
write_reg(g, 0x01, 0x0100);
|
||||
write_reg(g, 0x02, 0x0300);
|
||||
write_reg(g, 0x03, 0x1038);//0x1030
|
||||
write_reg(g, 0x08, 0x0604);
|
||||
write_reg(g, 0x09, 0x0000);
|
||||
write_reg(g, 0x0A, 0x0008);
|
||||
|
||||
write_reg(0x0041,0x0002);
|
||||
write_reg(0x0060,0x2700);
|
||||
write_reg(0x0061,0x0001);
|
||||
write_reg(0x0090,0x0182);
|
||||
write_reg(0x0093,0x0001);
|
||||
write_reg(0x00a3,0x0010);
|
||||
write_reg(g, 0x41, 0x0002);
|
||||
write_reg(g, 0x60, 0x2700);
|
||||
write_reg(g, 0x61, 0x0001);
|
||||
write_reg(g, 0x90, 0x0182);
|
||||
write_reg(g, 0x93, 0x0001);
|
||||
write_reg(g, 0xa3, 0x0010);
|
||||
gfxSleepMilliseconds(10);
|
||||
|
||||
//################# void Gamma_Set(void) ####################//
|
||||
write_reg(0x30,0x0000);
|
||||
write_reg(0x31,0x0502);
|
||||
write_reg(0x32,0x0307);
|
||||
write_reg(0x33,0x0305);
|
||||
write_reg(0x34,0x0004);
|
||||
write_reg(0x35,0x0402);
|
||||
write_reg(0x36,0x0707);
|
||||
write_reg(0x37,0x0503);
|
||||
write_reg(0x38,0x1505);
|
||||
write_reg(0x39,0x1505);
|
||||
write_reg(g, 0x30, 0x0000);
|
||||
write_reg(g, 0x31, 0x0502);
|
||||
write_reg(g, 0x32, 0x0307);
|
||||
write_reg(g, 0x33, 0x0305);
|
||||
write_reg(g, 0x34, 0x0004);
|
||||
write_reg(g, 0x35, 0x0402);
|
||||
write_reg(g, 0x36, 0x0707);
|
||||
write_reg(g, 0x37, 0x0503);
|
||||
write_reg(g, 0x38, 0x1505);
|
||||
write_reg(g, 0x39, 0x1505);
|
||||
gfxSleepMilliseconds(10);
|
||||
|
||||
//################## void Display_ON(void) ####################//
|
||||
write_reg(0x0007,0x0001);
|
||||
write_reg(g, 0x07, 0x0001);
|
||||
gfxSleepMilliseconds(10);
|
||||
write_reg(0x0007,0x0021);
|
||||
write_reg(0x0007,0x0023);
|
||||
write_reg(g, 0x07, 0x0021);
|
||||
write_reg(g, 0x07, 0x0023);
|
||||
gfxSleepMilliseconds(10);
|
||||
write_reg(0x0007,0x0033);
|
||||
write_reg(g, 0x07, 0x0033);
|
||||
gfxSleepMilliseconds(10);
|
||||
write_reg(0x0007,0x0133);
|
||||
write_reg(g, 0x07, 0x0133);
|
||||
|
||||
// chinese code ends here
|
||||
|
||||
// Finish Init
|
||||
post_init_board(g);
|
||||
|
||||
// Release the bus
|
||||
release_bus(g);
|
||||
|
||||
// Turn on the backlight
|
||||
set_backlight(GDISP_INITIAL_BACKLIGHT);
|
||||
set_backlight(g, GDISP_INITIAL_BACKLIGHT);
|
||||
|
||||
/* Initialise the GDISP structure */
|
||||
g->g.Width = GDISP_SCREEN_WIDTH;
|
||||
|
@ -184,101 +192,101 @@ LLDSPEC bool_t gdisp_lld_init(GDISPDriver *g) {
|
|||
}
|
||||
|
||||
#if GDISP_HARDWARE_STREAM_WRITE
|
||||
LLDSPEC void gdisp_lld_write_start(GDISPDriver *g) {
|
||||
acquire_bus();
|
||||
LLDSPEC void gdisp_lld_write_start(GDisplay *g) {
|
||||
acquire_bus(g);
|
||||
set_viewport(g);
|
||||
}
|
||||
LLDSPEC void gdisp_lld_write_color(GDISPDriver *g) {
|
||||
write_data(g->p.color);
|
||||
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
|
||||
write_data(g, g->p.color);
|
||||
}
|
||||
LLDSPEC void gdisp_lld_write_stop(GDISPDriver *g) {
|
||||
release_bus();
|
||||
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
|
||||
release_bus(g);
|
||||
}
|
||||
LLDSPEC void gdisp_lld_write_pos(GDISPDriver *g) {
|
||||
LLDSPEC void gdisp_lld_write_pos(GDisplay *g) {
|
||||
set_cursor(g);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if GDISP_HARDWARE_STREAM_READ
|
||||
LLDSPEC void gdisp_lld_read_start(GDISPDriver *g) {
|
||||
acquire_bus();
|
||||
LLDSPEC void gdisp_lld_read_start(GDisplay *g) {
|
||||
acquire_bus(g);
|
||||
set_viewport(g);
|
||||
set_cursor(g);
|
||||
setreadmode();
|
||||
dummy_read();
|
||||
setreadmode(g);
|
||||
dummy_read(g);
|
||||
}
|
||||
LLDSPEC color_t gdisp_lld_read_color(GDISPDriver *g) {
|
||||
return read_data();
|
||||
LLDSPEC color_t gdisp_lld_read_color(GDisplay *g) {
|
||||
return read_data(g);
|
||||
}
|
||||
LLDSPEC void gdisp_lld_read_stop(GDISPDriver *g) {
|
||||
setwritemode();
|
||||
release_bus();
|
||||
LLDSPEC void gdisp_lld_read_stop(GDisplay *g) {
|
||||
setwritemode(g);
|
||||
release_bus(g);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
|
||||
LLDSPEC void gdisp_lld_control(GDISPDriver *g) {
|
||||
LLDSPEC void gdisp_lld_control(GDisplay *g) {
|
||||
switch(g->p.x) {
|
||||
case GDISP_CONTROL_POWER:
|
||||
if (g->g.Powermode == (powermode_t)g->p.ptr)
|
||||
return;
|
||||
switch((powermode_t)g->p.ptr) {
|
||||
case powerOff:
|
||||
acquire_bus();
|
||||
write_reg(0x0007, 0x0000);
|
||||
write_reg(0x0010, 0x0000);
|
||||
write_reg(0x0011, 0x0000);
|
||||
write_reg(0x0012, 0x0000);
|
||||
write_reg(0x0013, 0x0000);
|
||||
release_bus();
|
||||
set_backlight(0);
|
||||
acquire_bus(g);
|
||||
write_reg(g, 0x07, 0x0000);
|
||||
write_reg(g, 0x10, 0x0000);
|
||||
write_reg(g, 0x11, 0x0000);
|
||||
write_reg(g, 0x12, 0x0000);
|
||||
write_reg(g, 0x13, 0x0000);
|
||||
release_bus(g);
|
||||
set_backlight(g, 0);
|
||||
break;
|
||||
|
||||
case powerOn:
|
||||
//*************Power On sequence ******************//
|
||||
acquire_bus();
|
||||
write_reg(0x0010, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
|
||||
write_reg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
|
||||
write_reg(0x0012, 0x0000); /* VREG1OUT voltage */
|
||||
write_reg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
|
||||
acquire_bus(g);
|
||||
write_reg(g, 0x10, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
|
||||
write_reg(g, 0x11, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
|
||||
write_reg(g, 0x12, 0x0000); /* VREG1OUT voltage */
|
||||
write_reg(g, 0x13, 0x0000); /* VDV[4:0] for VCOM amplitude */
|
||||
gfxSleepMilliseconds(200); /* Dis-charge capacitor power voltage */
|
||||
write_reg(0x0010, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
|
||||
write_reg(0x0011, 0x0147); /* DC1[2:0], DC0[2:0], VC[2:0] */
|
||||
write_reg(g, 0x10, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
|
||||
write_reg(g, 0x11, 0x0147); /* DC1[2:0], DC0[2:0], VC[2:0] */
|
||||
gfxSleepMilliseconds(50);
|
||||
write_reg(0x0012, 0x013C); /* VREG1OUT voltage */
|
||||
write_reg(g, 0x12, 0x013C); /* VREG1OUT voltage */
|
||||
gfxSleepMilliseconds(50);
|
||||
write_reg(0x0013, 0x0E00); /* VDV[4:0] for VCOM amplitude */
|
||||
write_reg(0x0029, 0x0009); /* VCM[4:0] for VCOMH */
|
||||
write_reg(g, 0x13, 0x0E00); /* VDV[4:0] for VCOM amplitude */
|
||||
write_reg(g, 0x29, 0x0009); /* VCM[4:0] for VCOMH */
|
||||
gfxSleepMilliseconds(50);
|
||||
write_reg(0x0007, 0x0173); /* 262K color and display ON */
|
||||
release_bus();
|
||||
set_backlight(g->g.Backlight);
|
||||
write_reg(g, 0x07, 0x0173); /* 262K color and display ON */
|
||||
release_bus(g);
|
||||
set_backlight(g, g->g.Backlight);
|
||||
break;
|
||||
|
||||
case powerSleep:
|
||||
acquire_bus();
|
||||
write_reg(0x0007, 0x0000); /* display OFF */
|
||||
write_reg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
|
||||
write_reg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
|
||||
write_reg(0x0012, 0x0000); /* VREG1OUT voltage */
|
||||
write_reg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
|
||||
acquire_bus(g);
|
||||
write_reg(g, 0x07, 0x0000); /* display OFF */
|
||||
write_reg(g, 0x10, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
|
||||
write_reg(g, 0x11, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
|
||||
write_reg(g, 0x12, 0x0000); /* VREG1OUT voltage */
|
||||
write_reg(g, 0x13, 0x0000); /* VDV[4:0] for VCOM amplitude */
|
||||
gfxSleepMilliseconds(200); /* Dis-charge capacitor power voltage */
|
||||
write_reg(0x0010, 0x0002); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
|
||||
release_bus();
|
||||
gdisp_lld_backlight(0);
|
||||
write_reg(g, 0x10, 0x0002); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
|
||||
release_bus(g);
|
||||
gdisp_lld_backlight(g, 0);
|
||||
break;
|
||||
|
||||
case powerDeepSleep:
|
||||
acquire_bus();
|
||||
write_reg(0x0007, 0x0000); /* display OFF */
|
||||
write_reg(0x0010, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
|
||||
write_reg(0x0011, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
|
||||
write_reg(0x0012, 0x0000); /* VREG1OUT voltage */
|
||||
write_reg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
|
||||
acquire_bus(g);
|
||||
write_reg(g, 0x07, 0x0000); /* display OFF */
|
||||
write_reg(g, 0x10, 0x0000); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
|
||||
write_reg(g, 0x11, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */
|
||||
write_reg(g, 0x12, 0x0000); /* VREG1OUT voltage */
|
||||
write_reg(g, 0x13, 0x0000); /* VDV[4:0] for VCOM amplitude */
|
||||
gfxSleepMilliseconds(200); /* Dis-charge capacitor power voltage */
|
||||
write_reg(0x0010, 0x0004); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
|
||||
release_bus();
|
||||
gdisp_lld_backlight(0);
|
||||
write_reg(g, 0x10, 0x0004); /* SAP, BT[3:0], APE, AP, DSTB, SLP */
|
||||
release_bus(g);
|
||||
gdisp_lld_backlight(g, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -292,41 +300,41 @@ LLDSPEC bool_t gdisp_lld_init(GDISPDriver *g) {
|
|||
return;
|
||||
switch((orientation_t)g->p.ptr) {
|
||||
case GDISP_ROTATE_0:
|
||||
acquire_bus();
|
||||
write_reg(0x0001, 0x0100);
|
||||
write_reg(0x0003, 0x1038);
|
||||
write_reg(0x0060, 0x2700);
|
||||
release_bus();
|
||||
acquire_bus(g);
|
||||
write_reg(g, 0x01, 0x0100);
|
||||
write_reg(g, 0x03, 0x1038);
|
||||
write_reg(g, 0x60, 0x2700);
|
||||
release_bus(g);
|
||||
g->g.Height = GDISP_SCREEN_HEIGHT;
|
||||
g->g.Width = GDISP_SCREEN_WIDTH;
|
||||
break;
|
||||
|
||||
case GDISP_ROTATE_90:
|
||||
acquire_bus();
|
||||
write_reg(0x0001, 0x0000);
|
||||
write_reg(0x0003, 0x1030);
|
||||
write_reg(0x0060, 0x2700);
|
||||
release_bus();
|
||||
acquire_bus(g);
|
||||
write_reg(g, 0x01, 0x0000);
|
||||
write_reg(g, 0x03, 0x1030);
|
||||
write_reg(g, 0x60, 0x2700);
|
||||
release_bus(g);
|
||||
g->g.Height = GDISP_SCREEN_WIDTH;
|
||||
g->g.Width = GDISP_SCREEN_HEIGHT;
|
||||
break;
|
||||
|
||||
case GDISP_ROTATE_180:
|
||||
acquire_bus();
|
||||
write_reg(0x0001, 0x0000);
|
||||
write_reg(0x0003, 0x1038);
|
||||
write_reg(0x0060, 0xa700);
|
||||
release_bus();
|
||||
acquire_bus(g);
|
||||
write_reg(g, 0x01, 0x0000);
|
||||
write_reg(g, 0x03, 0x1038);
|
||||
write_reg(g, 0x60, 0xa700);
|
||||
release_bus(g);
|
||||
g->g.Height = GDISP_SCREEN_HEIGHT;
|
||||
g->g.Width = GDISP_SCREEN_WIDTH;
|
||||
break;
|
||||
|
||||
case GDISP_ROTATE_270:
|
||||
acquire_bus();
|
||||
write_reg(0x0001, 0x0100);
|
||||
write_reg(0x0003, 0x1030);
|
||||
write_reg(0x0060, 0xA700);
|
||||
release_bus();
|
||||
acquire_bus(g);
|
||||
write_reg(g, 0x01, 0x0100);
|
||||
write_reg(g, 0x03, 0x1030);
|
||||
write_reg(g, 0x60, 0xA700);
|
||||
release_bus(g);
|
||||
g->g.Height = GDISP_SCREEN_WIDTH;
|
||||
g->g.Width = GDISP_SCREEN_HEIGHT;
|
||||
break;
|
||||
|
@ -341,7 +349,7 @@ LLDSPEC bool_t gdisp_lld_init(GDISPDriver *g) {
|
|||
case GDISP_CONTROL_BACKLIGHT:
|
||||
if ((unsigned)g->p.ptr > 100)
|
||||
g->p.ptr = (void *)100;
|
||||
set_backlight((unsigned)g->p.ptr);
|
||||
set_backlight(g, (unsigned)g->p.ptr);
|
||||
g->g.Backlight = (unsigned)g->p.ptr;
|
||||
return;
|
||||
|
||||
|
@ -353,5 +361,3 @@ LLDSPEC bool_t gdisp_lld_init(GDISPDriver *g) {
|
|||
#endif
|
||||
|
||||
#endif /* GFX_USE_GDISP */
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -1,5 +1,2 @@
|
|||
# List the required driver.
|
||||
GFXSRC += $(GFXLIB)/drivers/gdisp/ILI9325/gdisp_lld.c
|
||||
|
||||
# Required include directories
|
||||
GFXINC += $(GFXLIB)/drivers/gdisp/ILI9325
|
||||
GFXSRC += $(GFXLIB)/drivers/gdisp/ILI9325/gdisp_lld.c
|
||||
|
|
|
@ -1,119 +0,0 @@
|
|||
/*
|
||||
* This file is subject to the terms of the GFX License. If a copy of
|
||||
* the license was not distributed with this file, you can obtain one at:
|
||||
*
|
||||
* http://ugfx.org/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
driver quickly hacked together from a chinese sourcecode that came
|
||||
with the board and existing ili9320 code by Chris van Dongen (sjaak)
|
||||
(sjaak2002 at msn.com)
|
||||
|
||||
Also added rotation for 180 and 270 degrees and minor tweaks to
|
||||
setcursor
|
||||
|
||||
Added code comes without warranty and free bugs. Feel free to use
|
||||
or misuse the added code :D
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @file drivers/gdisp/ILI9325/gdisp_lld_board_hy_stm32_100p.h
|
||||
* @brief GDISP Graphic Driver subsystem board interface for the ILI9325 display.
|
||||
*
|
||||
* @addtogroup GDISP
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef GDISP_LLD_BOARD_H
|
||||
#define GDISP_LLD_BOARD_H
|
||||
|
||||
#define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */
|
||||
#define GDISP_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */
|
||||
|
||||
static inline void init_board(void) {
|
||||
/* FSMC setup for F1 */
|
||||
rccEnableAHB(RCC_AHBENR_FSMCEN, 0);
|
||||
|
||||
/* set pin modes */
|
||||
/* IOBus busD = {GPIOD, PAL_WHOLE_PORT, 0};
|
||||
IOBus busE = {GPIOE, PAL_WHOLE_PORT, 0};
|
||||
palSetBusMode(&busD, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
|
||||
palSetBusMode(&busE, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
|
||||
palSetPadMode(GPIOE, GPIOE_TFT_RST, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOD, GPIOD_TFT_LIGHT, PAL_MODE_OUTPUT_PUSHPULL); */
|
||||
|
||||
const unsigned char FSMC_Bank = 0;
|
||||
|
||||
/* FSMC timing */
|
||||
FSMC_Bank1->BTCR[FSMC_Bank+1] = (6) | (10 << 8) | (10 << 16);
|
||||
|
||||
/* Bank1 NOR/SRAM control register configuration
|
||||
* This is actually not needed as already set by default after reset */
|
||||
FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN;
|
||||
|
||||
}
|
||||
|
||||
static inline void setpin_reset(bool_t state) {
|
||||
if(state)
|
||||
palClearPad(GPIOE, GPIOE_TFT_RST);
|
||||
else
|
||||
palSetPad(GPIOE, GPIOE_TFT_RST);
|
||||
}
|
||||
|
||||
static inline void write_index(uint16_t reg) {
|
||||
GDISP_REG = reg;
|
||||
}
|
||||
|
||||
static inline void write_data(uint16_t data) {
|
||||
GDISP_RAM = data;
|
||||
}
|
||||
|
||||
static inline uint16_t read_data(void) {
|
||||
return GDISP_RAM;
|
||||
}
|
||||
|
||||
static inline void set_backlight(uint8_t percent) {
|
||||
(void)percent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Take exclusive control of the bus
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void acquire_bus(void) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release exclusive control of the bus
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void release_bus(void) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the bus in read mode
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void setreadmode(void) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the bus back into write mode
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void setwritemode(void) {
|
||||
|
||||
}
|
||||
|
||||
#endif /* GDISP_LLD_BOARD_H */
|
||||
/** @} */
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
* This file is subject to the terms of the GFX License. If a copy of
|
||||
* the license was not distributed with this file, you can obtain one at:
|
||||
*
|
||||
* http://ugfx.org/license.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file drivers/gdisp/ILI9325/gdisp_lld_board_template.h
|
||||
* @brief GDISP Graphic Driver subsystem board interface for the ILI9325 display.
|
||||
*
|
||||
* @addtogroup GDISP
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef GDISP_LLD_BOARD_H
|
||||
#define GDISP_LLD_BOARD_H
|
||||
|
||||
/**
|
||||
* @brief Initialise the board for the display.
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void init_board(void) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set or clear the lcd reset pin.
|
||||
*
|
||||
* @param[in] state TRUE = lcd in reset, FALSE = normal operation
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void setpin_reset(bool_t state) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the lcd back-light level.
|
||||
*
|
||||
* @param[in] percent 0 to 100%
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void set_backlight(uint8_t percent) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Take exclusive control of the bus
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void acquire_bus(void) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release exclusive control of the bus
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void release_bus(void) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Send data to the index register.
|
||||
*
|
||||
* @param[in] index The index register to set
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void write_index(uint16_t index) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Send data to the lcd.
|
||||
*
|
||||
* @param[in] data The data to send
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void write_data(uint16_t data) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the bus in read mode
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void setreadmode(void) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the bus back into write mode
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline void setwritemode(void) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read data from the lcd.
|
||||
*
|
||||
* @return The data from the lcd
|
||||
* @note The chip select may need to be asserted/de-asserted
|
||||
* around the actual spi read
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
static inline uint16_t read_data(void) {
|
||||
|
||||
}
|
||||
|
||||
#endif /* GDISP_LLD_BOARD_H */
|
||||
/** @} */
|
||||
|
|
@ -22,9 +22,6 @@
|
|||
/* Driver hardware support. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#define GDISP_DRIVER_NAME "ILI9325"
|
||||
#define GDISP_DRIVER_STRUCT GDISP_ILI9325
|
||||
|
||||
#define GDISP_HARDWARE_STREAM_WRITE TRUE
|
||||
#define GDISP_HARDWARE_STREAM_READ TRUE
|
||||
#define GDISP_HARDWARE_STREAM_POS TRUE
|
||||
|
|
Loading…
Add table
Reference in a new issue