forked from xuos/xiuos
				
			add wifi esp8285 and lcd driver for xidatong-riscv64 on nuttx
it is OK
This commit is contained in:
		
						commit
						8e5c61c487
					
				|  | @ -1,29 +1,37 @@ | ||||||
| SRC_FILES := test_shell.c |  | ||||||
| 
 |  | ||||||
| ifeq ($(CONFIG_USER_TEST_ADC),y) |  | ||||||
| 	SRC_FILES += test_adc.c |  | ||||||
| endif |  | ||||||
| 
 |  | ||||||
| ifeq ($(CONFIG_USER_TEST_DAC),y) |  | ||||||
| 	SRC_FILES += test_dac.c |  | ||||||
| endif |  | ||||||
| 
 |  | ||||||
| ifeq ($(CONFIG_USER_TEST_SEMC),y) |  | ||||||
| 	SRC_FILES += test_extsram.c |  | ||||||
| endif |  | ||||||
| 
 |  | ||||||
| ifeq ($(CONFIG_USER_TEST_LCD),y) |  | ||||||
| 	SRC_FILES += |  | ||||||
| endif |  | ||||||
| 
 |  | ||||||
| ifeq ($(CONFIG_ADD_XIZI_FETURES),y) |  | ||||||
| include $(KERNEL_ROOT)/compiler.mk |  | ||||||
| endif |  | ||||||
| 
 |  | ||||||
| include $(KERNEL_ROOT)/.config | include $(KERNEL_ROOT)/.config | ||||||
| ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) | ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) | ||||||
|     include $(APPDIR)/Make.defs |     include $(APPDIR)/Make.defs | ||||||
|     CSRCS += test_extsram.c test_lcd.c | 
 | ||||||
|  |     ifeq ($(CONFIG_USER_TEST_SEMC),y) | ||||||
|  |         CSRCS += test_extsram.c | ||||||
|  |     endif | ||||||
|  | 
 | ||||||
|  |     ifeq ($(CONFIG_USER_TEST_LCD),y) | ||||||
|  |         CSRCS += test_lcd.c | ||||||
|  |     endif | ||||||
|  | 
 | ||||||
|     include $(APPDIR)/Application.mk |     include $(APPDIR)/Application.mk | ||||||
|  | 
 | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
|  | ifeq ($(CONFIG_ADD_XIZI_FETURES),y) | ||||||
|  |     SRC_FILES := test_shell.c | ||||||
|  | 
 | ||||||
|  |     ifeq ($(CONFIG_USER_TEST_ADC),y) | ||||||
|  |         SRC_FILES += test_adc.c | ||||||
|  |     endif | ||||||
|  | 
 | ||||||
|  |     ifeq ($(CONFIG_USER_TEST_DAC),y) | ||||||
|  |         SRC_FILES += test_dac.c | ||||||
|  |     endif | ||||||
|  | 
 | ||||||
|  |     ifeq ($(CONFIG_USER_TEST_SEMC),y) | ||||||
|  |         SRC_FILES += test_extsram.c | ||||||
|  |     endif | ||||||
|  | 
 | ||||||
|  |     ifeq ($(CONFIG_USER_TEST_LCD),y) | ||||||
|  |         SRC_FILES += | ||||||
|  |     endif | ||||||
|  | 
 | ||||||
|  |     include $(KERNEL_ROOT)/compiler.mk | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | @ -22,17 +22,11 @@ | ||||||
|  * Included Files |  * Included Files | ||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
| 
 | 
 | ||||||
| #include <nuttx/config.h> | #include <transform.h> | ||||||
| 
 | 
 | ||||||
| #ifdef ADD_NUTTX_FETURES | #ifdef ADD_NUTTX_FETURES | ||||||
| 
 | 
 | ||||||
| #ifdef CONFIG_K210_LCD | #ifdef CONFIG_K210_LCD | ||||||
| 
 |  | ||||||
| #include "nuttx/arch.h" |  | ||||||
| #include "nuttx/lcd/lt768.h" |  | ||||||
| #include "nuttx/lcd/lt768_lib.h" |  | ||||||
| #include "nuttx/lcd/k210_lcd.h" |  | ||||||
| 
 |  | ||||||
