boards/arm/stm32/nucleo-f446re: added support for ili9225 display
Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This commit is contained in:
parent
cf7cfa682b
commit
4b8df9f835
@ -558,3 +558,18 @@ Configurations
|
|||||||
|
|
||||||
Functionality of CAN driver can be tested by calling application
|
Functionality of CAN driver can be tested by calling application
|
||||||
"can" in NuttShell. This application sends 100 messages over CAN 1.
|
"can" in NuttShell. This application sends 100 messages over CAN 1.
|
||||||
|
|
||||||
|
lcd:
|
||||||
|
----
|
||||||
|
This is basically an nsh configuration (see above) with added support
|
||||||
|
of ILI9225 176x220 TFT display and test framebuffer application.
|
||||||
|
|
||||||
|
Display connection is set to SPI 3 and pinout is following:
|
||||||
|
|
||||||
|
CS D8
|
||||||
|
RST D6
|
||||||
|
RS D7
|
||||||
|
SDA D4
|
||||||
|
CLK D3
|
||||||
|
|
||||||
|
Framebuffer application can be started from terminal by typing "fb".
|
||||||
|
63
boards/arm/stm32/nucleo-f446re/configs/lcd/defconfig
Normal file
63
boards/arm/stm32/nucleo-f446re/configs/lcd/defconfig
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#
|
||||||
|
# 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_NSH_DISABLE_IFCONFIG is not set
|
||||||
|
# CONFIG_NSH_DISABLE_PS is not set
|
||||||
|
# CONFIG_STM32_FLASH_PREFETCH is not set
|
||||||
|
CONFIG_ARCH="arm"
|
||||||
|
CONFIG_ARCH_BOARD="nucleo-f446re"
|
||||||
|
CONFIG_ARCH_BOARD_NUCLEO_F446RE=y
|
||||||
|
CONFIG_ARCH_BUTTONS=y
|
||||||
|
CONFIG_ARCH_CHIP="stm32"
|
||||||
|
CONFIG_ARCH_CHIP_STM32=y
|
||||||
|
CONFIG_ARCH_CHIP_STM32F446R=y
|
||||||
|
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||||
|
CONFIG_ARCH_STACKDUMP=y
|
||||||
|
CONFIG_BOARD_LATE_INITIALIZE=y
|
||||||
|
CONFIG_BOARD_LOOPSPERMSEC=8499
|
||||||
|
CONFIG_BUILTIN=y
|
||||||
|
CONFIG_DRIVERS_VIDEO=y
|
||||||
|
CONFIG_EXAMPLES_FB=y
|
||||||
|
CONFIG_HAVE_CXX=y
|
||||||
|
CONFIG_HAVE_CXXINITIALIZE=y
|
||||||
|
CONFIG_INTELHEX_BINARY=y
|
||||||
|
CONFIG_LCD=y
|
||||||
|
CONFIG_LCD_FRAMEBUFFER=y
|
||||||
|
CONFIG_LCD_ILI9225=y
|
||||||
|
CONFIG_LCD_PORTRAIT=y
|
||||||
|
CONFIG_MAX_TASKS=16
|
||||||
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
CONFIG_NSH_FILEIOSIZE=512
|
||||||
|
CONFIG_NSH_LINELEN=64
|
||||||
|
CONFIG_NSH_READLINE=y
|
||||||
|
CONFIG_PREALLOC_TIMERS=4
|
||||||
|
CONFIG_RAM_SIZE=131072
|
||||||
|
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=14
|
||||||
|
CONFIG_START_MONTH=10
|
||||||
|
CONFIG_START_YEAR=2014
|
||||||
|
CONFIG_STM32_CRC=y
|
||||||
|
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||||
|
CONFIG_STM32_OTGFS=y
|
||||||
|
CONFIG_STM32_PWR=y
|
||||||
|
CONFIG_STM32_SPI3=y
|
||||||
|
CONFIG_STM32_USART2=y
|
||||||
|
CONFIG_SYSTEM_NSH=y
|
||||||
|
CONFIG_TASK_NAME_SIZE=0
|
||||||
|
CONFIG_TESTING_OSTEST=y
|
||||||
|
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||||
|
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||||
|
CONFIG_VIDEO_FB=y
|
@ -300,6 +300,10 @@
|
|||||||
#define GPIO_SPI2_MOSI GPIO_SPI2_MOSI_1
|
#define GPIO_SPI2_MOSI GPIO_SPI2_MOSI_1
|
||||||
#define GPIO_SPI2_SCK GPIO_SPI2_SCK_2
|
#define GPIO_SPI2_SCK GPIO_SPI2_SCK_2
|
||||||
|
|
||||||
|
#define GPIO_SPI3_MISO GPIO_SPI3_MISO_1
|
||||||
|
#define GPIO_SPI3_MOSI GPIO_SPI3_MOSI_1
|
||||||
|
#define GPIO_SPI3_SCK GPIO_SPI3_SCK_1
|
||||||
|
|
||||||
/* CAN */
|
/* CAN */
|
||||||
|
|
||||||
#define GPIO_CAN1_RX GPIO_CAN1_RX_2
|
#define GPIO_CAN1_RX GPIO_CAN1_RX_2
|
||||||
|
@ -32,6 +32,10 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y)
|
|||||||
CSRCS += stm32_buttons.c
|
CSRCS += stm32_buttons.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_LCD_ILI9225),y)
|
||||||
|
CSRCS += stm32_ili9225.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADC),y)
|
ifeq ($(CONFIG_ADC),y)
|
||||||
CSRCS += stm32_adc.c
|
CSRCS += stm32_adc.c
|
||||||
ifeq ($(CONFIG_INPUT_AJOYSTICK),y)
|
ifeq ($(CONFIG_INPUT_AJOYSTICK),y)
|
||||||
|
@ -58,6 +58,8 @@
|
|||||||
# undef HAVE_MMCSD
|
# undef HAVE_MMCSD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define HAVE_LCD 1
|
||||||
|
|
||||||
/* LED. User LD2: the green LED is a user LED connected to Arduino signal
|
/* LED. User LD2: the green LED is a user LED connected to Arduino signal
|
||||||
* D13 corresponding to MCU I/O PA5 (pin 21) or PB13 (pin 34) depending on
|
* D13 corresponding to MCU I/O PA5 (pin 21) or PB13 (pin 34) depending on
|
||||||
* the STM32 target.
|
* the STM32 target.
|
||||||
@ -125,6 +127,15 @@
|
|||||||
GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN5)
|
GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN5)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LCD
|
||||||
|
#define GPIO_LCD_CS (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
|
||||||
|
GPIO_OUTPUT_SET | GPIO_PORTA | GPIO_PIN9)
|
||||||
|
#define GPIO_LCD_RST (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
|
||||||
|
GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN10)
|
||||||
|
#define GPIO_LCD_RS (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
|
||||||
|
GPIO_OUTPUT_SET | GPIO_PORTA | GPIO_PIN8)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Devices on the onboard bus.
|
/* Devices on the onboard bus.
|
||||||
*
|
*
|
||||||
* Note that these are unshifted addresses.
|
* Note that these are unshifted addresses.
|
||||||
@ -220,6 +231,9 @@ extern struct spi_dev_s *g_spi1;
|
|||||||
#ifdef CONFIG_STM32_SPI2
|
#ifdef CONFIG_STM32_SPI2
|
||||||
extern struct spi_dev_s *g_spi2;
|
extern struct spi_dev_s *g_spi2;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_STM32_SPI3
|
||||||
|
extern struct spi_dev_s *g_spi3;
|
||||||
|
#endif
|
||||||
#ifdef HAVE_MMCSD
|
#ifdef HAVE_MMCSD
|
||||||
extern struct sdio_dev_s *g_sdio;
|
extern struct sdio_dev_s *g_sdio;
|
||||||
#endif
|
#endif
|
||||||
|
@ -47,6 +47,10 @@
|
|||||||
#include "board_qencoder.h"
|
#include "board_qencoder.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_VIDEO_FB
|
||||||
|
#include <nuttx/video/fb.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "nucleo-f446re.h"
|
#include "nucleo-f446re.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -132,6 +136,16 @@ int stm32_bringup(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_VIDEO_FB
|
||||||
|
/* Initialize and register the framebuffer driver */
|
||||||
|
|
||||||
|
ret = fb_register(0, 0);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: fb_register() failed %d\n", ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SENSORS_QENCODER
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
/* Initialize and register the qencoder driver */
|
/* Initialize and register the qencoder driver */
|
||||||
|
|
||||||
|
125
boards/arm/stm32/nucleo-f446re/src/stm32_ili9225.c
Normal file
125
boards/arm/stm32/nucleo-f446re/src/stm32_ili9225.c
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/stm32/nucleo-f446re/src/stm32_ili9225.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/ili9225.h>
|
||||||
|
|
||||||
|
#include "stm32_spi.h"
|
||||||
|
#include "nucleo-f446re.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define LCD_SPI_PORTNO 3
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* 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(GPIO_LCD_RST);
|
||||||
|
|
||||||
|
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(GPIO_LCD_RST, 0);
|
||||||
|
up_mdelay(1);
|
||||||
|
stm32_gpiowrite(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 = ili9225_lcdinitialize(g_spidev);
|
||||||
|
if (!g_lcd)
|
||||||
|
{
|
||||||
|
lcderr("ERROR: Failed to bind SPI port 3 to LCD %d\n", devno);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lcdinfo("SPI port 3 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);
|
||||||
|
}
|
@ -53,6 +53,9 @@ struct spi_dev_s *g_spi1;
|
|||||||
#ifdef CONFIG_STM32_SPI2
|
#ifdef CONFIG_STM32_SPI2
|
||||||
struct spi_dev_s *g_spi2;
|
struct spi_dev_s *g_spi2;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_STM32_SPI3
|
||||||
|
struct spi_dev_s *g_spi3;
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
@ -88,6 +91,18 @@ void weak_function stm32_spidev_initialize(void)
|
|||||||
|
|
||||||
g_spi2 = stm32_spibus_initialize(2);
|
g_spi2 = stm32_spibus_initialize(2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_STM32_SPI3
|
||||||
|
/* Configure SPI-based devices */
|
||||||
|
|
||||||
|
g_spi3 = stm32_spibus_initialize(3);
|
||||||
|
|
||||||
|
#ifdef HAVE_LCD
|
||||||
|
stm32_configgpio(GPIO_LCD_CS);
|
||||||
|
stm32_configgpio(GPIO_LCD_RS);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -157,6 +172,10 @@ void stm32_spi3select(FAR struct spi_dev_s *dev, uint32_t devid,
|
|||||||
{
|
{
|
||||||
spiinfo("devid: %d CS: %s\n",
|
spiinfo("devid: %d CS: %s\n",
|
||||||
(int)devid, selected ? "assert" : "de-assert");
|
(int)devid, selected ? "assert" : "de-assert");
|
||||||
|
|
||||||
|
#ifdef HAVE_LCD
|
||||||
|
stm32_gpiowrite(GPIO_LCD_CS, !selected);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, uint32_t devid)
|
uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||||
@ -206,7 +225,8 @@ int stm32_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
|||||||
#ifdef CONFIG_STM32_SPI3
|
#ifdef CONFIG_STM32_SPI3
|
||||||
int stm32_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
int stm32_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||||
{
|
{
|
||||||
return OK;
|
stm32_gpiowrite(GPIO_LCD_RS, !cmd);
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_SPI_CMDDATA */
|
#endif /* CONFIG_SPI_CMDDATA */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user