90typedef enum : uint32_t {
103typedef enum : uint8_t {
112typedef enum : uint16_t {
117typedef enum : uint8_t {
122typedef enum : uint8_t {
239 .byte_swap = {
false,
true,
true},
242 .one_field_only =
false,
243 .bundle_write =
false,
244 .low_pass_filter =
false,
245 .image_area_size = 0U,
330 static const char k_hex[] =
"0123456789ABCDEF";
336 i = (uint8_t)(i - 1U);
364 uint8_t i = (uint8_t)
sizeof(buf);
367 i = (uint8_t)(i - 1U);
370 }
while ((v != 0U) && (i > 0U));
371 const uint32_t len = (uint32_t)((uint8_t)
sizeof(buf) - i);
399 if ((frame ==
nullptr) || (frame->
data ==
nullptr)) {
413 const uint32_t n = frame->
bytes;
417 for (uint32_t i = 0U; i < n; i += 1U) {
418 const uint32_t b = (uint32_t)frame->
data[i];
466 const uint8_t reg = 0U;
493 __asm__
volatile(
"wfi");
513 uint32_t cpuclk0_hz = 0U;
699 bool frame_ok =
false;
711 (void)
cam_puts(frame_ok ?
"OK" :
"ERR");
734 bool plausible =
false;
749 (void)
cam_puts(rgb_ok ?
"OK" :
"ERR");
753 (void)
cam_puts((plausible && rgb_ok) ?
" verdict=PASS\r\n" :
" verdict=FAIL\r\n");
801 uint32_t cnt_ref = 0U;
802 bool gpt_running =
false;
807 if (cnt != cnt_ref) {
813 (void)
cam_puts(gpt_running ?
"RUN" :
"DEAD");
834 (void)
cam_puts(id_ok ?
"OK" :
"ERR");
837 (void)
cam_puts(
" verdict=FAIL\r\n");
856 (void)
cam_puts(
"cam: bringup ERROR verdict=FAIL\r\n");
void main(void)
Secure fallback main entry point.
static ra8_ov5640_t s_camera_sensor
Transport-independent OV5640 instance bound to the EK-RA8D2 SCCB bus.
App-specific GPIO diagnostic for the parallel DVP camera signals.
ra8_err_t cam_probe_sync_activity(cam_ceu_sync_probe_t *out_probe)
Measure DVP sync, clock, and data activity before CEU routing.
SDRAM-backed RGB888 views of one packed VGA UYVY camera frame.
@ k_cam_uyvy_frame_bytes
640 x 480 x 2-byte packed UYVY input.
@ k_cam_image_height_px
Unrotated and 180-degree height.
@ k_cam_image_width_px
Unrotated and 180-degree width.
ra8_err_t cam_image_generate(const uint8_t *uyvy, uint32_t source_bytes)
Convert one packed Cb-Y0-Cr-Y1 VGA frame into all four RGB views.
const uint32_t g_cam_rgb_frame_bytes
Stable byte count of each exported RGB888 buffer.
static ra8_camera_frame_t s_camera_frame
Last immutable frame view returned by the generic source.
static ra8_err_t cam_sensor_bind(void)
Bind the reusable sensor driver to the EK-RA8D2 SCCB adapter.
static void cam_print_hsync_probe(const cam_ceu_sync_probe_t *probe)
Print horizontal-sync pulse diagnostics.
static void cam_finish_verdict(bool frame_ok)
Validate, convert, and report the completed camera frame.
static ra8_err_t cam_puts(const char *s)
Write a NUL-terminated string to the SCI8 console.
cam_gpt_t
GPT channel that generates XCLK on GTIOC12A (P501).
@ k_cam_xclk_gpt_ch
P501 = GTIOC12A per RA8D2 datasheet pinout.
cam_u8_t
8-bit app constants: hex/decimal printing, bus scan, U15 expander.
@ k_cam_scan_hi
Last 7-bit address in the bus scan.
@ k_cam_scan_lo
First 7-bit address in the bus scan.
@ k_cam_nibble_mask
Low-nibble mask for hex printing.
@ k_cam_byte_max
Maximum byte value (min-scan seed).
@ k_cam_dec_base
Base for decimal printing.
static ra8_camera_source_ceu_state_t s_camera_source_state
static void cam_bus_scan(void)
Probe every 7-bit I2C address on ch1 and print those that ACK.
volatile uint32_t g_cam_verdict
1 = plausible camera frame (PASS), 0 = FAIL.
static ra8_err_t cam_put_u32(uint32_t value)
Write an unsigned decimal integer to the console.
static uint32_t cam_strlen(const char *s)
Bounded length of a NUL-terminated C string.
static ra8_err_t cam_prepare_capture(void)
Configure the sensor, sample DVP, and prepare the CEU.
static ra8_camera_source_t s_camera_source
Generic CEU source handle and caller-owned backend state.
volatile uint32_t g_cam_chipid
Chip ID read over SCCB (0x300A<<8 | 0x300B).
static bool cam_capture_frame_and_report(bool ready)
Attempt one frame capture and print CEU completion diagnostics.
static void cam_run(void)
Run the capture pipeline and emit the plausibility banner.
static ra8_err_t cam_bringup(void)
Bring up clocks, console, SDRAM, XCLK, SCCB and parallel camera.
static uint8_t s_camera_capture[k_cam_uyvy_frame_bytes]
App-owned, cache-line-aligned target for one packed VGA capture.
static void cam_park(void)
Park forever after the self-test has reported its verdict.
static ra8_err_t cam_capture_source_bind(void)
Bind the generic CEU source to app-owned state and VGA metadata.
cam_capture_geom_t
Packed VGA UYVY CEU geometry.
@ k_cam_line_bytes
640 pixels x 2 packed bytes.
volatile uint32_t g_cam_mean
Mean byte value across the captured frame.
static void cam_print_data_probe(const cam_ceu_sync_probe_t *probe)
Print pixel-clock and sampled data diagnostics.
static void cam_print_sync_probe(const cam_ceu_sync_probe_t *probe)
Print the complete GPIO-observed DVP diagnostic snapshot.
volatile uint32_t g_cam_max
Maximum byte value across the captured frame.
static bool cam_frame_is_plausible(const ra8_camera_frame_t *frame)
Compute min / max / mean over the CEU frame and store to globals.
cam_u32_t
Scalar app tunables (baud, clocks, GPT limits, decimal cap).
@ k_cam_capture_poll_ms
CEU completion-poll interval.
@ k_cam_dec_cap
Max value cam_put_u32 can render.
@ k_cam_baud
SCI8 console baud.
@ k_cam_mode_settle_ms
Settle after selecting parallel mode.
@ k_cam_string_cap
Console-string scan safety bound.
@ k_cam_cache_line
DMA buffer cache-line alignment.
@ k_cam_gpt_probe_iters
GTCNT samples to prove the timer runs.
@ k_cam_xclk_hz
OV5640 XVCLK input-clock target, Hz.
@ k_cam_capture_tries
CEU poll cap (~4 seconds).
volatile uint32_t g_cam_min
Minimum byte value across the captured frame.
static ra8_err_t cam_put_hex(uint32_t value, uint8_t width)
Write width hex nibbles of value (big-endian) to the console.
static void cam_print_line_probe(const cam_ceu_sync_probe_t *probe)
Print per-line pixel-clock diagnostics.
static const uint8_t k_cam_tag[]
Console tag prefix for every banner line.
volatile uint32_t g_cam_frame_ok
1 when the CEU signalled a completed capture, else 0.
cam_capture_layout_t
Packed VGA UYVY storage layout.
@ k_cam_bytes_per_pixel
UYVY bytes per pixel.
static void cam_capture_and_verdict(void)
Configure the sensor, capture one frame, and print the verdict.
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_camera_reset(void)
Pulse the J35 camera reset input and leave the sensor released.
ra8_err_t ra8_board_camera_sccb_write_reg(void *ctx, uint8_t address, uint16_t reg, uint8_t value)
Write one 16-bit-addressed SCCB register on the J35 camera bus.
ra8_err_t ra8_board_camera_sccb_read_reg(void *ctx, uint8_t address, uint16_t reg, uint8_t *out_value)
Read one 16-bit-addressed SCCB register on the J35 camera bus.
@ k_ra8_board_camera_i2c_channel
RIIC1 serves J35 SCCB.
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_camera_xclk_start(uint32_t frequency_hz)
Start the J35 camera sensor input clock (XCLK) on P501/GTIOC12A.
ra8_err_t ra8_board_uart_console_init(uint32_t baud)
Configure SCI8 + PD02/PD03 as the debug-console UART.
ra8_err_t ra8_board_camera_route_parallel_pins(void)
Route J35 D[7:0], VSYNC, HSYNC and PCLK to the CEU peripheral.
ra8_err_t ra8_board_camera_select_parallel(void)
Drive only SW4-6 ON through U15, selecting J35 parallel DVP.
void ra8_board_camera_delay_ms(void *ctx, uint32_t milliseconds)
Millisecond delay adapter for transport-independent camera drivers.
Boot entry points shared between a vector table and its startup code.
Transport-neutral camera source and image-codec facade.
@ k_ra8_camera_format_uyvy422
Packed Cb, Y0, Cr, Y1 pixel pairs.
ra8_err_t ra8_camera_source_capture(ra8_camera_source_t *source, const ra8_camera_buffer_t *buffer, ra8_camera_frame_t *out_frame)
Capture one frame into a caller-owned buffer.
RA8 CEU capture backend for the transport-neutral camera facade.
ra8_err_t ra8_camera_source_ceu_get_last_events(const ra8_camera_source_ceu_state_t *state, uint32_t *out_events)
Read the most recent CEU event snapshot retained by the backend.
ra8_err_t ra8_camera_source_ceu_init(ra8_camera_source_t *source, ra8_camera_source_ceu_state_t *state, const ra8_camera_source_ceu_cfg_t *cfg)
Initialize the CEU and bind it as a generic camera source.
Capture Engine Unit (CEU) camera-capture driver.
@ k_ra8_ceu_input_cb0_y0_cr0_y1
Cb0 Y0 Cr0 Y1.
@ k_ra8_ceu_burst_32
32-byte bus bursts.
@ k_ra8_ceu_capture_single
CE auto-clears after CPE.
@ k_ra8_ceu_fmt_data_synchronous
Raw synchronous data fetch.
@ k_ra8_ceu_field_immediate
Capture starts at next VD.
@ k_ra8_ceu_pol_high_active
Sync signal is active high.
@ k_ra8_ceu_bus_8_bit
VIO_D[7:0] used.
@ k_ra8_ceu_edge_rising
Sample on rising VIO_CLK edge.
@ k_ra8_ceu_output_ycbcr_422
Pass-through (no conversion).
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.
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_RANGE(value, min, max, errcode)
Reject out-of-range value, returning errcode.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
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.
Full-featured General PWM Timer (GPT) driver.
ra8_err_t ra8_gpt_read(uint8_t channel, uint32_t *out)
Read the current counter value.
I2C Bus Interface (IIC) controller driver – polling mode.
ra8_err_t ra8_i2c_scan(uint8_t channel, uint8_t peripheral_7b, bool *out_acked)
Probe whether a 7-bit peripheral address ACKs.
ra8_err_t ra8_i2c_transfer(uint8_t channel, uint8_t peripheral_7b, const uint8_t *wr, uint32_t wr_len, uint8_t *rd, uint32_t rd_len)
Combined write-then-RESTART-then-read in one bus transaction.
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.
Transport-independent OmniVision OV5640 sensor driver.
ra8_err_t ra8_ov5640_configure(ra8_ov5640_t *dev, ra8_ov5640_mode_t mode)
Software-reset and program one validated output mode.
ra8_err_t ra8_ov5640_probe(ra8_ov5640_t *dev, uint16_t *out_id)
Probe both legal SCCB addresses and verify chip ID 0x5640.
@ k_ra8_ov5640_mode_vga_uyvy
Packed VGA UYVY DVP stream.
ra8_err_t ra8_ov5640_init(ra8_ov5640_t *dev, const ra8_ov5640_bus_t *bus)
Bind a caller-supplied SCCB transport without touching the sensor.
High-level GPIO helpers on top of the PORT + PFS register layer.
External SDRAM controller driver (framework).
ra8_err_t ra8_sdramc_init(void)
Initialise the external SDRAM at k_ra8_sdram_base_addr.
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.
Snapshot of DVP sync activity observed through GPIO input samples.
uint32_t vsync_edges
Observed VIO_VD transitions.
uint32_t hsync_edges
Observed VIO_HD transitions.
uint32_t measured_lines
Completed HREF pulses measured in PCLK edges.
uint8_t data_and
AND reduction of sampled VIO_D[7:0].
uint32_t hsync_high_cycles_min
Shortest high run, CPU cycles.
uint32_t hsync_low_min
Shortest observed low run, samples.
uint32_t line_pclk_long
HREF pulses exceeding 1024 sampled PCLK rises.
uint8_t data_min
Minimum sampled VIO_D[7:0] value.
uint32_t pclk_edges
Observed VIO_CLK transitions.
uint32_t pclk_half_cycles_min
Shortest observed VIO_CLK half-period.
uint32_t hsync_high_max
Longest observed high run, samples.
uint8_t data_or
OR reduction of sampled VIO_D[7:0].
uint32_t line_pclk_mean
Mean PCLK rises inside measured HREF pulses.
uint32_t line_pclk_max
Maximum PCLK rises inside one HREF pulse.
uint32_t line_pclk_min
Minimum PCLK rises inside one HREF pulse.
uint32_t data_samples
Data bytes sampled on active-line PCLK rises.
uint8_t data_max
Maximum sampled VIO_D[7:0] value.
uint32_t hsync_high_min
Shortest observed high run, samples.
uint32_t data_changes
Changes between consecutive sampled bytes.
uint32_t hsync_low_max
Longest observed low run, samples.
uint32_t hsync_high_cycles_max
Longest high run, CPU cycles.
Caller-owned writable byte-buffer description.
Immutable view of one captured or encoded image.
ra8_camera_format_t format
Pixel or compressed-image layout.
const uint8_t * data
Borrowed immutable image bytes.
uint32_t bytes
Valid bytes beginning at data.
uint16_t height
Image height in pixels.
uint16_t width
Image width in pixels.
uint32_t stride_bytes
Bytes between uncompressed rows.
Backend configuration, including native CEU register descriptor.
Caller-owned CEU source state.
Caller-owned handle binding one source backend and its context.
Injected SCCB and time services.
Caller-owned sensor instance; supports multiple independent parts.