| void LcdDemo(void) | void LcdDemo(void) | ||||||
| { | { | ||||||
|     int x1 = 50, y1 = 50, x2 = LCD_XSIZE_TFT - 50, y2 = LCD_YSIZE_TFT - 50; |     int x1 = 50, y1 = 50, x2 = LCD_XSIZE_TFT - 50, y2 = LCD_YSIZE_TFT - 50; | ||||||
|  | @ -72,18 +66,6 @@ void LcdDemo(void) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #else | #else | ||||||
| 
 |  | ||||||
| #include <sys/ioctl.h> |  | ||||||
| #include <sys/mman.h> |  | ||||||
| #include <unistd.h> |  | ||||||
| #include <stdlib.h> |  | ||||||
| #include <stdio.h> |  | ||||||
| #include <fcntl.h> |  | ||||||
| #include <errno.h> |  | ||||||
| 
 |  | ||||||
| #include <nuttx/video/fb.h> |  | ||||||
| #include <nuttx/video/rgbcolors.h> |  | ||||||
| 
 |  | ||||||
| /****************************************************************************
 | /****************************************************************************
 | ||||||
|  * Preprocessor Definitions |  * Preprocessor Definitions | ||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
|  |  | ||||||
|  | @ -384,7 +384,6 @@ int AdapterWifiTestWithParam(int argc, char *argv[]) | ||||||
|     strcpy(apt_param->wifi_ssid, wifi_param[APT_WIFI_PARAM_SSID]); |     strcpy(apt_param->wifi_ssid, wifi_param[APT_WIFI_PARAM_SSID]); | ||||||
|     strcpy(apt_param->wifi_pwd, wifi_param[APT_WIFI_PARAM_PWD]); |     strcpy(apt_param->wifi_pwd, wifi_param[APT_WIFI_PARAM_PWD]); | ||||||
| 
 | 
 | ||||||
| 	printf("2022-10-14 Mr. Wang commit Wifi\n"); |  | ||||||
| 	printf("apt %p ssid %p %s\n", apt_param, apt_param->wifi_ssid); | 	printf("apt %p ssid %p %s\n", apt_param, apt_param->wifi_ssid); | ||||||
| 
 | 
 | ||||||
|     CHECK_RET(AdapterDeviceOpen(adapter)); |     CHECK_RET(AdapterDeviceOpen(adapter)); | ||||||
|  |  | ||||||
|  | @ -238,7 +238,7 @@ static int Esp8285WifiSetUp(struct Adapter *adapter) | ||||||
| 
 | 
 | ||||||
|     result = GetReplyText(reply); |     result = GetReplyText(reply); | ||||||
|     if (!result) { |     if (!result) { | ||||||
|         printf("%s %n get reply failed.\n",__func__,__LINE__); |         printf("%s %d get reply failed.\n",__func__,__LINE__); | ||||||
|         ret = -1; |         ret = -1; | ||||||
|         goto __exit; |         goto __exit; | ||||||
|     } |     } | ||||||
|  | @ -355,7 +355,7 @@ static int Esp8285WifiNetstat(struct Adapter *adapter) | ||||||
| 
 | 
 | ||||||
|     result = GetReplyText(reply); |     result = GetReplyText(reply); | ||||||
|     if (!result) { |     if (!result) { | ||||||
|         printf("%s %n get reply failed.\n",__func__,__LINE__); |         printf("%s %d get reply failed.\n",__func__,__LINE__); | ||||||
|         ret = -1; |         ret = -1; | ||||||
|         goto __exit; |         goto __exit; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -25,11 +25,33 @@ | ||||||
| #include <nuttx/pthread.h> | #include <nuttx/pthread.h> | ||||||
| #include <nuttx/semaphore.h> | #include <nuttx/semaphore.h> | ||||||
| #include <nuttx/time.h> | #include <nuttx/time.h> | ||||||
|  | #include <sys/ioctl.h> | ||||||
| #include <stddef.h> | #include <stddef.h> | ||||||
| #include <stdint.h> | #include <stdint.h> | ||||||
| #include <nuttx/wireless/lpwan/sx127x.h> | #include <unistd.h> | ||||||
|  | #include <stdlib.h> | ||||||
|  | #include <stdio.h> | ||||||
|  | #include <fcntl.h> | ||||||
|  | #include <errno.h> | ||||||
| #include <nuttx/ioexpander/gpio.h> | #include <nuttx/ioexpander/gpio.h> | ||||||
| #include <termios.h> | #include <termios.h> | ||||||
|  | #include <nuttx/arch.h> | ||||||
|  | 
 | ||||||
|  | #ifdef CONFIG_ADAPTER_SX1278 | ||||||
|  | #include <nuttx/wireless/lpwan/sx127x.h> | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #ifdef CONFIG_USER_TEST_LCD | ||||||
|  | #ifdef CONFIG_K210_LCD | ||||||
|  | #  include "nuttx/lcd/lt768.h" | ||||||
|  | #  include "nuttx/lcd/lt768_lib.h" | ||||||
|  | #  include "nuttx/lcd/if_port.h" | ||||||
|  | #else | ||||||
|  | #  include <sys/mman.h> | ||||||
|  | #  include <nuttx/video/fb.h> | ||||||
|  | #  include <nuttx/video/rgbcolors.h> | ||||||
|  | #endif | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| typedef uint8_t uint8; | typedef uint8_t uint8; | ||||||
| typedef uint16_t uint16; | typedef uint16_t uint16; | ||||||
|  |  | ||||||
|  | @ -63,6 +63,5 @@ CONFIG_K210_LCD=y | ||||||
| CONFIG_K210_LCD_BACKLIGHT=y | CONFIG_K210_LCD_BACKLIGHT=y | ||||||
| CONFIG_LCD=y | CONFIG_LCD=y | ||||||
| CONFIG_LCD_LT768=y | CONFIG_LCD_LT768=y | ||||||
| 
 |  | ||||||
| CONFIG_USER_TEST=y | CONFIG_USER_TEST=y | ||||||
| CONFIG_USER_TEST_LCD=y | CONFIG_USER_TEST_LCD=y | ||||||
|  |  | ||||||
|  | @ -0,0 +1,77 @@ | ||||||
|  | # | ||||||
|  | # 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_NSH_DISABLE_LOSMART is not set | ||||||
|  | # CONFIG_STANDARD_SERIAL is not set | ||||||
|  | CONFIG_ADD_NUTTX_FETURES=y | ||||||
|  | CONFIG_ARCH="risc-v" | ||||||
|  | CONFIG_ARCH_BOARD="xidatong-riscv64" | ||||||
|  | CONFIG_ARCH_BOARD_XIDATONG_RISCV64=y | ||||||
|  | CONFIG_ARCH_CHIP="k210" | ||||||
|  | CONFIG_ARCH_CHIP_K210=y | ||||||
|  | CONFIG_ARCH_INTERRUPTSTACK=2048 | ||||||
|  | CONFIG_ARCH_RISCV=y | ||||||
|  | CONFIG_ARCH_STACKDUMP=y | ||||||
|  | CONFIG_BINFMT_DISABLE=y | ||||||
|  | CONFIG_BOARD_LOOPSPERMSEC=46000 | ||||||
|  | CONFIG_BUILTIN=y | ||||||
|  | CONFIG_DEBUG_FULLOPT=y | ||||||
|  | CONFIG_DEBUG_SYMBOLS=y | ||||||
|  | CONFIG_EXAMPLES_HELLO=y | ||||||
|  | CONFIG_IDLETHREAD_STACKSIZE=2048 | ||||||
|  | CONFIG_INIT_ENTRYPOINT="nsh_main" | ||||||
|  | CONFIG_INIT_STACKSIZE=3072 | ||||||
|  | CONFIG_INTELHEX_BINARY=y | ||||||
|  | CONFIG_LIBC_PERROR_STDOUT=y | ||||||
|  | CONFIG_LIBC_STRERROR=y | ||||||
|  | CONFIG_NSH_ARCHINIT=y | ||||||
|  | CONFIG_NSH_BUILTIN_APPS=y | ||||||
|  | CONFIG_NSH_DISABLE_IFUPDOWN=y | ||||||
|  | CONFIG_NSH_DISABLE_MKDIR=y | ||||||
|  | CONFIG_NSH_DISABLE_RM=y | ||||||
|  | CONFIG_NSH_DISABLE_RMDIR=y | ||||||
|  | CONFIG_NSH_DISABLE_UMOUNT=y | ||||||
|  | CONFIG_NSH_READLINE=y | ||||||
|  | CONFIG_NSH_STRERROR=y | ||||||
|  | CONFIG_PREALLOC_TIMERS=4 | ||||||
|  | CONFIG_RAM_SIZE=2097152 | ||||||
|  | CONFIG_RAM_START=0x80400000 | ||||||
|  | CONFIG_RAW_BINARY=y | ||||||
|  | CONFIG_READLINE_CMD_HISTORY=y | ||||||
|  | CONFIG_READLINE_CMD_HISTORY_LEN=100 | ||||||
|  | CONFIG_READLINE_CMD_HISTORY_LINELEN=120 | ||||||
|  | CONFIG_RR_INTERVAL=200 | ||||||
|  | CONFIG_SCHED_WAITPID=y | ||||||
|  | CONFIG_STACK_COLORATION=y | ||||||
|  | CONFIG_START_DAY=28 | ||||||
|  | CONFIG_START_MONTH=12 | ||||||
|  | CONFIG_START_YEAR=2019 | ||||||
|  | CONFIG_SYSTEM_NSH=y | ||||||
|  | CONFIG_TASK_NAME_SIZE=20 | ||||||
|  | CONFIG_TESTING_GETPRIME=y | ||||||
|  | CONFIG_UART0_SERIAL_CONSOLE=y | ||||||
|  | CONFIG_READLINE_TABCOMPLETION=y | ||||||
|  | CONFIG_SCHED_HPWORK=y | ||||||
|  | CONFIG_DEV_GPIO=y | ||||||
|  | CONFIG_BOARDCTL_RESET=y | ||||||
|  | CONFIG_K210_16550_UART=y | ||||||
|  | CONFIG_K210_16550_UART1=y | ||||||
|  | CONFIG_K210_16550_UART1_BASE=0x50210000 | ||||||
|  | CONFIG_K210_16550_UART1_CLOCK=195000000 | ||||||
|  | CONFIG_K210_16550_UART1_IRQ=38 | ||||||
|  | CONFIG_K210_16550_UART1_BAUD=115200 | ||||||
|  | CONFIG_K210_16550_UART1_PARITY=0 | ||||||
|  | CONFIG_K210_16550_UART1_BITS=8 | ||||||
|  | CONFIG_K210_16550_UART1_2STOP=0 | ||||||
|  | CONFIG_K210_16550_UART1_RXBUFSIZE=128 | ||||||
|  | CONFIG_K210_16550_UART1_TXBUFSIZE=128 | ||||||
|  | CONFIG_SUPPORT_CONNECTION_FRAMEWORK=y | ||||||
|  | CONFIG_CONNECTION_FRAMEWORK_DEBUG=y | ||||||
|  | CONFIG_CONNECTION_ADAPTER_WIFI=y | ||||||
|  | CONFIG_ADAPTER_ESP8285_WIFI=y | ||||||
|  | CONFIG_ADAPTER_WIFI_ESP8285="esp8285_wifi" | ||||||
|  | CONFIG_ADAPTER_ESP8285_DRIVER="/dev/ttyS1" | ||||||
|  | @ -55,7 +55,7 @@ | ||||||
| 
 | 
 | ||||||
| /* GPIO pins used by the GPIO Subsystem */ | /* GPIO pins used by the GPIO Subsystem */ | ||||||
| 
 | 
 | ||||||
| #define BOARD_NGPIOOUT    4 /* Amount of GPIO Output pins */ | #define BOARD_NGPIOOUT    3 /* Amount of register GPIO Output pins */ | ||||||
| #define BOARD_NGPIOINT    0 /* Amount of GPIO Input */ | #define BOARD_NGPIOINT    0 /* Amount of GPIO Input */ | ||||||
| 
 | 
 | ||||||
| /****************************************************************************
 | /****************************************************************************
 | ||||||
|  | @ -111,6 +111,14 @@ extern "C" | ||||||
| #define BSP_ENET_NRST   13 | #define BSP_ENET_NRST   13 | ||||||
| #define BSP_ENET_NINT   14 | #define BSP_ENET_NINT   14 | ||||||
| 
 | 
 | ||||||
|  | /* LCD IO */ | ||||||
|  | #define BSP_LCD_NRST        37 | ||||||
|  | #define BSP_LCD_SCLK        38 | ||||||
|  | #define BSP_LCD_MOSI        39 | ||||||
|  | #define BSP_LCD_MISO        40 | ||||||
|  | #define BSP_LCD_NCS         41 | ||||||
|  | #define BSP_LCD_BL_PIN      47 | ||||||
|  | 
 | ||||||
| /* I2C  */ | /* I2C  */ | ||||||
| #define BSP_IIC_SDA     15 | #define BSP_IIC_SDA     15 | ||||||
| #define BSP_IIC_SCL     17 | #define BSP_IIC_SCL     17 | ||||||
|  | @ -157,6 +165,14 @@ extern "C" | ||||||
| #define FPIOA_ENET_MOSI 23 | #define FPIOA_ENET_MOSI 23 | ||||||
| #define FPIOA_ENET_NCS  31 | #define FPIOA_ENET_NCS  31 | ||||||
| 
 | 
 | ||||||
|  | /* LCD FPIOA */ | ||||||
|  | #define FPIOA_LCD_NRST      0 | ||||||
|  | #define FPIOA_LCD_BL        9 | ||||||
|  | #define FPIOA_LCD_SCLK      28 | ||||||
|  | #define FPIOA_LCD_MOSI      29 | ||||||
|  | #define FPIOA_LCD_MISO      23  | ||||||
|  | #define FPIOA_LCD_NCS       31 | ||||||
|  | 
 | ||||||
| /* I2C  */ | /* I2C  */ | ||||||
| #define FPIOA_IIC_SDA  7 | #define FPIOA_IIC_SDA  7 | ||||||
| #define FPIOA_IIC_SCL  8 | #define FPIOA_IIC_SCL  8 | ||||||
|  |  | ||||||
|  | @ -35,7 +35,7 @@ CSRCS += k210_leds.c | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| ifeq ($(CONFIG_K210_LCD),y) | ifeq ($(CONFIG_K210_LCD),y) | ||||||
| CSRCS += k210_lcd.c lcd_demo.c | CSRCS += k210_lcd.c | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| ifeq ($(CONFIG_DEV_GPIO),y) | ifeq ($(CONFIG_DEV_GPIO),y) | ||||||
|  |  | ||||||
|  | @ -32,12 +32,16 @@ | ||||||
| 
 | 
 | ||||||
| #include <nuttx/board.h> | #include <nuttx/board.h> | ||||||
| #include <nuttx/fs/fs.h> | #include <nuttx/fs/fs.h> | ||||||
|  | #include <nuttx/arch.h> | ||||||
| 
 | 
 | ||||||
| #include "k210.h" | #include "k210.h" | ||||||
| #include "k210_clockconfig.h" | #include "k210_clockconfig.h" | ||||||
| #include "xidatong-riscv64.h" | #include "xidatong-riscv64.h" | ||||||
| #include <arch/board/board.h> | #include <arch/board/board.h> | ||||||
| #include "k210_sysctl.h" | #include "k210_sysctl.h" | ||||||
|  | #include "k210_fpioa.h" | ||||||
|  | #include "k210_gpiohs.h" | ||||||
|  | #include "k210_gpio_common.h" | ||||||
| 
 | 
 | ||||||
| #ifdef CONFIG_BSP_USING_CH438 | #ifdef CONFIG_BSP_USING_CH438 | ||||||
| #  include "k210_ch438.h" | #  include "k210_ch438.h" | ||||||
|  | @ -80,18 +84,21 @@ int k210_bringup(void) | ||||||
| 
 | 
 | ||||||
| #ifdef CONFIG_K210_LCD | #ifdef CONFIG_K210_LCD | ||||||
|   k210_sysctl_init(); |   k210_sysctl_init(); | ||||||
|   ret = board_lcd_initialize(); |   board_lcd_initialize(); | ||||||
|   if (ret < 0) |  | ||||||
|     { |  | ||||||
|       syslog(LOG_NOTICE, "board lcd initialize %d\n", ret); |  | ||||||
|     } |  | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef CONFIG_K210_16550_UART1 | #ifdef CONFIG_K210_16550_UART1 | ||||||
|   sysctl_clock_enable(SYSCTL_CLOCK_UART1); |   sysctl_clock_enable(SYSCTL_CLOCK_UART1); | ||||||
|   sysctl_reset(SYSCTL_RESET_UART1); |   sysctl_reset(SYSCTL_RESET_UART1); | ||||||
|   fpioa_set_function(GPIO_WIFI_RXD, FPOA_USART1_RX); | 
 | ||||||
|   fpioa_set_function(GPIO_WIFI_TXD, FPOA_USART1_TX); |   fpioa_set_function(GPIO_WIFI_TXD, FPOA_USART1_RX); | ||||||
|  |   fpioa_set_function(GPIO_WIFI_RXD, FPOA_USART1_TX); | ||||||
|  | 
 | ||||||
|  |   fpioa_set_function(GPIO_WIFI_EN, K210_IO_FUNC_GPIOHS0 + GPIO_WIFI_EN); | ||||||
|  |   k210_gpiohs_set_direction(GPIO_WIFI_EN, GPIO_DM_OUTPUT); | ||||||
|  |   k210_gpiohs_set_value(GPIO_WIFI_EN, GPIO_PV_LOW); | ||||||
|  |   up_mdelay(50); | ||||||
|  |   k210_gpiohs_set_value(GPIO_WIFI_EN, GPIO_PV_HIGH); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifdef CONFIG_K210_16550_UART2 | #ifdef CONFIG_K210_16550_UART2 | ||||||
|  |  | ||||||
|  | @ -88,16 +88,14 @@ static const uint32_t g_gpiooutputs[BOARD_NGPIOOUT] = | ||||||
| { | { | ||||||
|   GPIO_E220_M0,  |   GPIO_E220_M0,  | ||||||
|   GPIO_E220_M1, |   GPIO_E220_M1, | ||||||
|   GPIO_E18_MODE, |   GPIO_E18_MODE | ||||||
|   GPIO_WIFI_EN |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| static const uint32_t g_fpioa[BOARD_NGPIOOUT] = | static const uint32_t g_fpioa[BOARD_NGPIOOUT] = | ||||||
| { | { | ||||||
|   FPIOA_E220_M0,  |   FPIOA_E220_M0,  | ||||||
|   FPIOA_E220_M1, |   FPIOA_E220_M1, | ||||||
|   FPIOA_E18_MODE, |   FPIOA_E18_MODE | ||||||
|   FPIOA_WIFI_EN |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| static struct k210gpio_dev_s g_gpout[BOARD_NGPIOOUT]; | static struct k210gpio_dev_s g_gpout[BOARD_NGPIOOUT]; | ||||||
|  | @ -173,7 +171,6 @@ int k210_gpio_init(void) | ||||||
|                         (K210_IO_FUNC_GPIOHS0 + g_fpioa[i]) | K210_IOFLAG_GPIOHS); |                         (K210_IO_FUNC_GPIOHS0 + g_fpioa[i]) | K210_IOFLAG_GPIOHS); | ||||||
|       k210_gpiohs_set_direction(g_fpioa[i], GPIO_DM_OUTPUT); |       k210_gpiohs_set_direction(g_fpioa[i], GPIO_DM_OUTPUT); | ||||||
|       k210_gpiohs_set_value(g_fpioa[i], false); |       k210_gpiohs_set_value(g_fpioa[i], false); | ||||||
| 
 |  | ||||||
|       pincount++; |       pincount++; | ||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -28,24 +28,24 @@ | ||||||
| #include "nuttx/arch.h" | #include "nuttx/arch.h" | ||||||
| #include "nuttx/lcd/lt768.h" | #include "nuttx/lcd/lt768.h" | ||||||
| #include "nuttx/lcd/lt768_lib.h" | #include "nuttx/lcd/lt768_lib.h" | ||||||
| #include "nuttx/lcd/k210_lcd.h" | #include "nuttx/lcd/if_port.h" | ||||||
|  | #include <nuttx/board.h> | ||||||
|  | #include <arch/board/board.h> | ||||||
| #ifdef CONFIG_LCD_LCDDRV_SPIIF | #ifdef CONFIG_LCD_LCDDRV_SPIIF | ||||||
| #include "nuttx/lcd/lcddrv_spiif.h" | #include "nuttx/lcd/lcddrv_spiif.h" | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | #define NCS_H() k210_gpiohs_set_value(FPIOA_LCD_NCS, GPIO_PV_HIGH); up_udelay(20) | ||||||
|  | #define NCS_L() k210_gpiohs_set_value(FPIOA_LCD_NCS, GPIO_PV_LOW); up_udelay(20) | ||||||
|  | #define CLK_H() k210_gpiohs_set_value(FPIOA_LCD_SCLK, GPIO_PV_HIGH); up_udelay(20) | ||||||
|  | #define CLK_L() k210_gpiohs_set_value(FPIOA_LCD_SCLK, GPIO_PV_LOW); up_udelay(20) | ||||||
|  | #define MOSI_H() k210_gpiohs_set_value(FPIOA_LCD_MOSI, GPIO_PV_HIGH) | ||||||
|  | #define MOSI_L() k210_gpiohs_set_value(FPIOA_LCD_MOSI, GPIO_PV_LOW) | ||||||
|  | 
 | ||||||
| /****************************************************************************
 | /****************************************************************************
 | ||||||
|  * Public Functions |  * Public Functions | ||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
| 
 | 
 | ||||||
| void test_delay(void) |  | ||||||
| { |  | ||||||
|     volatile uint32_t i = 0; |  | ||||||
|     for (i = 0; i < 200; ++i) |  | ||||||
|     { |  | ||||||
|         __asm("NOP"); /* delay */ |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void lcd_pin_init(void) | void lcd_pin_init(void) | ||||||
| { | { | ||||||
|     k210_fpioa_config(BSP_LCD_NRST, HS_GPIO(FPIOA_LCD_NRST) | K210_IOFLAG_GPIOHS); |     k210_fpioa_config(BSP_LCD_NRST, HS_GPIO(FPIOA_LCD_NRST) | K210_IOFLAG_GPIOHS); | ||||||
|  | @ -60,9 +60,9 @@ void lcd_pin_init(void) | ||||||
|     k210_gpiohs_set_direction(FPIOA_LCD_MOSI, GPIO_DM_OUTPUT); |     k210_gpiohs_set_direction(FPIOA_LCD_MOSI, GPIO_DM_OUTPUT); | ||||||
|     k210_gpiohs_set_direction(FPIOA_LCD_NCS, GPIO_DM_OUTPUT); |     k210_gpiohs_set_direction(FPIOA_LCD_NCS, GPIO_DM_OUTPUT); | ||||||
| 
 | 
 | ||||||
|     lcd_set_pin(FPIOA_LCD_SCLK, GPIO_PV_HIGH); |     k210_gpiohs_set_value(FPIOA_LCD_SCLK, GPIO_PV_HIGH); | ||||||
|     lcd_set_pin(FPIOA_LCD_NCS, GPIO_PV_HIGH); |     k210_gpiohs_set_value(FPIOA_LCD_NCS, GPIO_PV_HIGH); | ||||||
|     lcd_set_pin(FPIOA_LCD_NRST, GPIO_PV_HIGH); |     k210_gpiohs_set_value(FPIOA_LCD_NRST, GPIO_PV_HIGH); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void lcd_backlight_init(bool enable) | void lcd_backlight_init(bool enable) | ||||||
|  | @ -86,74 +86,74 @@ uint8_t lcd_transfer_byte(uint8_t dat) | ||||||
| 
 | 
 | ||||||
|     for(i = 0; i < 8; i++) |     for(i = 0; i < 8; i++) | ||||||
|     { |     { | ||||||
|         CLK_H; |         CLK_H(); | ||||||
| 
 | 
 | ||||||
|         // MOSI during falling edge
 |         // MOSI during falling edge
 | ||||||
|         if((dat << i) & 0x80) |         if((dat << i) & 0x80) | ||||||
|         { |         { | ||||||
|             MOSI_H; |             MOSI_H(); | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             MOSI_L; |             MOSI_L(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         CLK_L; |         CLK_L(); | ||||||
| 
 | 
 | ||||||
|         // MISO during rising edge
 |         // MISO during rising edge
 | ||||||
|         rx_data <<= 1; |         rx_data <<= 1; | ||||||
|         if(lcd_get_pin(FPIOA_LCD_MISO)) |         if(k210_gpiohs_get_value(FPIOA_LCD_MISO)) | ||||||
|             rx_data ++; |             rx_data ++; | ||||||
|     } |     } | ||||||
|     CLK_H; |     CLK_H(); | ||||||
|     return rx_data; |     return rx_data; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void LCD_CmdWrite(uint8_t cmd) | void LCD_CmdWrite(uint8_t cmd) | ||||||
| { | { | ||||||
|     NCS_L; |     NCS_L(); | ||||||
|     lcd_transfer_byte(0x00); |     lcd_transfer_byte(0x00); | ||||||
|     lcd_transfer_byte(cmd); |     lcd_transfer_byte(cmd); | ||||||
|     NCS_H; |     NCS_H(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void LCD_DataWrite(uint8_t data) | void LCD_DataWrite(uint8_t data) | ||||||
| { | { | ||||||
|     NCS_L; |     NCS_L(); | ||||||
|     lcd_transfer_byte(0x80); |     lcd_transfer_byte(0x80); | ||||||
|     lcd_transfer_byte(data); |     lcd_transfer_byte(data); | ||||||
|     NCS_H; |     NCS_H(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void LCD_DataWrite_Pixel(uint8_t data) | void LCD_DataWrite_Pixel(uint8_t data) | ||||||
| { | { | ||||||
|     NCS_L; |     NCS_L(); | ||||||
|     lcd_transfer_byte(0x80); |     lcd_transfer_byte(0x80); | ||||||
|     lcd_transfer_byte(data); |     lcd_transfer_byte(data); | ||||||
|     NCS_H; |     NCS_H(); | ||||||
|     NCS_L; |     NCS_L(); | ||||||
|     lcd_transfer_byte(0x80); |     lcd_transfer_byte(0x80); | ||||||
|     lcd_transfer_byte(data >> 8); |     lcd_transfer_byte(data >> 8); | ||||||
|     NCS_H; |     NCS_H(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| uint8_t LCD_StatusRead(void) | uint8_t LCD_StatusRead(void) | ||||||
| { | { | ||||||
|     uint8_t temp = 0; |     uint8_t temp = 0; | ||||||
|     NCS_L; |     NCS_L(); | ||||||
|     lcd_transfer_byte(0x40); |     lcd_transfer_byte(0x40); | ||||||
|     temp = lcd_transfer_byte(0xff); |     temp = lcd_transfer_byte(0xff); | ||||||
|     NCS_H; |     NCS_H(); | ||||||
|     return temp; |     return temp; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| uint8_t LCD_DataRead(void) | uint8_t LCD_DataRead(void) | ||||||
| { | { | ||||||
|     uint8_t temp = 0; |     uint8_t temp = 0; | ||||||
|     NCS_L; |     NCS_L(); | ||||||
|     lcd_transfer_byte(0xc0); |     lcd_transfer_byte(0xc0); | ||||||
|     temp = lcd_transfer_byte(0xff); |     temp = lcd_transfer_byte(0xff); | ||||||
|     NCS_H; |     NCS_H(); | ||||||
|     return temp; |     return temp; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -195,11 +195,12 @@ void lcd_drv_init(void) | ||||||
|  * |  * | ||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
| 
 | 
 | ||||||
| void board_lcd_initialize(void) | int board_lcd_initialize(void) | ||||||
| { | { | ||||||
|     /* Configure the LCD backlight (and turn the backlight off) */ |     /* Configure the LCD backlight (and turn the backlight off) */ | ||||||
|     lcd_backlight_init(true); |     lcd_backlight_init(true); | ||||||
|     lcd_drv_init(); |     lcd_drv_init(); | ||||||
|  |     return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /****************************************************************************
 | /****************************************************************************
 | ||||||
|  |  | ||||||
|  | @ -1,64 +0,0 @@ | ||||||
| /****************************************************************************
 |  | ||||||
|  * lcd_demo.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. |  | ||||||
|  * |  | ||||||
|  ****************************************************************************/ |  | ||||||
| 
 |  | ||||||
| /**
 |  | ||||||
| * @file lcd_demo.c |  | ||||||
| * @brief |  | ||||||
| * @version 1.0.0 |  | ||||||
| * @author AIIT XUOS Lab |  | ||||||
| * @date 2022-07-21 |  | ||||||
| */ |  | ||||||
| 
 |  | ||||||
| /****************************************************************************
 |  | ||||||
|  * Included Files |  | ||||||
|  ****************************************************************************/ |  | ||||||
| 
 |  | ||||||
| #include "nuttx/arch.h" |  | ||||||
| #include "nuttx/lcd/lt768.h" |  | ||||||
| #include "nuttx/lcd/lt768_lib.h" |  | ||||||
| #include "nuttx/lcd/k210_lcd.h" |  | ||||||
| 
 |  | ||||||
| void LcdDemo(void) |  | ||||||
| { |  | ||||||
| //    int x1 = 0, y1 = 0, x2 = LCD_XSIZE_TFT, y2 = LCD_YSIZE_TFT;
 |  | ||||||
|     int x1 = 100, y1 = 100, x2 = 200, y2 = 200; |  | ||||||
| 
 |  | ||||||
|     Main_Image_Start_Address(LCD_START_ADDR); |  | ||||||
|     Main_Image_Width(LCD_XSIZE_TFT); |  | ||||||
|     Main_Window_Start_XY(0, 0); |  | ||||||
|     Canvas_Image_Start_address(LCD_START_ADDR); |  | ||||||
|     Canvas_image_width(LCD_XSIZE_TFT); |  | ||||||
|     Active_Window_XY(0, 0); |  | ||||||
|     Active_Window_WH(LCD_XSIZE_TFT, LCD_YSIZE_TFT); |  | ||||||
|     up_mdelay(10); |  | ||||||
|     Canvas_Image_Start_address(LCD_START_ADDR); |  | ||||||
| 
 |  | ||||||
|     for(int i = 0; i < 3; i++) |  | ||||||
|     { |  | ||||||
|         syslog(LOG_NOTICE, "Disp_demo %d\n", i); |  | ||||||
|         LT768_DrawSquare_Fill(x1, y1, x2, y2, Red); |  | ||||||
|         up_mdelay(2000); |  | ||||||
|         LT768_DrawSquare_Fill(x1, y1, x2, y2, Green); |  | ||||||
|         up_mdelay(2000); |  | ||||||
|         LT768_DrawSquare_Fill(x1, y1, x2, y2, Blue); |  | ||||||
|         up_mdelay(2000); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
|  | @ -101,8 +101,8 @@ void gpio_set_drive_mode(uint8_t pin, gpio_drive_mode_t mode) | ||||||
|     int io_number = fpioa_get_io_by_function(K210_IO_FUNC_GPIO0 + pin); |     int io_number = fpioa_get_io_by_function(K210_IO_FUNC_GPIO0 + pin); | ||||||
|     DEBUGASSERT(io_number >= 0); |     DEBUGASSERT(io_number >= 0); | ||||||
| 
 | 
 | ||||||
|     fpioa_pull_t pull; |     fpioa_pull_t pull = FPIOA_PULL_NONE; | ||||||
|     uint32_t dir; |     uint32_t dir = 0; | ||||||
| 
 | 
 | ||||||
|     switch(mode) |     switch(mode) | ||||||
|     { |     { | ||||||
|  |  | ||||||
|  | @ -1839,11 +1839,9 @@ void Display_ON(void) | ||||||
|     uint8_t temp; |     uint8_t temp; | ||||||
|     LCD_CmdWrite(0x12); |     LCD_CmdWrite(0x12); | ||||||
|     temp = LCD_DataRead(); |     temp = LCD_DataRead(); | ||||||
|     syslog(LOG_NOTICE, "Display_ON.pre_read=%02x\n", temp); |  | ||||||
|     temp |= cSetb6; |     temp |= cSetb6; | ||||||
|     LCD_DataWrite(temp); |     LCD_DataWrite(temp); | ||||||
|     temp = LCD_DataRead(); |     temp = LCD_DataRead(); | ||||||
|     syslog(LOG_NOTICE, "Display_ON.write_read=%02x\n", temp); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Display_OFF(void) | void Display_OFF(void) | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| /****************************************************************************
 | /****************************************************************************
 | ||||||
|  * k210_lcd.h |  * if_port.h | ||||||
|  * |  * | ||||||
|  * Licensed to the Apache Software Foundation (ASF) under one or more |  * Licensed to the Apache Software Foundation (ASF) under one or more | ||||||
|  * contributor license agreements.  See the NOTICE file distributed with |  * contributor license agreements.  See the NOTICE file distributed with | ||||||
|  | @ -19,73 +19,31 @@ | ||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| * @file k210_lcd.h | * @file if_port.h | ||||||
| * @brief | * @brief | ||||||
| * @version 1.0.0 | * @version 1.0.0 | ||||||
| * @author AIIT XUOS Lab | * @author AIIT XUOS Lab | ||||||
| * @date 2022-07-21 | * @date 2022-07-21 | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| #ifndef __K210_LCD_H_ | #ifndef _IF_PORT_H | ||||||
| #define __K210_LCD_H_ | #define _IF_PORT_H | ||||||
| 
 | 
 | ||||||
| #include <stdbool.h> | #include <stdbool.h> | ||||||
| 
 |  | ||||||
| #include <debug.h> | #include <debug.h> | ||||||
| #include <syslog.h> | #include <syslog.h> | ||||||
| 
 |  | ||||||
| #include "nuttx/lcd/lt768.h" | #include "nuttx/lcd/lt768.h" | ||||||
| #include "nuttx/lcd/lt768_lib.h" | #include "nuttx/lcd/lt768_lib.h" | ||||||
| 
 | 
 | ||||||
| //PIN.define
 |  | ||||||
| #define BSP_LCD_NRST        37 |  | ||||||
| #define BSP_LCD_SCLK        38 |  | ||||||
| #define BSP_LCD_MOSI        39 |  | ||||||
| #define BSP_LCD_MISO        40 |  | ||||||
| #define BSP_LCD_NCS         41 |  | ||||||
| #define BSP_LCD_BL_PIN      47 |  | ||||||
| 
 |  | ||||||
| //FPIOA.define
 |  | ||||||
| #define FPIOA_LCD_NRST      0 |  | ||||||
| #define FPIOA_LCD_BL        9 |  | ||||||
| #define FPIOA_LCD_SCLK      28 |  | ||||||
| #define FPIOA_LCD_MOSI      29 |  | ||||||
| #define FPIOA_LCD_MISO      23 //can't use GPIOHS30
 |  | ||||||
| #define FPIOA_LCD_NCS       31 |  | ||||||
| 
 |  | ||||||
| #define GPIO_PV_HIGH 1 // true
 |  | ||||||
| #define GPIO_PV_LOW 0  // false
 |  | ||||||
| 
 |  | ||||||
| #define LCD_START_ADDR 0 | #define LCD_START_ADDR 0 | ||||||
| #define STM32_FSMC_8 0 | #define STM32_FSMC_8 0 | ||||||
| 
 | 
 | ||||||
| #define lcd_set_pin k210_gpiohs_set_value |  | ||||||
| #define lcd_get_pin k210_gpiohs_get_value |  | ||||||
| 
 |  | ||||||
| void test_delay(void); |  | ||||||
| 
 |  | ||||||
| #define lcd_delay() up_udelay(20) |  | ||||||
| 
 |  | ||||||
| #define NCS_H lcd_set_pin(FPIOA_LCD_NCS, GPIO_PV_HIGH); lcd_delay() |  | ||||||
| #define NCS_L lcd_set_pin(FPIOA_LCD_NCS, GPIO_PV_LOW); lcd_delay() |  | ||||||
| 
 |  | ||||||
| #define CLK_H lcd_set_pin(FPIOA_LCD_SCLK, GPIO_PV_HIGH); lcd_delay() |  | ||||||
| #define CLK_L lcd_set_pin(FPIOA_LCD_SCLK, GPIO_PV_LOW); lcd_delay() |  | ||||||
| 
 |  | ||||||
| #define MOSI_H lcd_set_pin(FPIOA_LCD_MOSI, GPIO_PV_HIGH) |  | ||||||
| #define MOSI_L lcd_set_pin(FPIOA_LCD_MOSI, GPIO_PV_LOW) |  | ||||||
| 
 |  | ||||||
| /*----------------------------------------------------------------------------*/ |  | ||||||
| 
 |  | ||||||
| void lcd_backlight_init(bool enable); | void lcd_backlight_init(bool enable); | ||||||
| void lcd_drv_init(void); | void lcd_drv_init(void); | ||||||
| 
 |  | ||||||
| void LCD_CmdWrite(uint8_t cmd); | void LCD_CmdWrite(uint8_t cmd); | ||||||
| void LCD_DataWrite(uint8_t data); | void LCD_DataWrite(uint8_t data); | ||||||
| uint8_t LCD_DataRead(void); | uint8_t LCD_DataRead(void); | ||||||
| uint8_t LCD_StatusRead(void); | uint8_t LCD_StatusRead(void); | ||||||
| void LCD_DataWrite_Pixel(uint8_t data); | void LCD_DataWrite_Pixel(uint8_t data); | ||||||
| 
 | 
 | ||||||
| /*----------------------------------------------------------------------------*/ |  | ||||||
| 
 |  | ||||||
| #endif | #endif | ||||||
		Loading…
	
		Reference in New Issue