e-ink ssd1680 driver

No BSP files
This commit is contained in:
Adam Kaliszan 2022-06-10 14:03:19 +02:00 committed by Xiang Xiao
parent 16286081e1
commit 88bfadc55d
5 changed files with 1824 additions and 0 deletions

View File

@ -1509,6 +1509,54 @@ config LCD_FT80X_AUDIO_GPIO
endif # LCD_FT80X
config LCD_SSD1680
bool "SSD1680 E-PAPER Single Chip Driver"
default n
select SPI_CMDDATA
---help---
e-paper Display Module based on SSD1680 controller.
Required SPI driver settings:
SPI_CMDDATA - Include support for cmd/data selection.
if LCD_SSD1680
choice
prompt "Display type and size"
default LCD_SSD1680_2_9
config LCD_SSD1680_2_13
bool "2.13 inch 122/250 mono"
config LCD_SSD1680_2_13_RED
bool "2.13 inch 122/250 tri color (red)"
config LCD_SSD1680_2_9
bool "2.9 inch 128/296 mono"
config LCD_SSD1680_2_9_RED
bool "2.9 inch 128/296 tri color (red)"
endchoice # Display size
config SSD1680_SPIMODE
int "SSD1680 SPI Mode"
default 0
range 0 3
---help---
Selects the SPI mode used with the SSD1680 device
config SSD1680_FREQUENCY
int "SSD1680 SPI Frequency"
default 2000000
range 100000 2000000
---help---
Selects the SPI bus frequency used with the SSD1680 device.
Max for read mode is 2.5 MHz, for write mode is 20 HHz
endif # LCD_SSD1680
endmenu # LCD Driver selection
endif # LCD

View File

@ -73,6 +73,10 @@ ifeq ($(CONFIG_LCD_SSD1289),y)
CSRCS += ssd1289.c
endif
ifeq ($(CONFIG_LCD_SSD1680),y)
CSRCS += ssd1680.c
endif
ifeq ($(CONFIG_LCD_SSD1351),y)
CSRCS += ssd1351.c
endif

1382
drivers/lcd/ssd1680.c Normal file

File diff suppressed because it is too large Load Diff

197
drivers/lcd/ssd1680.h Normal file
View File

@ -0,0 +1,197 @@
/****************************************************************************
* drivers/lcd/ssd1680.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __DRIVERS_LCD_SSD1680_H
#define __DRIVERS_LCD_SSD1680_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <nuttx/lcd/lcd.h>
#include <nuttx/lcd/ssd1680.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Limitations of the current configuration that I hope to fix someday */
#if !defined(CONFIG_LCD_SSD1680_2_13) && !defined(CONFIG_LCD_SSD1680_2_9)
# error "Unknown and unsupported SSD16800 LCD"
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef CONFIG_NX_BGCOLOR
# define CONFIG_NX_BGCOLOR SSD1680_Y1_BLACK
#endif
/* SSD1680 Commands *********************************************************/
#define SSD1680_DRIVER_CONTROL 0x01
#define SSD1680_GATE_VOLTAGE 0x03
#define SSD1680_SOURCE_VOLTAGE 0x04
#define SSD1680_PROGOTP_INITIAL 0x08
#define SSD1680_PROGREG_INITIAL 0x09
#define SSD1680_READREG_INITIAL 0x0A
#define SSD1680_BOOST_SOFTSTART 0x0C
#define SSD1680_GATE_SCAN_POSITION 0x0F
#define SSD1680_DEEP_SLEEP 0x10
#define SSD1680_DATA_MODE 0x11
#define SSD1680_SW_RESET 0x12
#define SSD1680_TEMP_CONTROL 0x18
#define SSD1680_TEMP_WRITE 0x1A
/* Execute sequence written in Control Register 2
* Wait till SSD1680 is not busy
*/
#define SSD1680_MASTER_ACTIVATE 0x20
#define SSD1680_DISP_CTRL1 0x21
/* Set control register 2.
* 1 byte of data with following bits:
* 0x80 - enable clock signal
* 0x40 - enable analog
* 0x20 - load temperature value (endless busy state. Don't use)
* 0x10 - Load LUT (endless busy state. Probably OTP wasn't prepared)
* 0x08 - Display Mode 2
* 0x04 - disable OSC
* 0x01 - disable clock signal
* 0x02 - disable analog
*/
#define SSD1680_DISP_CTRL2 0x22
#define SSD1680_WRITE_RAM1 0x24
#define SSD1680_WRITE_RAM2 0x26
#define SSD1680_WRITE_VCOM 0x2C
#define SSD1680_READ_OTP 0x2D
#define SSD1680_READ_STATUS 0x2F
#define SSD1680_WRITE_LUT 0x32
#define SSD1680_WRITE_BORDER 0x3C
#define SSD1680_SET_RAMXPOS 0x44
#define SSD1680_SET_RAMYPOS 0x45
#define SSD1680_SET_RAMXCOUNT 0x4E
#define SSD1680_SET_RAMYCOUNT 0x4F
#define SSD1680_NOP 0x7F
/* Color Properties *********************************************************/
#if defined(CONFIG_LCD_SSD1680_2_13) || defined(CONFIG_LCD_SSD1680_2_9)
/* 1 bit per pixel */
# define SSD1680_DEV_COLORFMT FB_FMT_Y1
# define SSD1680_DEV_BPP 1
# define SSD1680_NO_OF_PLANES 1
#elif defined (CONFIG_LCD_SSD1680_2_13_RED) || (CONFIG_LCD_SSD1680_2_9_RED)
/* 2 bits per pixel, it is not agrayscale, but indexed colours */
# define SSD1680_DEV_COLORFMT FB_FMT_Y2
# define SSD1680_DEV_BPP 2
# define SSD1680_NO_OF_PLANES 1
#else
#error "Can't prepare macros for not supported display"
#endif
#if SSD1680_DEV_BPP == 1
# define SSD1680_PDF 3
# define SSD1680_PDV 8
#elif SSD1680_DEV_BPP == 2
# define SSD1680_PDF 2
# define SSD1680_PDV 4
#else
# error "SSD1680: Bits per pixel not defined"
#endif
/* Display Resolution
*
* The SSD1680 display controller can handle a resolution of 176/296.
* The portrait mode is default.
* Display size vs its resolution:
* 2.13 : 122 / 250
* 2.9 : 128 / 296
*/
#if defined(CONFIG_LCD_SSD1680_2_13) || defined(CONFIG_LCD_SSD1680_2_13_RED)
# define SSD1680_DEV_GATE_LAYOUT 0x00
# define SSD1680_DEV_NATIVE_XRES 122
# define SSD1680_DEV_NATIVE_YRES 250
#elif defined(CONFIG_LCD_SSD1680_2_9) || defined(CONFIG_LCD_SSD1680_2_9_RED)
# define SSD1680_DEV_GATE_LAYOUT 0x00
# define SSD1680_DEV_NATIVE_XRES 128
# define SSD1680_DEV_NATIVE_YRES 296
#endif
/* SSD1680 memory write algorithm */
#if defined(CONFIG_LCD_PORTRAIT)
# define SSD1680_VAL_DATA_MODE 0x03
#elif defined(CONFIG_LCD_RPORTRAIT)
# define SSD1680_VAL_DATA_MODE 0x02
#elif defined(CONFIG_LCD_LANDSCAPE)
# define SSD1680_VAL_DATA_MODE 0x07
#elif defined(CONFIG_LCD_RLANDSCAPE)
# define SSD1680_VAL_DATA_MODE 0x07
#endif
/* Rotating screen if the orientation is changed */
#if defined(CONFIG_LCD_PORTRAIT) || defined(CONFIG_LCD_RPORTRAIT)
/* Calculate number of bytes per row.
* In case of tri-color display there are two 1-bit data arrays
* In order to simplify communication with controller, we need to provide
* a number that is multiplication of 8 (not 4 even if we have 2 bpp)
*/
# define SSD1680_DEV_ROWSIZE \
((SSD1680_DEV_NATIVE_XRES + SSD1680_PDV - 1) >> SSD1680_PDF)
# define SSD1680_DEV_FB_XRES SSD1680_DEV_NATIVE_XRES
# define SSD1680_DEV_FB_YRES SSD1680_DEV_NATIVE_YRES
#else /* Landstape */
# define SSD1680_DEV_ROWSIZE \
((SSD1680_DEV_NATIVE_YRES + SSD1680_PDV - 1) >> SSD1680_PDF)
# define SSD1680_DEV_FB_XRES SSD1680_DEV_NATIVE_YRES
# define SSD1680_DEV_FB_YRES SSD1680_DEV_NATIVE_XRES
#endif /* Landstape */
#define SSD1680_DEV_X_ROUND_UP \
(((SSD1680_DEV_NATIVE_XRES + SSD1680_PDV - 1) >> SSD1680_PDF) << SSD1680_PDF)
#define SSD1680_DEV_Y_ROUND_UP \
(((SSD1680_DEV_NATIVE_YRES + SSD1680_PDV - 1) >> SSD1680_PDF) << SSD1680_PDF)
#define SSD1680_DEV_FBSIZE ((SSD1680_DEV_ROWSIZE) * (SSD1680_DEV_FB_YRES))
/****************************************************************************
* Public Type Definition
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#endif /* __DRIVERS_LCD_SSD1680_H */

193
include/nuttx/lcd/ssd1680.h Normal file
View File

