82typedef enum : uint16_t {
94typedef enum : uint16_t {
107typedef enum : uint16_t {
118typedef enum : uint32_t {
132typedef enum : uint8_t {
152typedef enum : uint16_t {
243typedef enum : uint16_t {
275 const uint32_t cell = (uint32_t)
k_ep_cell;
276 const uint32_t sum = ((uint32_t)x / cell) + ((uint32_t)y / cell);
308static bool ep_region_fits(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t pw, uint16_t ph)
310 return ((uint32_t)x + (uint32_t)w <= (uint32_t)pw) && ((uint32_t)y + (uint32_t)h <= (uint32_t)ph);
357 buf[0] = (uint8_t)
'0';
364 tmp[n] = (uint8_t)(
'0' + (uint8_t)(v % (uint32_t)
k_ep_radix));
368 for (uint32_t i = 0U; i < n; i++) {
369 buf[i] = tmp[n - 1U - i];
393 __asm__
volatile(
"wfi");
411static void ep_emit(
const uint8_t* data, uint32_t len)
431 uint32_t cpuclk0_hz = 0U;
488 .pclka_hz = pclka_hz,
617 .store = {.read =
nullptr, .write =
nullptr, .ctx =
nullptr},
618 .has_provisioned =
false,
619 .provisioned_mv = 0U,
642 uint16_t* px = (uint16_t*)
s_fb.pixels;
643 for (uint16_t y = 0U; y <
s_fb.height_px; ++y) {
644 const uint32_t row = (uint32_t)y * (uint32_t)
s_fb.width_px;
645 for (uint16_t x = 0U; x <
s_fb.width_px; ++x) {
664 uint16_t* px = (uint16_t*)
s_fb.pixels;
667 for (uint16_t y = (uint16_t)
k_ep_box_y; y < y_limit; ++y) {
668 const uint32_t row = (uint32_t)y * (uint32_t)
s_fb.width_px;
669 for (uint16_t x = (uint16_t)
k_ep_box_x; x < x_limit; ++x) {
692 static const uint8_t k_prefix[] =
"epaper: ";
693 static const uint8_t k_ms_sep[] =
" ms=";
694 static const uint8_t k_px_sep[] =
" px=";
697 for (uint32_t i = 0U; i < (
sizeof(k_prefix) - 1U); i++) {
698 line[pos++] = k_prefix[i];
700 for (uint32_t i = 0U; (label[i] !=
'\0') && (pos < (uint32_t)
k_ep_line_max); i++) {
701 line[pos++] = (uint8_t)label[i];
703 for (uint32_t i = 0U; i < (
sizeof(k_ms_sep) - 1U); i++) {
704 line[pos++] = k_ms_sep[i];
707 for (uint32_t i = 0U; i < (
sizeof(k_px_sep) - 1U); i++) {
708 line[pos++] = k_px_sep[i];
711 line[pos++] = (uint8_t)
k_ep_cr;
712 line[pos++] = (uint8_t)
k_ep_lf;
729 static const uint8_t k_prefix[] =
"epaper: init ok panel=";
732 for (uint32_t i = 0U; i < (
sizeof(k_prefix) - 1U); i++) {
733 line[pos++] = k_prefix[i];
736 line[pos++] = (uint8_t)
'x';
738 line[pos++] = (uint8_t)
k_ep_cr;
739 line[pos++] = (uint8_t)
k_ep_lf;
811 uint32_t pclka_hz = 0U;
void main(void)
Secure fallback main entry point.
@ k_ep_uart_baud
Console baud.
static display_handle_t * s_display
static uint16_t s_framebuffer[(size_t) k_panel_height_px *(size_t) k_panel_width_px]
1024x600 RGB565 framebuffer in external SDRAM (GLCDC scans this).
static const uint8_t k_ep_msg_pass[]
PASS / FAIL banners.
ep_bus_t
SPI + UART bring-up parameters.
@ k_ep_spi_baud_hz
10 MHz (<= IT8951 24 MHz ceiling).
@ k_ep_spi_channel
SPI_B channel 0 drives the panel.
@ k_ep_heartbeat_ms
LED heartbeat period after PASS.
@ k_ep_powerup_ms
PLL / panel settle before init.
static void ep_paint_region_black(void)
Blacken the partial-refresh sub-rectangle in the framebuffer.
ep_fmt_t
UART line-formatting constants.
@ k_ep_radix
Decimal radix.
@ k_ep_line_max
Max chars in one console line.
@ k_ep_dec_digits
Max decimal digits for a uint32_t.
ep_color_t
RGB565 shades used by the test pattern.
@ k_ep_white
Full white (maps to 8bpp 255).
@ k_ep_black
Full black (maps to 8bpp 0).
static bool ep_calibrate_vcom(void)
Resolve this panel's VCOM and programme it, or refuse to draw.
ep_geom_t
Panel + framebuffer geometry.
@ k_ep_panel_w
Panel + framebuffer width (px).
@ k_ep_cell
Checkerboard cell size (px).
@ k_ep_panel_h
Panel + framebuffer height (px).
static ra8_epaper_cfg_t s_epaper_cfg
IT8951 descriptor handed to the e-ink backend via panel_timing.
static const uint8_t k_ep_msg_fail[]
static void ep_panic_halt(void)
Halt forever with the red board LED on.
static uint16_t ep_checker_px(uint16_t x, uint16_t y)
Checkerboard colour for a framebuffer pixel.
static void ep_run_refresh_cycle(ra8_err_t *full_err, ra8_err_t *part_err)
Drive the full (checker/GC16) then partial (box/A2) refresh cycle.
static ra8_err_t ep_vcom_get(void *ctx, uint16_t *out_mv)
ra8_epd_cal read seam bound to the IT8951 VCOM command.
ep_pin_t
IT8951 control GPIOs on the (hypothetical) e-paper carrier.
@ k_ep_hrdy_pin
IT8951 HRDY (P4_01).
@ k_ep_reset_pin
IT8951 /RESET (P4_00).
static display_caps_t s_caps
Cached backend caps + framebuffer descriptor.
static const uint8_t k_ep_msg_no_vcom[]
Banner for the INV-VCOM-1 refusal.
static void ep_emit(const uint8_t *data, uint32_t len)
Emit a NUL-free byte span on the SCI console (best effort).
static void ep_report_init(void)
Print epaper: init ok panel=<w>x<h>.
static ra8_io_spi_bus_t s_spi_bus
ra8_io SPI-bus handle bound to SPI_B channel 0.
static bool ep_flush_ok(ra8_err_t init_err, ra8_err_t full_err, ra8_err_t part_err)
PASS verdict: every stage returned k_ra8_ok.
static void ep_bringup_panel_bus(uint32_t pclka_hz)
Configure the panel GPIOs + SPI bus and fill s_epaper_cfg.
static ra8_err_t ep_vcom_set(void *ctx, uint16_t mv)
ra8_epd_cal write seam bound to the IT8951 VCOM command.
static void ep_report_stage(const char *label, uint32_t dt_ms, uint32_t pixels)
Print epaper: <label> ms=<dt> px=<count> on the console.
static bool ep_region_fits(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t pw, uint16_t ph)
Whether a rectangle (w, h >= 1) fits wholly inside the panel.
ep_region_t
Sub-rectangle updated by the partial refresh.
@ k_ep_box_h
Partial-region height (px).
@ k_ep_box_y
Partial-region top edge (px).
@ k_ep_box_w
Partial-region width (px).
@ k_ep_box_x
Partial-region left edge (px).
ep_vcom_limits_t
The plausible VCOM magnitude window for this panel family.
@ k_ep_vcom_max_mv
Highest plausible magnitude, millivolts.
@ k_ep_vcom_min_mv
Lowest plausible magnitude, millivolts.
static void ep_paint_checker(void)
Paint the whole framebuffer with the checkerboard pattern.
static void ep_bringup_core(uint32_t *out_pclka_hz)
Bring up clocks, MSTP, SysTick, the console and both LEDs.
static uint32_t ep_u32_to_dec(uint8_t *buf, uint32_t val)
Write the decimal digits of val into buf; return the count.
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_led_toggle(ra8_board_led_id_t led)
Toggle led's output state.
ra8_err_t ra8_board_led_init(ra8_board_led_id_t led)
Configure led as a digital output, initial level low (off).
ra8_err_t ra8_board_led_on(ra8_board_led_id_t led)
Drive led HIGH (light it).
@ k_ra8_board_led_blue
Convenience aliases by colour.
@ k_ra8_board_led_red
RA8 board led red.
ra8_err_t ra8_board_uart_console_write(const uint8_t *data, size_t len)
Polled blocking write to the J-Link OB VCOM console.
ra8_err_t ra8_board_uart_console_init(uint32_t baud)
Configure SCI8 + PD02/PD03 as the debug-console UART.
Boot entry points shared between a vector table and its startup code.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_get_clock_hz(ra8_clock_id_t id, uint32_t *out_hz)
Query the current frequency of a clock-tree domain.
@ k_ra8_clock_id_cpuclk0
Cortex-M85 CPUCLK0.
@ k_ra8_clock_id_pclka
PCLKA.
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Display Platform Abstraction Layer for the RA8D2.
@ k_display_pixfmt_rgb565
16 bpp, 5/6/5 packed.
ra8_err_t display_get_caps(const display_handle_t *d, display_caps_t *out)
Query the bound backend's runtime capabilities.
display_rect_t display_full_rect(const display_handle_t *d)
Convenience helper returning the rect covering the whole framebuffer.
ra8_err_t display_deinit(const display_handle_t *d)
Release the backend and invalidate the PAL handle.
ra8_err_t display_get_framebuffer(const display_handle_t *d, display_fb_t *out)
Return the framebuffer descriptor the backend is targeting.
ra8_err_t display_flush(const display_handle_t *d, display_rect_t rect, display_refresh_hint_t hint)
Commit pending framebuffer changes to the panel.
struct display_handle display_handle_t
ra8_err_t display_init(const display_cfg_t *cfg, display_handle_t **out_handle)
Initialise the display PAL and bring the selected backend up to a state where display_flush succeeds.
@ k_display_refresh_fast
Prioritise latency.
@ k_display_refresh_quality
Prioritise final quality.
E-ink backend (IT8951) for the display PAL.
const display_backend_iface_t k_display_backend_eink_it8951
E-ink (IT8951) backend vtable.
IT8951 e-paper controller SPI driver – public API.
ra8_err_t ra8_epaper_set_vcom(uint16_t mv)
Programme the controller's VCOM, verify it, and grant the INV-VCOM-1 permit.
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_waveform_cfg_for_lut(const char *lut_version, ra8_epaper_waveform_cfg_t *out_cfg)
Fill a waveform map from a controller-reported LUT version.
Per-device e-paper panel calibration (VCOM) – record, storage seam, resolution policy.
ra8_err_t ra8_epd_cal_resolve(const ra8_epd_cal_cfg_t *cfg, ra8_epd_cal_result_t *out_result)
Resolve the VCOM to drive this panel at, or fail safe.
ra8_err_t ra8_epd_cal_apply(const ra8_epd_cal_cfg_t *cfg, const ra8_epd_cal_result_t *result)
Programme a resolved VCOM onto the controller and confirm it took.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
ra8_io SPI-bus facade – one controller-transfer vtable over thechip's two SPI implementations.
ra8_err_t ra8_io_spi_bus_as_ops(const ra8_io_spi_bus_t *bus, ra8_spi_bus_ops_t *out)
Expose a bound bus through the Ring-3 seam ra8_spi_bus_ops_t.
SPI_B backend binder for the ra8_io SPI-bus facade.
ra8_err_t ra8_io_spi_bus_bind_spi_b(ra8_io_spi_bus_t *bus, uint8_t channel)
Bind bus to SPI_B channel channel.
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_init(void)
Re-establish the ra8_mstp ref-count table from current hardware state.
Active display-panel descriptor for the EK-RA8D2 (ER-TFT070-6).
@ k_ra8_board_fb_align_bytes
GLCDC AXI burst alignment, in bytes.
Typed Port / Pin Constants for the RA8D2 IOPORT Module.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
@ k_ra8_port_4
RA8 port 4.
#define RA8_PIN(port, pin)
Build a ra8_port_pin_t from explicit port / pin indices.
@ k_ra8_level_high
Drive or read 1.
@ k_ra8_pull_up
Internal pull-up.
High-level GPIO helpers on top of the PORT + PFS register layer.
ra8_err_t ra8_gpio_input_init(ra8_port_pin_t pin, ra8_pin_pull_t pull)
Configure a pin as a digital input.
ra8_err_t ra8_gpio_output_init(ra8_port_pin_t pin, ra8_level_t init_level)
Configure a pin as a digital output and drive it to an initial level.
SPI_B controller driver (RA8D2 Type-B SPI peripheral).
@ k_ra8_spi_mode_0
CPOL=0, CPHA=0.
ra8_err_t ra8_spi_init(uint8_t channel, const ra8_spi_cfg_t *cfg)
Initialise an SPI channel with a full config descriptor.
SysTick-based tick counter, delay and timestamp helpers.
ra8_err_t ra8_time_init(uint32_t cpu_hz)
Initialise SysTick for a 1 kHz tick interrupt.
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
uint32_t ra8_now_ms(void)
Short-form alias for ra8_time_ms().
Capabilities a backend reports after display_init.
Configuration descriptor passed into display_init.
Framebuffer descriptor returned by display_get_framebuffer.
Rectangle in framebuffer coordinates passed into display_flush.
Configuration descriptor for ra8_epaper_init.
Everything ra8_epd_cal_resolve needs.
Outcome of ra8_epd_cal_resolve.
Caller-allocated SPI-bus handle binding a backend to its context.
Caller-filled SPI transfer seam: one full-duplex byte exchange.
Configuration descriptor for ra8_spi_init.