mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 21:34:07 +08:00
Add 2.4 Inch TFT LCD Shield ILI9341 for nucleo-l152re, 8080 MCU 8-bit bus interface I
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
#
|
||||
# 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_LIBC_LONG_LONG is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NX_DISABLE_16BPP is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="nucleo-l152re"
|
||||
CONFIG_ARCH_BOARD_NUCLEO_L152RE=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32L152RE=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=2796
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DISABLE_ENVIRON=y
|
||||
CONFIG_EXAMPLES_HELLO=y
|
||||
CONFIG_EXAMPLES_NX=y
|
||||
CONFIG_EXAMPLES_NXDEMO=y
|
||||
CONFIG_EXAMPLES_NXDEMO_BPP=16
|
||||
CONFIG_EXAMPLES_NX_BPP=16
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_FS_PROCFS_REGISTER=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LCD=y
|
||||
CONFIG_LCD_EXTERNINIT=y
|
||||
CONFIG_LCD_FRAMEBUFFER=y
|
||||
CONFIG_LCD_ILI9341=y
|
||||
CONFIG_LCD_ILI9341_IFACE0=y
|
||||
CONFIG_LCD_ILI9341_IFACE0_PORTRAIT=y
|
||||
CONFIG_LCD_PORTRAIT=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MQ_MAXMSGSIZE=64
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NUNGET_CHARS=0
|
||||
CONFIG_NX=y
|
||||
CONFIG_NXFONT_MONO5X8=y
|
||||
CONFIG_NXFONT_SANS22X29B=y
|
||||
CONFIG_NXFONT_SANS23X27=y
|
||||
CONFIG_NX_BLOCKING=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PTHREAD_MUTEX_UNSAFE=y
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=1536
|
||||
CONFIG_RAM_SIZE=81920
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=19
|
||||
CONFIG_START_MONTH=5
|
||||
CONFIG_START_YEAR=2013
|
||||
CONFIG_STDIO_DISABLE_BUFFERING=y
|
||||
CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG=y
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=1536
|
||||
CONFIG_TLS_NELEM=0
|
||||
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||
CONFIG_USERMAIN_STACKSIZE=1536
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
@@ -217,4 +217,10 @@
|
||||
#define GPIO_USART2_RX GPIO_USART2_RX_1 /* PA3 */
|
||||
#define GPIO_USART2_TX GPIO_USART2_TX_1 /* PA2 */
|
||||
|
||||
/* SPI1 */
|
||||
|
||||
#define GPIO_SPI1_MOSI GPIO_SPI1_MOSI_2
|
||||
#define GPIO_SPI1_MISO GPIO_SPI1_MISO_2
|
||||
#define GPIO_SPI1_SCK GPIO_SPI1_SCK_1
|
||||
|
||||
#endif /* __BOARDS_ARM_STM32_NUCLEO_L152RE_INCLUDE_BOARD_H */
|
||||
|
||||
@@ -36,6 +36,14 @@ ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
||||
CSRCS += stm32_appinitialize.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LCD_ILI9341),y)
|
||||
CSRCS += stm32_ili93418b.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_MMCSD_SPI),y)
|
||||
CSRCS += stm32_spisd.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path board
|
||||
VPATH += :board
|
||||
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/* LED definitions **********************************************************/
|
||||
|
||||
/* The Nucleo L152RE board has three LEDs. Two of these are controlled by
|
||||
* logic on the board and are not available for software control:
|
||||
*
|
||||
@@ -72,6 +73,7 @@
|
||||
#define LED_DRIVER_PATH "/dev/userleds"
|
||||
|
||||
/* Button definitions *******************************************************/
|
||||
|
||||
/* The Nucleo L152RE supports two buttons; only one button is controllable
|
||||
* by software:
|
||||
*
|
||||
@@ -88,4 +90,46 @@
|
||||
|
||||
#define GPIO_BTN_USER (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTC|GPIO_PIN13)
|
||||
|
||||
/* ILI9341 pins */
|
||||
#define GPIO_OUT (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_PULLUP | GPIO_SPEED_40MHz | GPIO_OUTPUT_CLEAR)
|
||||
|
||||
#define GPIO_LCD_RST (GPIO_OUT | GPIO_PORTC | GPIO_PIN1) /* PC1 or PB9 A4 */
|
||||
#define GPIO_LCD_CS (GPIO_OUT | GPIO_PORTB | GPIO_PIN0) /* PB0 A3 */
|
||||
#define GPIO_LCD_RS (GPIO_OUT | GPIO_PORTA | GPIO_PIN4) /* PA4 A2 */
|
||||
#define GPIO_LCD_WR (GPIO_OUT | GPIO_PORTA | GPIO_PIN1) /* PA1 A1 */
|
||||
#define GPIO_LCD_RD (GPIO_OUT | GPIO_PORTA | GPIO_PIN0) /* PA0 A0 */
|
||||
|
||||
/* -------LCD pin------------- mcu ping ------------------------CN9 ---GPIO */
|
||||
|
||||
#define GPIO_LCD_D0 ( GPIO_OUT | GPIO_PORTA | GPIO_PIN9) /* D8 PA9 */
|
||||
#define GPIO_LCD_D1 ( GPIO_OUT | GPIO_PORTC | GPIO_PIN7) /* D9 PC7 */
|
||||
#define GPIO_LCD_D2 ( GPIO_OUT | GPIO_PORTA | GPIO_PIN10) /* D2 PA10 */
|
||||
#define GPIO_LCD_D3 ( GPIO_OUT | GPIO_PORTB | GPIO_PIN3) /* D3 PB3 */
|
||||
#define GPIO_LCD_D4 ( GPIO_OUT | GPIO_PORTB | GPIO_PIN5) /* D4 PB5 */
|
||||
#define GPIO_LCD_D5 ( GPIO_OUT | GPIO_PORTB | GPIO_PIN4) /* D5 PB4 */
|
||||
#define GPIO_LCD_D6 ( GPIO_OUT | GPIO_PORTB | GPIO_PIN10) /* D6 PB10 */
|
||||
#define GPIO_LCD_D7 ( GPIO_OUT | GPIO_PORTA | GPIO_PIN8) /* D7 PA8 */
|
||||
|
||||
#ifdef CONFIG_LCD_ILI9341
|
||||
FAR struct lcd_dev_s *stm32_ili93418b_initialize(void);
|
||||
#endif
|
||||
|
||||
/* SPI sd card */
|
||||
|
||||
#define GPIO_SPI1_CS (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_40MHz | \
|
||||
GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN6)
|
||||
|
||||
#ifdef CONFIG_MMCSD_SPI
|
||||
int stm32_spisd_initialize(int port, int minor);
|
||||
#endif
|
||||
|
||||
/* procfs File System */
|
||||
|
||||
#ifdef CONFIG_FS_PROCFS
|
||||
#ifdef CONFIG_NSH_PROC_MOUNTPOINT
|
||||
#define STM32_PROCFS_MOUNTPOINT CONFIG_NSH_PROC_MOUNTPOINT
|
||||
#else
|
||||
#define STM32_PROCFS_MOUNTPOINT "/proc"
|
||||
#endif
|
||||
#endif /* CONFIG_FS_PROCFS */
|
||||
#endif /* __BOARDS_ARM_STM32_NUCLEO_L152RE_SRC_NUCLEO_L152RE_H */
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/leds/userled.h>
|
||||
@@ -91,6 +92,29 @@ int board_app_initialize(uintptr_t arg)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FS_PROCFS
|
||||
/* Mount the procfs file system */
|
||||
|
||||
ret = mount(0, STM32_PROCFS_MOUNTPOINT, "procfs", 0, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
|
||||
STM32_PROCFS_MOUNTPOINT, ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MMCSD_SPI
|
||||
|
||||
/* Initialize the MMC/SD SPI driver (SPI1 is used) */
|
||||
|
||||
ret = stm32_spisd_initialize(1, CONFIG_NSH_MMCSDMINOR);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize SD slot %d: %d\n",
|
||||
CONFIG_NSH_MMCSDMINOR, ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,138 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/stm32/stm32-l152re/src/stm32_spisd.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 <debug.h>
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/mmcsd.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "arm_arch.h"
|
||||
#include "chip.h"
|
||||
#include "stm32_spi.h"
|
||||
#include "stm32_gpio.h"
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#include "nucleo-l152re.h"
|
||||
|
||||
#if defined(CONFIG_STM32_SPI1)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DISABLE_MOUNTPOINT
|
||||
#error "SD driver requires CONFIG_DISABLE_MOUNTPOINT to be disabled"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name:
|
||||
* stm32_spi1register
|
||||
*
|
||||
* Description:
|
||||
* Registers media change callback
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_spi1register(struct spi_dev_s *dev, spi_mediachange_t callback,
|
||||
void *arg)
|
||||
{
|
||||
/* TODO: media change callback */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
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");
|
||||
#if defined(CONFIG_MMCSD_SPI)
|
||||
stm32_gpiowrite(GPIO_SPI1_CS, !selected);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
uint8_t ret = 0;
|
||||
#if defined(CONFIG_MMCSD_SPI)
|
||||
if (devid == SPIDEV_MMCSD(0))
|
||||
{
|
||||
ret |= SPI_STATUS_PRESENT;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int stm32_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid,
|
||||
bool cmd)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_spisd_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize SPI-based SD card and card detect thread.
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_spisd_initialize(int port, int minor)
|
||||
{
|
||||
struct spi_dev_s *spi;
|
||||
int rv;
|
||||
stm32_configgpio(GPIO_SPI1_SCK);
|
||||
stm32_configgpio(GPIO_SPI1_CS); /* Assign CS */
|
||||
stm32_gpiowrite(GPIO_SPI1_CS, 1); /* Ensure the CS is inactive */
|
||||
|
||||
mcinfo("INFO: Initializing mmcsd port %d minor %d \n",
|
||||
port, minor);
|
||||
|
||||
spi = stm32_spibus_initialize(port);
|
||||
if (spi == NULL)
|
||||
{
|
||||
mcerr("ERROR: Failed to initialize SPI port %d\n", port);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
rv = mmcsd_spislotinitialize(minor, minor, spi);
|
||||
if (rv < 0)
|
||||
{
|
||||
mcerr("ERROR: Failed to bind SPI port %d to SD slot %d\n",
|
||||
port, minor);
|
||||
return rv;
|
||||
}
|
||||
|
||||
spiinfo("INFO: mmcsd card has been initialized successfully\n");
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_STM32_SPI1 */
|
||||
Reference in New Issue
Block a user