boards/raspberrypi-pico: Pico Display Pack (ST7789 LCD) support
This commit is contained in:
parent
aa718dcbac
commit
5699dd86eb
@ -30,6 +30,10 @@ ifeq ($(CONFIG_LCD_SSD1306),y)
|
||||
CSRCS += rp2040_ssd1306.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LCD_ST7789),y)
|
||||
CSRCS += rp2040_st7789.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_RP2040_SPISD),y)
|
||||
CSRCS += rp2040_spisd.c
|
||||
endif
|
||||
|
124
boards/arm/rp2040/common/src/rp2040_st7789.c
Normal file
124
boards/arm/rp2040/common/src/rp2040_st7789.c
Normal file
@ -0,0 +1,124 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/rp2040/common/src/rp2040_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 "rp2040_spi.h"
|
||||
#include "rp2040_gpio.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define LCD_SPI_PORTNO 0
|
||||
|
||||
/****************************************************************************
|
||||
* 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)
|
||||
{
|
||||
g_spidev = rp2040_spibus_initialize(LCD_SPI_PORTNO);
|
||||
if (!g_spidev)
|
||||
{
|
||||
lcderr("ERROR: Failed to initialize SPI port %d\n", LCD_SPI_PORTNO);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* SPI RX is not used. Same pin is used as LCD Data/Command control */
|
||||
|
||||
rp2040_gpio_init(CONFIG_RP2040_SPI0_GPIO);
|
||||
rp2040_gpio_setdir(CONFIG_RP2040_SPI0_GPIO, true);
|
||||
rp2040_gpio_put(CONFIG_RP2040_SPI0_GPIO, true);
|
||||
|
||||
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 0 to LCD %d\n", devno);
|
||||
}
|
||||
else
|
||||
{
|
||||
lcdinfo("SPI port 0 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);
|
||||
}
|
@ -19,6 +19,8 @@ Currently only the following devices are suppored.
|
||||
BOOTSEL mode will be created.
|
||||
- BMP180 sensor at I2C0 (don't forget to define I2C0 GPIOs at "I2C0 GPIO pin assign" in Board Selection menu)
|
||||
- INA219 sensor / module (don't forget to define I2C0 GPIOs at "I2C0 GPIO pin assign" in Board Selection menu)
|
||||
- Pico Display Pack (ST7789 LCD)
|
||||
- RGB leds and buttons are not supported yet.
|
||||
|
||||
Not supported:
|
||||
- All other devices
|
||||
@ -102,6 +104,11 @@ Defconfigs
|
||||
INT ----- GP11 (Pin 15)
|
||||
RESET ----- GP10 (Pin 14)
|
||||
|
||||
- displaypack
|
||||
Pico Display Pack support
|
||||
See the following page for connection:
|
||||
https://shop.pimoroni.com/products/pico-display-pack
|
||||
|
||||
License exceptions
|
||||
==================
|
||||
|
||||
|
@ -0,0 +1,98 @@
|
||||
#
|
||||
# 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_EXAMPLES_NXLINES_DEFAULT_COLORS is not set
|
||||
# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set
|
||||
# CONFIG_LIBC_LONG_LONG is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_DISABLE_DATE is not set
|
||||
# CONFIG_NSH_DISABLE_LOSMART is not set
|
||||
# CONFIG_NSH_DISABLE_PRINTF is not set
|
||||
# CONFIG_NSH_DISABLE_TRUNCATE is not set
|
||||
# CONFIG_NXFONTS_DISABLE_16BPP is not set
|
||||
# CONFIG_NX_DISABLE_16BPP is not set
|
||||
# CONFIG_NX_PACKEDMSFIRST is not set
|
||||
# CONFIG_NX_WRITEONLY is not set
|
||||
# CONFIG_STANDARD_SERIAL is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="raspberrypi-pico"
|
||||
CONFIG_ARCH_BOARD_RASPBERRYPI_PICO=y
|
||||
CONFIG_ARCH_CHIP="rp2040"
|
||||
CONFIG_ARCH_CHIP_RP2040=y
|
||||
CONFIG_ARCH_RAMVECTORS=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=10450
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_ASSERTIONS=y
|
||||
CONFIG_DEBUG_FEATURES=y
|
||||
CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DISABLE_POSIX_TIMERS=y
|
||||
CONFIG_DRIVERS_VIDEO=y
|
||||
CONFIG_EXAMPLES_FB=y
|
||||
CONFIG_EXAMPLES_HELLO=y
|
||||
CONFIG_EXAMPLES_NX=y
|
||||
CONFIG_EXAMPLES_NXDEMO=y
|
||||
CONFIG_EXAMPLES_NXDEMO_BPP=16
|
||||
CONFIG_EXAMPLES_NXHELLO=y
|
||||
CONFIG_EXAMPLES_NXHELLO_BPP=16
|
||||
CONFIG_EXAMPLES_NXLINES=y
|
||||
CONFIG_EXAMPLES_NXLINES_BGCOLOR=0x0320
|
||||
CONFIG_EXAMPLES_NXLINES_BORDERCOLOR=0xffe0
|
||||
CONFIG_EXAMPLES_NXLINES_BORDERWIDTH=4
|
||||
CONFIG_EXAMPLES_NXLINES_BPP=16
|
||||
CONFIG_EXAMPLES_NXLINES_CIRCLECOLOR=0xf7bb
|
||||
CONFIG_EXAMPLES_NXLINES_LINECOLOR=0xffe0
|
||||
CONFIG_EXAMPLES_NX_BPP=16
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_FS_PROCFS_REGISTER=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_LCD=y
|
||||
CONFIG_LCD_DEV=y
|
||||
CONFIG_LCD_FRAMEBUFFER=y
|
||||
CONFIG_LCD_MAXCONTRAST=255
|
||||
CONFIG_LCD_NOGETRUN=y
|
||||
CONFIG_LCD_ST7789=y
|
||||
CONFIG_LCD_ST7789_FREQUENCY=64000000
|
||||
CONFIG_LCD_ST7789_XOFFSET=53
|
||||
CONFIG_LCD_ST7789_XRES=135
|
||||
CONFIG_LCD_ST7789_YOFFSET=40
|
||||
CONFIG_LCD_ST7789_YRES=240
|
||||
CONFIG_MAX_TASKS=8
|
||||
CONFIG_MQ_MAXMSGSIZE=64
|
||||
CONFIG_NFILE_DESCRIPTORS=6
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NX=y
|
||||
CONFIG_NXFONTS_PACKEDMSFIRST=y
|
||||
CONFIG_NXFONT_SANS40X49B=y
|
||||
CONFIG_NX_BLOCKING=y
|
||||
CONFIG_RAM_SIZE=270336
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_READLINE_CMD_HISTORY=y
|
||||
CONFIG_RP2040_SPI0=y
|
||||
CONFIG_RP2040_SPI0_GPIO=16
|
||||
CONFIG_RP2040_SPI=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_SPI_CMDDATA=y
|
||||
CONFIG_START_DAY=9
|
||||
CONFIG_START_MONTH=2
|
||||
CONFIG_START_YEAR=2021
|
||||
CONFIG_SYSLOG_CONSOLE=y
|
||||
CONFIG_SYSTEM_I2CTOOL=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_SPITOOL=y
|
||||
CONFIG_TESTING_GETPRIME=y
|
||||
CONFIG_TESTING_OSTEST=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
CONFIG_VIDEO_FB=y
|
@ -33,6 +33,10 @@
|
||||
|
||||
#include "rp2040_pico.h"
|
||||
|
||||
#ifdef CONFIG_VIDEO_FB
|
||||
# include <nuttx/video/fb.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -122,5 +126,13 @@ int rp2040_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_VIDEO_FB
|
||||
ret = fb_register(0, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
_err("ERROR: Failed to initialize Frame Buffer Driver.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -86,6 +86,26 @@ uint8_t rp2040_spi0status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
# endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
int rp2040_spi0cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
#ifdef CONFIG_LCD_ST7789
|
||||
if (devid == SPIDEV_DISPLAY(0))
|
||||
{
|
||||
/* This is the Data/Command control pad which determines whether the
|
||||
* data bits are data or a command.
|
||||
*/
|
||||
|
||||
rp2040_gpio_put(CONFIG_RP2040_SPI0_GPIO, !cmd);
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RP2040_SPI1
|
||||
@ -107,4 +127,11 @@ uint8_t rp2040_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
# endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
int rp2040_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user