Skip to content
Snippets Groups Projects
Commit d11050e9 authored by Gregory Nutt's avatar Gregory Nutt
Browse files

Add support for the UG-2843HHSWEG04 OLED and for the SAM4L Xplained Pro OLED...

Add support for the UG-2843HHSWEG04 OLED and for the SAM4L Xplained Pro OLED module that uses that OLED.
parent a60e38e1
No related branches found
No related tags found
No related merge requests found
Showing
with 756 additions and 269 deletions
......@@ -5032,3 +5032,12 @@
#5. From Dave (ziggurat29, 2013-6-22).
* configs/sam4l-xplained/src/sam_slcd.c: LED1 segment LCD module is now
functional (2013-6-23).
* drivers/lcd/ssd1306.c and include/nuttx/lcd/ssd1306.h. Renamed
ug-2864hsweg01.c and .h to ssd1306.c and .h. Extended to support the
UG-2832HSWEG04 which is very similar and also based on the SSD1306
controller (2013-6-23).
* configs/sam4l-xplained/src/sam_ug2832hsweg04.c: Add support for the
UG-2832HSWEG04 OLED on the SAM4L Xplained Pro's OLED1 module
(2013-6-23).
* include/debug.h: Added macro DEBUGPANIC for forces crashes when debug
is enabled.
......@@ -33,7 +33,6 @@ Contents
- FPU
- FSMC SRAM
- SSD1289
- UG-2864AMBAG01 / UG-2964SWEG01
- Mikroe-STM32F4-specific Configuration Options
- Configurations
......
......@@ -116,31 +116,64 @@ Modules
CONFIG_SAM4L_XPLAINED_IOMODULE_EXT1=y : The module is installed in EXT1
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
module.
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.
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:
----------------------
CONFIG_SAM4L_XPLAINED_OLED1MODULE=y : Informs the system that the
I/O1 module is installed
CONFIG_SAM4L_XPLAINED_OLED1MODULE=y : Informs the system that the
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
-----
This module provides a A segment LCD that connects directly to the "EXT5 SEGMENT LCD"
connector
This module provides a A segment LCD that connects directly to the "EXT5
SEGMENT LCD" connector
Configuration Options:
----------------------
CONFIG_SAM4L_XPLAINED_SLCD1MODULE=y : Informs the system that the
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
------
......@@ -681,7 +714,17 @@ Configuration sub-directories
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
changes to the configuration:
......@@ -730,16 +773,6 @@ Configuration sub-directories
behave very well (since its outgoing prompts also appear as incoming
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
functional. Testing, however, has been very light. Example:
......@@ -755,7 +788,61 @@ Configuration sub-directories
This is a test
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
changes to the configuration:
......
......@@ -76,6 +76,14 @@ CSRCS += sam_mmcsd.c
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))
SRCS = $(ASRCS) $(CSRCS)
......
......@@ -175,14 +175,15 @@
/* I/O1
*
* 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
* --- -------------- --------------- -------------------------------------
* 15 PC03 SPI/NPCS0 PB11 SPI/NPCS2 Active low chip select OUTPUT, pulled
* 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.
*/
......@@ -194,8 +195,9 @@
# if defined(CONFIG_SAM4L_XPLAINED_IOMODULE_EXT1)
# if defined(SAM4L_XPLAINED_OLED1MODULE) && defined(SAM4L_XPLAINED_OLED1MODULE_EXT1)
# error I/O1 and OLED1 cannot both reside in EXT1
# if defined(CONFIG_SAM4L_XPLAINED_OLED1MODULE) && \
defined(CONFIG_SAM4L_XPLAINED_OLED1MODULE_EXT1)
# error I/O1 and OLED1 modules cannot both reside in EXT1
# endif
# 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
# endif
# if defined(SAM4L_XPLAINED_OLED1MODULE) && defined(SAM4L_XPLAINED_OLED1MODULE_EXT2)
# error I/O1 and OLED1 cannot both reside in EXT2
# if defined(CONFIG_SAM4L_XPLAINED_OLED1MODULE) && \
defined(CONFIG_SAM4L_XPLAINED_OLED1MODULE_EXT2)
# error I/O1 and OLED1 modules cannot both reside in EXT2
# endif
# define GPIO_CD (GPIO_INTERRUPT | GPIO_INT_CHANGE | GPIO_PULL_UP | \
......@@ -229,6 +232,82 @@
# 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
************************************************************************************/
......
......@@ -101,6 +101,11 @@ void weak_function sam_spiinitialize(void)
sam_configgpio(GPIO_SD_CD); /* Card detect input */
sam_configgpio(GPIO_SD_CS); /* Chip select output */
#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);
}
#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
}
......@@ -211,3 +231,47 @@ uint8_t sam_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
}
#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
/****************************************************************************
* 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
- FSMC SRAM
- SSD1289
- UG-2864AMBAG01 / UG-2964SWEG01
- UG-2864AMBAG01 / UG-2864HSWEG01
- STM32F4Discovery-specific Configuration Options
- Configurations
......@@ -707,8 +707,8 @@ The following summarize the bit banging oprations:
WriteData(data);
}
UG-2864AMBAG01 / UG-2964SWEG01
==============================
UG-2864AMBAG01 / UG-2864HSWEG01
===============================
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
......@@ -740,9 +740,9 @@ that I am using:
(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
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
===============================================
......@@ -1437,7 +1437,7 @@ Where <subdir> is one of the following:
reconfiguration process.
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
'make menuconfig'):
......
......@@ -96,7 +96,7 @@
#define GPIO_CS_MEMS (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
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)
* PC0 OTG_FS_PowerSwitchOn
......@@ -134,7 +134,7 @@
* (1) Required because of on-board MEMS
* -------------------------------------------------------------------------
*/
#if defined(CONFIG_LCD_UG2864AMBAG01) || defined(CONFIG_LCD_UG2864HSWEG01)
# define GPIO_OLED_RESET (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN6)
......
......@@ -44,7 +44,7 @@
#include <nuttx/spi.h>
#include <nuttx/lcd/lcd.h>
#include <nuttx/lcd/ug-2864hsweg01.h>
#include <nuttx/lcd/ssd1306.h>
#include "stm32_gpio.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 */
dev = ug2864hsweg01_initialize(spi, devno);
dev = ssd1306_initialize(spi, devno);
if (!dev)
{
lcddbg("Failed to bind SPI port 1 to OLED %d: %d\n", devno);
......
......@@ -205,6 +205,7 @@ config LCD_MIO283QT2
config LCD_UG9664HSWAG01
bool "UG-9664HSWAG01 OLED Display Module"
default n
depends on SPI
---help---
OLED Display Module, UG-9664HSWAG01, Univision Technology Inc. Used
with the LPCXpresso and Embedded Artists base board.
......@@ -221,6 +222,7 @@ if LCD_UG9664HSWAG01
config UG9664HSWAG01_SPIMODE
int "UG-9664HSWAG01 SPI Mode"
default 0
range 0 3
---help---
Controls the SPI mode
......@@ -247,6 +249,68 @@ config UG9664HSWAG01_POWER
endif
config LCD_UG2864HSWEG01
bool "UG-2864HSWEG01 OLED Display Module"
default n
depends on SPI
select LCD_SSD1306
---help---
OLED Display Module, UG-2864HSWEG01, Univision Technology Inc based
on the Solomon Tech SSD1306 LCD controller.
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
Required SPI driver settings:
SPI_CMDDATA - Include support for cmd/data selection.
config LCD_UG2832HSWEG04
bool "UG-2832HSWEG04 OLED Display Module"
default n
depends on SPI && !LCD_UG2864HSWEG01
select LCD_SSD1306
---help---
OLED Display Module, UG-UG2832HSWEG04, Univision Technology Inc
based on the Solomon Tech SSD1306 LCD controller. Used with the
Atmel SAM4L Xplained Pro board on the OLED1 module.
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
Required SPI driver settings:
SPI_CMDDATA - Include support for cmd/data selection.
config LCD_SSD1306
bool
if LCD_SSD1306
config SSD1306_SPIMODE
int "SSD1306 SPI Mode"
default 0
range 0 3
---help---
Selects the SPI mode used with the SSD1306 device
config SSD1306_FREQUENCY
int "SSD1306 SPI Frequency"
default 3500000
---help---
Selects the SPI bus frequency used with the SSD1306 device
#config SSD1306_NINTERFACES
# int "Number of SSD1306 Devices"
# default 1
# ---help---
# Specifies the number of physical SSD1306 devices that will be
# supported. NOTE: At present, this must be undefined or defined to
# be 1.
endif
config LCD_ST7567
bool "ST7567 LCD Display Module"
default n
......@@ -266,6 +330,7 @@ if LCD_ST7567
config ST7567_SPIMODE
int "ST7567 SPI Mode"
default 0
range 0 3
---help---
Controls the SPI mode
......@@ -319,9 +384,10 @@ config LCD_UG2864AMBAG01
if LCD_UG2864AMBAG01
config UG2864AMBAG01_SPIMODE
config UG2864AMBAG01_SPIMODE
int "UG-2864AMBAG01 SPI Mode"
default 3
range 0 3
---help---
Controls the SPI mode
......
......@@ -51,14 +51,14 @@ ifeq ($(CONFIG_LCD_UG2864AMBAG01),y)
CSRCS += ug-2864ambag01.c
endif
ifeq ($(CONFIG_LCD_UG2864HSWEG01),y)
CSRCS += ug-2864hsweg01.c
endif
ifeq ($(CONFIG_LCD_UG9664HSWAG01),y)
CSRCS += ug-9664hswag01.c
endif
ifeq ($(CONFIG_LCD_SSD1306),y)
CSRCS += ssd1306.c
endif
ifeq ($(CONFIG_LCD_SSD1289),y)
CSRCS += ssd1289.c
endif
......
......@@ -118,6 +118,11 @@ Re-usable LCD drivers reside in the drivers/lcd directory:
Technology Inc. Used with the LPC Xpresso and Embedded Artists
base board.
ssd1306.c. OLED Display Modules based on the SSD1306 controllers.
This includes the UG-2864HSWEG01 and UG2832HSWEG04, Both from Univision
Technology Inc. The latter is used with the OLED1 module that comes
with the Atmel SAM4l Xplained Pro board.
Examples: configs/
==================
......
This diff is collapsed.
......@@ -63,43 +63,51 @@
# define VERIFY(f) \
{ if ((f) < 0) up_assert((const uint8_t *)__FILE__, (int)__LINE__); }
# define PANIC() \
up_assert((const uint8_t *)__FILE__, (int)__LINE__)
# ifdef CONFIG_DEBUG
# define DEBUGASSERT(f) \
{ if (!(f)) up_assert((const uint8_t *)__FILE__, (int)__LINE__); }
# define DEBUGVERIFY(f) \
{ if ((f) < 0) up_assert((const uint8_t *)__FILE__, (int)__LINE__); }
# define DEBUGPANIC() \
up_assert((const uint8_t *)__FILE__, (int)__LINE__)
# else
# define DEBUGASSERT(f)
# define DEBUGVERIFY(f) ((void)(f))
# endif /* CONFIG_DEBUG */
# define DEBUGPANIC()
# define PANIC() \
up_assert((const uint8_t *)__FILE__, (int)__LINE__)
# endif /* CONFIG_DEBUG */
#else
# define ASSERT(f) \
{ if (!(f)) up_assert(); }
# define VERIFY(f) \
{ if ((f) < 0) up_assert(); }
# define ASSERT(f) { if (!(f)) up_assert(); }
# define VERIFY(f) { if ((f) < 0) up_assert(); }
# define PANIC() up_assert()
# ifdef CONFIG_DEBUG
# define DEBUGASSERT(f) \
{ if (!(f)) up_assert(); }
# define DEBUGVERIFY(f) \
{ if ((f) < 0) up_assert(); }
# define DEBUGASSERT(f) { if (!(f)) up_assert(); }
# define DEBUGVERIFY(f) { if ((f) < 0) up_assert(); }
# define DEBUGPANIC() up_assert()
# else
# define DEBUGASSERT(f)
# define DEBUGVERIFY(f) ((void)(f))
# endif /* CONFIG_DEBUG */
# define PANIC(code) \
up_assert()
# define DEBUGPANIC()
# endif /* CONFIG_DEBUG */
#endif
#ifndef assert
#define assert ASSERT
# define assert ASSERT
#endif
/****************************************************************************
......
/**************************************************************************************
* include/nuttx/lcd/ug-2864hsweg01.h
*
* Driver for Univision UG-2864HSWEG01 OLED display (wih SSD1306 controller) in SPI
* mode
* Driver for Univision UG-2864HSWEG01 OLED display or UG-2832HSWEG04 both with the
* Univision SSD1306 controller in SPI mode
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* References:
* 1. Product Specification (Preliminary), Part Name: OEL Display Module, Part ID:
* UG-2864HSWEG01, Doc No: SAS1-9046-B, Univision Technology Inc.
* 2. SSD1306, 128 X 64 Dot Matrix OLED/PLED, Preliminary Segment/Common Driver with
* 2. Product Specification, Part Name: OEL Display Module, Part ID: UG-2832HSWEG04,
* Doc No.: SAS1-B020-B, Univision Technology Inc.
* 3. SSD1306, 128 X 64 Dot Matrix OLED/PLED, Preliminary Segment/Common Driver with
* Controller, Solomon Systech
*
* Redistribution and use in source and binary forms, with or without
......@@ -42,8 +44,8 @@
*
**************************************************************************************/
#ifndef __INCLUDE_NUTTX_UG_8264HSWEG01_H
#define __INCLUDE_NUTTX_UG_8264HSWEG01_H
#ifndef __INCLUDE_NUTTX_SSD1306_H
#define __INCLUDE_NUTTX_SSD1306_H
/**************************************************************************************
* Included Files
......@@ -55,7 +57,7 @@
#include <nuttx/arch.h>
#ifdef CONFIG_LCD_UG2864HSWEG01
#ifdef CONFIG_LCD_SSD1306
/**************************************************************************************
* Pre-processor Definitions
......@@ -196,7 +198,7 @@ extern "C"
**************************************************************************************/
/**************************************************************************************
* Name: ug2864hsweg01_initialize
* Name: ssd1306initialize
*
* Description:
* Initialize the UG-2864HSWEG01 video hardware. The initial state of the
......@@ -218,11 +220,10 @@ extern "C"
struct lcd_dev_s; /* See include/nuttx/lcd/lcd.h */
struct spi_dev_s; /* See include/nuttx/spi.h */
FAR struct lcd_dev_s *ug2864hsweg01_initialize(FAR struct spi_dev_s *spi,
unsigned int devno);
FAR struct lcd_dev_s *ssd1306_initialize(FAR struct spi_dev_s *spi, unsigned int devno);
/************************************************************************************************
* Name: ug2864hsweg01_fill
* Name: ssd1306_fill
*
* Description:
* This non-standard method can be used to clear the entire display by writing one
......@@ -236,11 +237,11 @@ FAR struct lcd_dev_s *ug2864hsweg01_initialize(FAR struct spi_dev_s *spi,
*
**************************************************************************************/
void ug2864hsweg01_fill(FAR struct lcd_dev_s *dev, uint8_t color);
void ssd1306_fill(FAR struct lcd_dev_s *dev, uint8_t color);
#ifdef __cplusplus
}
#endif
#endif /* CONFIG_LCD_UG2864HSWEG01 */
#endif /* __INCLUDE_NUTTX_UG_8264HSWEG01_H */
#endif /* CONFIG_LCD_SSD1306 */
#endif /* __INCLUDE_NUTTX_SSD1306_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment