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

OV5640 parallel (CEU) camera capture + plausibility self-test. More...

#include <stdint.h>
#include "cam_ceu.h"
#include "cam_image.h"
#include "ra8_board_ek_ra8d2.h"
#include "ra8_boot_entry.h"
#include "ra8_camera.h"
#include "ra8_camera_source_ceu.h"
#include "ra8_ceu.h"
#include "ra8_cgc.h"
#include "ra8_check.h"
#include "ra8_err.h"
#include "ra8_gpt.h"
#include "ra8_i2c.h"
#include "ra8_isr.h"
#include "ra8_mstp.h"
#include "ra8_ov5640.h"
#include "ra8_port_utils.h"
#include "ra8_sdramc.h"
#include "ra8_time.h"
Include dependency graph for main.c:

Go to the source code of this file.

Enumerations

enum  cam_u32_t : uint32_t {
  k_cam_baud = 115200U ,
  k_cam_xclk_hz = 24000000U ,
  k_cam_mode_settle_ms = 100U ,
  k_cam_capture_poll_ms = 5U ,
  k_cam_capture_tries = 800U ,
  k_cam_cache_line = 32U ,
  k_cam_string_cap = 1024U ,
  k_cam_dec_cap = 99999999U ,
  k_cam_gpt_probe_iters = 64U
}
 Scalar app tunables (baud, clocks, GPT limits, decimal cap). More...
enum  cam_u8_t : uint8_t {
  k_cam_nibble_mask = 0x0FU ,
  k_cam_dec_base = 10U ,
  k_cam_byte_max = 0xFFU ,
  k_cam_scan_lo = 0x08U ,
  k_cam_scan_hi = 0x77U
}
 8-bit app constants: hex/decimal printing, bus scan, U15 expander. More...
enum  cam_capture_geom_t : uint16_t { k_cam_line_bytes = 1280U }
 Packed VGA UYVY CEU geometry. More...
enum  cam_capture_layout_t : uint8_t { k_cam_bytes_per_pixel = 2U }
 Packed VGA UYVY storage layout. More...
enum  cam_gpt_t : uint8_t { k_cam_xclk_gpt_ch = 12U }
 GPT channel that generates XCLK on GTIOC12A (P501). More...

Functions

static ra8_err_t cam_sensor_bind (void)
 Bind the reusable sensor driver to the EK-RA8D2 SCCB adapter.
static ra8_err_t cam_capture_source_bind (void)
 Bind the generic CEU source to app-owned state and VGA metadata.
static uint32_t cam_strlen (const char *s)
 Bounded length of a NUL-terminated C string.
static ra8_err_t cam_puts (const char *s)
 Write a NUL-terminated string to the SCI8 console.
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 ra8_err_t cam_put_u32 (uint32_t value)
 Write an unsigned decimal integer to the console.
static bool cam_frame_is_plausible (const ra8_camera_frame_t *frame)
 Compute min / max / mean over the CEU frame and store to globals.
static void cam_bus_scan (void)
 Probe every 7-bit I2C address on ch1 and print those that ACK.
static void cam_park (void)
 Park forever after the self-test has reported its verdict.
static ra8_err_t cam_bringup (void)
 Bring up clocks, console, SDRAM, XCLK, SCCB and parallel camera.
static void cam_print_hsync_probe (const cam_ceu_sync_probe_t *probe)
 Print horizontal-sync pulse diagnostics.
static void cam_print_data_probe (const cam_ceu_sync_probe_t *probe)
 Print pixel-clock and sampled data diagnostics.
static void cam_print_line_probe (const cam_ceu_sync_probe_t *probe)
 Print per-line pixel-clock diagnostics.
static void cam_print_sync_probe (const cam_ceu_sync_probe_t *probe)
 Print the complete GPIO-observed DVP diagnostic snapshot.
static ra8_err_t cam_prepare_capture (void)
 Configure the sensor, sample DVP, and prepare the CEU.
static bool cam_capture_frame_and_report (bool ready)
 Attempt one frame capture and print CEU completion diagnostics.
