co5300 0.1.0

A platform-agnostic, transport-agnostic driver for the Chipone CO5300 AMOLED display controller
Documentation

Chipone CO5300 AMOLED Display Controller Driver

Crates.io Docs Build Status Safety Dance MSRV EUPL 1.2 licensed Apache 2.0 licensed MIT licensed

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, on embedded-hal 1.0 SpiDevice and OutputPin;
  • single-line SPI with the datasheet's 02h instruction/address framing: FramedSpiInterface, no D/C pin needed;
  • Quad-SPI: build an adapter on the qspi framing 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 co5300::{Co5300, Config, SpiInterface};

let mut display = Co5300::new(SpiInterface::new(spi, dc), Config::new(410, 502));
co5300::reset(&mut rst, &mut delay)?;
display.init(&mut delay, &[])?; // panel-specific commands go in the slice

display.set_window(0, 0, 410, 2)?;
display.write_pixels(&rows)?;          // RAMWR
display.write_pixels_continue(&more)?; // RAMWRC
display.set_brightness(0x80)?;

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 embedded_graphics::framebuffer::{Framebuffer, buffer_size};
use embedded_graphics::image::Image;
use embedded_graphics::mono_font::{MonoTextStyle, ascii::FONT_6X10};
use embedded_graphics::pixelcolor::{Rgb565, raw::{BigEndian, RawU16}};
use embedded_graphics::prelude::*;
use embedded_graphics::text::Text;

// A 120 x 20 band: even size and even position keep the blit exact.
type Band = Framebuffer<Rgb565, RawU16, BigEndian, 120, 20, { buffer_size::<Rgb565>(120, 20) }>;
let mut band = Band::new();
let style = MonoTextStyle::new(&FONT_6X10, Rgb565::WHITE);
Text::new("Hello", Point::new(2, 14), style).draw(&mut band).unwrap(); // Infallible
Image::new(&band.as_image(), Point::new(40, 100)).draw(&mut display)?; // one fill_contiguous

Implemented so far

  • Hardware reset with datasheet timing, and initialization: panel commands, user command page, SetSPIMode for 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

  • CSX may go high between a command byte and its parameters in 4-wire SPI mode.
  • init holds the brightness from Config (default FFh), since the reset default 00h shows nothing; it relies on WRCTRLD's reset default (BCTRL set).
  • COLMOD is written with the same format in VIPF and IFPF.
  • reset holds RESX low 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: