boards/arm/imxrt/teensy-4.x: Added support for LCD display with ST7789
Signed-off-by: Michal Lenc <lencmich@fel.cvut.cz>
This commit is contained in:
parent
570aa3cdac
commit
1502693f93
61
boards/arm/imxrt/teensy-4.x/configs/lcd-4.1/defconfig
Normal file
61
boards/arm/imxrt/teensy-4.x/configs/lcd-4.1/defconfig
Normal file
@ -0,0 +1,61 @@
|
||||
#
|
||||
# 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="arm"
|
||||
CONFIG_ARCH_BOARD="teensy-4.x"
|
||||
CONFIG_ARCH_BOARD_TEENSY_4X=y
|
||||
CONFIG_ARCH_CHIP="imxrt"
|
||||
CONFIG_ARCH_CHIP_IMXRT=y
|
||||
CONFIG_ARCH_CHIP_MIMXRT1062DVL6A=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARMV7M_DCACHE=y
|
||||
CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
|
||||
CONFIG_ARMV7M_ICACHE=y
|
||||
CONFIG_ARMV7M_USEBASEPRI=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=104926
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_CDCACM=y
|
||||
CONFIG_CDCACM_CONSOLE=y
|
||||
CONFIG_DRIVERS_VIDEO=y
|
||||
CONFIG_EXAMPLES_FB=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_IMXRT_LPSPI4=y
|
||||
CONFIG_IMXRT_LPUART1=y
|
||||
CONFIG_IMXRT_USBDEV=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LCD=y
|
||||
CONFIG_LCD_FRAMEBUFFER=y
|
||||
CONFIG_LCD_PORTRAIT=y
|
||||
CONFIG_LCD_ST7789=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_DISABLE_IFUPDOWN=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NSH_USBCONSOLE=y
|
||||
CONFIG_NXFONTS_DISABLE_16BPP=y
|
||||
CONFIG_NXFONTS_DISABLE_1BPP=y
|
||||
CONFIG_NXFONTS_DISABLE_24BPP=y
|
||||
CONFIG_NXFONTS_DISABLE_2BPP=y
|
||||
CONFIG_NXFONTS_DISABLE_32BPP=y
|
||||
CONFIG_NXFONTS_DISABLE_4BPP=y
|
||||
CONFIG_NXFONTS_DISABLE_8BPP=y
|
||||
CONFIG_RAM_SIZE=1048576
|
||||
CONFIG_RAM_START=0x20200000
|
||||
CONFIG_SPI=y
|
||||
CONFIG_SPI_CMDDATA=y
|
||||
CONFIG_START_DAY=14
|
||||
CONFIG_START_MONTH=3
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TEENSY_41=y
|
||||
CONFIG_USBDEV=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
CONFIG_VIDEO_FB=y
|
@ -54,4 +54,8 @@ ifeq ($(CONFIG_IMXRT_ADC),y)
|
||||
CSRCS += imxrt_adc.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LCD_ST7789),y)
|
||||
CSRCS += imxrt_st7789.c
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/boards/Board.mk
|
||||
|
@ -34,7 +34,6 @@
|
||||
|
||||
#include "arm_arch.h"
|
||||
|
||||
#include "imxrt_config.h"
|
||||
#include "imxrt_lpspi.h"
|
||||
#include "imxrt_gpio.h"
|
||||
#include "teensy-4.h"
|
||||
@ -62,6 +61,7 @@ void weak_function imxrt_spidev_initialize(void)
|
||||
#endif
|
||||
#ifdef CONFIG_IMXRT_LPSPI4
|
||||
imxrt_config_gpio(GPIO_LPSPI4_CS); /* LPSPI4 chip select */
|
||||
imxrt_config_gpio(GPIO_LCD_CD);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -146,8 +146,10 @@ void imxrt_lpspi4select(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n", (int)devid,
|
||||
selected ? "assert" : "de-assert");
|
||||
|
||||
if (devid == SPIDEV_DISPLAY(0))
|
||||
{
|
||||
imxrt_gpio_write(GPIO_LPSPI4_CS, !selected);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t imxrt_lpspi4status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
@ -204,7 +206,15 @@ int imxrt_lpspi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
#ifdef CONFIG_IMXRT_LPSPI4
|
||||
int imxrt_lpspi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
if (devid == SPIDEV_DISPLAY(0))
|
||||
{
|
||||
imxrt_gpio_write(GPIO_LCD_CD, !cmd);
|
||||
return OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_SPI_CMDDATA */
|
||||
|
125
boards/arm/imxrt/teensy-4.x/src/imxrt_st7789.c
Normal file
125
boards/arm/imxrt/teensy-4.x/src/imxrt_st7789.c
Normal file
@ -0,0 +1,125 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/imxrt/teensy-4.x/src/imxrt_st7789.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 <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/lcd/lcd.h>
|
||||
#include <nuttx/lcd/st7789.h>
|
||||
|
||||
#include "imxrt_lpspi.h"
|
||||
#include "teensy-4.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define LCD_SPI_PORTNO 4
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static struct spi_dev_s *g_spidev;
|
||||
static struct lcd_dev_s *g_lcd = NULL;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_lcd_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the LCD video hardware. The initial state of the LCD is
|
||||
* fully initialized, display memory cleared, and the LCD ready to use, but
|
||||
* with the power setting at 0 (full off).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_lcd_initialize(void)
|
||||
{
|
||||
imxrt_config_gpio(GPIO_LCD_RST);
|
||||
|
||||
g_spidev = imxrt_lpspibus_initialize(LCD_SPI_PORTNO);
|
||||
if (!g_spidev)
|
||||
{
|
||||
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
imxrt_gpio_write(GPIO_LCD_RST, 0);
|
||||
up_mdelay(1);
|
||||
imxrt_gpio_write(GPIO_LCD_RST, 1);
|
||||
up_mdelay(120);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_lcd_getdev
|
||||
*
|
||||
* Description:
|
||||
* Return a a reference to the LCD object for the specified LCD. This
|
||||
* allows support for multiple LCD devices.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct lcd_dev_s *board_lcd_getdev(int devno)
|
||||
{
|
||||
g_lcd = st7789_lcdinitialize(g_spidev);
|
||||
if (!g_lcd)
|
||||
{
|
||||
lcderr("ERROR: Failed to bind SPI port 4 to LCD %d\n", devno);
|
||||
}
|
||||
else
|
||||
{
|
||||
lcdinfo("SPI port 4 bound to LCD %d\n", devno);
|
||||
return g_lcd;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_lcd_uninitialize
|
||||
*
|
||||
* Description:
|
||||
* Uninitialize the LCD support
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void board_lcd_uninitialize(void)
|
||||
{
|
||||
/* Turn the display off */
|
||||
|
||||
g_lcd->setpower(g_lcd, 0);
|
||||
}
|
@ -79,6 +79,14 @@
|
||||
# define GPIO_LPSPI4_CS (GPIO_OUTPUT | GPIO_OUTPUT_ONE | \
|
||||
GPIO_PORT2 | GPIO_PIN0 | IOMUX_LPSPI4_CS)
|
||||
|
||||
/* LCD dispay */
|
||||
|
||||
# define GPIO_LCD_RST (GPIO_OUTPUT | GPIO_OUTPUT_ONE | \
|
||||
GPIO_PORT2 | GPIO_PIN18 | IOMUX_LPSPI4_CS) /* B1_02 */
|
||||
|
||||
# define GPIO_LCD_CD (GPIO_OUTPUT | GPIO_OUTPUT_ONE | \
|
||||
GPIO_PORT2 | GPIO_PIN19 | IOMUX_LPSPI4_CS) /* B1_03 */
|
||||
|
||||
/* USB OTG ID Pin: GPIO_AD_B1_02 */
|
||||
|
||||
#define GPIO_USBOTG_ID (GPIO_USB_OTG1_ID_1 | IOMUX_USBOTG_ID_DEFAULT) /* AD_B1_02 */
|
||||
|
Loading…
Reference in New Issue
Block a user