ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
main.c File Reference

IT8951 e-paper full + partial refresh demo through the display PAL. More...

#include <stddef.h>
#include <stdint.h>
#include "ra8_board_ek_ra8d2.h"
#include "ra8_boot_entry.h"
#include "ra8_cgc.h"
#include "ra8_display_pal.h"
#include "ra8_display_pal_eink.h"
#include "ra8_epaper.h"
#include "ra8_epd_cal.h"
#include "ra8_err.h"
#include "ra8_io_spi_bus.h"
#include "ra8_io_spi_bus_spi_b.h"
#include "ra8_isr.h"
#include "ra8_mstp.h"
#include "ra8_panel.h"
#include "ra8_port_constants.h"
#include "ra8_port_utils.h"
#include "ra8_spi.h"
#include "ra8_time.h"
Include dependency graph for main.c:

Go to the source code of this file.

Enumerations

enum  ep_geom_t : uint16_t {
  k_ep_panel_w = 128U ,
  k_ep_panel_h = 128U ,
  k_ep_cell = 16U
}
 Panel + framebuffer geometry. More...
enum  ep_region_t : uint16_t {
  k_ep_box_x = 48U ,
  k_ep_box_y = 48U ,
  k_ep_box_w = 32U ,
  k_ep_box_h = 32U
}
 Sub-rectangle updated by the partial refresh. More...
enum  ep_color_t : uint16_t {
  k_ep_white = 0xFFFFU ,
  k_ep_black = 0x0000U
}
 RGB565 shades used by the test pattern. More...
enum  ep_bus_t : uint32_t {
  k_ep_spi_channel = 0U ,
  k_ep_spi_baud_hz = 10000000U ,
  k_ep_uart_baud = 115200U ,
  k_ep_powerup_ms = 50U ,
  k_ep_heartbeat_ms = 500U
}
 SPI + UART bring-up parameters. More...
enum  ep_fmt_t : uint8_t {
  k_ep_line_max = 48U ,
  k_ep_dec_digits = 10U ,
  k_ep_radix = 10U ,
  k_ep_cr = '\r' ,
  k_ep_lf = '\n'
}
 UART line-formatting constants. More...
enum  ep_pin_t : uint16_t {
  k_ep_reset_pin = ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_4) << 8) | (uint16_t)(k_ra8_pin_0))) ,
  k_ep_hrdy_pin = ((ra8_port_pin_t)(((uint16_t)(k_ra8_port_4) << 8) | (uint16_t)(k_ra8_pin_1)))
}
 IT8951 control GPIOs on the (hypothetical) e-paper carrier. More...
enum  ep_vcom_limits_t : uint16_t {
  k_ep_vcom_min_mv = 200U ,
  k_ep_vcom_max_mv = 4000U
}
 The plausible VCOM magnitude window for this panel family. More...

Functions

static uint16_t ep_checker_px (uint16_t x, uint16_t y)
 Checkerboard colour for a framebuffer pixel.
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.
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 uint32_t ep_u32_to_dec (uint8_t *buf, uint32_t val)
 Write the decimal digits of val into buf; return the count.
static void ep_panic_halt (void)
 Halt forever with the red board LED on.
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_bringup_core (uint32_t *out_pclka_hz)
 Bring up clocks, MSTP, SysTick, the console and both LEDs.
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_get (void *ctx, uint16_t *out_mv)
 ra8_epd_cal read seam bound to the IT8951 VCOM command.
static ra8_err_t ep_vcom_set (void *ctx, uint16_t mv)
 ra8_epd_cal write seam bound to the IT8951 VCOM command.
static bool ep_calibrate_vcom (void)
 Resolve this panel's VCOM and programme it, or refuse to draw.
static void ep_paint_checker (void)
 Paint the whole framebuffer with the checkerboard pattern.
static void ep_paint_region_black (void)
 Blacken the partial-refresh sub-rectangle in the framebuffer.
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 void ep_report_init (void)
 Print epaper: init ok panel=<w>x<h>.
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.
void main (void)
 Application entry: e-ink full + partial refresh through the PAL.

Variables

