49static const char*
s_tag =
"EPAPER";
60typedef enum : uint16_t {
73typedef enum : uint16_t {
95typedef enum : uint16_t {
104typedef enum : uint16_t {
114typedef enum : uint32_t {
147typedef enum : uint16_t {
158typedef enum : uint8_t {
223 return bus->
xfer8(bus->
ctx, lo, &rx);
272#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
281#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
282 if (ra8_fake_mmio_wait_eval(hrdy_key, i, ready)) {
528 const uint16_t arg0 =
566 for (
size_t i = 0U; (i + 1U) < buf_len; i += 2U) {
567 const uint16_t word =
574 if ((buf_len & 1U) != 0U) {
575 const uint16_t word =
603 *out_mode = (uint16_t)wf->
init;
606 *out_mode = (uint16_t)wf->
du;
609 *out_mode = (uint16_t)wf->
gc16;
612 *out_mode = (uint16_t)wf->
a2;
764 uint16_t readback = 0U;
769 if (readback != mv) {
827 if ((serr !=
k_ra8_ok) || (buf_len != expect)) {
904#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
906 volatile const void* lut_probe = (
volatile const void*)
s_panel.cfg.bus.ctx;
914#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
915 if (ra8_fake_mmio_wait_eval(lut_probe, i, (status == 0U))) {
943 uint16_t wf_mode = 0U;
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
ra8_board_eth_pin_t pin
Pin.
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
static ra8_epaper_panel_t s_panel
Single-instance panel context.
ra8_epaper_cmd_t
Subset of IT8951 user commands used by this driver.
@ k_ra8_epaper_cmd_sys_run
Wake from standby.
@ k_ra8_epaper_cmd_reg_rd
Register read.
@ k_ra8_epaper_cmd_ld_img_end
End load.
@ k_ra8_epaper_cmd_sleep
Enter deep-sleep.
@ k_ra8_epaper_cmd_reg_wr
Register write.
@ k_ra8_epaper_cmd_dpy_area
Refresh rectangle.
@ k_ra8_epaper_cmd_get_dev_info
40-byte info block.
@ k_ra8_epaper_cmd_ld_img_area
Begin load (rectangle).
@ k_ra8_epaper_cmd_vcom
Get / set VCOM bias.
ra8_err_t ra8_epaper_display_area(const ra8_epaper_area_t *area, ra8_epaper_waveform_t waveform)
Refresh the indicated rectangle on the physical panel.
ra8_err_t ra8_epaper_dev_info(ra8_epaper_dev_info_t *out_info)
Hand back the GET_DEV_INFO block captured during init.
ra8_epaper_wire_pf_t
LD_IMG_AREA arg0 pixel-format codes (IT8951 programming guide).
@ k_ra8_epaper_wire_pf_2bpp
2 bits per pixel.
@ k_ra8_epaper_wire_pf_8bpp
8 bits per pixel.
@ k_ra8_epaper_wire_pf_3bpp
3 bits per pixel.
@ k_ra8_epaper_wire_pf_4bpp
4 bits per pixel.
ra8_epaper_preamble_t
SPI preamble words (DS chapter 3.4 table 3-3).
@ k_ra8_epaper_preamble_cmd
Host -> command write.
@ k_ra8_epaper_preamble_rd
Host <- data read.
@ k_ra8_epaper_preamble_wr
Host -> data write.
static ra8_err_t internal_ra8_epaper_send16(uint16_t word)
Send a 16-bit word MSB-first over the injected SPI bus seam.
static ra8_err_t internal_ra8_epaper_read_data16(uint16_t *out_word)
Read a 16-bit data word (DS chapter 3.4).
static uint16_t internal_ra8_epaper_wire_pf(ra8_epaper_pixel_format_t pf)
Map a driver pixel-format selector onto the LD_IMG_AREA wire code.
static ra8_err_t internal_ra8_epaper_stream_pixels(const uint8_t *buf, size_t buf_len)
Stream a packed pixel buffer into the controller as 16-bit words.
static ra8_err_t internal_ra8_epaper_write_data16(uint16_t word)
Send a 16-bit data word (DS chapter 3.4).
ra8_epaper_state_t
Driver lifecycle state.
@ k_ra8_epaper_state_ready
Initialized and idle.
@ k_ra8_epaper_state_uninit
Not initialized yet.
static ra8_err_t internal_ra8_epaper_reg_read(uint16_t reg, uint16_t *value)
Read from an IT8951 internal register.
static ra8_err_t internal_ra8_epaper_write_cmd(uint16_t cmd)
Send a command code (DS chapter 3.4).
ra8_err_t ra8_epaper_set_vcom(uint16_t mv)
Implementation of ra8_epaper_set_vcom() – write, then read back and compare before granting the INV-V...
static ra8_err_t internal_ra8_epaper_send_load_args(const ra8_epaper_area_t *area, ra8_epaper_pixel_format_t pf, ra8_epaper_endian_t endian)
Send the LD_IMG_AREA argument block (5 words: arg0..arg4).
ra8_err_t ra8_epaper_init(const ra8_epaper_cfg_t *cfg)
Bring up the IT8951 panel against the injected SPI bus seam.
static ra8_err_t internal_ra8_epaper_wait_ready(void)
Block until the panel asserts HRDY.
ra8_epaper_reg_t
Memory-mapped controller registers we touch.
@ k_ra8_epaper_reg_lisar_hi
LISAR high half.
@ k_ra8_epaper_reg_lisar_lo
LISAR low half (DS 4.4).
@ k_ra8_epaper_reg_lutafsr
LUT busy status.
ra8_err_t ra8_epaper_sleep(void)
Drop the panel into deep-sleep (~15 uA per Waveshare AN).
static ra8_err_t internal_ra8_epaper_resolve_waveform(ra8_epaper_waveform_t waveform, uint16_t *out_mode)
Resolve a symbolic waveform selector into this panel's LUT mode.
ra8_err_t ra8_epaper_get_vcom(uint16_t *out_mv)
Read the controller's current VCOM setting, in millivolts.
ra8_err_t ra8_epaper_load_image(const ra8_epaper_area_t *area, const uint8_t *buf, size_t buf_len, ra8_epaper_pixel_format_t pf, ra8_epaper_endian_t endian)
Push a packed greyscale buffer into the controller's frame RAM.
static ra8_err_t internal_ra8_epaper_reg_write(uint16_t reg, uint16_t value)
Write to an IT8951 internal register.
static ra8_err_t internal_ra8_epaper_recv16(uint16_t *out_word)
Receive one 16-bit word MSB-first.
static ra8_err_t internal_ra8_epaper_send_display_args(const ra8_epaper_area_t *area, uint16_t wf_mode)
Send the DPY_AREA argument block (5 words: x,y,w,h,wf).
ra8_epaper_limits_t
Bounded retry / sizing limits.
@ k_ra8_epaper_white_pad
0xFF pad for odd tail.
@ k_ra8_epaper_byte_mask
Low-byte extraction mask.
@ k_ra8_epaper_lut_poll_max
LUT-busy poll budget.
@ k_ra8_epaper_dummy_tx
Dummy byte for SPI reads.
@ k_ra8_epaper_pf_shift
LD_IMG_AREA arg0 PF shift.
@ k_ra8_epaper_byte_shift
Bits per byte.
@ k_ra8_epaper_dev_info_words
40-byte block / 2.
@ k_ra8_epaper_status_unset
Pre-read sentinel value.
@ k_ra8_epaper_reset_pulse_ms
Reset assert dwell.
@ k_ra8_epaper_busy_poll_max
Outer HRDY poll budget.
static ra8_err_t internal_ra8_epaper_wait_lut_idle(void)
Poll REG_LUTAFSR until the controller reports every LUT idle.
static ra8_err_t internal_ra8_epaper_validate_load(const ra8_epaper_area_t *area, size_t buf_len, ra8_epaper_pixel_format_t pf)
Validate a load request's lifecycle, buffer size and geometry.
static ra8_err_t internal_ra8_epaper_read_dev_info(ra8_epaper_dev_info_t *out)
Read and decode the 40-byte GET_DEV_INFO response.
ra8_epaper_vcom_arg_t
Argument word selecting the direction of the VCOM command.
@ k_ra8_epaper_vcom_get
Read VCOM; one word follows back.
@ k_ra8_epaper_vcom_set
Write VCOM; one word follows out.
bool ra8_epaper_vcom_verified(void)
Implementation of ra8_epaper_vcom_verified() – the latch alone already implies the lifecycle state.
static void internal_ra8_epaper_pulse_reset(void)
Pulse the panel /RESET line low for 10 ms then back high.
IT8951 e-paper controller SPI driver – public API.
ra8_epaper_pixel_format_t
Source pixel depth for a ra8_epaper_load_image transfer.
@ k_ra8_epaper_pf_1bpp
1 bpp bi-level, 8 px per byte (A2).
@ k_ra8_epaper_pf_4bpp
4 bpp, 2 px per byte – preferred.
@ k_ra8_epaper_pf_2bpp
2 bpp, 4 px per byte.
@ k_ra8_epaper_pf_8bpp
8 bpp, one byte per pixel.
ra8_err_t ra8_epaper_validate_cfg(const ra8_epaper_cfg_t *cfg)
Validate a panel descriptor without touching any hardware.
ra8_epaper_waveform_t
Symbolic IT8951 panel-refresh waveform selectors.
@ k_ra8_epaper_wf_init
INIT - flush to white, slowest.
@ k_ra8_epaper_wf_a2
A2 - black/white only, fastest.
@ k_ra8_epaper_wf_gc16
GC16 - 16-grey full quality.
@ k_ra8_epaper_wf_du
DU - direct update, 1 bpp, fast.
ra8_epaper_endian_t
Source-buffer endianness flag for the LD_IMG_AREA transfer.
bool ra8_epaper_area_is_aligned(const ra8_epaper_area_t *area, ra8_epaper_pixel_format_t pf)
Report whether area satisfies the depth's X/width alignment.
ra8_err_t ra8_epaper_decode_dev_info(const uint16_t *words, size_t count, ra8_epaper_dev_info_t *out_info)
Decode a raw GET_DEV_INFO word block into a device-info struct.
bool ra8_epaper_geometry_agrees(const ra8_epaper_dev_info_t *info, const ra8_epaper_cfg_t *cfg)
Report whether reported panel geometry matches the descriptor.
ra8_err_t ra8_epaper_image_bytes(const ra8_epaper_area_t *area, ra8_epaper_pixel_format_t pf, size_t *out_bytes)
Bytes a packed source buffer needs for area at depth pf.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_err_hw_timeout
Hardware timed out waiting for a flag or handshake.
@ k_ra8_err_validation_failed
Validation rule failed (caller-supplied invariant not satisfied).
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Bounded wait-flag primitives for RA8D2 HAL drivers.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_warn(tag, message)
RA8 log warn.
#define ra8_log_info(tag, message)
RA8 log info.
#define ra8_log_error(tag, message)
RA8 log error.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
ra8_level_t
Digital output / input level.
@ k_ra8_level_high
Drive or read 1.
@ k_ra8_level_low
Drive or read 0.
#define RA8_PIN_PORT(p)
Extract the port index from a packed ra8_port_pin_t.
IOPORT (GPIO) register layout for the Renesas RA8D2.
static volatile r_port_regs_t * ra8_port(ra8_port_t port)
Get the PORT register window for a given port index.
High-level GPIO helpers on top of the PORT + PFS register layer.
ra8_err_t ra8_gpio_read(ra8_port_pin_t pin, ra8_level_t *out_level)
Read a previously-configured input.
ra8_err_t ra8_gpio_write(ra8_port_pin_t pin, ra8_level_t level)
Drive a previously-configured output to the given level.
Injected SPI-bus seam consumed by Ring-3 SPI device drivers.
SysTick-based tick counter, delay and timestamp helpers.
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
volatile uint32_t PCNTR2
PCNTR2 – { EIDR[31:16], PIDR[15:0] } (read-only).
Rectangle descriptor (top-left + size) used by load + display.
uint16_t x
Top-left X in panel coords (0 = left).
uint16_t y
Top-left Y in panel coords (0 = top).
uint16_t height
Height in pixels.
uint16_t width
Width in pixels.
Configuration descriptor for ra8_epaper_init.
Decoded GET_DEV_INFO (0x0302) response.
File-scope panel context.
ra8_epaper_cfg_t cfg
Copy of init cfg.
ra8_epaper_state_t state
Current lifecycle state.
ra8_epaper_dev_info_t info
Decoded GET_DEV_INFO from init.
uint16_t vcom_mv
Last verified VCOM magnitude, mV.
bool vcom_verified
INV-VCOM-1 permit; see.
Caller-filled SPI transfer seam: one full-duplex byte exchange.
void * ctx
Opaque cookie handed to xfer8 (binder-owned).
ra8_err_t(* xfer8)(void *ctx, uint8_t tx, uint8_t *rx)
Full-duplex single-byte exchange on the bound bus.