Expand description
§Chipone CO5300 AMOLED Display Controller Driver
A no_std driver for the CO5300, following the CO5300 datasheet V0.01 (Chipone, 24 July
2023). The driver speaks commands; how they reach the chip is up to an Interface
implementation, so the same driver runs over:
- 4-wire SPI with a D/C pin:
SpiInterface, onembedded-halSpiDeviceandOutputPin; - single-line SPI with the datasheet’s instruction/address framing:
FramedSpiInterface; - Quad-SPI, through your HAL’s half-duplex transfer and the
qspiframing helper; - a MIPI-DSI panel IO, such as ESP-IDF’s
esp_lcd_panel_io_tx_param/tx_color(see below).
Enable the async feature for an async driver (asynch::Co5300) on AsyncInterface,
and the embedded-graphics feature for a DrawTarget
that writes straight to the chip’s frame memory, without a frame buffer in the host.
use co5300::{Co5300, Config, SpiInterface};
let iface = SpiInterface::new(spi, dc);
let mut display = Co5300::new(iface, Config::new(410, 502));
// After a hardware reset (`co5300::reset`): sleep out, RGB565, full brightness, display on.
display.init(&mut delay, &[])?;
// Fill the top-left 4 x 2 pixels with red (RGB565, MSB first).
display.set_window(0, 0, 4, 2)?;
display.write_pixels(&[0xF8, 0x00].repeat(8))?;§Panel initialization
The CO5300 drives many different AMOLED panels; their power, gamma and timing settings
live in the manufacturer command pages and come from the panel vendor, not from the chip
datasheet. Co5300::init therefore only sends the chip-level commands the datasheet
requires and accepts a panel-specific command list, sent first:
const PANEL: &[PanelCommand] = &[
(0xFE, &[0x20]), // vendor page, unlock, settings ...
(0xFE, &[0x00]),
];
display.init(&mut delay, PANEL)?;panel::ESPRESSIF_DEFAULT holds the default sequence of Espressif’s esp_lcd_co5300
component.
§Window alignment
CASET and RASET require an even start and an even length (datasheet sections 7.5.21
and 7.5.22). Co5300::set_window rejects other windows with Error::InvalidWindow;
the embedded-graphics target widens them, see its documentation.
§MIPI-DSI: ESP-IDF panel IO
On a board where the CO5300 hangs off MIPI-DSI (such as the Kode Dot below), the ESP-IDF DSI bus stays in charge; an adapter in the board crate forwards the two calls:
struct PanelIo(esp_lcd_panel_io_handle_t);
impl co5300::Interface for PanelIo {
type Error = EspError;
// MIPI-DSI: no SetSPIMode (C4h) in `init`.
const SPI_RAM_WRITE: bool = false;
fn write_command(&mut self, command: u8, params: &[u8]) -> Result<(), EspError> {
esp!(unsafe {
esp_lcd_panel_io_tx_param(self.0, command.into(), params.as_ptr().cast(), params.len())
})
}
fn write_pixels(&mut self, command: u8, data: &[u8]) -> Result<(), EspError> {
esp!(unsafe {
esp_lcd_panel_io_tx_color(self.0, command.into(), data.as_ptr().cast(), data.len())
})
}
}When the pixels come from a DPI frame buffer (video mode), only the command path is used.
§Board: Kode Dot
The Kode Dot (ESP32-P4) drives the CO5300 over MIPI-DSI; ESP-IDF owns the DSI bus, the
DPI interface and the frame buffer. The panel is 410 × 502 pixels (KODE_DOT in the
handheld screen constants), so use Config::new(410, 502). Before init:
- The panel supply
VCI_ENcomes from TCA6408A pin P7: latch P7 high, then make it an output, then wait 20 ms. - Reset is shared with the touch controller on GPIO7: low for 10 ms, high, then wait
120 ms (
resetdoes exactly this). - The DSI PHY LDO runs at 2.5 V.
The datasheet lists resolutions up to 480 lines (and 192 × 960); 502 lines is the board’s value, not one of the datasheet’s.
Re-exports§
pub use co5300_registers as registers;
Modules§
- asynch
async - Async driver on
AsyncInterface. - graphics
embedded-graphics - An
embedded-graphicsDrawTargeton the blocking driver. - panel
- Panel-specific command lists for
Co5300::init. - qspi
- Quad-SPI framing, independent of any HAL.
Structs§
- Address
Range - An inclusive column or row range, the parameters of
CASET(2Ah) andRASET(2Bh). - Co5300
- Blocking CO5300 driver.
- Config
- Display geometry and the settings
Co5300::initapplies. - Ctrl
Display WRCTRLD(53h), datasheet section 7.5.40.- Framed
SpiInterface - The CO5300 on a single-line SPI bus (
CSX,SCL,SDI), using the Quad-SPI interface’s Standard SPI framing (datasheet section 5.2.2, “QSPI 1-wire write”). - Madctl
MADCTL(36h), datasheet section 7.5.29.- SpiInterface
- The CO5300 on a 4-wire SPI bus:
CSX,SCL,SDIand theD/CXpin.
Enums§
- AclMode
- The ACL (auto current limit) setting in
AclControl, datasheet section 7.5.42. - Command
- The user command set (
CMD1), datasheet section 7.4 “Command List”. - Enhancement
Level - The sunlight readable enhancement level in
ColorEnhance, datasheet section 7.5.44. - Error
- A driver error.
- Pixel
Format - A pixel format in
Colmod, datasheet section 7.5.32. - SpiError
- An error of
SpiInterface: either the SPI device or the D/C pin failed. - Tearing
Effect - The tearing effect output mode (
TEON, 35h).
Constants§
- RESET_
LOW_ MS - How long
resetholdsRESXlow, in milliseconds. - RESET_
WAIT_ MS - How long
resetwaits after releasingRESX, in milliseconds. - SLEEP_
OUT_ TO_ DISPLAY_ ON_ MS - The wait between
SLPOUTandDISPON, in milliseconds (T4, section 5.6.2). - SLEEP_
WAIT_ MS - The wait after
SLPINorSLPOUTbefore the next command, in milliseconds (sections 7.5.11 and 7.5.12). - SOFTWARE_
RESET_ WAIT_ MS - The wait after
SWRESETbeforeSLPOUTwhen reset in Sleep Out mode, in milliseconds (section 7.5.2). Other commands may follow after 5 ms.
Traits§
- Async
Interface async - The async twin of
Interface. - Interface
- A transport that carries CO5300 commands and pixel data.
Functions§
- reset
- Resets the chip through its active-low
RESXpin: low forRESET_LOW_MS, high, then a wait ofRESET_WAIT_MS.
Type Aliases§
- Panel
Command - A panel-specific command: the command code and its parameter bytes.