static uint16_t s_framebuffer [(uint32_t) k_ep_panel_w *(uint32_t) k_ep_panel_h]
 RGB565 framebuffer in SRAM, 64-byte AXI-burst aligned.
static ra8_io_spi_bus_t s_spi_bus
 ra8_io SPI-bus handle bound to SPI_B channel 0.
static ra8_epaper_cfg_t s_epaper_cfg
 IT8951 descriptor handed to the e-ink backend via panel_timing.
static display_handle_ts_display = nullptr
 PAL handle returned by display_init.
static display_caps_t s_caps
 Cached backend caps + framebuffer descriptor.
static display_fb_t s_fb
static const uint8_t k_ep_msg_pass [] = "epaper: PASS\r\n"
 PASS / FAIL banners.
static const uint8_t k_ep_msg_fail [] = "epaper: FAIL\r\n"
static const uint8_t k_ep_msg_no_vcom [] = "epaper: NO TRUSTED VCOM -- panel left dark\r\n"
 Banner for the INV-VCOM-1 refusal.

Detailed Description

IT8951 e-paper full + partial refresh demo through the display PAL.

Tag
[Ring 6 / APP] {World: S}

End-to-end example for the e-ink display path (#256): it drives an IT8951-compatible e-paper panel entirely through libs/ra8_display_pal's e-ink backend (k_display_backend_eink_it8951), which sits on the ra8_epaper HAL driver over an injected ra8_io_spi_bus seam. The app itself never names ra8_epaper_* – it paints a canonical RGB565 framebuffer and calls the same six PAL entry points the LCD demo uses.

Flow:

  1. Bring up clocks, MSTP, SysTick, the SCI console and two LEDs.
  2. Configure the panel's /RESET (output) and HRDY (input) GPIOs, bring up SPI_B channel 0 (mode 0, 10 MHz – under the IT8951's 24 MHz ceiling), and bind it into the ra8_epaper bus seam via ra8_io_spi_bus.
  3. display_init with the e-ink backend + the BSP-style IT8951 descriptor carried in display_cfg_t.panel_timing.
  4. Paint a checkerboard test pattern and FULL-refresh it (GC16 quality), timing the flush over SysTick and reporting it on the UART.
  5. Blacken a sub-region and PARTIAL-refresh just that rectangle (A2 fast), again timing + reporting.
  6. display_deinit sleeps the panel; print epaper: PASS.

Hardware / off-target

The EK-RA8D2 ships a parallel-RGB TFT, not e-paper, so on-panel HIL is pending an IT8951 carrier on the bench (see README). tools/ra8_emulator models the IT8951 as an SPI device (--eink): it answers HRDY, the GET_DEV_INFO drain and the LUTAFSR "LUT idle" poll, so this whole path runs headlessly to its epaper: PASS banner – EIL == HIL.

The reported refresh times are informational: on silicon a GC16 full refresh is hundreds of milliseconds and an A2 partial tens; under ra8_emulator the modelled controller completes instantly, so the numbers are near zero. The PASS verdict never depends on a timing value.

Since
0.1.0

Definition in file main.c.

Enumeration Type Documentation

◆ ep_bus_t

enum ep_bus_t : uint32_t

SPI + UART bring-up parameters.

Since
0.1.0
Enumerator
k_ep_spi_channel 

SPI_B channel 0 drives the panel.

k_ep_spi_baud_hz 

10 MHz (<= IT8951 24 MHz ceiling).

k_ep_uart_baud 

SCI console baud.

k_ep_powerup_ms 

PLL / panel settle before init.

k_ep_heartbeat_ms 

LED heartbeat period after PASS.

Definition at line 118 of file main.c.

◆ ep_color_t

enum ep_color_t : uint16_t

RGB565 shades used by the test pattern.

Since
0.1.0
Enumerator
k_ep_white 

Full white (maps to 8bpp 255).

k_ep_black 

Full black (maps to 8bpp 0).

Definition at line 107 of file main.c.

◆ ep_fmt_t

enum ep_fmt_t : uint8_t

UART line-formatting constants.

Since
0.1.0
Enumerator
k_ep_line_max 

Max chars in one console line.

k_ep_dec_digits 

Max decimal digits for a uint32_t.

k_ep_radix 

Decimal radix.

k_ep_cr 

Ep cr.

k_ep_lf 

Ep lf.

Definition at line 132 of file main.c.

◆ ep_geom_t

enum ep_geom_t : uint16_t

Panel + framebuffer geometry.

A modest 128 x 128 8bpp panel keeps the per-pixel SPI streaming fast under ra8_emulator while still exercising a full + partial refresh. RGB565 framebuffer = 128 * 128 * 2 = 32 KiB in SRAM.

Since
0.1.0
Enumerator
k_ep_panel_w 

Panel + framebuffer width (px).

k_ep_panel_h 

Panel + framebuffer height (px).

k_ep_cell 

Checkerboard cell size (px).

Definition at line 82 of file main.c.

◆ ep_pin_t

enum ep_pin_t : uint16_t

IT8951 control GPIOs on the (hypothetical) e-paper carrier.

These are NOT stock EK-RA8D2 board facts – the EK ships a parallel TFT – so they live in the app, not the board layer. They match the pins the ra8_emulator IT8951 model drives (P4_00 /RESET, P4_01 HRDY). The SPI_B COPI/CIPO/SCK routing for the carrier is documented in the README; ra8_emulator does not require it.

Since
0.1.0
Enumerator
k_ep_reset_pin 

IT8951 /RESET (P4_00).

k_ep_hrdy_pin 

IT8951 HRDY (P4_01).

Definition at line 152 of file main.c.

◆ ep_region_t

enum ep_region_t : uint16_t

Sub-rectangle updated by the partial refresh.

Since
0.1.0
Enumerator
k_ep_box_x 

Partial-region left edge (px).

k_ep_box_y 

Partial-region top edge (px).

k_ep_box_w 

Partial-region width (px).

k_ep_box_h 

Partial-region height (px).

Definition at line 94 of file main.c.

◆ ep_vcom_limits_t

enum ep_vcom_limits_t : uint16_t

The plausible VCOM magnitude window for this panel family.

A range, never a value: the range says "no sane panel is calibrated outside this", which is enough to reject a controller reporting 0 or 0xFFFF, while carrying none of the per-unit information that makes a hardcoded VCOM damaging. Panels in this family ship labelled around -1.5 V; the window is deliberately wider than that so a legitimately unusual panel is not locked out.

Invariant
min is non-zero, so a controller reporting zero can never pass the range check.
min <= max.
See also
ra8_epd_cal_limits_mv_t
Since
0.1.0
Enumerator
k_ep_vcom_min_mv 

Lowest plausible magnitude, millivolts.

k_ep_vcom_max_mv 

Highest plausible magnitude, millivolts.

Definition at line 243 of file main.c.

Function Documentation

◆ ep_bringup_core()

void ep_bringup_core ( uint32_t * out_pclka_hz)
static

Bring up clocks, MSTP, SysTick, the console and both LEDs.

Parameters
[out]out_pclka_hzReceives PCLKA in Hz (SPI clock source).
Precondition
Reset_Handler ran .data/.bss init.
out_pclka_hz != NULL.
Postcondition
Clocks, MSTP, SysTick, console and LEDs are live.
*out_pclka_hz holds PCLKA in Hz.
Note
Not thread-safe; single-shot helper. Panic-halts on any failure.
Since
0.1.0

Definition at line 429 of file main.c.

References ep_panic_halt(), k_ep_uart_baud, k_ra8_board_led_blue, k_ra8_board_led_red, k_ra8_clock_id_cpuclk0, k_ra8_clock_id_pclka, k_ra8_ok, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), and ra8_time_init().

Referenced by main().

◆ ep_bringup_panel_bus()

void ep_bringup_panel_bus ( uint32_t pclka_hz)
static

Configure the panel GPIOs + SPI bus and fill s_epaper_cfg.

Drives /RESET high (output), configures HRDY as a pulled-up input, brings up SPI_B channel 0 in mode 0 as controller, binds it into an ra8_io_spi_bus and exposes it through the Ring-3 seam the IT8951 descriptor carries.

