forked from xuos/xiuos
				
			Merge pull request 'merge code' (#7) from develop into prepare_for_master
This commit is contained in:
		
						commit
						15ae618a3b
					
				| 
						 | 
					@ -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
 | 
				
			||||||
 ****************************************************************************/
 | 
					 ****************************************************************************/
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -80,11 +80,7 @@ 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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					@ -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