mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Add support for the UG-2843HHSWEG04 OLED and for the SAM4L Xplained Pro OLED module that uses that OLED.
This commit is contained in:
@@ -33,7 +33,6 @@ Contents
|
|||||||
- FPU
|
- FPU
|
||||||
- FSMC SRAM
|
- FSMC SRAM
|
||||||
- SSD1289
|
- SSD1289
|
||||||
- UG-2864AMBAG01 / UG-2964SWEG01
|
|
||||||
- Mikroe-STM32F4-specific Configuration Options
|
- Mikroe-STM32F4-specific Configuration Options
|
||||||
- Configurations
|
- Configurations
|
||||||
|
|
||||||
|
|||||||
@@ -116,31 +116,64 @@ Modules
|
|||||||
CONFIG_SAM4L_XPLAINED_IOMODULE_EXT1=y : The module is installed in EXT1
|
CONFIG_SAM4L_XPLAINED_IOMODULE_EXT1=y : The module is installed in EXT1
|
||||||
CONFIG_SAM4L_XPLAINED_IOMODULE_EXT2=y : The mdoule is installed in EXT2
|
CONFIG_SAM4L_XPLAINED_IOMODULE_EXT2=y : The mdoule is installed in EXT2
|
||||||
|
|
||||||
|
See the set-up in the discussion of the nsh configuration below for other
|
||||||
|
required configuration options.
|
||||||
|
|
||||||
NOTE: As of this writing, only the SD card slot is supported in the I/O1
|
NOTE: As of this writing, only the SD card slot is supported in the I/O1
|
||||||
module.
|
module.
|
||||||
|
|
||||||
OLED1
|
OLED1
|
||||||
-----
|
-----
|
||||||
This module provides an OLED plus 3 additional switches and 3 additional\
|
This module provides an OLED plus 3 additional switches and 3 additional
|
||||||
LEDs.
|
LEDs.
|
||||||
|
|
||||||
|
OLED1 Connector
|
||||||
|
--------------
|
||||||
|
OLED1 EXT1 EXT2 Other use of either pin
|
||||||
|
----------------- -------------------- -------------------- ------------------------------------
|
||||||
|
1 ID 1 1
|
||||||
|
2 GND 2 GND 2
|
||||||
|
3 BUTTON2 3 PA04 ADCIFE/AD0 3 PA07 ADCIFE/AD2
|
||||||
|
4 BUTTON3 4 PA05 ADCIFE/AD1 4 PB02 ADCIFE/AD3
|
||||||
|
5 DATA_CMD_SEL 5 PB12 GPIO 5 PC08 GPIO PB12 and PC8 on EXT5
|
||||||
|
6 LED3 6 PC02 GPIO 6 PB10 GPIO PB10 on EXT5
|
||||||
|
7 LED1 7 PC00 TC/1/A0 7 PC04 TC/1/A2
|
||||||
|
8 LED2 8 PC01 TC/1/B0 8 PC05 TC/1/B2 PC05 on EXT5
|
||||||
|
9 BUTTON1 9 PC25 EIC/EXTINT2 9 PC06 EIC/EXTINT8 PC25 on EXT5
|
||||||
|
10 DISPLAY_RESET 10 PB13 SPI/NPCS1 10 PC09 GPIO PB13 on EXT5
|
||||||
|
11 N/C 11 PA23 TWIMS/0/TWD 11 PB14 TWIMS/3/TWD PB14 on EXT3&4, PA23 and PB14 on EXT5
|
||||||
|
12 N/C 12 PA24 TWIMS/0/TWCK 12 PB15 TWIMS/3/TWCK PB15 on EXT3&4, PA24 and PB15 on EXT5
|
||||||
|
13 N/C 13 PB00 USART/0/RXD 13 PC26 USART/1/RXD PB00 on EXT4, PC26 on EXT3&5
|
||||||
|
14 N/C 14 PB01 USART/0/TXD 14 PC27 USART/1/TXD PB01 on EXT4, PC27 on EXT3&5
|
||||||
|
15 DISPLAY_SS 15 PC03 SPI/NPCS0 15 PB11 SPI/NPCS2 PB11 on EXT5
|
||||||
|
16 SPI_MOSI 16 PA22 SPI/MOSI 16 PA22 SPI/MOSI PA22 on EXT5
|
||||||
|
17 N/C 17 PA21 SPI/MISO 17 PA21 SPI/MISO PA21 on EXT5
|
||||||
|
18 SPI_SCK 18 PC30 SPI/SCK 18 PC30 SPI/SCK PC30 on EXT5
|
||||||
|
19 GND 19 GND GND
|
||||||
|
20 VCC 20 VCC VCC
|
||||||
|
|
||||||
Configuration Options:
|
Configuration Options:
|
||||||
----------------------
|
----------------------
|
||||||
CONFIG_SAM4L_XPLAINED_OLED1MODULE=y : Informs the system that the
|
CONFIG_SAM4L_XPLAINED_OLED1MODULE=y : Informs the system that the
|
||||||
I/O1 module is installed
|
I/O1 module is installed
|
||||||
|
CONFIG_SAM4L_XPLAINED_OLED1MODULE_EXT1=y : The module is installed in EXT1
|
||||||
|
CONFIG_SAM4L_XPLAINED_OLED1MODULE_EXT2=y : The mdoule is installed in EXT2
|
||||||
|
|
||||||
NOTE: As of this writing, the OLED1 module is not supported.
|
See the set-up in the discussion of the nsh configuration below for other
|
||||||
|
required configuration options.
|
||||||
|
|
||||||
SLCD1
|
SLCD1
|
||||||
-----
|
-----
|
||||||
This module provides a A segment LCD that connects directly to the "EXT5 SEGMENT LCD"
|
This module provides a A segment LCD that connects directly to the "EXT5
|
||||||
connector
|
SEGMENT LCD" connector
|
||||||
|
|
||||||
Configuration Options:
|
Configuration Options:
|
||||||
----------------------
|
----------------------
|
||||||
CONFIG_SAM4L_XPLAINED_SLCD1MODULE=y : Informs the system that the
|
CONFIG_SAM4L_XPLAINED_SLCD1MODULE=y : Informs the system that the
|
||||||
I/O1 module is installed
|
I/O1 module is installed
|
||||||
|
|
||||||
NOTE: As of this writing, the SLCD1 module is not supported.
|
See the set-up in the discussion of the nsh configuration below for other
|
||||||
|
required configuration options.
|
||||||
|
|
||||||
PROTO1
|
PROTO1
|
||||||
------
|
------
|
||||||
@@ -681,7 +714,17 @@ Configuration sub-directories
|
|||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
|
|
||||||
1. If the I/O1 module is connected to the SAM4L Xplained Pro, then
|
1. NOTE: If you get a compilation error like:
|
||||||
|
|
||||||
|
libxx_new.cxx:74:40: error: 'operator new' takes type 'size_t'
|
||||||
|
('unsigned int') as first parameter [-fper
|
||||||
|
|
||||||
|
Sometimes NuttX and your toolchain will disagree on the underlying
|
||||||
|
type of size_t; sometimes it is an 'unsigned int' and sometimes it is
|
||||||
|
an 'unsigned long int'. If this error occurs, then you may need to
|
||||||
|
toggle the value of CONFIG_CXX_NEWLONG.
|
||||||
|
|
||||||
|
2. If the I/O1 module is connected to the SAM4L Xplained Pro, then
|
||||||
support for the SD card slot can be enabled by making the following
|
support for the SD card slot can be enabled by making the following
|
||||||
changes to the configuration:
|
changes to the configuration:
|
||||||
|
|
||||||
@@ -730,16 +773,6 @@ Configuration sub-directories
|
|||||||
behave very well (since its outgoing prompts also appear as incoming
|
behave very well (since its outgoing prompts also appear as incoming
|
||||||
commands).
|
commands).
|
||||||
|
|
||||||
NOTE: If you get a compilation error like:
|
|
||||||
|
|
||||||
libxx_new.cxx:74:40: error: 'operator new' takes type 'size_t'
|
|
||||||
('unsigned int') as first parameter [-fper
|
|
||||||
|
|
||||||
Sometimes NuttX and your toolchain will disagree on the underlying
|
|
||||||
type of size_t; sometimes it is an 'unsigned int' and sometimes it is
|
|
||||||
an 'unsigned long int'. If this error occurs, then you may need to
|
|
||||||
toggle the value of CONFIG_CXX_NEWLONG.
|
|
||||||
|
|
||||||
STATUS: As of 2013-6-18, this configuration appears completely
|
STATUS: As of 2013-6-18, this configuration appears completely
|
||||||
functional. Testing, however, has been very light. Example:
|
functional. Testing, however, has been very light. Example:
|
||||||
|
|
||||||
@@ -755,7 +788,61 @@ Configuration sub-directories
|
|||||||
This is a test
|
This is a test
|
||||||
nsh>
|
nsh>
|
||||||
|
|
||||||
2. If the LCD1 module is connected to the SAM4L Xplained Pro, then
|
3. If the OLED1 module is connected to the SAM4L Xplained Pro, then
|
||||||
|
support for the OLED display can be enabled by making the following
|
||||||
|
changes to the configuration:
|
||||||
|
|
||||||
|
System Type -> Peripherals:
|
||||||
|
CONFIG_SAM34_SPI=y : Enable the SAM4L SPI peripheral
|
||||||
|
|
||||||
|
Device Drivers -> SPI
|
||||||
|
CONFIG_SPI=y : Enable SPI support
|
||||||
|
CONFIG_SPI_EXCHANGE=y : The exchange() method is supported
|
||||||
|
CONFIG_SPI_CMDDATA=y : CMD/DATA support is required
|
||||||
|
CONFIG_SPI_OWNBUS=y : Smaller code if this is the only SPI device
|
||||||
|
|
||||||
|
Device Drivers -> LCDs
|
||||||
|
CONFIG_LCD=y : Enable LCD support
|
||||||
|
CONFIG_LCD_MAXCONTRAST=255 : Maximum contrast value
|
||||||
|
CONFIG_LCD_UG2832HSWEG04=y : Enable support for the OLED
|
||||||
|
CONFIG_LCD_SSD1306_SPIMODE=0 : SPI Mode 0
|
||||||
|
CONFIG_LCD_SSD1306_SPIMODE=3500000 : Pick an SPI frequency
|
||||||
|
|
||||||
|
Board Selection -> SAM4L Xplained Pro Modules
|
||||||
|
CONFIG_SAM4L_XPLAINED_OLED1MODULE=y : OLED1 module is connected
|
||||||
|
CONFIG_SAM4L_XPLAINED_OLED1MODULE_EXT1=y : In EXT1, or EXT2
|
||||||
|
CONFIG_SAM4L_XPLAINED_OLED1MODULE_EXT2=y
|
||||||
|
|
||||||
|
The NX graphics subsystem also needs to be configured:
|
||||||
|
|
||||||
|
CONFIG_NX=y : Enable graphics support
|
||||||
|
CONFIG_NX_LCDDRIVER=y : Using an LCD driver
|
||||||
|
CONFIG_NX_NPLANES=1 : With a single color plane
|
||||||
|
CONFIG_NX_WRITEONLY=y : This is a write only LCD
|
||||||
|
CONFIG_NX_DISABLE_2BPP=y : Disable all resolutions except 1BPP
|
||||||
|
CONFIG_NX_DISABLE_4BPP=y
|
||||||
|
CONFIG_NX_DISABLE_8BPP=y
|
||||||
|
CONFIG_NX_DISABLE_16BPP=y
|
||||||
|
CONFIG_NX_DISABLE_24BPP=y
|
||||||
|
CONFIG_NX_DISABLE_32BPP=y
|
||||||
|
CONFIG_NX_PACKEDMSFIRST=y
|
||||||
|
CONFIG_NXTK_BORDERWIDTH=2 : Use a small border
|
||||||
|
CONFIG_NXTK_DEFAULT_BORDERCOLORS=y : Default border colors
|
||||||
|
CONFIG_NXFONTS_CHARBITS=7 : 7-bit fonts
|
||||||
|
CONFIG_NXFONT_SANS17X23B=y : Pick a font (any that will fit)
|
||||||
|
|
||||||
|
Then, in order to use the OLED, you will need to build some kind of
|
||||||
|
graphics application or use one of the NuttX graphics examples.
|
||||||
|
Here, for example, is the setup for the graphic "Hello, World!"
|
||||||
|
example:
|
||||||
|
|
||||||
|
CONFIG_EXAMPLES_NXHELLO=y : Enables the example
|
||||||
|
CONFIG_EXAMPLES_NXHELLO_DEFAULT_COLORS=y : Use default colors (monochrome)
|
||||||
|
CONFIG_EXAMPLES_NXHELLO_DEFAULT_FONT=y : Use the default font
|
||||||
|
CONFIG_EXAMPLES_NXHELLO_BPP=1 : One bit per pixel
|
||||||
|
CONFIG_EXAMPLES_NXHELLO_EXTERNINIT=y : Special initialization is required.
|
||||||
|
|
||||||
|
4. If the LCD1 module is connected to the SAM4L Xplained Pro, then
|
||||||
support for the SLCDt can be enabled by making the following
|
support for the SLCDt can be enabled by making the following
|
||||||
changes to the configuration:
|
changes to the configuration:
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,14 @@ CSRCS += sam_mmcsd.c
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_SAM34_SPI),y)
|
||||||
|
ifeq ($(CONFIG_SAM4L_XPLAINED_OLED1MODULE),y)
|
||||||
|
ifeq ($(CONFIG_LCD_UG2832HSWEG04),y)
|
||||||
|
CSRCS += sam_ug2832hsweg04.c
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||||
|
|
||||||
SRCS = $(ASRCS) $(CSRCS)
|
SRCS = $(ASRCS) $(CSRCS)
|
||||||
|
|||||||
@@ -175,14 +175,15 @@
|
|||||||
/* I/O1
|
/* I/O1
|
||||||
*
|
*
|
||||||
* Support for the microSD card slot on the I/O1 module. The I/O1 requires
|
* Support for the microSD card slot on the I/O1 module. The I/O1 requires
|
||||||
* SPI support and two GPIOs. These two GPIOs will vary if the
|
* SPI support and two GPIOs. These the GPIOs will vary if the I/O1
|
||||||
|
* is installed on the EXT1 or EXT2 connector:
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* PIN EXT1 EXT2 Description
|
* PIN EXT1 EXT2 Description
|
||||||
* --- -------------- --------------- -------------------------------------
|
* --- -------------- --------------- -------------------------------------
|
||||||
* 15 PC03 SPI/NPCS0 PB11 SPI/NPCS2 Active low chip select OUTPUT, pulled
|
* 15 PC03 SPI/NPCS0 PB11 SPI/NPCS2 Active low chip select OUTPUT, pulled
|
||||||
* high on board.
|
* high on board.
|
||||||
* 10 PB13 SPI/NPCS1 10 PC09 GPIO Active low card detect INPUT, must
|
* 10 PB13 SPI/NPCS1 PC09 GPIO Active low card detect INPUT, must
|
||||||
* use internal pull-up.
|
* use internal pull-up.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -194,8 +195,9 @@
|
|||||||
|
|
||||||
# if defined(CONFIG_SAM4L_XPLAINED_IOMODULE_EXT1)
|
# if defined(CONFIG_SAM4L_XPLAINED_IOMODULE_EXT1)
|
||||||
|
|
||||||
# if defined(SAM4L_XPLAINED_OLED1MODULE) && defined(SAM4L_XPLAINED_OLED1MODULE_EXT1)
|
# if defined(CONFIG_SAM4L_XPLAINED_OLED1MODULE) && \
|
||||||
# error I/O1 and OLED1 cannot both reside in EXT1
|
defined(CONFIG_SAM4L_XPLAINED_OLED1MODULE_EXT1)
|
||||||
|
# error I/O1 and OLED1 modules cannot both reside in EXT1
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# define GPIO_SD_CD (GPIO_INTERRUPT | GPIO_INT_CHANGE | GPIO_PULL_UP | \
|
# define GPIO_SD_CD (GPIO_INTERRUPT | GPIO_INT_CHANGE | GPIO_PULL_UP | \
|
||||||
@@ -212,8 +214,9 @@
|
|||||||
# error I/O1 cannot be in EXT2 if the LCD1 module is connected
|
# error I/O1 cannot be in EXT2 if the LCD1 module is connected
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(SAM4L_XPLAINED_OLED1MODULE) && defined(SAM4L_XPLAINED_OLED1MODULE_EXT2)
|
# if defined(CONFIG_SAM4L_XPLAINED_OLED1MODULE) && \
|
||||||
# error I/O1 and OLED1 cannot both reside in EXT2
|
defined(CONFIG_SAM4L_XPLAINED_OLED1MODULE_EXT2)
|
||||||
|
# error I/O1 and OLED1 modules cannot both reside in EXT2
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# define GPIO_CD (GPIO_INTERRUPT | GPIO_INT_CHANGE | GPIO_PULL_UP | \
|
# define GPIO_CD (GPIO_INTERRUPT | GPIO_INT_CHANGE | GPIO_PULL_UP | \
|
||||||
@@ -229,6 +232,82 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* OLED1
|
||||||
|
*
|
||||||
|
* Support for the microSD card slot on the I/O1 module. The I/O1 requires
|
||||||
|
* SPI support and three output GPIOs. These the GPIOs will vary if the OLED1
|
||||||
|
* is installed on the EXT1 or EXT2 connector:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* PIN EXT1 EXT2 Description
|
||||||
|
* --- -------------- --------------- -------------------------------------
|
||||||
|
* 5 PB12 GPIO PC08 GPIO DATA_CMD_SEL
|
||||||
|
* 10 PB13 SPI/NPCS1 PC09 GPIO DISPLAY_RESET. Active low.
|
||||||
|
* 15 PC03 SPI/NPCS0 PB11 SPI/NPCS2 DISPLAY_SS. Active low.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SAM4L_XPLAINED_OLED1MODULE
|
||||||
|
|
||||||
|
# ifndef CONFIG_SAM34_SPI
|
||||||
|
# error CONFIG_SAM34_SPI is required to use the OLED1 module
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef CONFIG_SPI_CMDDATA
|
||||||
|
# error CONFIG_SPI_CMDDATA is required to use the OLED1 module
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef CONFIG_LCD_SSD1306
|
||||||
|
# error CONFIG_LCD_SSD1306 is required to use the OLED1 module
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef CONFIG_LCD_UG2832HSWEG04
|
||||||
|
# error CONFIG_LCD_UG2832HSWEG04 is required to use the OLED1 module
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(CONFIG_SAM4L_XPLAINED_OLED1MODULE_EXT1)
|
||||||
|
|
||||||
|
# if defined(CONFIG_SAM4L_XPLAINED_IOMODULE) && \
|
||||||
|
defined(CONFIG_SAM4L_XPLAINED_IOMODULE_EXT1)
|
||||||
|
# error OLED1 and I/O1 modules cannot both reside in EXT1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define GPIO_OLED_DATA (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_CLEAR | \
|
||||||
|
GPIO_PORTB | GPIO_PIN12)
|
||||||
|
# define GPIO_OLED_RST (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_CLEAR | \
|
||||||
|
GPIO_PORTB | GPIO_PIN13)
|
||||||
|
# define GPIO_OLED_CS (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_SET | \
|
||||||
|
GPIO_PORTC | GPIO_PIN3)
|
||||||
|
# define OLED_CSNO 0
|
||||||
|
|
||||||
|
# elif defined(CONFIG_SAM4L_XPLAINED_OLED1MODULE_EXT2)
|
||||||
|
|
||||||
|
# ifndef CONFIG_SAM4L_XPLAINED_SLCD1MODULE
|
||||||
|
# error OLED1 cannot be in EXT2 if the LCD1 module is connected
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(CONFIG_SAM4L_XPLAINED_IOMODULE) && \
|
||||||
|
defined(CONFIG_SAM4L_XPLAINED_IOMODULE_EXT2)
|
||||||
|
# error OLED1 and I/O1 modules cannot both reside in EXT2
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define GPIO_OLED_DATA (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_CLEAR | \
|
||||||
|
GPIO_PORTC | GPIO_PIN8)
|
||||||
|
# define GPIO_OLED_RST (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_CLEAR | \
|
||||||
|
GPIO_PORTc | GPIO_PIN9)
|
||||||
|
# define GPIO_OLED_CS (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_SET | \
|
||||||
|
GPIO_PORTB | GPIO_PIN11)
|
||||||
|
# define OLED_CSNO 2
|
||||||
|
|
||||||
|
# else
|
||||||
|
# error Which connector is the OLED1 module installed in?
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_LCD_UG2864AMBAG01) || defined(CONFIG_LCD_UG2864HSWEG01)
|
||||||
|
# define GPIO_SD_CS (GPIO_OUTPUT | GPIO_PULL_NONE | GPIO_OUTPUT_SET | \
|
||||||
|
GPIO_PORTB | GPIO_PIN11)
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|||||||
@@ -101,6 +101,11 @@ void weak_function sam_spiinitialize(void)
|
|||||||
sam_configgpio(GPIO_SD_CD); /* Card detect input */
|
sam_configgpio(GPIO_SD_CD); /* Card detect input */
|
||||||
sam_configgpio(GPIO_SD_CS); /* Chip select output */
|
sam_configgpio(GPIO_SD_CS); /* Chip select output */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_SAM4L_XPLAINED_OLED1MODULE
|
||||||
|
sam_configgpio(GPIO_OLED_DATA); /* Command/data */
|
||||||
|
sam_configgpio(GPIO_OLED_CS ); /* Card detect input */
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -172,6 +177,21 @@ void sam_spiselect(enum spi_dev_e devid, bool selected)
|
|||||||
|
|
||||||
sam_gpiowrite(GPIO_SD_CS, !selected);
|
sam_gpiowrite(GPIO_SD_CS, !selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SAM4L_XPLAINED_OLED1MODULE
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_SAM4L_XPLAINED_OLED1MODULE
|
||||||
|
/* Select/de-select the OLED */
|
||||||
|
|
||||||
|
if (devid == SPIDEV_DISPLAY)
|
||||||
|
{
|
||||||
|
/* Active low */
|
||||||
|
|
||||||
|
sam_gpiowrite(GPIO_OLED_CS, !selected);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,3 +231,47 @@ uint8_t sam_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_SAM34_SPI */
|
#endif /* CONFIG_SAM34_SPI */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: sam_spicmddata
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Some SPI devices require an additional control to determine if the SPI
|
||||||
|
* data being sent is a command or is data. If CONFIG_SPI_CMDDATA then
|
||||||
|
* this function will be called to different be command and data transfers.
|
||||||
|
*
|
||||||
|
* This is often needed, for example, by LCD drivers. Some LCD hardware
|
||||||
|
* may be configured to use 9-bit data transfers with the 9th bit
|
||||||
|
* indicating command or data. That same hardware may be configurable,
|
||||||
|
* instead, to use 8-bit data but to require an additional, board-
|
||||||
|
* specific GPIO control to distinguish command and data. This function
|
||||||
|
* would be needed in that latter case.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - SPI device info
|
||||||
|
* devid - Identifies the (logical) device
|
||||||
|
*
|
||||||
|
* Returned Values:
|
||||||
|
* Zero on success; a negated errno on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SPI_CMDDATA
|
||||||
|
int sam_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_SAM4L_XPLAINED_OLED1MODULE
|
||||||
|
if (devid == SPIDEV_DISPLAY)
|
||||||
|
{
|
||||||
|
/* This is the Data/Command control pad which determines whether the
|
||||||
|
* data bits are data or a command.
|
||||||
|
*
|
||||||
|
* High: the inputs are treated as display data.
|
||||||
|
* Low: the inputs are transferred to the command registers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
(void)sam_gpiowrite(GPIO_OLED_DATA, !cmd);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,181 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* config/sam4l-xplained/src/sam_ug2832hsweg04.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* OLED1 Connector:
|
||||||
|
*
|
||||||
|
* OLED1 EXT1 EXT2 Other use of either pin
|
||||||
|
* ----------------- -------------------- -------------------- ------------------------------------
|
||||||
|
* 1 ID 1 1
|
||||||
|
* 2 GND 2 GND 2
|
||||||
|
* 3 BUTTON2 3 PA04 ADCIFE/AD0 3 PA07 ADCIFE/AD2
|
||||||
|
* 4 BUTTON3 4 PA05 ADCIFE/AD1 4 PB02 ADCIFE/AD3
|
||||||
|
* 5 DATA_CMD_SEL 5 PB12 GPIO 5 PC08 GPIO PB12 and PC8 on EXT5
|
||||||
|
* 6 LED3 6 PC02 GPIO 6 PB10 GPIO PB10 on EXT5
|
||||||
|
* 7 LED1 7 PC00 TC/1/A0 7 PC04 TC/1/A2
|
||||||
|
* 8 LED2 8 PC01 TC/1/B0 8 PC05 TC/1/B2 PC05 on EXT5
|
||||||
|
* 9 BUTTON1 9 PC25 EIC/EXTINT2 9 PC06 EIC/EXTINT8 PC25 on EXT5
|
||||||
|
* 10 DISPLAY_RESET 10 PB13 SPI/NPCS1 10 PC09 GPIO PB13 on EXT5
|
||||||
|
* 11 N/C 11 PA23 TWIMS/0/TWD 11 PB14 TWIMS/3/TWD PB14 on EXT3&4, PA23 and PB14 on EXT5
|
||||||
|
* 12 N/C 12 PA24 TWIMS/0/TWCK 12 PB15 TWIMS/3/TWCK PB15 on EXT3&4, PA24 and PB15 on EXT5
|
||||||
|
* 13 N/C 13 PB00 USART/0/RXD 13 PC26 USART/1/RXD PB00 on EXT4, PC26 on EXT3&5
|
||||||
|
* 14 N/C 14 PB01 USART/0/TXD 14 PC27 USART/1/TXD PB01 on EXT4, PC27 on EXT3&5
|
||||||
|
* 15 DISPLAY_SS 15 PC03 SPI/NPCS0 15 PB11 SPI/NPCS2 PB11 on EXT5
|
||||||
|
* 16 SPI_MOSI 16 PA22 SPI/MOSI 16 PA22 SPI/MOSI PA22 on EXT5
|
||||||
|
* 17 N/C 17 PA21 SPI/MISO 17 PA21 SPI/MISO PA21 on EXT5
|
||||||
|
* 18 SPI_SCK 18 PC30 SPI/SCK 18 PC30 SPI/SCK PC30 on EXT5
|
||||||
|
* 19 GND 19 GND GND
|
||||||
|
* 20 VCC 20 VCC VCC
|
||||||
|
*
|
||||||
|
* OLED1 signals
|
||||||
|
*
|
||||||
|
* DATA_CMD_SEL - Data/command select. Used to choose whether the
|
||||||
|
* communication is data to the display memory or a command to the LCD
|
||||||
|
* controller. High = data, low = command
|
||||||
|
* DISPLAY_RESET - Reset signal to the OLED display, active low. Used during
|
||||||
|
* initialization of the display.
|
||||||
|
* DISPLAY_SS - SPI slave select signal, must be held low during SPI
|
||||||
|
* communication.
|
||||||
|
* SPI_MOSI - SPI master out, slave in signal. Used to write data to the
|
||||||
|
* display
|
||||||
|
* SPI_SCK SPI - clock signal, generated by the master.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/spi.h>
|
||||||
|
#include <nuttx/lcd/lcd.h>
|
||||||
|
#include <nuttx/lcd/ssd1306.h>
|
||||||
|
|
||||||
|
#include "sam_gpio.h"
|
||||||
|
#include "sam4l-xplained.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_SAM4L_XPLAINED_OLED1MODULE
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-Processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
/* Configuration ************************************************************/
|
||||||
|
/* The pin configurations here require that SPI1 is selected */
|
||||||
|
|
||||||
|
#ifndef CONFIG_LCD_SSD1306
|
||||||
|
# error "The OLED driver requires CONFIG_LCD_SSD1306 in the configuration"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_LCD_UG2832HSWEG04
|
||||||
|
# error "The OLED driver requires CONFIG_LCD_UG2832HSWEG04 in the configuration"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_SAM34_SPI
|
||||||
|
# error "The OLED driver requires CONFIG_SAM34_SPI in the configuration"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_SPI_CMDDATA
|
||||||
|
# error "The OLED driver requires CONFIG_SPI_CMDDATA in the configuration"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Debug ********************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_LCD
|
||||||
|
# define lcddbg(format, arg...) dbg(format, ##arg)
|
||||||
|
# define lcdvdbg(format, arg...) vdbg(format, ##arg)
|
||||||
|
#else
|
||||||
|
# define lcddbg(x...)
|
||||||
|
# define lcdvdbg(x...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_nxdrvinit
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Called by NX initialization logic to configure the OLED.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
FAR struct lcd_dev_s *up_nxdrvinit(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)sam_configgpio(GPIO_OLED_RST);
|
||||||
|
|
||||||
|
/* Wait a bit then release the OLED from the reset state */
|
||||||
|
|
||||||
|
up_mdelay(20);
|
||||||
|
sam_gpiowrite(GPIO_OLED_RST, true);
|
||||||
|
|
||||||
|
/* Get the SPI1 port interface */
|
||||||
|
|
||||||
|
spi = up_spiinitialize(OLED_CSNO);
|
||||||
|
if (!spi)
|
||||||
|
{
|
||||||
|
lcddbg("Failed to initialize SPI port 1\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Bind the SPI port to the OLED */
|
||||||
|
|
||||||
|
dev = ssd1306_initialize(spi, devno);
|
||||||
|
if (!dev)
|
||||||
|
{
|
||||||
|
lcddbg("Failed to bind SPI port 1 to OLED %d: %d\n", devno);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lcdvdbg("Bound SPI port 1 to OLED %d\n", devno);
|
||||||
|
|
||||||
|
/* And turn the OLED on */
|
||||||
|
|
||||||
|
(void)dev->setpower(dev, CONFIG_LCD_MAXPOWER);
|
||||||
|
return dev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_SAM4L_XPLAINED_OLED1MODULE */
|
||||||
@@ -33,7 +33,7 @@ Contents
|
|||||||
- FPU
|
- FPU
|
||||||
- FSMC SRAM
|
- FSMC SRAM
|
||||||
- SSD1289
|
- SSD1289
|
||||||
- UG-2864AMBAG01 / UG-2964SWEG01
|
- UG-2864AMBAG01 / UG-2864HSWEG01
|
||||||
- STM32F4Discovery-specific Configuration Options
|
- STM32F4Discovery-specific Configuration Options
|
||||||
- Configurations
|
- Configurations
|
||||||
|
|
||||||
@@ -707,8 +707,8 @@ The following summarize the bit banging oprations:
|
|||||||
WriteData(data);
|
WriteData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
UG-2864AMBAG01 / UG-2964SWEG01
|
UG-2864AMBAG01 / UG-2864HSWEG01
|
||||||
==============================
|
===============================
|
||||||
|
|
||||||
I purchased an OLED display on eBay. The OLED is 128x64 monochrome and
|
I purchased an OLED display on eBay. The OLED is 128x64 monochrome and
|
||||||
is based on an UG-2864AMBAG01 OLED controller. The OLED can run in either
|
is based on an UG-2864AMBAG01 OLED controller. The OLED can run in either
|
||||||
@@ -740,9 +740,9 @@ that I am using:
|
|||||||
(1) Required because of on-board MEMS
|
(1) Required because of on-board MEMS
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
Darcy Gong recently added support for the UG-2964SWEG01 OLED which is also
|
Darcy Gong recently added support for the UG-2864HSWEG01 OLED which is also
|
||||||
an option with this configuratin. I have little technical information about
|
an option with this configuratin. I have little technical information about
|
||||||
the UG-2964SWEG01 interface (see configs/stm32f4discovery/src/up_ug2864sweg01.c).
|
the UG-2864HSWEG01 interface (see configs/stm32f4discovery/src/up_ug2864hsweg01.c).
|
||||||
|
|
||||||
STM32F4Discovery-specific Configuration Options
|
STM32F4Discovery-specific Configuration Options
|
||||||
===============================================
|
===============================================
|
||||||
@@ -1437,7 +1437,7 @@ Where <subdir> is one of the following:
|
|||||||
reconfiguration process.
|
reconfiguration process.
|
||||||
|
|
||||||
3. This configured can be re-configured to use either the
|
3. This configured can be re-configured to use either the
|
||||||
UG-2864AMBAG01 or UG-2864SWEG01 0.96 inch OLEDs by adding
|
UG-2864AMBAG01 or UG-2864HSWEG01 0.96 inch OLEDs by adding
|
||||||
or changing the following items in the configuration (using
|
or changing the following items in the configuration (using
|
||||||
'make menuconfig'):
|
'make menuconfig'):
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
#define GPIO_CS_MEMS (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
#define GPIO_CS_MEMS (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||||
GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN3)
|
GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN3)
|
||||||
|
|
||||||
/* USB OTG FS
|
/* USB OTG FS
|
||||||
*
|
*
|
||||||
* PA9 OTG_FS_VBUS VBUS sensing (also connected to the green LED)
|
* PA9 OTG_FS_VBUS VBUS sensing (also connected to the green LED)
|
||||||
* PC0 OTG_FS_PowerSwitchOn
|
* PC0 OTG_FS_PowerSwitchOn
|
||||||
@@ -134,7 +134,7 @@
|
|||||||
* (1) Required because of on-board MEMS
|
* (1) Required because of on-board MEMS
|
||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(CONFIG_LCD_UG2864AMBAG01) || defined(CONFIG_LCD_UG2864HSWEG01)
|
#if defined(CONFIG_LCD_UG2864AMBAG01) || defined(CONFIG_LCD_UG2864HSWEG01)
|
||||||
# define GPIO_OLED_RESET (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
# define GPIO_OLED_RESET (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||||
GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN6)
|
GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN6)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
#include <nuttx/spi.h>
|
#include <nuttx/spi.h>
|
||||||
#include <nuttx/lcd/lcd.h>
|
#include <nuttx/lcd/lcd.h>
|
||||||
#include <nuttx/lcd/ug-2864hsweg01.h>
|
#include <nuttx/lcd/ssd1306.h>
|
||||||
|
|
||||||
#include "stm32_gpio.h"
|
#include "stm32_gpio.h"
|
||||||
#include "stm32f4discovery-internal.h"
|
#include "stm32f4discovery-internal.h"
|
||||||
@@ -140,7 +140,7 @@ FAR struct lcd_dev_s *up_nxdrvinit(unsigned int devno)
|
|||||||
{
|
{
|
||||||
/* Bind the SPI port to the OLED */
|
/* Bind the SPI port to the OLED */
|
||||||
|
|
||||||
dev = ug2864hsweg01_initialize(spi, devno);
|
dev = ssd1306_initialize(spi, devno);
|
||||||
if (!dev)
|
if (!dev)
|
||||||
{
|
{
|
||||||
lcddbg("Failed to bind SPI port 1 to OLED %d: %d\n", devno);
|
lcddbg("Failed to bind SPI port 1 to OLED %d: %d\n", devno);
|
||||||
|
|||||||
Reference in New Issue
Block a user