Parameters
[in]pclka_hzPCLKA in Hz (SPI clock source).
Precondition
ep_bringup_core has run.
pclka_hz != 0.
Postcondition
On success s_epaper_cfg.bus.xfer8 is non-NULL and the panel GPIOs are configured.
s_spi_bus is bound to SPI_B channel 0.
Note
Not thread-safe; single-shot helper. Panic-halts on any failure.
Since
0.1.0

Definition at line 477 of file main.c.

References ep_panic_halt(), k_ep_hrdy_pin, k_ep_panel_h, k_ep_panel_w, k_ep_reset_pin, k_ep_spi_baud_hz, k_ep_spi_channel, k_ra8_level_high, k_ra8_ok, k_ra8_pull_up, k_ra8_spi_mode_0, ra8_epaper_waveform_cfg_for_lut(), ra8_gpio_input_init(), ra8_gpio_output_init(), ra8_io_spi_bus_as_ops(), ra8_io_spi_bus_bind_spi_b(), ra8_spi_init(), s_epaper_cfg, and s_spi_bus.

Referenced by main().

◆ ep_calibrate_vcom()

bool ep_calibrate_vcom ( void )
static

Resolve this panel's VCOM and programme it, or refuse to draw.

The INV-VCOM-1 gate, and the reason this app cannot simply start flushing after display_init. ra8_epd_cal_resolve walks the controller's own persisted value, then the per-device record, then an operator-supplied value, and fails rather than inventing one; ra8_epd_cal_apply programmes the winner and confirms it by readback. Only then does the driver permit a refresh at all.

The store seams are left unbound on purpose. Reading the per-device record needs a fault-tolerant extra-MRAM probe (a virgin page bus-faults on the first read), which today exists only inside the DFU anti-rollback module and has not been lifted into a shared helper. TODO(shared fault-tolerant extra-MRAM probe helper + per-device config record reader): bind store.read / store.write once that lands, at which point a provisioned unit resolves from its own record instead of trusting whatever the controller board happens to hold.

Until then this app resolves from the controller's persisted value, which is what makes a vendor-provisioned driver board work out of the box, and refuses to drive anything that cannot supply one.

Returns
true when a VCOM was resolved, programmed and verified.
Return values
trueRefresh is permitted.
falseNo trusted VCOM; the caller must leave the panel dark.
Precondition
display_init succeeded, so ra8_epaper_init has run.
The SPI bus seam is bound.
Postcondition
On true the controller reports the resolved VCOM.
On false no display command has been issued.
Note
Not thread-safe; boot-path use only.
Since
0.1.0

Definition at line 612 of file main.c.

References ep_vcom_get(), ep_vcom_set(), k_ep_vcom_max_mv, k_ep_vcom_min_mv, k_ra8_ok, ra8_epd_cal_apply(), and ra8_epd_cal_resolve().

Referenced by main().

◆ ep_checker_px()

uint16_t ep_checker_px ( uint16_t x,
uint16_t y )
static

Checkerboard colour for a framebuffer pixel.

black when ((x/cell) + (y/cell)) is odd, else white – a classic e-ink alignment pattern.

Parameters
[in]xColumn (0 .. k_ep_panel_w-1).
[in]yRow (0 .. k_ep_panel_h-1).
Returns
RGB565 colour for (x, y).
Return values
k_ep_blackOdd cell.
k_ep_whiteEven cell.
Precondition
x < k_ep_panel_w.
y < k_ep_panel_h.
Postcondition
No state mutated.
Return depends solely on (x, y).
Note
Pure function; thread-safe.
Since
0.1.0

Definition at line 273 of file main.c.

References k_ep_black, k_ep_cell, and k_ep_white.

Referenced by ep_paint_checker().

◆ ep_emit()

void ep_emit ( const uint8_t * data,
uint32_t len )
static

Emit a NUL-free byte span on the SCI console (best effort).

Parameters
[in]dataBytes to write.
[in]lenByte count.
Precondition
ra8_board_uart_console_init succeeded.
data != NULL.
Postcondition
len bytes have been queued to the console.
No app state mutated.
Note
Not thread-safe.
Since
0.1.0

Definition at line 411 of file main.c.

References ra8_board_uart_console_write().

Referenced by ep_report_init(), ep_report_stage(), and main().

◆ ep_flush_ok()

bool ep_flush_ok ( ra8_err_t init_err,
ra8_err_t full_err,
ra8_err_t part_err )
static

PASS verdict: every stage returned k_ra8_ok.

Parameters
[in]init_errdisplay_init result.
[in]full_errfull-refresh display_flush result.
[in]part_errpartial-refresh display_flush result.
Returns
true iff all three stages succeeded.
Return values
trueAll three are k_ra8_ok.
falseAny stage failed.
Precondition
None.
None.
Postcondition
No state mutated.
Return depends solely on the inputs.
Note
Pure function; thread-safe.
Since
0.1.0

Definition at line 332 of file main.c.

References k_ra8_ok.

Referenced by main().

◆ ep_paint_checker()

void ep_paint_checker ( void )
static

Paint the whole framebuffer with the checkerboard pattern.

Precondition
display_get_framebuffer populated s_fb.
s_fb.pixels is reachable.
Postcondition
Every framebuffer pixel holds its checker colour.
No other state mutated.
Note
Not thread-safe.
Since
0.1.0

Definition at line 640 of file main.c.

References ep_checker_px(), and s_fb.

Referenced by ep_run_refresh_cycle().

◆ ep_paint_region_black()

void ep_paint_region_black ( void )
static

Blacken the partial-refresh sub-rectangle in the framebuffer.

Precondition
display_get_framebuffer populated s_fb.
The region fits inside the framebuffer.
Postcondition
Every pixel of the region is k_ep_black.
Pixels outside the region are untouched.
Note
Not thread-safe.
Since
0.1.0

Definition at line 662 of file main.c.

References k_ep_black, k_ep_box_h, k_ep_box_w, k_ep_box_x, k_ep_box_y, and s_fb.

Referenced by ep_run_refresh_cycle().

◆ ep_panic_halt()

void ep_panic_halt ( void )
static

Halt forever with the red board LED on.

Precondition
None.
None.
Postcondition
Function never returns; CPU parked in WFI.
Red LED is on.
Note
IRQ-safe (no shared state mutated after entry).
Since
0.1.0

Definition at line 389 of file main.c.

References k_ra8_board_led_red, and ra8_board_led_on().

Referenced by ep_bringup_core(), ep_bringup_panel_bus(), ep_parse_or_halt(), ep_setup_or_halt(), and main().

◆ ep_region_fits()

bool ep_region_fits ( uint16_t x,
uint16_t y,
uint16_t w,
uint16_t h,
uint16_t pw,
uint16_t ph )
static

Whether a rectangle (w, h >= 1) fits wholly inside the panel.

Compound bounds guard used before the partial flush so a bad region is rejected rather than clipped. The right / bottom edge checks subsume the left / top ones for a non-empty rectangle, so the decision is the two INDEPENDENT edge tests – one on the x axis, one on the y axis.

Parameters
[in]xRectangle left edge.
[in]yRectangle top edge.
[in]wRectangle width (>= 1).
[in]hRectangle height (>= 1).
[in]pwPanel width.
[in]phPanel height.
Returns
true iff the rectangle is fully on-panel.
Return values
trueBoth the right and bottom edges are in range.
falseEither edge steps out of bounds.
Precondition
None.
None.
Postcondition
No state mutated.
Return depends solely on the inputs.
Note
Pure function; thread-safe.
Since
0.1.0

Definition at line 308 of file main.c.

Referenced by ep_run_refresh_cycle().

◆ ep_report_init()

void ep_report_init ( void )
static

Print epaper: init ok panel=<w>x<h>.

Precondition
display_init succeeded.
ra8_board_uart_console_init succeeded.
Postcondition
One line queued to the console.
No app state mutated.
Note
Not thread-safe.
Since
0.1.0

Definition at line 727 of file main.c.

References ep_emit(), ep_u32_to_dec(), k_ep_cr, k_ep_lf, k_ep_line_max, k_ep_panel_h, and k_ep_panel_w.

Referenced by main().

◆ ep_report_stage()

void ep_report_stage ( const char * label,
uint32_t dt_ms,
uint32_t pixels )
static

Print epaper: <label> ms=<dt> px=<count> on the console.

Parameters
[in]labelNUL-terminated stage label (e.g. "full-refresh").
[in]dt_msMeasured flush time in milliseconds.
[in]pixelsPixels refreshed this stage.
Precondition
label != NULL.
ra8_board_uart_console_init succeeded.
Postcondition
One formatted line has been queued to the console.
No app state mutated.
Note
Not thread-safe.
Since
0.1.0

Definition at line 690 of file main.c.

References ep_emit(), ep_u32_to_dec(), k_ep_cr, k_ep_lf, and k_ep_line_max.

Referenced by ep_run_refresh_cycle().

◆ ep_run_refresh_cycle()

void ep_run_refresh_cycle ( ra8_err_t * full_err,
ra8_err_t * part_err )
static

Drive the full (checker/GC16) then partial (box/A2) refresh cycle.

Repaints the framebuffer and flushes it twice through the display PAL: a full-panel quality refresh, then a bounds-checked partial fast refresh of the demo box. Each stage's flush time and pixel count are reported. The partial stage is skipped – leaving part_err at k_ra8_err_invalid_arg – when the box does not fit the panel.

Parameters
[out]full_errReceives the full-refresh flush result.
[out]part_errReceives the partial-refresh flush result, or k_ra8_err_invalid_arg when the box was out of bounds.
Precondition
full_err != NULL and part_err != NULL.
display_init succeeded and s_display is valid.
Postcondition
*full_err and *part_err hold this cycle's flush results.
The panel has been refreshed at least once.
Note
Not thread-safe; single-caller boot context.
Since
0.1.0

Definition at line 765 of file main.c.

References display_flush(), display_full_rect(), ep_paint_checker(), ep_paint_region_black(), ep_region_fits(), ep_report_stage(), k_display_refresh_fast, k_display_refresh_quality, k_ep_box_h, k_ep_box_w, k_ep_box_x, k_ep_box_y, k_ep_panel_h, k_ep_panel_w, k_ra8_err_invalid_arg, ra8_now_ms(), and s_display.

Referenced by main().

◆ ep_u32_to_dec()

uint32_t ep_u32_to_dec ( uint8_t * buf,
uint32_t val )
static

Write the decimal digits of val into buf; return the count.

Parameters
[out]bufDestination (>= k_ep_dec_digits bytes).
[in]valValue to render.
Returns
Number of digit bytes written (1 .. k_ep_dec_digits).
Return values
1For val == 0.
Precondition
buf != NULL.
buf has room for k_ep_dec_digits bytes.
Postcondition
buf[0..n-1] hold the decimal digits.
No other state mutated.
Note
Pure aside from writing buf.
Since
0.1.0

Definition at line 354 of file main.c.

References k_ep_dec_digits, and k_ep_radix.

Referenced by ep_report_init(), and ep_report_stage().

◆ ep_vcom_get()

ra8_err_t ep_vcom_get ( void * ctx,
uint16_t * out_mv )
static

ra8_epd_cal read seam bound to the IT8951 VCOM command.

Adapts the driver's context-free signature onto the seam's (ctx, out) shape. ctx is unused: the driver keeps one panel per build.

Parameters
[in]ctxUnused seam context.
[out]out_mvReceives the controller's VCOM magnitude; non-NULL.
Returns
ra8_err_t Forwarded from ra8_epaper_get_vcom.
Return values
k_ra8_okController answered.
k_ra8_err_null_ptrout_mv is NULL.
Precondition
ra8_epaper_init succeeded.
out_mv is writable.
Postcondition
No panel pixels are disturbed.
ctx is untouched.
Note
Not thread-safe.
Since
0.1.0

Definition at line 541 of file main.c.

References ra8_epaper_get_vcom().

Referenced by ep_calibrate_vcom().

◆ ep_vcom_set()

ra8_err_t ep_vcom_set ( void * ctx,
uint16_t mv )
static

ra8_epd_cal write seam bound to the IT8951 VCOM command.

The driver's ra8_epaper_set_vcom verifies its own write by reading it back, so a k_ra8_ok from here means the controller confirmed the value – not merely that bytes were clocked out.

