Chipone CO5300 AMOLED Display Controller Driver
A platform-agnostic, transport-agnostic driver for the Chipone CO5300 AMOLED display controller.
The driver speaks CO5300 commands through an Interface trait with two methods,
write_command(cmd, params) and write_pixels(cmd, data), plus an async twin
(AsyncInterface, async feature). That fits:
- 4-wire SPI with a D/C pin:
SpiInterface, onembedded-hal1.0SpiDeviceandOutputPin; - single-line SPI with the datasheet's
02hinstruction/address framing:FramedSpiInterface, no D/C pin needed; - Quad-SPI: build an adapter on the
qspiframing helper and your HAL's half-duplex transfer (no HAL dependency in this crate); - MIPI-DSI through ESP-IDF's
esp_lcd_panel_io_tx_param/tx_color, as on the Kode Dot (an example adapter is in the crate documentation).
use ;
let mut display = new;
reset?;
display.init?; // panel-specific commands go in the slice
display.set_window?;
display.write_pixels?; // RAMWR
display.write_pixels_continue?; // RAMWRC
display.set_brightness?;
With the embedded-graphics feature, the driver is a DrawTarget<Color = Rgb565> that
writes through the interface, a window and a contiguous fill at a time, with no frame
buffer in the host. The chip only accepts windows with an even start and length, so
unaligned areas are widened by one pixel with their edge pixels repeated.
Text, lines and outlines draw single pixels through draw_iter, and each one becomes a
2 × 2 block costing three bus transfers, so they come out smeared and slow. Draw them into
an embedded-graphics Framebuffer instead, the whole display or a band of rows, and
blit it with one aligned fill_contiguous, which is exact and fast. Image over
Framebuffer::as_image does that:
use ;
use Image;
use ;
use ;
use *;
use Text;
// A 120 x 20 band: even size and even position keep the blit exact.
type Band = }>;
let mut band = new;
let style = new;
new.draw.unwrap; // Infallible
new.draw?; // one fill_contiguous
Implemented so far
- Hardware reset with datasheet timing, and initialization: panel commands, user command
page,
SetSPIModefor SPI transports,SLPOUT,COLMOD, brightness,DISPON - Sleep in/out, display on/off, software reset, deep standby, idle mode
- Brightness, brightness control, HBM brightness and mode, ACL, sunlight enhancement
- Pixel format (RGB565, RGB666, RGB888),
MADCTL, inversion - Tearing effect on/off and scan line
- Memory window with alignment checks, memory write and continue
- Direct access to the command map via
co5300-registers
Not implemented: reads (no interface needs them for drawing), partial mode, the
manufacturer command pages beyond passing them through init.
Sources
Chip facts are from the CO5300 datasheet V0.01 (24 July 2023); the register facts are
listed in co5300-registers. The driver adds:
| Fact | Source |
|---|---|
Interfaces: MIPI-DSI and Quad-SPI, selected by IM[1:0] |
Datasheet 1; 4.4; 5.1 |
Quad-SPI framing: 02h, {00h, CMD, 00h}, parameters, all on SIO0; pixel instructions and line usage; RGB565 MSB first |
Datasheet 5.2.1; 5.2.2 (figures on pages 21–24) |
D/CX: low command, high parameter or display data; DCX setup/hold 4 ns |
Datasheet 4.2; 6.4 |
| SDI sampled on the rising edge of SCL; write cycle ≥ 20 ns | Datasheet 5.2; 6.4 |
RESX low ≥ 10 µs; wait 5 ms before commands and 120 ms before SLPOUT |
Datasheet 6.6 |
Power-on: initial code, then SLPOUT, then ≥ 60 ms to DISPON |
Datasheet 5.6.2 (T4) |
5 ms after SLPIN/SLPOUT; 120 ms from SLPOUT to SLPIN; 83 ms from SLPIN to RESX low |
Datasheet 7.5.11; 7.5.12; 5.6.3 (T6) |
5 ms after SWRESET, 120 ms before SLPOUT if reset in Sleep Out mode |
Datasheet 7.5.2 |
RAMWR starts at the window origin; RAMWRC continues |
Datasheet 7.5.23; 7.5.33 |
| Window start and length even | Datasheet 7.5.21; 7.5.22 |
| Up to 480 source columns | Datasheet 1 |
| 4-wire SPI byte layout: one 8-bit command byte with D/C low, then parameters with D/C high | esp_lcd_co5300 v2.2.0, CO5300_PANEL_IO_SPI_CONFIG (lcd_cmd_bits = 8, dc_gpio_num) |
| SPI mode 0 works | esp_lcd_co5300 v2.2.0, spi_mode = 0 |
SPI and Quad-SPI hosts set C4h = 80h during initialization |
esp_lcd_co5300 v2.2.0, vendor_specific_init_default; Zephyr display_co5300.c, co5300_configure_panel (SPI and MSPI buses only) |
Plain SPI hosts use the 02h single-line framing |
Zephyr chipone,co5300-spi.yaml |
panel::ESPRESSIF_DEFAULT command list |
esp_lcd_co5300 v2.2.0, vendor_specific_init_default |
No code was taken from esp_lcd_co5300, Zephyr or other CO5300 drivers; the facts above
were restated from them.
Assumptions
CSXmay go high between a command byte and its parameters in 4-wire SPI mode.initholds the brightness fromConfig(defaultFFh), since the reset default00hshows nothing; it relies onWRCTRLD's reset default (BCTRLset).COLMODis written with the same format inVIPFandIFPF.resetholdsRESXlow for 10 ms, not the 10 µs minimum, so it also ends deep standby (more than 3 ms).
License
Copyright © 2026 Markus Mayer
Triple licensed under your choice of either of:
- European Union Public Licence, Version 1.2, (LICENSE-EUPL or https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12)
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)