xtensa/esp32s3: LCD controller driver
This commit is contained in:
parent
3a08c0a1e6
commit
6ac28d5526
@ -715,6 +715,16 @@ config ESP32S3_WCL
|
|||||||
select ARCH_USE_MPU
|
select ARCH_USE_MPU
|
||||||
select XTENSA_HAVE_GENERAL_EXCEPTION_HOOKS if BUILD_PROTECTED
|
select XTENSA_HAVE_GENERAL_EXCEPTION_HOOKS if BUILD_PROTECTED
|
||||||
|
|
||||||
|
config ESP32S3_LCD
|
||||||
|
bool "LCD"
|
||||||
|
default n
|
||||||
|
select DRIVERS_VIDEO
|
||||||
|
select VIDEO_FB
|
||||||
|
select FB_UPDATE
|
||||||
|
help
|
||||||
|
---help---
|
||||||
|
LCD controller that outputs parallel data and supports RGB interface.
|
||||||
|
|
||||||
endmenu # ESP32-S3 Peripheral Selection
|
endmenu # ESP32-S3 Peripheral Selection
|
||||||
|
|
||||||
menuconfig ESP32S3_WIFI_BT_COEXIST
|
menuconfig ESP32S3_WIFI_BT_COEXIST
|
||||||
@ -1713,6 +1723,153 @@ config ESP32S3_OTG_DEBUG_REGISTER
|
|||||||
|
|
||||||
endmenu # USB OTG Configuration
|
endmenu # USB OTG Configuration
|
||||||
|
|
||||||
|
menu "LCD Controller Configuration"
|
||||||
|
depends on ESP32S3_LCD
|
||||||
|
|
||||||
|
menu "LCD Pin Configuration"
|
||||||
|
|
||||||
|
config ESP32S3_LCD_PCLK_PIN
|
||||||
|
int "LCD Pixel Clock Signal Pin"
|
||||||
|
default 9
|
||||||
|
|
||||||
|
config ESP32S3_LCD_VSYNC_PIN
|
||||||
|
int "LCD Vertical Synchronization Pin"
|
||||||
|
default 3
|
||||||
|
|
||||||
|
config ESP32S3_LCD_HSYNC_PIN
|
||||||
|
int "LCD Horizontal Synchronization Pin"
|
||||||
|
default 46
|
||||||
|
|
||||||
|
config ESP32S3_LCD_HE_PIN
|
||||||
|
int "LCD Horizontal Enable Pin"
|
||||||
|
default 17
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA0_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-0 Pin"
|
||||||
|
default 10
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA1_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-1 Pin"
|
||||||
|
default 11
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA2_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-2 Pin"
|
||||||
|
default 12
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA3_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-3 Pin"
|
||||||
|
default 13
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA4_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-4 Pin"
|
||||||
|
default 14
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA5_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-5 Pin"
|
||||||
|
default 21
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA6_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-6 Pin"
|
||||||
|
default 47
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA7_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-7 Pin"
|
||||||
|
default 48
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA8_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-8 Pin"
|
||||||
|
default 45
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA9_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-9 Pin"
|
||||||
|
default 38
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA10_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-10 Pin"
|
||||||
|
default 39
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA11_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-11 Pin"
|
||||||
|
default 40
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA12_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-12 Pin"
|
||||||
|
default 41
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA13_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-13 Pin"
|
||||||
|
default 42
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA14_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-14 Pin"
|
||||||
|
default 2
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA15_PIN
|
||||||
|
int "LCD Parallel Output Data Bit-15 Pin"
|
||||||
|
default 1
|
||||||
|
|
||||||
|
endmenu
|
||||||
|
|
||||||
|
menu "LCD Display Configuration"
|
||||||
|
depends on ESP32S3_LCD
|
||||||
|
|
||||||
|
config ESP32S3_LCD_VRES
|
||||||
|
int "LCD Vertical Resolution"
|
||||||
|
default 480
|
||||||
|
|
||||||
|
config ESP32S3_LCD_HRES
|
||||||
|
int "LCD Horizontal Resolution"
|
||||||
|
default 480
|
||||||
|
|
||||||
|
config ESP32S3_LCD_CLOCK_MHZ
|
||||||
|
int "LCD Pixel Clock Frequency in MHz"
|
||||||
|
default 2
|
||||||
|
|
||||||
|
config ESP32S3_LCD_VFRONTPORCH
|
||||||
|
int "LCD Vertical Front Porch"
|
||||||
|
default 40
|
||||||
|
|
||||||
|
config ESP32S3_LCD_VBACKPORCH
|
||||||
|
int "LCD Vertical Back Porch"
|
||||||
|
default 20
|
||||||
|
|
||||||
|
config ESP32S3_LCD_VPULSEWIDTH
|
||||||
|
int "LCD Vertical Pulse Width"
|
||||||
|
default 13
|
||||||
|
|
||||||
|
config ESP32S3_LCD_HFRONTPORCH
|
||||||
|
int "LCD Horizontal Front Porch"
|
||||||
|
default 40
|
||||||
|
|
||||||
|
config ESP32S3_LCD_HBACKPORCH
|
||||||
|
int "LCD Horizontal Back Porch"
|
||||||
|
default 20
|
||||||
|
|
||||||
|
config ESP32S3_LCD_HPULSEWIDTH
|
||||||
|
int "LCD Horizontal Pulse Width"
|
||||||
|
default 15
|
||||||
|
|
||||||
|
config ESP32S3_LCD_BUFFER_LAYERS
|
||||||
|
int "LCD Buffer Layer Number"
|
||||||
|
default 1
|
||||||
|
|
||||||
|
choice
|
||||||
|
prompt "LCD Data Width"
|
||||||
|
default ESP32S3_LCD_DATA_16BIT
|
||||||
|
|
||||||
|
config ESP32S3_LCD_DATA_16BIT
|
||||||
|
bool "16-bit"
|
||||||
|
|
||||||
|
endchoice # LCD Data Width
|
||||||
|
|
||||||
|
endmenu
|
||||||
|
|
||||||
|
config ESP32S3_LCD_REGDEBUG
|
||||||
|
bool "LCD Debug Registers"
|
||||||
|
default n
|
||||||
|
|
||||||
|
endmenu
|
||||||
|
|
||||||
menu "Application Image Configuration"
|
menu "Application Image Configuration"
|
||||||
|
|
||||||
choice
|
choice
|
||||||
|
@ -158,6 +158,10 @@ ifeq ($(CONFIG_RTC_DRIVER),y)
|
|||||||
CHIP_CSRCS += esp32s3_rtc_lowerhalf.c
|
CHIP_CSRCS += esp32s3_rtc_lowerhalf.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ESP32S3_LCD),y)
|
||||||
|
CHIP_CSRCS += esp32s3_lcd.c
|
||||||
|
endif
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
# Espressif HAL for 3rd Party Platforms
|
# Espressif HAL for 3rd Party Platforms
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
@ -391,6 +391,47 @@ void esp32s3_dma_wait_idle(int chan, bool tx)
|
|||||||
while ((waitbits & regval) == 0);
|
while ((waitbits & regval) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp32s3_dma_set_ext_memblk
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Configure DMA external memory block size.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* chan - DMA channel
|
||||||
|
* tx - true: TX mode; false: RX mode
|
||||||
|
* type - block size type
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void esp32s3_dma_set_ext_memblk(int chan, bool tx,
|
||||||
|
enum esp32s3_dma_ext_memblk_e type)
|
||||||
|
{
|
||||||
|
uint32_t val;
|
||||||
|
|
||||||
|
if (tx)
|
||||||
|
{
|
||||||
|
val = ((uint32_t)type << DMA_OUT_EXT_MEM_BK_SIZE_CH0_S);
|
||||||
|
|
||||||
|
CLR_GDMA_CH_BITS(DMA_OUT_CONF1_CH0_REG,
|
||||||
|
chan,
|
||||||
|
DMA_OUT_EXT_MEM_BK_SIZE_CH0_M);
|
||||||
|
SET_GDMA_CH_BITS(DMA_OUT_CONF1_CH0_REG, chan, val);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
val = ((uint32_t)type << DMA_IN_EXT_MEM_BK_SIZE_CH0_S);
|
||||||
|
|
||||||
|
CLR_GDMA_CH_BITS(DMA_IN_CONF1_CH0_REG,
|
||||||
|
chan,
|
||||||
|
DMA_IN_EXT_MEM_BK_SIZE_CH0_M);
|
||||||
|
SET_GDMA_CH_BITS(DMA_IN_CONF1_CH0_REG, chan, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp32s3_dma_init
|
* Name: esp32s3_dma_init
|
||||||
*
|
*
|
||||||
|
@ -104,6 +104,13 @@ enum esp32s3_dma_periph_e
|
|||||||
ESP32S3_DMA_PERIPH_NUM,
|
ESP32S3_DMA_PERIPH_NUM,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum esp32s3_dma_ext_memblk_e
|
||||||
|
{
|
||||||
|
ESP32S3_DMA_EXT_MEMBLK_16B = 0,
|
||||||
|
ESP32S3_DMA_EXT_MEMBLK_32B = 1,
|
||||||
|
ESP32S3_DMA_EXT_MEMBLK_64B = 2
|
||||||
|
};
|
||||||
|
|
||||||
/* DMA descriptor type */
|
/* DMA descriptor type */
|
||||||
|
|
||||||
struct esp32s3_dmadesc_s
|
struct esp32s3_dmadesc_s
|
||||||
@ -230,6 +237,25 @@ void esp32s3_dma_disable(int chan, bool tx);
|
|||||||
|
|
||||||
void esp32s3_dma_wait_idle(int chan, bool tx);
|
void esp32s3_dma_wait_idle(int chan, bool tx);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp32s3_dma_set_ext_memblk
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Configure DMA external memory block size.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* chan - DMA channel
|
||||||
|
* tx - true: TX mode; false: RX mode
|
||||||
|
* type - block size type
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void esp32s3_dma_set_ext_memblk(int chan, bool tx,
|
||||||
|
enum esp32s3_dma_ext_memblk_e type);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp32s3_dma_init
|
* Name: esp32s3_dma_init
|
||||||
*
|
*
|
||||||
|
@ -63,21 +63,32 @@
|
|||||||
|
|
||||||
void up_idle(void)
|
void up_idle(void)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_SUPPRESS_INTERRUPTS) || defined(CONFIG_SUPPRESS_TIMER_INTS)
|
/* Report loop explanation here */
|
||||||
/* If the system is idle and there are no timer interrupts, then process
|
|
||||||
* "fake" timer interrupts. Hopefully, something will wake up.
|
|
||||||
*/
|
|
||||||
|
|
||||||
nxsched_process_timer();
|
#ifdef CONFIG_ESP32S3_SPEED_UP_ISR
|
||||||
|
for (; ; )
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_SUPPRESS_INTERRUPTS) || defined(CONFIG_SUPPRESS_TIMER_INTS)
|
||||||
|
/* If the system is idle and there are no timer interrupts, then
|
||||||
|
* process "fake" timer interrupts. Hopefully, something will wake up.
|
||||||
|
*/
|
||||||
|
|
||||||
|
nxsched_process_timer();
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* This would be an appropriate place to put some MCU-specific logic to
|
/* This would be an appropriate place to put some MCU-specific logic
|
||||||
* sleep in a reduced power mode until an interrupt occurs to save power
|
* to sleep in a reduced power mode until an interrupt occurs to save
|
||||||
*/
|
* power.
|
||||||
|
*/
|
||||||
|
|
||||||
#if XCHAL_HAVE_INTERRUPTS
|
# if XCHAL_HAVE_INTERRUPTS
|
||||||
__asm__ __volatile__ ("waiti 0");
|
__asm__ __volatile__ ("waiti 0");
|
||||||
#endif
|
# endif
|
||||||
|
#endif /* CONFIG_SUPPRESS_INTERRUPTS || CONFIG_SUPPRESS_TIMER_INTS */
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_SPEED_UP_ISR
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
1010
arch/xtensa/src/esp32s3/esp32s3_lcd.c
Normal file
1010
arch/xtensa/src/esp32s3/esp32s3_lcd.c
Normal file
File diff suppressed because it is too large
Load Diff
1349
arch/xtensa/src/esp32s3/hardware/esp32s3_lcd_cam.h
Normal file
1349
arch/xtensa/src/esp32s3/hardware/esp32s3_lcd_cam.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -11,3 +11,14 @@ config ESP32S3_MERGE_BINS
|
|||||||
device.
|
device.
|
||||||
This is only useful when the path to binary files (e.g. bootloader)
|
This is only useful when the path to binary files (e.g. bootloader)
|
||||||
is provided via the ESPTOOL_BINDIR variable.
|
is provided via the ESPTOOL_BINDIR variable.
|
||||||
|
|
||||||
|
config ESP32S3_SPEED_UP_ISR
|
||||||
|
bool "Speed up ISR"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
Move ESP32-S3's interrupt, OS timer tick, and scheduler functions
|
||||||
|
from Flash to IRAM. This can speed up interrupt service processing
|
||||||
|
and also reduce reading data from Flash.
|
||||||
|
|
||||||
|
If you run applications that need continue reading data from PSRAM,
|
||||||
|
such as LCD display, please select this option.
|
||||||
|
@ -27,3 +27,5 @@
|
|||||||
api_vhci_host_send_packet = API_vhci_host_send_packet;
|
api_vhci_host_send_packet = API_vhci_host_send_packet;
|
||||||
api_vhci_host_register_callback = API_vhci_host_register_callback;
|
api_vhci_host_register_callback = API_vhci_host_register_callback;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
PROVIDE( cache_writeback_addr = Cache_WriteBack_Addr );
|
@ -88,6 +88,31 @@ SECTIONS
|
|||||||
*libsched.a:sched_thistask.*(.literal .text .literal.* .text.*)
|
*libsched.a:sched_thistask.*(.literal .text .literal.* .text.*)
|
||||||
*libsched.a:spinlock.*(.literal .text .literal.* .text.*)
|
*libsched.a:spinlock.*(.literal .text .literal.* .text.*)
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_SPEED_UP_ISR
|
||||||
|
*libarch.a:xtensa_irqdispatch.*(.literal.xtensa_irq_dispatch .text.xtensa_irq_dispatch)
|
||||||
|
*libarch.a:xtensa_switchcontext.*(.literal.up_switch_context .text.up_switch_context)
|
||||||
|
*libarch.a:xtensa_modifyreg32.*(.literal.modifyreg32 .text.modifyreg32)
|
||||||
|
|
||||||
|
*libarch.a:esp32s3_irq.*(.literal.xtensa_int_decode .text.xtensa_int_decode)
|
||||||
|
*libarch.a:esp32s3_timerisr.*(.literal.systimer_isr .text.systimer_isr)
|
||||||
|
*libarch.a:esp32s3_idle.*(.literal.up_idle .text.up_idle)
|
||||||
|
*libarch.a:esp32s3_dma.*(.literal.esp32s3_dma_load .text.esp32s3_dma_load \
|
||||||
|
.literal.esp32s3_dma_enable .text.esp32s3_dma_enable)
|
||||||
|
|
||||||
|
*libsched.a:sched_processtimer.*(.literal.nxsched_process_timer .text.nxsched_process_timer)
|
||||||
|
*libsched.a:clock_initialize.*(.literal.clock_timer .text.clock_timer)
|
||||||
|
*libsched.a:wd_start.*(.literal.wd_timer .text.wd_timer)
|
||||||
|
*libsched.a:sched_roundrobin.*(.literal.nxsched_process_roundrobin .text.nxsched_process_roundrobin)
|
||||||
|
*libsched.a:sched_reprioritizertr.*(.literal.nxsched_reprioritize_rtr .text.nxsched_reprioritize_rtr)
|
||||||
|
*libsched.a:sched_removereadytorun.*(.literal.nxsched_remove_readytorun .text.nxsched_remove_readytorun)
|
||||||
|
*libsched.a:sched_addreadytorun.*(.literal.nxsched_add_readytorun .text.nxsched_add_readytorun)
|
||||||
|
*libsched.a:sched_addprioritized.*(.literal.nxsched_add_prioritized .text.nxsched_add_prioritized)
|
||||||
|
*libsched.a:sched_mergepending.*(.literal.nxsched_merge_pending .text.nxsched_merge_pending)
|
||||||
|
*libsched.a:sched_resumescheduler.*(.literal.nxsched_resume_scheduler .text.nxsched_resume_scheduler)
|
||||||
|
|
||||||
|
*libc.a:bin/sq_remfirst.*(.literal.sq_remfirst .text.sq_remfirst)
|
||||||
|
#endif
|
||||||
|
|
||||||
*(.wifirxiram .wifirxiram.*)
|
*(.wifirxiram .wifirxiram.*)
|
||||||
*(.wifi0iram .wifi0iram.*)
|
*(.wifi0iram .wifi0iram.*)
|
||||||
*(.wifiorslpiram .wifiorslpiram.*)
|
*(.wifiorslpiram .wifiorslpiram.*)
|
||||||
|
@ -49,4 +49,30 @@ config ESP32S3_SPIFLASH_LITTLEFS
|
|||||||
|
|
||||||
endchoice # ESP32S3_SPIFLASH_FS
|
endchoice # ESP32S3_SPIFLASH_FS
|
||||||
|
|
||||||
|
config ESP32S3_BOARD_I2C
|
||||||
|
bool
|
||||||
|
default y if ESP32S3_I2C0 || ESP32S3_I2C1
|
||||||
|
|
||||||
|
config ESP32S3_BOARD_IOEXPANDER
|
||||||
|
bool "Enable Board IO Expander"
|
||||||
|
default n
|
||||||
|
depends on ESP32S3_BOARD_I2C
|
||||||
|
---help---
|
||||||
|
Enable board IO expander support, IC is TC9554.
|
||||||
|
|
||||||
|
config ESP32S3_BOARD_LCD
|
||||||
|
bool "Enable Board LCD"
|
||||||
|
default n
|
||||||
|
depends on ESP32S3_LCD
|
||||||
|
select ESP32S3_BOARD_IOEXPANDER
|
||||||
|
---help---
|
||||||
|
Enable board LCD support, IC is GC9503CV.
|
||||||
|
|
||||||
|
config ESP32S3_BOARD_TOUCHPAD
|
||||||
|
bool "Enable Board Touchpad"
|
||||||
|
default n
|
||||||
|
depends on ESP32S3_BOARD_I2C
|
||||||
|
---help---
|
||||||
|
Enable board touchpad support, IC is FT5X06.
|
||||||
|
|
||||||
endif # ARCH_BOARD_ESP32S3_LCD_EV
|
endif # ARCH_BOARD_ESP32S3_LCD_EV
|
||||||
|
63
boards/xtensa/esp32s3/esp32s3-lcd-ev/configs/lcd/defconfig
Normal file
63
boards/xtensa/esp32s3/esp32s3-lcd-ev/configs/lcd/defconfig
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#
|
||||||
|
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||||
|
#
|
||||||
|
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||||
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
|
# modifications.
|
||||||
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
|
CONFIG_ARCH="xtensa"
|
||||||
|
CONFIG_ARCH_BOARD="esp32s3-lcd-ev"
|
||||||
|
CONFIG_ARCH_BOARD_COMMON=y
|
||||||
|
CONFIG_ARCH_BOARD_ESP32S3_LCD_EV=y
|
||||||
|
CONFIG_ARCH_CHIP="esp32s3"
|
||||||
|
CONFIG_ARCH_CHIP_ESP32S3=y
|
||||||
|
CONFIG_ARCH_CHIP_ESP32S3WROOM2=y
|
||||||
|
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||||
|
CONFIG_ARCH_STACKDUMP=y
|
||||||
|
CONFIG_ARCH_XTENSA=y
|
||||||
|
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||||
|
CONFIG_BUILTIN=y
|
||||||
|
CONFIG_DEBUG_ASSERTIONS=y
|
||||||
|
CONFIG_DEBUG_ASSERTIONS_EXPRESSION=y
|
||||||
|
CONFIG_DEBUG_FEATURES=y
|
||||||
|
CONFIG_ESP32S3_BOARD_LCD=y
|
||||||
|
CONFIG_ESP32S3_DMA=y
|
||||||
|
CONFIG_ESP32S3_I2C0=y
|
||||||
|
CONFIG_ESP32S3_I2C0_SCLPIN=18
|
||||||
|
CONFIG_ESP32S3_I2C0_SDAPIN=8
|
||||||
|
CONFIG_ESP32S3_LCD=y
|
||||||
|
CONFIG_ESP32S3_LCD_CLOCK_MHZ=3
|
||||||
|
CONFIG_ESP32S3_SPEED_UP_ISR=y
|
||||||
|
CONFIG_ESP32S3_SPIRAM=y
|
||||||
|
CONFIG_ESP32S3_SPIRAM_MODE_OCT=y
|
||||||
|
CONFIG_ESP32S3_SPIRAM_SPEED_80M=y
|
||||||
|
CONFIG_ESP32S3_UART0=y
|
||||||
|
CONFIG_EXAMPLES_FB=y
|
||||||
|
CONFIG_FS_PROCFS=y
|
||||||
|
CONFIG_HAVE_CXX=y
|
||||||
|
CONFIG_HAVE_CXXINITIALIZE=y
|
||||||
|
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||||
|
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||||
|
CONFIG_INIT_STACKSIZE=3072
|
||||||
|
CONFIG_INTELHEX_BINARY=y
|
||||||
|
CONFIG_MM_REGIONS=2
|
||||||
|
CONFIG_NDEBUG=y
|
||||||
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
CONFIG_NSH_FILEIOSIZE=512
|
||||||
|
CONFIG_NSH_LINELEN=64
|
||||||
|
CONFIG_NSH_READLINE=y
|
||||||
|
CONFIG_PREALLOC_TIMERS=4
|
||||||
|
CONFIG_RAM_SIZE=114688
|
||||||
|
CONFIG_RAM_START=0x20000000
|
||||||
|
CONFIG_RR_INTERVAL=200
|
||||||
|
CONFIG_SCHED_WAITPID=y
|
||||||
|
CONFIG_START_DAY=6
|
||||||
|
CONFIG_START_MONTH=12
|
||||||
|
CONFIG_START_YEAR=2011
|
||||||
|
CONFIG_SYSLOG_BUFFER=y
|
||||||
|
CONFIG_SYSTEM_NSH=y
|
||||||
|
CONFIG_UART0_SERIAL_CONSOLE=y
|
78
boards/xtensa/esp32s3/esp32s3-lcd-ev/configs/lvgl/defconfig
Normal file
78
boards/xtensa/esp32s3/esp32s3-lcd-ev/configs/lvgl/defconfig
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#
|
||||||
|
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||||
|
#
|
||||||
|
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||||
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
|
# modifications.
|
||||||
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
|
CONFIG_ARCH="xtensa"
|
||||||
|
CONFIG_ARCH_BOARD="esp32s3-lcd-ev"
|
||||||
|
CONFIG_ARCH_BOARD_COMMON=y
|
||||||
|
CONFIG_ARCH_BOARD_ESP32S3_LCD_EV=y
|
||||||
|
CONFIG_ARCH_CHIP="esp32s3"
|
||||||
|
CONFIG_ARCH_CHIP_ESP32S3=y
|
||||||
|
CONFIG_ARCH_CHIP_ESP32S3WROOM2=y
|
||||||
|
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||||
|
CONFIG_ARCH_STACKDUMP=y
|
||||||
|
CONFIG_ARCH_XTENSA=y
|
||||||
|
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||||
|
CONFIG_BUILTIN=y
|
||||||
|
CONFIG_DEBUG_ASSERTIONS=y
|
||||||
|
CONFIG_DEBUG_ASSERTIONS_EXPRESSION=y
|
||||||
|
CONFIG_DEBUG_FEATURES=y
|
||||||
|
CONFIG_ESP32S3_BOARD_LCD=y
|
||||||
|
CONFIG_ESP32S3_BOARD_TOUCHPAD=y
|
||||||
|
CONFIG_ESP32S3_DMA=y
|
||||||
|
CONFIG_ESP32S3_I2C0=y
|
||||||
|
CONFIG_ESP32S3_I2C0_SCLPIN=18
|
||||||
|
CONFIG_ESP32S3_I2C0_SDAPIN=8
|
||||||
|
CONFIG_ESP32S3_LCD=y
|
||||||
|
CONFIG_ESP32S3_LCD_CLOCK_MHZ=3
|
||||||
|
CONFIG_ESP32S3_SPEED_UP_ISR=y
|
||||||
|
CONFIG_ESP32S3_SPIRAM=y
|
||||||
|
CONFIG_ESP32S3_SPIRAM_MODE_OCT=y
|
||||||
|
CONFIG_ESP32S3_SPIRAM_SPEED_80M=y
|
||||||
|
CONFIG_ESP32S3_UART0=y
|
||||||
|
CONFIG_EXAMPLES_LVGLDEMO=y
|
||||||
|
CONFIG_FS_PROCFS=y
|
||||||
|
CONFIG_FT5X06_POLLMODE=y
|
||||||
|
CONFIG_FT5X06_SINGLEPOINT=y
|
||||||
|
CONFIG_GRAPHICS_LVGL=y
|
||||||
|
CONFIG_HAVE_CXX=y
|
||||||
|
CONFIG_HAVE_CXXINITIALIZE=y
|
||||||
|
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||||
|
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||||
|
CONFIG_INIT_STACKSIZE=3072
|
||||||
|
CONFIG_INPUT=y
|
||||||
|
CONFIG_INPUT_FT5X06=y
|
||||||
|
CONFIG_INTELHEX_BINARY=y
|
||||||
|
CONFIG_LV_FONT_MONTSERRAT_20=y
|
||||||
|
CONFIG_LV_MEMCPY_MEMSET_STD=y
|
||||||
|
CONFIG_LV_MEM_CUSTOM=y
|
||||||
|
CONFIG_LV_PORT_USE_FBDEV=y
|
||||||
|
CONFIG_LV_PORT_USE_TOUCHPAD=y
|
||||||
|
CONFIG_LV_TICK_CUSTOM=y
|
||||||
|
CONFIG_LV_TICK_CUSTOM_INCLUDE="port/lv_port_tick.h"
|
||||||
|
CONFIG_LV_USE_DEMO_WIDGETS=y
|
||||||
|
CONFIG_MM_REGIONS=2
|
||||||
|
CONFIG_NDEBUG=y
|
||||||
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
CONFIG_NSH_FILEIOSIZE=512
|
||||||
|
CONFIG_NSH_LINELEN=64
|
||||||
|
CONFIG_NSH_READLINE=y
|
||||||
|
CONFIG_PREALLOC_TIMERS=4
|
||||||
|
CONFIG_RAM_SIZE=114688
|
||||||
|
CONFIG_RAM_START=0x20000000
|
||||||
|
CONFIG_RR_INTERVAL=200
|
||||||
|
CONFIG_SCHED_LPWORK=y
|
||||||
|
CONFIG_SCHED_WAITPID=y
|
||||||
|
CONFIG_START_DAY=6
|
||||||
|
CONFIG_START_MONTH=12
|
||||||
|
CONFIG_START_YEAR=2011
|
||||||
|
CONFIG_SYSLOG_BUFFER=y
|
||||||
|
CONFIG_SYSTEM_NSH=y
|
||||||
|
CONFIG_UART0_SERIAL_CONSOLE=y
|
@ -41,6 +41,18 @@ ifeq ($(CONFIG_WS2812),y)
|
|||||||
CSRCS += esp32s3_ws2812.c
|
CSRCS += esp32s3_ws2812.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ESP32S3_BOARD_IOEXPANDER),y)
|
||||||
|
CSRCS += esp32s3_ioexpander.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ESP32S3_BOARD_LCD),y)
|
||||||
|
CSRCS += esp32s3_lcd.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ESP32S3_BOARD_TOUCHPAD),y)
|
||||||
|
CSRCS += esp32s3_touchscreen.c
|
||||||
|
endif
|
||||||
|
|
||||||
DEPPATH += --dep-path board
|
DEPPATH += --dep-path board
|
||||||
VPATH += :board
|
VPATH += :board
|
||||||
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board
|
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board
|
||||||
|
@ -39,6 +39,10 @@
|
|||||||
|
|
||||||
#define BUTTON_BOOT 0
|
#define BUTTON_BOOT 0
|
||||||
|
|
||||||
|
/* I2C Port */
|
||||||
|
|
||||||
|
#define I2C_PORT 0
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -94,5 +98,99 @@ int board_spiflash_init(void);
|
|||||||
int board_ws2812_initialize(int devno, int spino, uint16_t nleds);
|
int board_ws2812_initialize(int devno, int spino, uint16_t nleds);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_lcd_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize LCD.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_ESP32S3_LCD) && defined(CONFIG_ESP32S3_BOARD_IOEXPANDER)
|
||||||
|
int board_lcd_initialize(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_touchscreen_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize touchpad.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_BOARD_TOUCHPAD
|
||||||
|
int board_touchscreen_initialize(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_ioexpander_set_pin
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Configure pin mode through the IO expander.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* input_mask - pin bit mask which need to be set input, if set pin 0 to
|
||||||
|
* to be input, please make: input_mask = (1 << 0)
|
||||||
|
* output_mask - pin bit mask which need to be set output, if set pin 1 to
|
||||||
|
* to be input, please make: output_mask = (1 << 1)
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_BOARD_IOEXPANDER
|
||||||
|
int board_ioexpander_set_pin(uint8_t input_mask, uint8_t output_mask);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_ioexpander_output
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set pin output level through the IO expander.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* pin - pin number
|
||||||
|
* level - true for high level, false for low.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_BOARD_IOEXPANDER
|
||||||
|
int board_ioexpander_output(int pin, bool level);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_ioexpander_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize IO expander driver.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_BOARD_IOEXPANDER
|
||||||
|
int board_ioexpander_initialize(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_LCD_EV_SRC_ESP32S3_LCD_EV_H */
|
#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_LCD_EV_SRC_ESP32S3_LCD_EV_H */
|
||||||
|
@ -225,6 +225,22 @@ int esp32s3_bringup(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_BOARD_LCD
|
||||||
|
ret = board_lcd_initialize();
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "Failed to initialize LCD driver\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP32S3_BOARD_TOUCHPAD
|
||||||
|
ret = board_touchscreen_initialize();
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "Failed to initialize touchscreen driver\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* If we got here then perhaps not all initialization was successful, but
|
/* If we got here then perhaps not all initialization was successful, but
|
||||||
* at least enough succeeded to bring-up NSH with perhaps reduced
|
* at least enough succeeded to bring-up NSH with perhaps reduced
|
||||||
* capabilities.
|
* capabilities.
|
||||||
|
171
boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_ioexpander.c
Normal file
171
boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_ioexpander.c
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_ioexpander.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <debug.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/board.h>
|
||||||
|
|
||||||
|
#include "esp32s3_i2c.h"
|
||||||
|
#include "esp32s3-lcd-ev.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define BOARD_IOEXPANDER_I2C_PORT I2C_PORT
|
||||||
|
|
||||||
|
#define BOARD_IOEXPANDER_I2C_ADDR (0x20)
|
||||||
|
#define BOARD_IOEXPANDER_I2C_CLOCK (400 * 1000)
|
||||||
|
|
||||||
|
#define BOARD_IOEXPANDER_SET_DIRECTION (3)
|
||||||
|
#define BOARD_IOEXPANDER_SET_OUTPUT (1)
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
struct ioexpander
|
||||||
|
{
|
||||||
|
struct i2c_master_s *i2c;
|
||||||
|
uint8_t output_val;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static const struct i2c_config_s g_i2c_config =
|
||||||
|
{
|
||||||
|
.frequency = BOARD_IOEXPANDER_I2C_CLOCK,
|
||||||
|
.address = BOARD_IOEXPANDER_I2C_ADDR,
|
||||||
|
.addrlen = 7
|
||||||
|
};
|
||||||
|
static struct ioexpander g_ioexpander;
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_ioexpander_set_pin
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Configure pin mode through the IO expander.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* input_mask - pin bit mask which need to be set input, if set pin 0 to
|
||||||
|
* to be input, please make: input_mask = (1 << 0)
|
||||||
|
* output_mask - pin bit mask which need to be set output, if set pin 1 to
|
||||||
|
* to be input, please make: output_mask = (1 << 1)
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int board_ioexpander_set_pin(uint8_t input_mask, uint8_t output_mask)
|
||||||
|
{
|
||||||
|
uint8_t data[2] =
|
||||||
|
{
|
||||||
|
BOARD_IOEXPANDER_SET_DIRECTION, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
if (input_mask & output_mask)
|
||||||
|
{
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
data[1] |= input_mask;
|
||||||
|
data[1] &= ~output_mask;
|
||||||
|
|
||||||
|
return i2c_write(g_ioexpander.i2c, &g_i2c_config, data, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_ioexpander_output
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set pin output level through the IO expander.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* pin - pin number
|
||||||
|
* level - true for high level, false for low.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int board_ioexpander_output(int pin, bool level)
|
||||||
|
{
|
||||||
|
uint8_t data[2] =
|
||||||
|
{
|
||||||
|
BOARD_IOEXPANDER_SET_OUTPUT, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
DEBUGASSERT(pin < 8);
|
||||||
|
|
||||||
|
if (level)
|
||||||
|
{
|
||||||
|
g_ioexpander.output_val |= 1 << pin;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_ioexpander.output_val &= ~(1 << pin);
|
||||||
|
}
|
||||||
|
|
||||||
|
data[1] = g_ioexpander.output_val;
|
||||||
|
|
||||||
|
return i2c_write(g_ioexpander.i2c, &g_i2c_config, data, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_ioexpander_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize IO expander driver.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int board_ioexpander_initialize(void)
|
||||||
|
{
|
||||||
|
g_ioexpander.i2c = esp32s3_i2cbus_initialize(BOARD_IOEXPANDER_I2C_PORT);
|
||||||
|
if (!g_ioexpander.i2c)
|
||||||
|
{
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
683
boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_lcd.c
Normal file
683
boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_lcd.c
Normal file
@ -0,0 +1,683 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_lcd.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <debug.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/board.h>
|
||||||
|
#include <nuttx/video/fb.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
|
|
||||||
|
#include "esp32s3_gpio.h"
|
||||||
|
#include "esp32s3-lcd-ev.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define CS_PIN 1
|
||||||
|
#define SCK_PIN 2
|
||||||
|
#define SDO_PIN 3
|
||||||
|
|
||||||
|
#define DELAY(us) esp_rom_delay_us(us)
|
||||||
|
#define CS(v) DEBUGASSERT(board_ioexpander_output(CS_PIN, v ? 1 : 0) == 0)
|
||||||
|
#define SCK(v) DEBUGASSERT(board_ioexpander_output(SCK_PIN, v ? 1 : 0) == 0)
|
||||||
|
#define SDO(v) DEBUGASSERT(board_ioexpander_output(SDO_PIN, v ? 1 : 0) == 0)
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
struct lcd_config_data
|
||||||
|
{
|
||||||
|
uint8_t cmd;
|
||||||
|
uint8_t data_bytes;
|
||||||
|
uint8_t data[52];
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* External Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
extern void esp_rom_delay_us(uint32_t us);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* LCD GC9503CV configuration parameters */
|
||||||
|
|
||||||
|
static const struct lcd_config_data g_lcd_config[] =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
/* Enable manufacture command set in page 0 */
|
||||||
|
|
||||||
|
0xf0, 5,
|
||||||
|
{
|
||||||
|
0x55, 0xaa, 0x52, 0x08, 0x00
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xf6, 2,
|
||||||
|
{
|
||||||
|
0x5a, 0x87
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xc1, 1,
|
||||||
|
{
|
||||||
|
0x3f
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xc2, 1,
|
||||||
|
{
|
||||||
|
0x0e
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xc6, 1,
|
||||||
|
{
|
||||||
|
0xf8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xc9, 1,
|
||||||
|
{
|
||||||
|
0x10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xcd, 1,
|
||||||
|
{
|
||||||
|
0x25
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xf8, 1,
|
||||||
|
{
|
||||||
|
0x8a
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xac, 1,
|
||||||
|
{
|
||||||
|
0x45
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Set VGH to be 13(15.00) */
|
||||||
|
|
||||||
|
0xa0, 1,
|
||||||
|
{
|
||||||
|
0xdd
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xa7, 1,
|
||||||
|
{
|
||||||
|
0x47
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xfa, 4,
|
||||||
|
{
|
||||||
|
0x00, 0x00, 0x00, 0x04
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Set VGL to be 5(-10.5) */
|
||||||
|
|
||||||
|
0x86, 4,
|
||||||
|
{
|
||||||
|
0x99, 0xa3, 0xa3, 0x51
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xa3, 1,
|
||||||
|
{
|
||||||
|
0xee
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xfd, 3,
|
||||||
|
{
|
||||||
|
0x3c, 0x3c, 0x00
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x71, 1,
|
||||||
|
{
|
||||||
|
0x48
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x72, 1,
|
||||||
|
{
|
||||||
|
0x48
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x73, 2,
|
||||||
|
{
|
||||||
|
0x00, 0x44
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x97, 1,
|
||||||
|
{
|
||||||
|
0xee
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x83, 1,
|
||||||
|
{
|
||||||
|
0x93
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Set adjustment of VGMP */
|
||||||
|
|
||||||
|
0x9a, 1,
|
||||||
|
{
|
||||||
|
0x72
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Set adjustment of VGMN */
|
||||||
|
|
||||||
|
0x9b, 1,
|
||||||
|
{
|
||||||
|
0x5a
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Set adjustment of VGSPN */
|
||||||
|
|
||||||
|
0x82, 2,
|
||||||
|
{
|
||||||
|
0x2c, 0x2c
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x6d, 32,
|
||||||
|
{
|
||||||
|
0x00, 0x1f, 0x19, 0x1a, 0x10, 0x0e, 0x0c, 0x0a,
|
||||||
|
0x02, 0x07, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
|
||||||
|
0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x08, 0x01,
|
||||||
|
0x09, 0x0b, 0x0d, 0x0f, 0x1a, 0x19, 0x1f, 0x00
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x64, 16,
|
||||||
|
{
|
||||||
|
0x38, 0x05, 0x01, 0xdb, 0x03, 0x03, 0x38, 0x04,
|
||||||
|
0x01, 0xdc, 0x03, 0x03, 0x7a, 0x7a, 0x7a, 0x7a
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x65, 16,
|
||||||
|
{
|
||||||
|
0x38, 0x03, 0x01, 0xdd, 0x03, 0x03, 0x38, 0x02,
|
||||||
|
0x01, 0xde, 0x03, 0x03, 0x7a, 0x7a, 0x7a, 0x7a
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x66, 16,
|
||||||
|
{
|
||||||
|
0x38, 0x01, 0x01, 0xdf, 0x03, 0x03, 0x38, 0x00,
|
||||||
|
0x01, 0xe0, 0x03, 0x03, 0x7a, 0x7a, 0x7a, 0x7a
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x67, 16,
|
||||||
|
{
|
||||||
|
0x30, 0x01, 0x01, 0xe1, 0x03, 0x03, 0x30, 0x02,
|
||||||
|
0x01, 0xe2, 0x03, 0x03, 0x7a, 0x7a, 0x7a, 0x7a
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x68, 13,
|
||||||
|
{
|
||||||
|
0x00, 0x08, 0x15, 0x08, 0x15, 0x7a, 0x7a, 0x08,
|
||||||
|
0x15, 0x08, 0x15, 0x7a, 0x7a
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x60, 8,
|
||||||
|
{
|
||||||
|
0x38, 0x08, 0x7a, 0x7a, 0x38, 0x09, 0x7a, 0x7a
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x63, 8,
|
||||||
|
{
|
||||||
|
0x31, 0xe4, 0x7a, 0x7a, 0x31, 0xe5, 0x7a, 0x7a
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x69, 7,
|
||||||
|
{
|
||||||
|
0x04, 0x22, 0x14, 0x22, 0x14, 0x22, 0x08
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x6b, 1,
|
||||||
|
{
|
||||||
|
0x07
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x7a, 2,
|
||||||
|
{
|
||||||
|
0x08, 0x13
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0x7b, 2,
|
||||||
|
{
|
||||||
|
0x08, 0x13
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xd1, 52,
|
||||||
|
{
|
||||||
|
0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18,
|
||||||
|
0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47,
|
||||||
|
0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68,
|
||||||
|
0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6,
|
||||||
|
0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba,
|
||||||
|
0x03, 0xc5, 0x03, 0xd0, 0x03, 0xe0, 0x03, 0xea,
|
||||||
|
0x03, 0xfa, 0x03, 0xff
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xd2, 52,
|
||||||
|
{
|
||||||
|
0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18,
|
||||||
|
0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47,
|
||||||
|
0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68,
|
||||||
|
0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6,
|
||||||
|
0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba,
|
||||||
|
0x03, 0xc5, 0x03, 0xd0, 0x03, 0xe0, 0x03, 0xea,
|
||||||
|
0x03, 0xfa, 0x03, 0xff
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xd3, 52,
|
||||||
|
{
|
||||||
|
0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18,
|
||||||
|
0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47,
|
||||||
|
0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68,
|
||||||
|
0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6,
|
||||||
|
0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba,
|
||||||
|
0x03, 0xc5, 0x03, 0xd0, 0x03, 0xe0, 0x03, 0xea,
|
||||||
|
0x03, 0xfa, 0x03, 0xff
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xd4, 52,
|
||||||
|
{
|
||||||
|
0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18,
|
||||||
|
0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47,
|
||||||
|
0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68,
|
||||||
|
0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6,
|
||||||
|
0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba,
|
||||||
|
0x03, 0xc5, 0x03, 0xd0, 0x03, 0xe0, 0x03, 0xea,
|
||||||
|
0x03, 0xfa, 0x03, 0xff
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xd5, 52,
|
||||||
|
{
|
||||||
|
0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18,
|
||||||
|
0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47,
|
||||||
|
0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68,
|
||||||
|
0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6,
|
||||||
|
0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba,
|
||||||
|
0x03, 0xc5, 0x03, 0xd0, 0x03, 0xe0, 0x03, 0xea,
|
||||||
|
0x03, 0xfa, 0x03, 0xff
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Unknown */
|
||||||
|
|
||||||
|
0xd6, 52,
|
||||||
|
{
|
||||||
|
0x00, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x18,
|
||||||
|
0x00, 0x21, 0x00, 0x2a, 0x00, 0x35, 0x00, 0x47,
|
||||||
|
0x00, 0x56, 0x00, 0x90, 0x00, 0xe5, 0x01, 0x68,
|
||||||
|
0x01, 0xd5, 0x01, 0xd7, 0x02, 0x36, 0x02, 0xa6,
|
||||||
|
0x02, 0xee, 0x03, 0x48, 0x03, 0xa0, 0x03, 0xba,
|
||||||
|
0x03, 0xc5, 0x03, 0xd0, 0x03, 0xe0, 0x03, 0xea,
|
||||||
|
0x03, 0xfa, 0x03, 0xff
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* 18-bit Pixel */
|
||||||
|
|
||||||
|
0x3a, 1,
|
||||||
|
{
|
||||||
|
0x60
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Enter sleep out mode, no parameters */
|
||||||
|
|
||||||
|
0x11, 0
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* 9-bit SPI Rising Mode
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: send_byte
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Send 9-bit data to LCD.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* data - TX data
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void send_byte(uint16_t data)
|
||||||
|
{
|
||||||
|
for (int n = 0; n < 9; n++)
|
||||||
|
{
|
||||||
|
if (data & 0x0100)
|
||||||
|
{
|
||||||
|
SDO(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDO(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
data = data << 1;
|
||||||
|
|
||||||
|
SCK(0);
|
||||||
|
DELAY(10);
|
||||||
|
SCK(1);
|
||||||
|
DELAY(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: send_cmd
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Send command to LCD.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* cmd - TX command
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void send_cmd(uint8_t cmd)
|
||||||
|
{
|
||||||
|
uint16_t spi_data = cmd;
|
||||||
|
|
||||||
|
CS(0);
|
||||||
|
DELAY(10);
|
||||||
|
|
||||||
|
send_byte(spi_data);
|
||||||
|
|
||||||
|
DELAY(10);
|
||||||
|
CS(1);
|
||||||
|
SCK(0);
|
||||||
|
SDO(0);
|
||||||
|
DELAY(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: send_data
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Send data to LCD.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* cmd - TX command
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void send_data(uint8_t data)
|
||||||
|
{
|
||||||
|
uint16_t spi_data = data;
|
||||||
|
|
||||||
|
CS(0);
|
||||||
|
DELAY(10);
|
||||||
|
|
||||||
|
spi_data &= 0x00ff;
|
||||||
|
spi_data |= 0x0100;
|
||||||
|
send_byte(spi_data);
|
||||||
|
|
||||||
|
DELAY(10);
|
||||||
|
CS(1);
|
||||||
|
SCK(0);
|
||||||
|
SDO(0);
|
||||||
|
DELAY(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: lcd_initialize_spi
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize write only SPI interface by IO expander.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void lcd_initialize_spi(void)
|
||||||
|
{
|
||||||
|
uint8_t pin_mask = (1 << CS_PIN) |
|
||||||
|
(1 << SCK_PIN) |
|
||||||
|
(1 << SDO_PIN);
|
||||||
|
|
||||||
|
DEBUGASSERT(board_ioexpander_initialize() == 0);
|
||||||
|
DEBUGASSERT(board_ioexpander_set_pin(0, pin_mask) == 0);
|
||||||
|
|
||||||
|
CS(1);
|
||||||
|
SCK(1);
|
||||||
|
SDO(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: lcd_configure_display
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Configure LCD with global configuration parameters.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void lcd_configure_display(void)
|
||||||
|
{
|
||||||
|
/* Pull-up V-SYNC pin to start configurating LCD */
|
||||||
|
|
||||||
|
esp32s3_configgpio(CONFIG_ESP32S3_LCD_VSYNC_PIN, OUTPUT | PULLUP);
|
||||||
|
esp32s3_gpiowrite(CONFIG_ESP32S3_LCD_VSYNC_PIN, 1);
|
||||||
|
|
||||||
|
for (int i = 0; i < nitems(g_lcd_config); i++)
|
||||||
|
{
|
||||||
|
send_cmd(g_lcd_config[i].cmd);
|
||||||
|
|
||||||
|
for (int j = 0; j < g_lcd_config[i].data_bytes; j++)
|
||||||
|
{
|
||||||
|
send_data(g_lcd_config[i].data[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait until LCD is ready */
|
||||||
|
|
||||||
|
nxsig_usleep(120 * 1000);
|
||||||
|
|
||||||
|
/* Display on */
|
||||||
|
|
||||||
|
send_cmd(0x29);
|
||||||
|
|
||||||
|
/* Wait until LCD is on */
|
||||||
|
|
||||||
|
nxsig_usleep(20 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_lcd_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize LCD.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int board_lcd_initialize(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
lcd_initialize_spi();
|
||||||
|
lcd_configure_display();
|
||||||
|
|
||||||
|
#ifdef CONFIG_VIDEO_FB
|
||||||
|
/* Initialize and register the framebuffer driver */
|
||||||
|
|
||||||
|
ret = fb_register(0, 0);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: fb_register() failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
UNUSED(ret);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
191
boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_touchscreen.c
Normal file
191
boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_touchscreen.c
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_touchscreen.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <syslog.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/input/ft5x06.h>
|
||||||
|
|
||||||
|
#include "esp32s3_i2c.h"
|
||||||
|
#include "esp32s3-lcd-ev.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define BOARD_TOUCHSCREEN_I2C_PORT I2C_PORT
|
||||||
|
|
||||||
|
#define BOARD_TOUCHSCREEN_I2C_ADDR (0x38)
|
||||||
|
#define BOARD_TOUCHSCREEN_I2C_CLOCK (400 * 1000)
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Function Ptototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CONFIG_FT5X06_POLLMODE
|
||||||
|
static int esp32s3_ft5x06_attach(const struct ft5x06_config_s *config,
|
||||||
|
xcpt_t isr, void *arg);
|
||||||
|
static void esp32s3_ft5x06_enable(const struct ft5x06_config_s *config,
|
||||||
|
bool enable);
|
||||||
|
static void esp32s3_ft5x06_clear(const struct ft5x06_config_s *config);
|
||||||
|
#endif
|
||||||
|
static void esp32s3_ft5x06_wakeup(const struct ft5x06_config_s *config);
|
||||||
|
static void esp32s3_ft5x06_nreset(const struct ft5x06_config_s *config,
|
||||||
|
bool state);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static const struct ft5x06_config_s g_ft5x06_config =
|
||||||
|
{
|
||||||
|
.address = BOARD_TOUCHSCREEN_I2C_ADDR,
|
||||||
|
.frequency = BOARD_TOUCHSCREEN_I2C_CLOCK,
|
||||||
|
#ifndef CONFIG_FT5X06_POLLMODE
|
||||||
|
.attach = esp32s3_ft5x06_attach,
|
||||||
|
.enable = esp32s3_ft5x06_enable,
|
||||||
|
.clear = esp32s3_ft5x06_clear,
|
||||||
|
#endif
|
||||||
|
.wakeup = esp32s3_ft5x06_wakeup,
|
||||||
|
.nreset = esp32s3_ft5x06_nreset
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CONFIG_FT5X06_POLLMODE
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp32s3_ft5x06_attach
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Attach an FT5x06 interrupt handler to a GPIO interrupt
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static int esp32s3_ft5x06_attach(const struct ft5x06_config_s *config,
|
||||||
|
xcpt_t isr, void *arg)
|
||||||
|
{
|
||||||
|
/* We do not have interrupt pin in the implementation */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp32s3_ft5x06_enable
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Enable or disable a GPIO interrupt
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void esp32s3_ft5x06_enable(const struct ft5x06_config_s *config,
|
||||||
|
bool enable)
|
||||||
|
{
|
||||||
|
/* We do not have interrupt pin in the implementation */
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp32s3_ft5x06_clear
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Acknowledge/clear any pending GPIO interrupt
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void esp32s3_ft5x06_clear(const struct ft5x06_config_s *config)
|
||||||
|
{
|
||||||
|
/* We do not have interrupt pin in the implementation */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp32s3_ft5x06_wakeup
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Issue WAKE interrupt to FT5x06 to change the FT5x06 from Hibernate to
|
||||||
|
* Active mode.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void esp32s3_ft5x06_wakeup(const struct ft5x06_config_s *config)
|
||||||
|
{
|
||||||
|
/* We do not have access to the WAKE pin in the implementation */
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp32s3_ft5x06_nreset
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Control the chip reset pin
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void esp32s3_ft5x06_nreset(const struct ft5x06_config_s *config,
|
||||||
|
bool state)
|
||||||
|
{
|
||||||
|
/* We do not have access to the RESET pin in the implementation */
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_touchscreen_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize touchpad.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int board_touchscreen_initialize(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct i2c_master_s *i2c;
|
||||||
|
|
||||||
|
i2c = esp32s3_i2cbus_initialize(BOARD_TOUCHSCREEN_I2C_PORT);
|
||||||
|
if (!i2c)
|
||||||
|
{
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ft5x06_register(i2c, &g_ft5x06_config, 0);
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user