Parameters
[in]ctxUnused seam context.
[in]mvVCOM magnitude to programme, millivolts.
Returns
ra8_err_t Forwarded from ra8_epaper_set_vcom.
Return values
k_ra8_okProgrammed and verified.
k_ra8_err_validation_failedReadback disagreed.
Precondition
ra8_epaper_init succeeded.
mv was range-checked by ra8_epd_cal.
Postcondition
On success the controller reports mv.
ctx is untouched.
Note
Not thread-safe.
Since
0.1.0

Definition at line 570 of file main.c.

References ra8_epaper_set_vcom().

Referenced by ep_calibrate_vcom().

◆ main()

void main ( void )

Application entry: e-ink full + partial refresh through the PAL.

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
On success the CPU heartbeats after epaper: PASS.
On any HAL error the console prints epaper: FAIL and the red LED latches on.
Since
0.1.0

Definition at line 809 of file main.c.

References display_deinit(), display_get_caps(), display_get_framebuffer(), display_init(), ep_bringup_core(), ep_bringup_panel_bus(), ep_calibrate_vcom(), ep_emit(), ep_flush_ok(), ep_panic_halt(), ep_report_init(), ep_run_refresh_cycle(), k_display_backend_eink_it8951, k_display_pixfmt_rgb565, k_ep_heartbeat_ms, k_ep_msg_fail, k_ep_msg_no_vcom, k_ep_msg_pass, k_ep_panel_h, k_ep_panel_w, k_ep_powerup_ms, k_ra8_board_led_blue, k_ra8_err_invalid_arg, k_ra8_ok, ra8_board_led_toggle(), ra8_delay_ms(), ra8_isr_globals_enable(), s_caps, s_display, s_epaper_cfg, s_fb, and s_framebuffer.

Variable Documentation

◆ k_ep_msg_fail

const uint8_t k_ep_msg_fail[] = "epaper: FAIL\r\n"
static

Definition at line 207 of file main.c.

Referenced by main().

◆ k_ep_msg_no_vcom

const uint8_t k_ep_msg_no_vcom[] = "epaper: NO TRUSTED VCOM -- panel left dark\r\n"
static

Banner for the INV-VCOM-1 refusal.

Deliberately distinct from the generic FAIL banner: "this panel has no trusted calibration" is a different fault from "the SPI bring-up broke", and the operator's next action differs (read the number off the flex cable and provision it, versus check the wiring).

Note
Read-only.
Since
0.1.0

Definition at line 222 of file main.c.

Referenced by main().

◆ k_ep_msg_pass

const uint8_t k_ep_msg_pass[] = "epaper: PASS\r\n"
static

PASS / FAIL banners.

Definition at line 206 of file main.c.

Referenced by main().

◆ s_caps

display_caps_t s_caps
static

Cached backend caps + framebuffer descriptor.

Definition at line 202 of file main.c.

Referenced by app_bringup_display(), and main().

◆ s_display

display_handle_t* s_display = nullptr
static

PAL handle returned by display_init.

Definition at line 199 of file main.c.

◆ s_epaper_cfg

ra8_epaper_cfg_t s_epaper_cfg
static

IT8951 descriptor handed to the e-ink backend via panel_timing.

Filled in ep_bringup_panel_bus; carries the injected SPI seam, the reset / busy GPIOs and the native panel size.

Note
File-scope so it out-lives display_init.
Since
0.1.0

Definition at line 196 of file main.c.

Referenced by ep_bringup_panel_bus(), and main().

◆ s_fb

◆ s_framebuffer

uint16_t s_framebuffer[(uint32_t) k_ep_panel_w *(uint32_t) k_ep_panel_h]
static

RGB565 framebuffer in SRAM, 64-byte AXI-burst aligned.

The PAL hands this pointer to the e-ink backend, which converts each flushed rectangle to 8bpp greyscale on the way to the IT8951.

Note
App-owned; only this file writes it.
Since
0.1.0

Definition at line 172 of file main.c.

◆ s_spi_bus

ra8_io_spi_bus_t s_spi_bus
static

ra8_io SPI-bus handle bound to SPI_B channel 0.

Out-lives every ra8_epaper call: the epaper bus seam's ctx points at this handle.

Note
File-scope so it survives past init.
Since
0.1.0

Definition at line 184 of file main.c.

Referenced by ep_bringup_panel_bus().