mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
stm32f4discovery: Add support to LCD ST7789
This commit is contained in:
committed by
Xiang Xiao
parent
ffc43c2d31
commit
43bce6d9b0
@@ -0,0 +1,69 @@
|
|||||||
|
#
|
||||||
|
# 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_FPU is not set
|
||||||
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
|
# CONFIG_NSH_CMDPARMS is not set
|
||||||
|
CONFIG_ARCH="arm"
|
||||||
|
CONFIG_ARCH_BOARD="stm32f4discovery"
|
||||||
|
CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y
|
||||||
|
CONFIG_ARCH_BUTTONS=y
|
||||||
|
CONFIG_ARCH_CHIP="stm32"
|
||||||
|
CONFIG_ARCH_CHIP_STM32=y
|
||||||
|
CONFIG_ARCH_CHIP_STM32F407VG=y
|
||||||
|
CONFIG_ARCH_STACKDUMP=y
|
||||||
|
CONFIG_BOARD_LATE_INITIALIZE=y
|
||||||
|
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||||
|
CONFIG_BUILTIN=y
|
||||||
|
CONFIG_DRIVERS_VIDEO=y
|
||||||
|
CONFIG_EXAMPLES_FB=y
|
||||||
|
CONFIG_EXAMPLES_HELLO=y
|
||||||
|
CONFIG_FS_PROCFS=y
|
||||||
|
CONFIG_HAVE_CXX=y
|
||||||
|
CONFIG_HAVE_CXXINITIALIZE=y
|
||||||
|
CONFIG_INTELHEX_BINARY=y
|
||||||
|
CONFIG_LCD=y
|
||||||
|
CONFIG_LCD_FRAMEBUFFER=y
|
||||||
|
CONFIG_LCD_NOGETRUN=y
|
||||||
|
CONFIG_LCD_PORTRAIT=y
|
||||||
|
CONFIG_LCD_ST7789=y
|
||||||
|
CONFIG_MAX_TASKS=16
|
||||||
|
CONFIG_MM_REGIONS=2
|
||||||
|
CONFIG_NFILE_DESCRIPTORS=8
|
||||||
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
CONFIG_NSH_FILEIOSIZE=512
|
||||||
|
CONFIG_NSH_LINELEN=64
|
||||||
|
CONFIG_NSH_READLINE=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_PREALLOC_TIMERS=4
|
||||||
|
CONFIG_RAM_SIZE=114688
|
||||||
|
CONFIG_RAM_START=0x20000000
|
||||||
|
CONFIG_RAW_BINARY=y
|
||||||
|
CONFIG_RR_INTERVAL=200
|
||||||
|
CONFIG_SCHED_WAITPID=y
|
||||||
|
CONFIG_SDCLONE_DISABLE=y
|
||||||
|
CONFIG_SPI_CMDDATA=y
|
||||||
|
CONFIG_START_DAY=6
|
||||||
|
CONFIG_START_MONTH=12
|
||||||
|
CONFIG_START_YEAR=2011
|
||||||
|
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||||
|
CONFIG_STM32_PWR=y
|
||||||
|
CONFIG_STM32_SPI1=y
|
||||||
|
CONFIG_STM32_USART2=y
|
||||||
|
CONFIG_SYSTEM_NSH=y
|
||||||
|
CONFIG_USART2_RXBUFSIZE=128
|
||||||
|
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||||
|
CONFIG_USART2_TXBUFSIZE=128
|
||||||
|
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||||
|
CONFIG_VIDEO_FB=y
|
||||||
@@ -175,6 +175,10 @@ ifeq ($(CONFIG_WL_GS2200M),y)
|
|||||||
CSRCS += stm32_gs2200m.c
|
CSRCS += stm32_gs2200m.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_LCD_ST7789),y)
|
||||||
|
CSRCS += stm32_st7789.c
|
||||||
|
endif
|
||||||
|
|
||||||
DEPPATH += --dep-path board
|
DEPPATH += --dep-path board
|
||||||
VPATH += :board
|
VPATH += :board
|
||||||
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
|
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
|
||||||
|
|||||||
@@ -63,7 +63,8 @@
|
|||||||
* Name: stm32_spidev_initialize
|
* Name: stm32_spidev_initialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Called to configure SPI chip select GPIO pins for the stm32f4discovery board.
|
* Called to configure SPI chip select GPIO pins for the stm32f4discovery
|
||||||
|
* board.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@@ -85,11 +86,11 @@ void weak_function stm32_spidev_initialize(void)
|
|||||||
stm32_configgpio(GPIO_MAX7219_CS); /* MAX7219 chip select */
|
stm32_configgpio(GPIO_MAX7219_CS); /* MAX7219 chip select */
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_LPWAN_SX127X
|
#ifdef CONFIG_LPWAN_SX127X
|
||||||
stm32_configgpio(GPIO_SX127X_CS); /* SX127x chip select*/
|
stm32_configgpio(GPIO_SX127X_CS); /* SX127x chip select */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_LCD_ST7567)
|
#if defined(CONFIG_LCD_ST7567) || defined(CONFIG_LCD_ST7567)
|
||||||
stm32_configgpio(STM32_LCD_CS); /* ST7567 chip select */
|
stm32_configgpio(STM32_LCD_CS); /* ST7567/ST7789 chip select */
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_STM32_SPI2) && defined(CONFIG_SENSORS_MAX6675)
|
#if defined(CONFIG_STM32_SPI2) && defined(CONFIG_SENSORS_MAX6675)
|
||||||
stm32_configgpio(GPIO_MAX6675_CS); /* MAX6675 chip select */
|
stm32_configgpio(GPIO_MAX6675_CS); /* MAX6675 chip select */
|
||||||
@@ -123,8 +124,8 @@ void weak_function stm32_spidev_initialize(void)
|
|||||||
* in your board-specific logic. These functions will perform chip
|
* in your board-specific logic. These functions will perform chip
|
||||||
* selection and status operations using GPIOs in the way your board
|
* selection and status operations using GPIOs in the way your board
|
||||||
* is configured.
|
* is configured.
|
||||||
* 3. Add a calls to stm32_spibus_initialize() in your low level application
|
* 3. Add a calls to stm32_spibus_initialize() in your low level
|
||||||
* initialization logic
|
* application initialization logic
|
||||||
* 4. The handle returned by stm32_spibus_initialize() may then be used to
|
* 4. The handle returned by stm32_spibus_initialize() may then be used to
|
||||||
* bind the SPI driver to higher level logic (e.g., calling
|
* bind the SPI driver to higher level logic (e.g., calling
|
||||||
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
|
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
|
||||||
@@ -133,9 +134,11 @@ void weak_function stm32_spidev_initialize(void)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_SPI1
|
#ifdef CONFIG_STM32_SPI1
|
||||||
void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||||
|
bool selected)
|
||||||
{
|
{
|
||||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" :
|
||||||
|
"de-assert");
|
||||||
|
|
||||||
#ifdef CONFIG_ENC28J60
|
#ifdef CONFIG_ENC28J60
|
||||||
if (devid == SPIDEV_ETHERNET(0))
|
if (devid == SPIDEV_ETHERNET(0))
|
||||||
@@ -153,7 +156,7 @@ void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_LCD_ST7567
|
#if defined(CONFIG_LCD_ST7567) || defined(CONFIG_LCD_ST7789)
|
||||||
if (devid == SPIDEV_DISPLAY(0))
|
if (devid == SPIDEV_DISPLAY(0))
|
||||||
{
|
{
|
||||||
stm32_gpiowrite(STM32_LCD_CS, !selected);
|
stm32_gpiowrite(STM32_LCD_CS, !selected);
|
||||||
@@ -196,9 +199,11 @@ uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_SPI2
|
#ifdef CONFIG_STM32_SPI2
|
||||||
void stm32_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
void stm32_spi2select(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||||
|
bool selected)
|
||||||
{
|
{
|
||||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" :
|
||||||
|
"de-assert");
|
||||||
|
|
||||||
#if defined(CONFIG_SENSORS_MAX31855)
|
#if defined(CONFIG_SENSORS_MAX31855)
|
||||||
if (devid == SPIDEV_TEMPERATURE(0))
|
if (devid == SPIDEV_TEMPERATURE(0))
|
||||||
@@ -239,9 +244,11 @@ uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, uint32_t devid)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_SPI3
|
#ifdef CONFIG_STM32_SPI3
|
||||||
void stm32_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
void stm32_spi3select(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||||
|
bool selected)
|
||||||
{
|
{
|
||||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" :
|
||||||
|
"de-assert");
|
||||||
|
|
||||||
#if defined(CONFIG_WL_GS2200M)
|
#if defined(CONFIG_WL_GS2200M)
|
||||||
if (devid == SPIDEV_WIRELESS(0))
|
if (devid == SPIDEV_WIRELESS(0))
|
||||||
@@ -284,7 +291,7 @@ uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, uint32_t devid)
|
|||||||
#ifdef CONFIG_STM32_SPI1
|
#ifdef CONFIG_STM32_SPI1
|
||||||
int stm32_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
int stm32_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_LCD_ST7567
|
#if defined(CONFIG_LCD_ST7567) || defined(CONFIG_LCD_ST7789)
|
||||||
if (devid == SPIDEV_DISPLAY(0))
|
if (devid == SPIDEV_DISPLAY(0))
|
||||||
{
|
{
|
||||||
/* This is the Data/Command control pad which determines whether the
|
/* This is the Data/Command control pad which determines whether the
|
||||||
|
|||||||
@@ -0,0 +1,129 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/stm32/stm32f4discovery/src/stm32_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 "stm32.h"
|
||||||
|
#include "stm32_gpio.h"
|
||||||
|
#include "stm32_spi.h"
|
||||||
|
#include "stm32f4discovery.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define LCD_SPI_PORTNO 1
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
stm32_configgpio(STM32_LCD_RST);
|
||||||
|
stm32_configgpio(STM32_LCD_RS);
|
||||||
|
|
||||||
|
g_spidev = stm32_spibus_initialize(LCD_SPI_PORTNO);
|
||||||
|
if (!g_spidev)
|
||||||
|
{
|
||||||
|
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
stm32_gpiowrite(STM32_LCD_RST, 0);
|
||||||
|
up_mdelay(1);
|
||||||
|
stm32_gpiowrite(STM32_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 %d to LCD %d\n", LCD_SPI_PORTNO,
|
||||||
|
devno);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lcdinfo("SPI port %d bound to LCD %d\n", LCD_SPI_PORTNO, 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);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user