Squashed commit of the following:
configs/flipnclick-pic32mz: Add an nxlines configuration for use in testing the custom HiletGo Click board. arch/mips/src/pic32mz: Correct some SPI-related typos. configs/flipnclick-pic32mz: Finishes integration of HiletGo OLED. drivers/lcd: Finish support for HiletGo OLED. drivers/lcd: Add configuration support for HiletGo OLED. configs/flipnclick-pic32mz: Add board support for HiletGo OLED.
This commit is contained in:
parent
9e4cd2f720
commit
642d7e3ce2
13 changed files with 615 additions and 24 deletions
|
@ -110,7 +110,7 @@
|
|||
#define PIC32MZ_SPI1_CON2SET (PIC32MZ_SPI1_K1BASE+PIC32MZ_SPI_CON2SET_OFFSET)
|
||||
#define PIC32MZ_SPI1_CON2INV (PIC32MZ_SPI1_K1BASE+PIC32MZ_SPI_CON2INV_OFFSET)
|
||||
|
||||
#if PIC32MZ_NSPI > 1
|
||||
#if CHIP_NSPI > 1
|
||||
# define PIC32MZ_SPI2_CON (PIC32MZ_SPI2_K1BASE+PIC32MZ_SPI_CON_OFFSET)
|
||||
# define PIC32MZ_SPI2_CONCLR (PIC32MZ_SPI2_K1BASE+PIC32MZ_SPI_CONCLR_OFFSET)
|
||||
# define PIC32MZ_SPI2_CONSET (PIC32MZ_SPI2_K1BASE+PIC32MZ_SPI_CONSET_OFFSET)
|
||||
|
@ -128,7 +128,7 @@
|
|||
# define PIC32MZ_SPI2_CON2INV (PIC32MZ_SPI2_K1BASE+PIC32MZ_SPI_CON2INV_OFFSET)
|
||||
#endif
|
||||
|
||||
#if PIC32MZ_NSPI > 2
|
||||
#if CHIP_NSPI > 2
|
||||
# define PIC32MZ_SPI3_CON (PIC32MZ_SPI3_K1BASE+PIC32MZ_SPI_CON_OFFSET)
|
||||
# define PIC32MZ_SPI3_CONCLR (PIC32MZ_SPI3_K1BASE+PIC32MZ_SPI_CONCLR_OFFSET)
|
||||
# define PIC32MZ_SPI3_CONSET (PIC32MZ_SPI3_K1BASE+PIC32MZ_SPI_CONSET_OFFSET)
|
||||
|
@ -145,7 +145,7 @@
|
|||
# define PIC32MZ_SPI3_CON2INV (PIC32MZ_SPI3_K1BASE+PIC32MZ_SPI_CON2INV_OFFSET)
|
||||
#endif
|
||||
|
||||
#if PIC32MZ_NSPI > 3
|
||||
#if CHIP_NSPI > 3
|
||||
# define PIC32MZ_SPI4_CON (PIC32MZ_SPI4_K1BASE+PIC32MZ_SPI_CON_OFFSET)
|
||||
# define PIC32MZ_SPI4_CONCLR (PIC32MZ_SPI4_K1BASE+PIC32MZ_SPI_CONCLR_OFFSET)
|
||||
# define PIC32MZ_SPI4_CONSET (PIC32MZ_SPI4_K1BASE+PIC32MZ_SPI_CONSET_OFFSET)
|
||||
|
@ -162,7 +162,7 @@
|
|||
# define PIC32MZ_SPI4_CON2INV (PIC32MZ_SPI4_K1BASE+PIC32MZ_SPI_CON2INV_OFFSET)
|
||||
#endif
|
||||
|
||||
#if PIC32MZ_NSPI > 4
|
||||
#if CHIP_NSPI > 4
|
||||
# define PIC32MZ_SPI5_CON (PIC32MZ_SPI5_K1BASE+PIC32MZ_SPI_CON_OFFSET)
|
||||
# define PIC32MZ_SPI5_CONCLR (PIC32MZ_SPI5_K1BASE+PIC32MZ_SPI_CONCLR_OFFSET)
|
||||
# define PIC32MZ_SPI5_CONSET (PIC32MZ_SPI5_K1BASE+PIC32MZ_SPI_CONSET_OFFSET)
|
||||
|
@ -179,7 +179,7 @@
|
|||
# define PIC32MZ_SPI5_CON2INV (PIC32MZ_SPI5_K1BASE+PIC32MZ_SPI_CON2INV_OFFSET)
|
||||
#endif
|
||||
|
||||
#if PIC32MZ_NSPI > 5
|
||||
#if CHIP_NSPI > 5
|
||||
# define PIC32MZ_SPI6_CON (PIC32MZ_SPI6_K1BASE+PIC32MZ_SPI_CON_OFFSET)
|
||||
# define PIC32MZ_SPI6_CONCLR (PIC32MZ_SPI6_K1BASE+PIC32MZ_SPI_CONCLR_OFFSET)
|
||||
# define PIC32MZ_SPI6_CONSET (PIC32MZ_SPI6_K1BASE+PIC32MZ_SPI_CONSET_OFFSET)
|
||||
|
|
|
@ -170,6 +170,58 @@ int pic32mz_spi6cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pic32mz_spi1/2/...register
|
||||
*
|
||||
* Description:
|
||||
* If the board supports a card detect callback to inform the SPI-based
|
||||
* MMC/SD driver when an SD card is inserted or removed, then
|
||||
* CONFIG_SPI_CALLBACK should be defined and the following function(s)
|
||||
* must be implemented. These functions implements the registercallback
|
||||
* method of the SPI interface (see include/nuttx/spi/spi.h for details)
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - Device-specific state data
|
||||
* callback - The function to call on the media change
|
||||
* arg - A caller provided value to return with the callback
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 on success; negated errno on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SPI_CALLBACK
|
||||
#ifdef CONFIG_PIC32MZ_SPI1
|
||||
int pic32mz_spi1register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
|
||||
FAR void *arg);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PIC32MZ_SPI2
|
||||
int pic32mz_spi2register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
|
||||
FAR void *arg);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PIC32MZ_SPI3
|
||||
int pic32mz_spi3register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
|
||||
FAR void *arg);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PIC32MZ_SPI4
|
||||
int pic32mz_spi4register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
|
||||
FAR void *arg);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PIC32MZ_SPI5
|
||||
int pic32mz_spi5register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
|
||||
FAR void *arg);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PIC32MZ_SPI6
|
||||
int pic32mz_spi6register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
|
||||
FAR void *arg);
|
||||
#endif
|
||||
#endif /* CONFIG_SPI_CALLBACK */
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
|
|
@ -4,4 +4,31 @@
|
|||
#
|
||||
|
||||
if ARCH_BOARD_FLIPNCLICK_PIC32MZ
|
||||
endif
|
||||
|
||||
|
||||
config FLIPNCLICK_PIC32MZ_HILETGO
|
||||
bool "HiletGo Click Present"
|
||||
default n
|
||||
depends on LCD_HILETGO
|
||||
select NXSTART_EXTERNINIT if NX
|
||||
|
||||
choice
|
||||
prompt "HiletGo mikroBUS"
|
||||
default FLIPNCLICK_PIC32MZ_HILETGO_MBA
|
||||
depends on FLIPNCLICK_PIC32MZ_HILETGO
|
||||
|
||||
config FLIPNCLICK_PIC32MZ_HILETGO_MBA
|
||||
bool "mikroBUS A"
|
||||
|
||||
config FLIPNCLICK_PIC32MZ_HILETGO_MBB
|
||||
bool "mikroBUS B"
|
||||
|
||||
config FLIPNCLICK_PIC32MZ_HILETGO_MBC
|
||||
bool "mikroBUS C"
|
||||
|
||||
config FLIPNCLICK_PIC32MZ_HILETGO_MBD
|
||||
bool "mikroBUS D"
|
||||
|
||||
endchoice # HiletGo mikroBUS
|
||||
|
||||
endif # ARCH_BOARD_FLIPNCLICK_PIC32MZ
|
||||
|
|
|
@ -17,6 +17,7 @@ Contents
|
|||
Serial Console
|
||||
SPI
|
||||
LEDs
|
||||
HiletGo OLED
|
||||
Configurations
|
||||
|
||||
Port Status
|
||||
|
@ -309,6 +310,30 @@ LEDs and Buttons
|
|||
The switches have external pull-up resistors. The switches are pulled high
|
||||
(+3.3V) and grounded when pressed.
|
||||
|
||||
HiletGo OLED
|
||||
============
|
||||
|
||||
Hardware
|
||||
--------
|
||||
The HiletGo is a 128x64 OLED that can be driven either via SPI or I2C (SPI
|
||||
is the default and is what is used here). I have mounted the OLED on a
|
||||
proto click board. The OLED is connected as follows:
|
||||
|
||||
OLED ALIAS DESCRIPTION PROTO CLICK
|
||||
----- ----------- ------------- -----------------
|
||||
GND Ground GND
|
||||
VCC Power Supply 5V (3-5V)
|
||||
D0 SCL,CLK,SCK Clock SCK
|
||||
D1 SDA,MOSI Data MOSI,SDI
|
||||
RES RST,RESET Reset RST (GPIO OUTPUT)
|
||||
DC AO Data/Command INT (GPIO OUTPUT)
|
||||
CS Chip Select CS (GPIO OUTPUT)
|
||||
|
||||
NOTE that this is a write-only display (MOSI only)!
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
Configurations
|
||||
==============
|
||||
|
||||
|
@ -374,3 +399,26 @@ Where <subdir> is one of the following:
|
|||
CONFIG_PIC32MZ_DEBUGGER_ENABLE=n : Debugger is disabled
|
||||
CONFIG_PIC32MZ_TRACE_ENABLE=n : Trace is disabled
|
||||
CONFIG_PIC32MZ_JTAG_ENABLE=n : JTAG is disabled
|
||||
|
||||
nxlines
|
||||
|
||||
This is an NSH configuration that supports the NX graphics example at
|
||||
apps/examples/nxlines as a built-in application.
|
||||
|
||||
NOTES:
|
||||
|
||||
1. This configuration derives from the nsh configuration. All of the
|
||||
notes there apply here as well.
|
||||
|
||||
2. The default configuration assumes there is the custom HiletGo OLED
|
||||
in the mikroBUS A slot (and a Mikroe RS-232 Click card in the
|
||||
mikroBUS B slot). That is easily changed by reconfiguring, however.
|
||||
See the section entitled "HiletGo OLED" for information about this
|
||||
custom click card.
|
||||
|
||||
STATUS:
|
||||
|
||||
2018-02-10: The debug output indicates that the nxlines example is
|
||||
running with no errors, however, nothing appears on the OLED display.
|
||||
This suggests either a problem with the pin configuration or else I
|
||||
have bungled the wiring of the custom card.
|
||||
|
|
62
configs/flipnclick-pic32mz/nxlines/defconfig
Normal file
62
configs/flipnclick-pic32mz/nxlines/defconfig
Normal file
|
@ -0,0 +1,62 @@
|
|||
# CONFIG_ARCH_RAMFUNCS is not set
|
||||
# CONFIG_NX_DISABLE_1BPP is not set
|
||||
# CONFIG_PIC32MZ_DEBUGGER_ENABLE is not set
|
||||
# CONFIG_PIC32MZ_TRACE_ENABLE is not set
|
||||
CONFIG_ARCH_BOARD_FLIPNCLICK_PIC32MZ=y
|
||||
CONFIG_ARCH_BOARD="flipnclick-pic32mz"
|
||||
CONFIG_ARCH_CHIP_PIC32MZ=y
|
||||
CONFIG_ARCH_CHIP_PIC32MZ2048EFH=y
|
||||
CONFIG_ARCH_CHIP_PIC32MZEF=y
|
||||
CONFIG_ARCH_MIPS=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH="mips"
|
||||
CONFIG_BOARD_LOOPSPERMSEC=7245
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_EXAMPLES_NSH=y
|
||||
CONFIG_EXAMPLES_NXLINES_BORDERWIDTH=4
|
||||
CONFIG_EXAMPLES_NXLINES_BPP=1
|
||||
CONFIG_EXAMPLES_NXLINES_LINEWIDTH=4
|
||||
CONFIG_EXAMPLES_NXLINES=y
|
||||
CONFIG_FLIPNCLICK_PIC32MZ_HILETGO=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HOST_WINDOWS=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LCD_HILETGO=y
|
||||
CONFIG_LCD_MAXCONTRAST=255
|
||||
CONFIG_LCD=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MAX_WDOGPARMS=2
|
||||
CONFIG_MIPS_MICROMIPS=y
|
||||
CONFIG_MIPS32_TOOLCHAIN_PINGUINOW=y
|
||||
CONFIG_MMCSD=y
|
||||
CONFIG_MQ_MAXMSGSIZE=64
|
||||
CONFIG_MTD=y
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NFILE_STREAMS=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_NX_BLOCKING=y
|
||||
CONFIG_NX=y
|
||||
CONFIG_NXFONT_TOM_THUMB_4X6=y
|
||||
CONFIG_NXTK_BORDERWIDTH=2
|
||||
CONFIG_PIC32MZ_ICESEL_CH2=y
|
||||
CONFIG_PIC32MZ_SPI2=y
|
||||
CONFIG_PIC32MZ_UART3=y
|
||||
CONFIG_PREALLOC_MQ_MSGS=8
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PREALLOC_WDOGS=8
|
||||
CONFIG_RAM_SIZE=131072
|
||||
CONFIG_RAM_START=0xa0000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=10
|
||||
CONFIG_START_MONTH=2
|
||||
CONFIG_UART3_SERIAL_CONSOLE=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
CONFIG_WDOG_INTRESERVE=1
|
|
@ -50,4 +50,8 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y)
|
|||
CSRCS += pic32mz_buttons.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_FLIPNCLICK_PIC32MZ_HILETGO),y)
|
||||
CSRCS += pic32mz_hiletgo.c
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/configs/Board.mk
|
||||
|
|
|
@ -48,6 +48,18 @@
|
|||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#define HAVE_HILETGO 1
|
||||
|
||||
/* The HiletGo LCD must be selected, installed on the Flip&Click, and must
|
||||
* be configured to use the SPI interface.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_LCD_HILETGO) || \
|
||||
!defined(CONFIG_FLIPNCLICK_PIC32MZ_HILETGO) || \
|
||||
!defined(CONFIG_LCD_SSD1306_SPI)
|
||||
# undef HAVE_HILETGO
|
||||
#endif
|
||||
|
||||
/* LEDs *********************************************************************/
|
||||
/* There are four LEDs on the top, red side of the board. Only one can be
|
||||
* controlled by software:
|
||||
|
@ -126,6 +138,78 @@
|
|||
#define GPIO_MBC_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTD | GPIO_PIN12)
|
||||
#define GPIO_MBD_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTD | GPIO_PIN13)
|
||||
|
||||
/* HiletGo OLED
|
||||
*
|
||||
* The HiletGo is a 128x64 OLED that can be driven either via SPI or I2C (SPI
|
||||
* is the default and is what is used here). I have mounted the OLED on a
|
||||
* proto click board. The OLED is connected as follows:
|
||||
*
|
||||
* OLED ALIAS DESCRIPTION PROTO CLICK
|
||||
* ----- ----------- ------------- -----------------
|
||||
* GND Ground GND
|
||||
* VCC Power Supply 5V (3-5V)
|
||||
* D0 SCL,CLK,SCK Clock SCK
|
||||
* D1 SDA,MOSI Data MOSI,SDI
|
||||
* RES RST,RESET Reset RST (GPIO OUTPUT)
|
||||
* DC AO Data/Command INT (GPIO OUTPUT)
|
||||
* CS Chip Select CS (GPIO OUTPUT)
|
||||
*
|
||||
* NOTE that this is a write-only display (MOSI only)!
|
||||
*
|
||||
* MikroBUS A: MikroBUS B:
|
||||
* Pin Board Signal PIC32MZ Pin Board Signal PIC32MZ
|
||||
* ---- ------------ ------- ---- ------------ -------
|
||||
* RST RST4 RE2 RST RST3 RG13
|
||||
* DC INT4 RD9 DC INT3 RG1
|
||||
*
|
||||
* MikroBUS C: MikroBUS D:
|
||||
* Pin Board Signal PIC32MZ Pin Board Signal PIC32MZ
|
||||
* ---- ------------ ------- ---- ------------ -------
|
||||
* RST RST1 RG14 RST RST2 RG12
|
||||
* DC INT1 RD5 DC INT2 RD4
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_FLIPNCLICK_PIC32MZ_HILETGO_MBA)
|
||||
# ifndef CONFIG_PIC32MZ_SPI2
|
||||
# error "The OLED driver requires CONFIG_PIC32MZ_SPI2 in the configuration"
|
||||
# endif
|
||||
|
||||
# define HILETGO_SPI_BUS 2
|
||||
# define GPIO_HILETGO_CS GPIO_MBA_CS
|
||||
# define GPIO_HILETGO_RST (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTE | GPIO_PIN2)
|
||||
# define GPIO_HILETGO_DC (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTD | GPIO_PIN9)
|
||||
|
||||
#elif defined(CONFIG_FLIPNCLICK_PIC32MZ_HILETGO_MBB)
|
||||
# ifndef CONFIG_PIC32MZ_SPI2
|
||||
# error "The OLED driver requires CONFIG_PIC32MZ_SPI2 in the configuration"
|
||||
# endif
|
||||
|
||||
# define HILETGO_SPI_BUS 2
|
||||
# define GPIO_HILETGO_CS GPIO_MBB_CS
|
||||
# define GPIO_HILETGO_RST (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTG | GPIO_PIN13)
|
||||
# define GPIO_HILETGO_DC (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTG | GPIO_PIN1)
|
||||
|
||||
#elif defined(CONFIG_FLIPNCLICK_PIC32MZ_HILETGO_MBC)
|
||||
# ifndef CONFIG_PIC32MZ_SPI1
|
||||
# error "The OLED driver requires CONFIG_PIC32MZ_SPI1 in the configuration"
|
||||
# endif
|
||||
|
||||
# define HILETGO_SPI_BUS 1
|
||||
# define GPIO_HILETGO_CS GPIO_MBC_CS
|
||||
# define GPIO_HILETGO_RST (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTG | GPIO_PIN14)
|
||||
# define GPIO_HILETGO_DC (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTD | GPIO_PIN5)
|
||||
|
||||
#elif defined(CONFIG_FLIPNCLICK_PIC32MZ_HILETGO_MBD)
|
||||
# ifndef CONFIG_PIC32MZ_SPI1
|
||||
# error "The OLED driver requires CONFIG_PIC32MZ_SPI1 in the configuration"
|
||||
# endif
|
||||
|
||||
# define HILETGO_SPI_BUS 1
|
||||
# define GPIO_HILETGO_CS GPIO_MBD_CS
|
||||
# define GPIO_HILETGO_RST (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTG | GPIO_PIN12)
|
||||
# define GPIO_HILETGO_DC (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORTD | GPIO_PIN4)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
@ -182,6 +266,21 @@ void pic32mz_led_initialize(void);
|
|||
|
||||
int pic32mz_bringup(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pic32mz_graphics_setup
|
||||
*
|
||||
* Description:
|
||||
* Called by either NX initialization logic (via board_graphics_setup) or
|
||||
* directly from the board bring-up logic in order to configure the
|
||||
* HiletGo OLED.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_HILETGO
|
||||
struct lcd_dev_s; /* Forward reference3 */
|
||||
FAR struct lcd_dev_s *pic32mz_graphics_setup(unsigned int devno);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -72,6 +72,15 @@ int pic32mz_bringup(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_HILETGO) && !defined(CONFIG_NXSTART_EXTERNINIT)
|
||||
/* Configure the HiletGo OLED */
|
||||
|
||||
if (pic32mz_graphics_setup(0) == NULL)
|
||||
{
|
||||
syslog(LOG_ERR,"ERROR: Failed to configure the HiletGo OLEDn");
|
||||
}
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
||||
|
|
172
configs/flipnclick-pic32mz/src/pic32mz_hiletgo.c
Normal file
172
configs/flipnclick-pic32mz/src/pic32mz_hiletgo.c
Normal file
|
@ -0,0 +1,172 @@
|
|||
/****************************************************************************
|
||||
* config/flipnclick-pic32mz/src/pic32mz_hiletgo.c
|
||||
*
|
||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* HiletGo OLED
|
||||
*
|
||||
* The HiletGo is a 128x64 OLED that can be driven either via SPI or I2C (SPI
|
||||
* is the default and is what is used here). I have mounted the OLED on a
|
||||
* proto click board. The OLED is connected as follows:
|
||||
*
|
||||
* OLED ALIAS DESCRIPTION PROTO CLICK
|
||||
* ----- ----------- ------------- -----------------
|
||||
* GND Ground GND
|
||||
* VCC Power Supply 5V (3-5V)
|
||||
* D0 SCL,CLK,SCK Clock SCK
|
||||
* D1 SDA,MOSI Data MOSI,SDI
|
||||
* RES RST,RESET Reset RST (GPIO OUTPUT)
|
||||
* DC AO Data/Command INT (GPIO OUTPUT)
|
||||
* CS Chip Select CS (GPIO OUTPUT)
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/lcd/lcd.h>
|
||||
#include <nuttx/lcd/ssd1306.h>
|
||||
|
||||
#if defined(CONFIG_VIDEO_FB) && defined(CONFIG_LCD_FRAMEBUFFER)
|
||||
# include <nuttx/video/fb.h>
|
||||
#endif
|
||||
|
||||
#include "pic32mz-gpio.h"
|
||||
#include "pic32mz-spi.h"
|
||||
|
||||
#include "flipnclick-pic32mz.h"
|
||||
|
||||
#ifdef HAVE_HILETGO
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifndef CONFIG_SPI_CMDDATA
|
||||
# error "The OLED driver requires CONFIG_SPI_CMDDATA in the configuration"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pic32mz_graphics_setup
|
||||
*
|
||||
* Description:
|
||||
* Called by either NX initialization logic (via board_graphics_setup) or
|
||||
* directly from the board bring-up logic in order to configure the
|
||||
* HiletGo OLED.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct lcd_dev_s *pic32mz_graphics_setup(unsigned int devno)
|
||||
{
|
||||
FAR struct spi_dev_s *spi;
|
||||
FAR struct lcd_dev_s *dev;
|
||||
|
||||
/* Configure the OLED GPIOs. This initial configuration is RESET low,
|
||||
* putting the OLED into reset state.
|
||||
*/
|
||||
|
||||
(void)pic32mz_configgpio(GPIO_HILETGO_RST);
|
||||
|
||||
/* Wait a bit then release the OLED from the reset state */
|
||||
|
||||
up_mdelay(20);
|
||||
pic32mz_gpiowrite(GPIO_HILETGO_RST, true);
|
||||
|
||||
/* Get the SPI1 port interface */
|
||||
|
||||
spi = pic32mz_spibus_initialize(HILETGO_SPI_BUS);
|
||||
if (!spi)
|
||||
{
|
||||
lcderr("ERROR: Failed to initialize SPI port 1\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Bind the SPI port to the OLED */
|
||||
|
||||
dev = ssd1306_initialize(spi, NULL, devno);
|
||||
if (!dev)
|
||||
{
|
||||
lcderr("ERROR: Failed to bind SPI port 1 to OLED %d: %d\n", devno);
|
||||
}
|
||||
else
|
||||
{
|
||||
lcdinfo("Bound SPI port 1 to OLED %d\n", devno);
|
||||
|
||||
/* And turn the OLED on */
|
||||
|
||||
(void)dev->setpower(dev, CONFIG_LCD_MAXPOWER);
|
||||
|
||||
#if defined(CONFIG_VIDEO_FB) && defined(CONFIG_LCD_FRAMEBUFFER)
|
||||
/* Initialize and register the simulated framebuffer driver */
|
||||
|
||||
ret = fb_register(0, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: fb_register() failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
return dev;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_graphics_setup
|
||||
*
|
||||
* Description:
|
||||
* Called by NX initialization logic to configure the OLED.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NXSTART_EXTERNINIT
|
||||
FAR struct lcd_dev_s *board_graphics_setup(unsigned int devno)
|
||||
{
|
||||
return pic32mz_graphics_setup(devno);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_HILETGO */
|
|
@ -43,9 +43,12 @@
|
|||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "pic32mz-gpio.h"
|
||||
|
||||
#include "flipnclick-pic32mz.h"
|
||||
|
||||
|
@ -67,7 +70,10 @@ void weak_function pic32mz_spidev_initialize(void)
|
|||
{
|
||||
/* Configure the SPI chip select GPIOs */
|
||||
|
||||
#warning "Missing logic"
|
||||
#ifdef CONFIG_LCD_HILETGO
|
||||
(void)pic32mz_configgpio(GPIO_HILETGO_CS);
|
||||
(void)pic32mz_configgpio(GPIO_HILETGO_DC);
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
|
@ -104,19 +110,32 @@ struct spi_dev_s;
|
|||
void pic32mz_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
#warning "Missing logic"
|
||||
|
||||
#if defined(CONFIG_FLIPNCLICK_PIC32MZ_HILETGO_MBA) || \
|
||||
defined(CONFIG_FLIPNCLICK_PIC32MZ_HILETGO_MBB)
|
||||
if (devid == SPIDEV_DISPLAY(0))
|
||||
{
|
||||
pic32mz_gpiowrite(GPIO_HILETGO_CS, !selected);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t pic32mz_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
spiinfo("Returning nothing\n");
|
||||
#warning "Missing logic"
|
||||
return 0;
|
||||
}
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
int pic32mz_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
#warning "Missing logic"
|
||||
#if defined(CONFIG_FLIPNCLICK_PIC32MZ_HILETGO_MBA) || \
|
||||
defined(CONFIG_FLIPNCLICK_PIC32MZ_HILETGO_MBB)
|
||||
if (devid == SPIDEV_DISPLAY(0))
|
||||
{
|
||||
pic32mz_gpiowrite(GPIO_HILETGO_CS, !cmd);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -126,19 +145,31 @@ int pic32mz_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
|||
void pic32mz_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
#warning "Missing logic"
|
||||
|
||||
#if defined(CONFIG_FLIPNCLICK_PIC32MZ_HILETGO_MBC) || \
|
||||
defined(CONFIG_FLIPNCLICK_PIC32MZ_HILETGO_MBD)
|
||||
if (devid == SPIDEV_DISPLAY(0))
|
||||
{
|
||||
pic32mz_gpiowrite(GPIO_HILETGO_CS, !selected);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t pic32mz_spi2status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
spiinfo("Returning nothing\n");
|
||||
#warning "Missing logic"
|
||||
return 0;
|
||||
}
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
int pic32mz_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
#warning "Missing logic"
|
||||
#if defined(CONFIG_FLIPNCLICK_PIC32MZ_HILETGO_MBC) || \
|
||||
defined(CONFIG_FLIPNCLICK_PIC32MZ_HILETGO_MBD)
|
||||
if (devid == SPIDEV_DISPLAY(0))
|
||||
{
|
||||
pic32mz_gpiowrite(GPIO_HILETGO_CS, !cmd);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -148,19 +179,16 @@ int pic32mz_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
|||
void pic32mz_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
#warning "Missing logic"
|
||||
}
|
||||
|
||||
uint8_t pic32mz_spi3status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
spiinfo("Returning nothing\n");
|
||||
#warning "Missing logic"
|
||||
return 0;
|
||||
}
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
int pic32mz_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
#warning "Missing logic"
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -170,19 +198,16 @@ int pic32mz_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
|||
void pic32mz_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
#warning "Missing logic"
|
||||
}
|
||||
|
||||
uint8_t pic32mz_spi4status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
spiinfo("Returning nothing\n");
|
||||
#warning "Missing logic"
|
||||
return 0;
|
||||
}
|
||||
#ifdef CONFIG_SPI_CMDDATA
|
||||
int pic32mz_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
||||
{
|
||||
#warning "Missing logic"
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -192,7 +217,6 @@ int pic32mz_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
|||
void pic32mz_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
#warning "Missing logic"
|
||||
}
|
||||
|
||||
uint8_t pic32mz_spi5status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
|
@ -232,4 +256,80 @@ int pic32mz_spi6cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pic32mz_spi1/2/...register
|
||||
*
|
||||
* Description:
|
||||
* If the board supports a card detect callback to inform the SPI-based
|
||||
* MMC/SD driver when an SD card is inserted or removed, then
|
||||
* CONFIG_SPI_CALLBACK should be defined and the following function(s)
|
||||
* must be implemented. These functions implements the registercallback
|
||||
* method of the SPI interface (see include/nuttx/spi/spi.h for details)
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - Device-specific state data
|
||||
* callback - The function to call on the media change
|
||||
* arg - A caller provided value to return with the callback
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 on success; negated errno on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SPI_CALLBACK
|
||||
#ifdef CONFIG_PIC32MZ_SPI1
|
||||
int pic32mz_spi1register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
|
||||
FAR void *arg)
|
||||
{
|
||||
#warning Missing logic
|
||||
return -ENOSYS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PIC32MZ_SPI2
|
||||
int pic32mz_spi2register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
|
||||
FAR void *arg)
|
||||
{
|
||||
#warning Missing logic
|
||||
return -ENOSYS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PIC32MZ_SPI3
|
||||
int pic32mz_spi3register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
|
||||
FAR void *arg)
|
||||
{
|
||||
#warning Missing logic
|
||||
return -ENOSYS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PIC32MZ_SPI4
|
||||
int pic32mz_spi4register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
|
||||
FAR void *arg)
|
||||
{
|
||||
#warning Missing logic
|
||||
return -ENOSYS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PIC32MZ_SPI5
|
||||
int pic32mz_spi5register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
|
||||
FAR void *arg)
|
||||
{
|
||||
#warning Missing logic
|
||||
return -ENOSYS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PIC32MZ_SPI6
|
||||
int pic32mz_spi6register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
|
||||
FAR void *arg)
|
||||
{
|
||||
#warning Missing logic
|
||||
return -ENOSYS;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_SPI_CALLBACK */
|
||||
|
||||
#endif /* CONFIG_PIC32MZ_SPI */
|
||||
|
|
|
@ -395,7 +395,6 @@ config LCD_UG2864HSWEG01
|
|||
config LCD_UG2832HSWEG04
|
||||
bool "UG-2832HSWEG04 OLED Display Module (SSD1306)"
|
||||
default n
|
||||
depends on !LCD_UG2864HSWEG01
|
||||
select LCD_SSD1306
|
||||
---help---
|
||||
OLED Display Module, UG-UG2832HSWEG04, Univision Technology Inc
|
||||
|
@ -412,7 +411,6 @@ config LCD_UG2832HSWEG04
|
|||
config LCD_DD12864WO4A
|
||||
bool "DD-12864WO-4A OLED Display Module"
|
||||
default n
|
||||
depends on !LCD_UG2864HSWEG01 && !LCD_UG2832HSWEG04
|
||||
select LCD_SSD1306
|
||||
select SPI_CMDDATA
|
||||
---help---
|
||||
|
@ -427,6 +425,18 @@ config LCD_DD12864WO4A
|
|||
Required SPI driver settings:
|
||||
SPI_CMDDATA - Include support for cmd/data selection.
|
||||
|
||||
config LCD_HILETGO
|
||||
bool "HiletGO 128x64 OLED"
|
||||
default n
|
||||
select LCD_SSD1306
|
||||
select SPI_CMDDATA
|
||||
---help---
|
||||
HiletGo 129x64 OLED Display Module, featuring an SSD1306.
|
||||
|
||||
Required LCD driver settings:
|
||||
LCD_MAXCONTRAST should be 255, but any value >0 and <=255 will be accepted.
|
||||
LCD_MAXPOWER should be 1: 0=off, 1=on
|
||||
|
||||
config LCD_SSD1306
|
||||
bool
|
||||
|
||||
|
|
|
@ -65,7 +65,8 @@
|
|||
#endif
|
||||
|
||||
#if !defined(CONFIG_LCD_SH1106_OLED_132) && !defined(CONFIG_LCD_UG2864HSWEG01) && \
|
||||
!defined(CONFIG_LCD_UG2832HSWEG04) && !defined(CONFIG_LCD_DD12864WO4A)
|
||||
!defined(CONFIG_LCD_UG2832HSWEG04) && !defined(CONFIG_LCD_DD12864WO4A) && \
|
||||
!defined(CONFIG_LCD_HILETGO)
|
||||
# error "Unknown and unsupported SSD1306 LCD"
|
||||
#endif
|
||||
|
||||
|
@ -171,6 +172,13 @@
|
|||
# define SSD1306_DEV_PAGES 8 /* 8 pages */
|
||||
# define SSD1306_DEV_CMNPAD 0x12 /* COM configuration */
|
||||
# undef IS_SSD1309
|
||||
#elif defined(CONFIG_LCD_HILETGO)
|
||||
# define SSD1306_DEV_NATIVE_XRES 128 /* Only 128 of 132 columns supported */
|
||||
# define SSD1306_DEV_NATIVE_YRES 64 /* 8 pages each 8 rows */
|
||||
# define SSD1306_DEV_XOFFSET 0 /* Offset to logical column 0 */
|
||||
# define SSD1306_DEV_PAGES 8 /* 8 pages */
|
||||
# define SSD1306_DEV_CMNPAD 0x12 /* COM configuration */
|
||||
# undef IS_SSD1309
|
||||
#elif defined(CONFIG_LCD_DD12864WO4A)
|
||||
# define SSD1306_DEV_NATIVE_XRES 128 /* 128 of 128 columns used */
|
||||
# define SSD1306_DEV_NATIVE_YRES 64 /* 8 pages each 8 rows */
|
||||
|
|
2
libnx/nxfonts/.gitignore
vendored
2
libnx/nxfonts/.gitignore
vendored
|
@ -1,4 +1,4 @@
|
|||
nxfonts_convert_*bpp.c
|
||||
nxfonts_bitmaps_*.c
|
||||
|
||||
nxfonts_tom-thumb-4x6.c
|
||||
|
||||
|
|
Loading…
Reference in a new issue