static void cam_finish_verdict (bool frame_ok)
 Validate, convert, and report the completed camera frame.
static void cam_capture_and_verdict (void)
 Configure the sensor, capture one frame, and print the verdict.
static void cam_run (void)
 Run the capture pipeline and emit the plausibility banner.
void main (void)
 Application entry: OV5640 CEU capture plausibility self-test.

Variables

volatile uint32_t g_cam_chipid = 0U
 Chip ID read over SCCB (0x300A<<8 | 0x300B).
volatile uint32_t g_cam_frame_ok = 0U
 1 when the CEU signalled a completed capture, else 0.
volatile uint32_t g_cam_min = 0U
 Minimum byte value across the captured frame.
volatile uint32_t g_cam_max = 0U
 Maximum byte value across the captured frame.
volatile uint32_t g_cam_mean = 0U
 Mean byte value across the captured frame.
volatile uint32_t g_cam_verdict = 0U
 1 = plausible camera frame (PASS), 0 = FAIL.
static const uint8_t k_cam_tag [] = "cam: "
 Console tag prefix for every banner line.
static ra8_ov5640_t s_camera_sensor
 Transport-independent sensor instance bound to the board SCCB adapter.
static ra8_camera_source_t s_camera_source
 Generic CEU source handle and caller-owned backend state.
static ra8_camera_source_ceu_state_t s_camera_source_state
static ra8_camera_frame_t s_camera_frame
 Last immutable frame view returned by the generic source.
static uint8_t s_camera_capture [k_cam_uyvy_frame_bytes]
 App-owned, cache-line-aligned target for one packed VGA capture.

Detailed Description

OV5640 parallel (CEU) camera capture + plausibility self-test.

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

End-to-end bring-up of the EK-RA8D2 on-board OV5640 5 MP CMOS sensor over the chip's Capture Engine Unit (CEU) parallel (DVP) path – the interface the board wires the camera to (connector J35, HUM Ch 60). The app drives the real HAL drivers with no fakes and reports a plausibility verdict over the SCI8 console plus a set of J-Link-probable globals:

  1. ra8_cgc_init / ra8_time_init / ra8_mstp_init – clocks + SysTick.
  2. ra8_board_uart_console_init – BSP SCI8 console (PD02 / PD03).
  3. XCLK: GPT channel 12 saw-PWM on GTIOC12A (P501) generates the ~24 MHz sensor input clock (XVCLK). The OV5640 needs XVCLK to answer even on its SCCB port, so this comes up first.
  4. I2C ch1 (SCL1 P512 / SDA1 P511) via the board's validated bring-up, then force SW4-6 = ON through the U15 expander so the Camera Expansion Board is in parallel (DVP) mode (the board default is MIPI). The OV5640 SCCB shares ch1 with U15 + the codec.
  5. Confirm the XCLK GPT counter advances, release the sensor RST strap (P709), then scan the bus and read the OV5640 chip-ID registers 0x300A/0x300B – the VERIFY-FIRST proof the sensor is present (expected 0x5640), trying SCCB 0x3C then 0x3D.
  6. Program the proven VGA YUV422 live-scene sequence, sample the active DVP signals through GPIO, then route VIO_D[7:0], VIO_VD, VIO_HD, and VIO_CLK to the CEU.
  7. ra8_camera_source_ceu captures one packed frame into app-owned, cache-line-aligned internal SRAM; the backend polls CEU completion.
  8. Plausibility stats over the frame, then firmware-side UYVY-to-RGB888 conversion into four cache-cleaned SDRAM buffers at 0/90/180/270. PASS requires a captured, non-degenerate frame and all four images.

The reusable ra8_ov5640 sensor driver owns sensor protocol and tables; the board adapter owns J35 routing/reset/SCCB; ra8_camera_source_ceu owns generic capture dispatch. This file owns app policy, caller-supplied source state/storage, console output, and the verdict. cam_ceu is limited to the HIL-only pre-routing GPIO activity probe.

Banner (scraped by the HIL gate once promoted): cam: gpt=RUN scan=3C:56.43:00. chipid=5640 xclk=OK rst=OK sccb=OK ceu=OK bytes=614400 frame=OK cetcr=........ min=.. max=.. mean=.. verdict=PASS