@ -0,0 +1,193 @@
/****************************************************************************
* include/nuttx/lcd/ssd1680.h
*
* Driver for Solomon Systech SSD1680 e-paper controller
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_LCD_SSD1680_H
#define __INCLUDE_NUTTX_LCD_SSD1680_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <nuttx/arch.h>
#ifdef CONFIG_LCD_SSD1680
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* SSD1680 configuration settings:
*
* CONFIG_SSD1680_SPIMODE - Controls the SPI mode
* CONFIG_SSD1680_FREQUENCY - Define to use a different bus frequency
*
* Required LCD driver settings:
*
* CONFIG_LCD_MAXCONTRAST should be 255, but any value >0 and <=255
* will be accepted.
* CONFIG_LCD_MAXPOWER must be 1
*
* Optional LCD driver settings:
* CONFIG_LCD_LANDSCAPE, CONFIG_LCD_PORTRAIT, CONFIG_LCD_RLANDSCAPE, and
* CONFIG_LCD_RPORTRAIT - Display orientation.
*
* Required SPI driver settings:
* CONFIG_SPI_CMDDATA - Include support for cmd/data selection.
*/
/* SPI Interface
*
* "The serial interface consists of serial clock SCL, serial data SI, CS and
* CMD/!DTA. SI is shifted into an 8-bit shift register on every rising edge
* of SCL in the order of D7, D6, ... and D0. CMD/!DTA is sampled on every
* eighth clock and the data byte in the shift register is written to the
* display data RAM or command register in the same clock."
*
* "This module determines whether the input data is interpreted as data or
* command. When CMD/!DTA = "H," the inputs at D7 - D0 are interpreted as
* data and be written to display RAM. When CMD/!DTA = "L", the inputs at
* D7 - D0 are interpreted as command, they will be decoded and be written
* to the corresponding command registers."
*/
#ifndef CONFIG_SPI_CMDDATA
# error "CONFIG_SPI_CMDDATA must be defined in your NuttX configuration"
#endif
/* Check contrast selection */
#if !defined(CONFIG_LCD_MAXCONTRAST)
# define CONFIG_LCD_MAXCONTRAST 255
#endif
#if CONFIG_LCD_MAXCONTRAST <= 0 || CONFIG_LCD_MAXCONTRAST > 255
# error "CONFIG_LCD_MAXCONTRAST exceeds supported maximum"
#endif
/* Check power setting */
#if !defined(CONFIG_LCD_MAXPOWER)
# define CONFIG_LCD_MAXPOWER 1
#endif
#if CONFIG_LCD_MAXPOWER != 1
# warning "CONFIG_LCD_MAXPOWER exceeds supported maximum"
# undef CONFIG_LCD_MAXPOWER
# define CONFIG_LCD_MAXPOWER 1
#endif
/* Color is 1bpp monochrome with leftmost column contained in bits 0 */
#ifdef CONFIG_NX_DISABLE_1BPP
# warning "1 bit-per-pixel support needed"
#endif
/* Orientation */
#if defined(CONFIG_LCD_LANDSCAPE)
# undef CONFIG_LCD_PORTRAIT
# undef CONFIG_LCD_RLANDSCAPE
# undef CONFIG_LCD_RPORTRAIT
#elif defined(CONFIG_LCD_PORTRAIT)
# undef CONFIG_LCD_LANDSCAPE
# undef CONFIG_LCD_RLANDSCAPE
# undef CONFIG_LCD_RPORTRAIT
#elif defined(CONFIG_LCD_RLANDSCAPE)
# undef CONFIG_LCD_LANDSCAPE
# undef CONFIG_LCD_PORTRAIT
# undef CONFIG_LCD_RPORTRAIT
#elif defined(CONFIG_LCD_RPORTRAIT)
# undef CONFIG_LCD_LANDSCAPE
# undef CONFIG_LCD_PORTRAIT
# undef CONFIG_LCD_RLANDSCAPE
#else
# define CONFIG_LCD_LANDSCAPE 1
# warning "Assuming landscape orientation"
#endif
/* Some important "colors" */
#define SSD1680_Y1_BLACK 0
#define SSD1680_Y1_WHITE 1
/****************************************************************************
* Public Types
****************************************************************************/
struct ssd1680_priv_s
{
bool (*set_vcc) (bool on); /* Allow board to control display power. Return
* true if request state set successfully. */
bool (*set_rst) (bool on); /* Hardware reset support */
bool (*check_busy) (void); /* Checks the state of busy pin */
};
/****************************************************************************
* Public Data
****************************************************************************/
#ifdef __cplusplus
extern "C"
{
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: ssd1680initialize
*
* Description:
* Initialize the video hardware. The initial state of the OLED is
* fully initialized, display memory cleared, and the OLED ready to
* use, but with the power setting at 0 (full off == sleep mode).
*
* Input Parameters:
*
* dev - A reference to the SPI driver instance.
* board_priv - Board specific structure.
*
* Returned Value:
*
* On success, this function returns a reference to the LCD object for
* the specified OLED. NULL is returned on any failure.
*
****************************************************************************/
struct lcd_dev_s; /* See include/nuttx/lcd/lcd.h */
struct spi_dev_s; /* See include/nuttx/spi/spi.h */
FAR struct lcd_dev_s *ssd1680_initialize(FAR struct spi_dev_s *dev,
FAR const struct ssd1680_priv_s *board_priv);
#ifdef __cplusplus
}
#endif
#endif /* CONFIG_LCD_SSD1680 */
#endif /* __INCLUDE_NUTTX_LCD_SSD1680_H */