Hardware: EK-RA8D2 with the OV5640 Camera Expansion Board on the underside FFC port (J35). SW4-6 is driven ON in firmware; no manual jumpers required.

Note
Bench status: validated on EK-RA8D2 silicon. The sensor ID reads 0x5640, DVP activity is observed on every data/sync signal, CEU completes a 614400-byte VGA capture, and the host dump decodes to a clean live image. See the README for still/video capture commands.
Since
0.1.0

Definition in file main.c.

Enumeration Type Documentation

◆ cam_capture_geom_t

enum cam_capture_geom_t : uint16_t

Packed VGA UYVY CEU geometry.

Enumerator
k_cam_line_bytes 

640 pixels x 2 packed bytes.

Definition at line 112 of file main.c.

◆ cam_capture_layout_t

enum cam_capture_layout_t : uint8_t

Packed VGA UYVY storage layout.

Enumerator
k_cam_bytes_per_pixel 

UYVY bytes per pixel.

Definition at line 117 of file main.c.

◆ cam_gpt_t

enum cam_gpt_t : uint8_t

GPT channel that generates XCLK on GTIOC12A (P501).

Enumerator
k_cam_xclk_gpt_ch 

P501 = GTIOC12A per RA8D2 datasheet pinout.

Definition at line 122 of file main.c.

◆ cam_u32_t

enum cam_u32_t : uint32_t

Scalar app tunables (baud, clocks, GPT limits, decimal cap).

Enumerator
k_cam_baud 

SCI8 console baud.

k_cam_xclk_hz 

OV5640 XVCLK input-clock target, Hz.

k_cam_mode_settle_ms 

Settle after selecting parallel mode.

k_cam_capture_poll_ms 

CEU completion-poll interval.

k_cam_capture_tries 

CEU poll cap (~4 seconds).

k_cam_cache_line 

DMA buffer cache-line alignment.

k_cam_string_cap 

Console-string scan safety bound.

k_cam_dec_cap 

Max value cam_put_u32 can render.

k_cam_gpt_probe_iters 

GTCNT samples to prove the timer runs.

Definition at line 90 of file main.c.

◆ cam_u8_t

enum cam_u8_t : uint8_t

8-bit app constants: hex/decimal printing, bus scan, U15 expander.

Enumerator
k_cam_nibble_mask 

Low-nibble mask for hex printing.

k_cam_dec_base 

Base for decimal printing.

k_cam_byte_max 

Maximum byte value (min-scan seed).

k_cam_scan_lo 

First 7-bit address in the bus scan.

k_cam_scan_hi 

Last 7-bit address in the bus scan.

Definition at line 103 of file main.c.

Function Documentation

◆ cam_bringup()

ra8_err_t cam_bringup ( void )
static

Bring up clocks, console, SDRAM, XCLK, SCCB and parallel camera.

Initializes dependencies in order, starts the sensor clock, and selects the U15 parallel-camera route without overwriting unrelated bits.

Returns
ra8_err_t from the first failing bring-up step, or ok.
Return values
k_ra8_okConsole, SDRAM, XCLK, and the U15 DVP route are live.
Precondition
Reset_Handler + SystemInit ran.
Single-threaded init context.
Postcondition
On ok the console prints, SDRAM responds, and the OV5640 has XVCLK + SCCB.
On ok the Camera Expansion Board is in parallel (DVP) mode.
Note
Thread safety: init context only.
Since
0.1.0

Definition at line 511 of file main.c.

References k_cam_baud, k_cam_mode_settle_ms, k_cam_xclk_hz, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_camera_select_parallel(), ra8_board_camera_xclk_start(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_delay_ms(), ra8_mstp_init(), ra8_sdramc_init(), and ra8_time_init().

Referenced by main().

◆ cam_bus_scan()

void cam_bus_scan ( void )
static

Probe every 7-bit I2C address on ch1 and print those that ACK.

A discovery aid: emits scan=3C.43. so the bench log shows exactly which devices answer on the SCCB bus (the OV5640 at 0x3C/0x3D, the U15 expander at 0x43, ...). Address-only probes, no register access.

Precondition
RIIC ch1 is initialized.
The console is up.
Postcondition
One scan=... field has been written for the run.
The bus is left idle.
Note
Thread safety: not thread-safe.
Since
0.1.0

Definition at line 453 of file main.c.

References cam_put_hex(), cam_puts(), k_cam_scan_hi, k_cam_scan_lo, k_ra8_board_camera_i2c_channel, k_ra8_ok, ra8_i2c_scan(), and ra8_i2c_transfer().

Referenced by cam_run().

◆ cam_capture_and_verdict()

void cam_capture_and_verdict ( void )
static

Configure the sensor, capture one frame, and print the verdict.

Called only after the OV5640 chip ID is confirmed. Emits the the DVP probe, CEU status, byte count, frame statistics, and verdict banner fields. PASS also requires all four RGB SDRAM views.

Precondition
cam_probe_sensor returned true (SCCB reaches the OV5640).
The sensor is out of reset; this function probes then routes DVP pins.
Postcondition
One verdict field has been written to SCI8.
g_cam_frame_ok / g_cam_verdict reflect the outcome.
Note
Thread safety: not thread-safe.
Since
0.1.0

Definition at line 770 of file main.c.

References cam_capture_frame_and_report(), cam_finish_verdict(), cam_prepare_capture(), and k_ra8_ok.

Referenced by cam_run().

◆ cam_capture_frame_and_report()

bool cam_capture_frame_and_report ( bool ready)
static

Attempt one frame capture and print CEU completion diagnostics.

Parameters
[in]readyWhether CEU preparation completed successfully.
Returns
true when one complete frame was captured.
Return values
trueCEU capture completed.
falsePreparation failed or capture timed out.
Precondition
The console is initialized.
ready reflects cam_prepare_capture.
Postcondition
Frame byte count and raw CETCR are printed.
g_cam_frame_ok reflects the returned value.
Note
Thread safety: not thread-safe.
Since
0.1.0

Definition at line 697 of file main.c.

References cam_put_hex(), cam_put_u32(), cam_puts(), g_cam_frame_ok, k_ra8_ok, ra8_camera_source_capture(), ra8_camera_source_ceu_get_last_events(), s_camera_capture, s_camera_frame, s_camera_source, and s_camera_source_state.

Referenced by cam_capture_and_verdict().

◆ cam_capture_source_bind()

ra8_err_t cam_capture_source_bind ( void )
static

Bind the generic CEU source to app-owned state and VGA metadata.

Configures a single-shot 8-bit synchronous UYVY capture with fixed VGA geometry and bounded polling.

Returns
Error from CEU configuration or generic-source binding.
Return values
k_ra8_okThe generic source is ready.
k_ra8_err_null_ptrInternal source bindings were invalid.
Precondition
Clocks and module-stop control are initialized.
Parallel camera pins have been routed to the CEU.
Postcondition
On success s_camera_source is ready for one-shot captures.
App-owned source state retains the configured VGA metadata.
Note
This function allocates no capture storage.
Since
0.1.0

Definition at line 210 of file main.c.

References k_cam_bytes_per_pixel, k_cam_capture_poll_ms, k_cam_capture_tries, k_cam_image_height_px, k_cam_image_width_px, k_cam_line_bytes, k_cam_uyvy_frame_bytes, k_ra8_camera_format_uyvy422, k_ra8_ceu_burst_32, k_ra8_ceu_bus_8_bit, k_ra8_ceu_capture_single, k_ra8_ceu_edge_rising, k_ra8_ceu_field_immediate, k_ra8_ceu_fmt_data_synchronous, k_ra8_ceu_input_cb0_y0_cr0_y1, k_ra8_ceu_output_ycbcr_422, k_ra8_ceu_pol_high_active, ra8_camera_source_ceu_init(), s_camera_source, and s_camera_source_state.

Referenced by cam_prepare_capture().

◆ cam_finish_verdict()

void cam_finish_verdict ( bool frame_ok)
static

Validate, convert, and report the completed camera frame.

Parameters
[in]frame_okWhether CEU capture completed.
Precondition
The console is initialized.
frame_ok reflects cam_capture_frame_and_report.
Postcondition
Frame statistics, RGB status, and verdict are printed.
g_cam_verdict is true only for a plausible converted frame.
Note
Thread safety: not thread-safe.
Since
0.1.0

Definition at line 732 of file main.c.

References cam_frame_is_plausible(), cam_image_generate(), cam_put_u32(), cam_puts(), g_cam_max, g_cam_mean, g_cam_min, g_cam_rgb_frame_bytes, g_cam_verdict, k_ra8_ok, and s_camera_frame.

Referenced by cam_capture_and_verdict().

◆ cam_frame_is_plausible()

bool cam_frame_is_plausible ( const ra8_camera_frame_t * frame)
static

Compute min / max / mean over the CEU frame and store to globals.

Validates the expected VGA UYVY geometry before reducing all bytes into simple non-degeneracy statistics for the HIL verdict.

Returns
true when the frame is non-degenerate (max != min).
Return values
trueFrame varies, consistent with a live non-degenerate capture.
falseFrame is all-identical, empty, or the buffer was unavailable.
Parameters
[in]frameCompleted generic-camera frame view.
Precondition
frame was returned by ra8_camera_source_capture.
The captured storage remains readable for frame->bytes bytes.
Postcondition
g_cam_min / g_cam_max / g_cam_mean reflect the frame.
Return distinguishes a live grab from an all-identical buffer.
Note
Thread safety: reads only the completed frame view and its storage.
Since
0.1.0

Definition at line 397 of file main.c.

References ra8_camera_frame_t::bytes, ra8_camera_frame_t::data, ra8_camera_frame_t::format, g_cam_max, g_cam_mean, g_cam_min, ra8_camera_frame_t::height, k_cam_byte_max, k_cam_image_height_px, k_cam_image_width_px, k_cam_line_bytes, k_cam_uyvy_frame_bytes, k_ra8_camera_format_uyvy422, ra8_camera_frame_t::stride_bytes, and ra8_camera_frame_t::width.

Referenced by cam_finish_verdict().

◆ cam_park()

void cam_park ( void )
static

Park forever after the self-test has reported its verdict.

Repeatedly enters wait-for-interrupt without returning to startup code.

Precondition
The verdict banner has been emitted.
Interrupt state is suitable for the application terminal state.
Postcondition
The CPU idles; only reset or a debugger wakes it.
No camera or console state is modified after entry.
Note
This is the intentional terminal state for the HIL image.
Since
0.1.0

Definition at line 490 of file main.c.

Referenced by main().

◆ cam_prepare_capture()

ra8_err_t cam_prepare_capture ( void )
static

Configure the sensor, sample DVP, and prepare the CEU.

Returns
Status of the first failed preparation stage.
Return values
k_ra8_okSensor, pin routing, and CEU are ready.
Precondition
The camera chip ID was confirmed.
Camera pins are not owned by another peripheral.
Postcondition
The CEU readiness field has been printed.
Success leaves the CEU ready for a single capture.
Note
Thread safety: init context only.
Since
0.1.0

Definition at line 663 of file main.c.

References cam_capture_source_bind(), cam_print_sync_probe(), cam_probe_sync_activity(), cam_puts(), k_ra8_ok, k_ra8_ov5640_mode_vga_uyvy, ra8_board_camera_route_parallel_pins(), ra8_ov5640_configure(), s_camera_frame, and s_camera_sensor.

Referenced by cam_capture_and_verdict().

◆ cam_print_data_probe()

void cam_print_data_probe ( const cam_ceu_sync_probe_t * probe)
static

Print pixel-clock and sampled data diagnostics.

Parameters
[in]probeCompleted DVP sync/data probe.
Precondition
probe is non-NULL and the console is initialized.
Postcondition
Pixel-clock and data fields are printed.
Note
Thread safety: not thread-safe.
Since
0.1.0

Definition at line 586 of file main.c.

References cam_put_hex(), cam_put_u32(), cam_puts(), cam_ceu_sync_probe_t::data_and, cam_ceu_sync_probe_t::data_changes, cam_ceu_sync_probe_t::data_max, cam_ceu_sync_probe_t::data_min, cam_ceu_sync_probe_t::data_or, cam_ceu_sync_probe_t::data_samples, cam_ceu_sync_probe_t::pclk_edges, and cam_ceu_sync_probe_t::pclk_half_cycles_min.

Referenced by cam_print_sync_probe().

◆ cam_print_hsync_probe()

void cam_print_hsync_probe ( const cam_ceu_sync_probe_t * probe)
static

Print horizontal-sync pulse diagnostics.

Parameters
[in]probeCompleted DVP sync/data probe.
Precondition
probe is non-NULL and the console is initialized.
Postcondition
HSYNC level and cycle fields are printed.
Note
Thread safety: not thread-safe.
Since
0.1.0

Definition at line 561 of file main.c.

References cam_put_u32(), cam_puts(), cam_ceu_sync_probe_t::hsync_high_cycles_max, cam_ceu_sync_probe_t::hsync_high_cycles_min, cam_ceu_sync_probe_t::hsync_high_max, cam_ceu_sync_probe_t::hsync_high_min, cam_ceu_sync_probe_t::hsync_low_max, and cam_ceu_sync_probe_t::hsync_low_min.

Referenced by cam_print_sync_probe().

◆ cam_print_line_probe()

void cam_print_line_probe ( const cam_ceu_sync_probe_t * probe)
static

Print per-line pixel-clock diagnostics.

Parameters
[in]probeCompleted DVP sync/data probe.
Precondition
probe is non-NULL and the console is initialized.
Postcondition
Line-count and line-clock fields are printed.
Note
Thread safety: not thread-safe.
Since
0.1.0

Definition at line 615 of file main.c.

References cam_put_u32(), cam_puts(), cam_ceu_sync_probe_t::line_pclk_long, cam_ceu_sync_probe_t::line_pclk_max, cam_ceu_sync_probe_t::line_pclk_mean, cam_ceu_sync_probe_t::line_pclk_min, and cam_ceu_sync_probe_t::measured_lines.

Referenced by cam_print_sync_probe().

◆ cam_print_sync_probe()

void cam_print_sync_probe ( const cam_ceu_sync_probe_t * probe)
static

Print the complete GPIO-observed DVP diagnostic snapshot.

Parameters
[in]probeCompleted DVP sync/data probe.
Precondition
probe is non-NULL.
The SCI8 console is initialized.
Postcondition
Every field in probe is represented in the banner.
probe is not modified.
Note
Thread safety: not thread-safe.
Since
0.1.0

Definition at line 640 of file main.c.

References cam_print_data_probe(), cam_print_hsync_probe(), cam_print_line_probe(), cam_put_u32(), cam_puts(), cam_ceu_sync_probe_t::hsync_edges, and cam_ceu_sync_probe_t::vsync_edges.

Referenced by cam_prepare_capture().

◆ cam_put_hex()

ra8_err_t cam_put_hex ( uint32_t value,
uint8_t width )
static

Write width hex nibbles of value (big-endian) to the console.

Formats uppercase hexadecimal into fixed stack storage before one write.

Parameters
[in]valueValue to print.
[in]widthNumber of nibbles (1..8).
Returns
ra8_err_t from the console write.
Return values
k_ra8_okDigits queued.
k_ra8_err_invalid_argwidth out of 1..8.
Precondition
width is 1..8.
ra8_board_uart_console_init has run.
Postcondition
Exactly width hex characters are emitted.
No other console state changes.
Note
Thread safety: not thread-safe.
Since
0.1.0

Definition at line 328 of file main.c.

References k_cam_nibble_mask, k_ra8_err_invalid_arg, ra8_board_uart_console_write(), and RA8_CHECK_RANGE.

Referenced by cam_bus_scan(), cam_capture_frame_and_report(), cam_print_data_probe(), and cam_run().

◆ cam_put_u32()

ra8_err_t cam_put_u32 ( uint32_t value)
static

Write an unsigned decimal integer to the console.

Formats the value backward into fixed stack storage before one write.

Parameters
[in]valueValue to print (0..99999999).
Returns
ra8_err_t from the console write.
Return values
k_ra8_okDigits queued.
k_ra8_err_invalid_argvalue exceeds 8 decimal digits.
Precondition
value fits in 8 decimal digits.
ra8_board_uart_console_init has run.
Postcondition
The decimal text of value is emitted.
No other console state changes.
Note
Thread safety: not thread-safe.
Since
0.1.0

Definition at line 358 of file main.c.

References k_cam_dec_base, k_cam_dec_cap, k_ra8_err_invalid_arg, and ra8_board_uart_console_write().

Referenced by cam_capture_frame_and_report(), cam_finish_verdict(), cam_print_data_probe(), cam_print_hsync_probe(), cam_print_line_probe(), and cam_print_sync_probe().

◆ cam_puts()

ra8_err_t cam_puts ( const char * s)
static

Write a NUL-terminated string to the SCI8 console.

Measures the bounded string and forwards its bytes to the board console.

Parameters
[in]sNon-NULL C string.
Returns
ra8_err_t from the BSP console write.
Return values
k_ra8_okString queued.
k_ra8_err_null_ptrs was NULL.
Precondition
s is non-NULL.
ra8_board_uart_console_init has run.
Postcondition
The bytes of s are handed to the console.
s is not modified.
Note
Thread safety: not thread-safe.
Since
0.1.0

Definition at line 305 of file main.c.

References cam_strlen(), ra8_board_uart_console_write(), and RA8_CHECK_NULL_PTR.

Referenced by cam_bus_scan(), cam_capture_frame_and_report(), cam_finish_verdict(), cam_prepare_capture(), cam_print_data_probe(), cam_print_hsync_probe(), cam_print_line_probe(), cam_print_sync_probe(), cam_run(), and main().

◆ cam_run()

void cam_run ( void )
static

Run the capture pipeline and emit the plausibility banner.

Reports progressively so a single flash reveals exactly which stage the hardware reached. The verdict is PASS only when the sensor ID is 0x5640, a frame was captured, it is non-degenerate, and the four RGB SDRAM views are complete.

Precondition
cam_bringup returned ok (console + XCLK + SCCB live).
The application owns the camera globals and static capture storage.
Postcondition
A cam: ...verdict=... line has been written to SCI8.
The result globals reflect the run.
Note
Thread safety: not thread-safe.
Since
0.1.0

Definition at line 792 of file main.c.

References cam_bus_scan(), cam_capture_and_verdict(), cam_put_hex(), cam_puts(), cam_sensor_bind(), g_cam_chipid, k_cam_gpt_probe_iters, k_cam_tag, k_cam_xclk_gpt_ch, k_ra8_ok, ra8_board_camera_reset(), ra8_gpt_read(), ra8_ov5640_probe(), and s_camera_sensor.

Referenced by main().

◆ cam_sensor_bind()

ra8_err_t cam_sensor_bind ( void )
static

Bind the reusable sensor driver to the EK-RA8D2 SCCB adapter.

Constructs a transport over board-owned SCCB and delay callbacks.

Returns
Repository error code.
Return values
k_ra8_okThe sensor instance was initialized.
k_ra8_err_null_ptrA required transport callback was unavailable.
Precondition
Board camera support is linked into the application.
No capture operation is concurrently using s_camera_sensor.
Postcondition
On success, s_camera_sensor is initialized at the primary address.
No sensor register transfer is performed by the binding itself.
Note
The board adapter owns the physical I2C channel.
Since
0.1.0

Definition at line 185 of file main.c.

References ra8_board_camera_delay_ms(), ra8_board_camera_sccb_read_reg(), ra8_board_camera_sccb_write_reg(), ra8_ov5640_init(), and s_camera_sensor.

Referenced by cam_run().

◆ cam_strlen()

uint32_t cam_strlen ( const char * s)
static

Bounded length of a NUL-terminated C string.

Scans at most k_cam_string_cap bytes to keep console helpers bounded.

Parameters
[in]sNon-NULL C string.
Returns
Length in bytes, capped at k_cam_string_cap.
Return values
uint32_tNumber of bytes preceding NUL or the configured cap.
Precondition
s is non-NULL.
The string is NUL-terminated within the cap.
Postcondition
Return value never exceeds the cap.
s is not modified.
Note
Thread safety: pure function.
Since
0.1.0

Definition at line 280 of file main.c.

References k_cam_string_cap, and RA8_CHECK_NULL_PTR.

Referenced by cam_puts().

◆ main()

void main ( void )

Application entry: OV5640 CEU capture plausibility self-test.

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR, FPU and priority grouping.
Postcondition
The verdict banner is on SCI8 and the CPU parks.
The result globals hold the outcome for SWD probing.
Since
0.1.0

Definition at line 853 of file main.c.

References cam_bringup(), cam_park(), cam_puts(), cam_run(), k_ra8_ok, and ra8_isr_globals_enable().

Variable Documentation

◆ g_cam_chipid

volatile uint32_t g_cam_chipid = 0U

Chip ID read over SCCB (0x300A<<8 | 0x300B).

0x5640 = OV5640.

Warning
Written once by main(); read via SWD.
Since
0.1.0

Definition at line 134 of file main.c.

Referenced by cam_run().

◆ g_cam_frame_ok

volatile uint32_t g_cam_frame_ok = 0U

1 when the CEU signalled a completed capture, else 0.

Warning
Written once by main().
Since
0.1.0

Definition at line 138 of file main.c.

Referenced by cam_capture_frame_and_report().

◆ g_cam_max

volatile uint32_t g_cam_max = 0U

Maximum byte value across the captured frame.

Warning
Written once by main().
Since
0.1.0

Definition at line 146 of file main.c.

Referenced by cam_finish_verdict(), and cam_frame_is_plausible().

◆ g_cam_mean

volatile uint32_t g_cam_mean = 0U

Mean byte value across the captured frame.

Warning
Written once by main().
Since
0.1.0

Definition at line 150 of file main.c.

Referenced by cam_finish_verdict(), and cam_frame_is_plausible().

◆ g_cam_min

volatile uint32_t g_cam_min = 0U

Minimum byte value across the captured frame.

Warning
Written once by main().
Since
0.1.0

Definition at line 142 of file main.c.

Referenced by cam_finish_verdict(), and cam_frame_is_plausible().

◆ g_cam_verdict

volatile uint32_t g_cam_verdict = 0U

1 = plausible camera frame (PASS), 0 = FAIL.

Warning
Written once by main().
Since
0.1.0

Definition at line 154 of file main.c.

Referenced by cam_finish_verdict().

◆ k_cam_tag

const uint8_t k_cam_tag[] = "cam: "
static

Console tag prefix for every banner line.

Definition at line 157 of file main.c.

Referenced by cam_run().

◆ s_camera_capture

uint8_t s_camera_capture[k_cam_uyvy_frame_bytes]
static

App-owned, cache-line-aligned target for one packed VGA capture.

Definition at line 170 of file main.c.

Referenced by cam_capture_frame_and_report().

◆ s_camera_frame

ra8_camera_frame_t s_camera_frame
static

Last immutable frame view returned by the generic source.

Definition at line 167 of file main.c.

Referenced by cam_capture_frame_and_report(), cam_finish_verdict(), and cam_prepare_capture().

◆ s_camera_sensor

ra8_ov5640_t s_camera_sensor
static

Transport-independent sensor instance bound to the board SCCB adapter.

Definition at line 160 of file main.c.

◆ s_camera_source

ra8_camera_source_t s_camera_source
static

Generic CEU source handle and caller-owned backend state.

Definition at line 163 of file main.c.

Referenced by cam_capture_frame_and_report(), and cam_capture_source_bind().

◆ s_camera_source_state

ra8_camera_source_ceu_state_t s_camera_source_state
static

Definition at line 164 of file main.c.

Referenced by cam_capture_frame_and_report(), and cam_capture_source_bind().