34typedef enum : uint32_t {
109 const uint32_t bounded = (count < pin_count) ? count : pin_count;
110 for (uint32_t i = 0U; i < bounded; i += 1U) {
131 uint32_t claimed = 0U;
132 for (; claimed < pin_count; claimed += 1U) {
166 if ((resolved.
port4 ==
nullptr) || (resolved.
port7 ==
nullptr) || (resolved.
port9 ==
nullptr) ||
167 (resolved.
port11 ==
nullptr)) {
193 uint8_t)(((p4 >> 0U) & 1U) | (((p9 >> 2U) & 1U) << 1U) |
237 .run_start_cycles = now,
238 .prior_pclk_cycles = now,
239 .high_min = UINT32_MAX,
240 .low_min = UINT32_MAX,
241 .high_cycles_min = UINT32_MAX,
242 .data_min = UINT8_MAX,
243 .data_and = UINT8_MAX,
261[[gnu::always_inline]]
static inline void
294 const uint32_t changed = current ^ state->
prior;
297 if ((changed & (1UL << (uint32_t)
k_ra8_pin_4)) != 0U) {
304 if (((current & (1UL << (uint32_t)
k_ra8_pin_4)) != 0U) &&
305 ((current & (1UL << (uint32_t)
k_ra8_pin_3)) != 0U)) {
328 state->
prior = current;
384 for (uint32_t i = 0U;
389 for (uint32_t i = 0U;
394 uint32_t line_pclk = 0U;
395 uint32_t line_sum = 0U;
396 uint32_t line_min = UINT32_MAX;
399 const uint32_t changed = current ^ prior;
400 if (((changed & (1UL << (uint32_t)
k_ra8_pin_4)) != 0U) &&
401 ((current & (1UL << (uint32_t)
k_ra8_pin_4)) != 0U) &&
402 ((current & (1UL << (uint32_t)
k_ra8_pin_3)) != 0U)) {
405 if (((changed & (1UL << (uint32_t)
k_ra8_pin_3)) != 0U) &&
406 ((current & (1UL << (uint32_t)
k_ra8_pin_3)) == 0U)) {
407 line_min = (line_pclk < line_min) ? line_pclk : line_min;
409 line_sum += line_pclk;
416 probe->
line_pclk_min = (line_min == UINT32_MAX) ? 0U : line_min;
static uint8_t cam_read_probe_data(const cam_probe_ports_t *ports)
Reconstruct VIO_D[7:0] from the three GPIO input banks.
static void cam_measure_lines(const cam_probe_ports_t *ports, uint32_t sync_mask, cam_ceu_sync_probe_t *probe)
Measure active-line PCLK counts with three bounded sampling loops.
static void cam_measure_sync(const cam_probe_ports_t *ports, uint32_t sync_mask, cam_ceu_sync_probe_t *probe)
Run the bounded sync/data sampling pass and finalize its statistics.
static ra8_err_t cam_claim_probe_pins(void)
Claim every parallel-camera pin as a temporary GPIO input.
static const cam_ceu_pin_t s_ceu_pins[]
The 11 EK-RA8D2 J35 parallel-camera pins that feed the CEU: VIO_D[7:0], VIO_VD, VIO_HD,...
static ra8_err_t cam_get_probe_ports(cam_probe_ports_t *ports)
Resolve the four register banks that carry the camera signals.
static void cam_sync_state_init(cam_sync_state_t *state, uint32_t prior)
Initialize sync-sampling state from the first masked sample.
static uint32_t cam_read_probe_sync(const cam_probe_ports_t *ports, uint32_t sync_mask)
Read and mask the three camera sync signals from PORT11.
static void cam_release_probe_pins(uint32_t count)
Release a bounded prefix of the temporary camera GPIO claims.
static void cam_record_probe_data(cam_sync_state_t *state, cam_ceu_sync_probe_t *probe, uint8_t data)
Fold one active-line camera byte into the probe statistics.
cam_ceu_poll_t
Bounded GPIO signal-activity sampling constants.
@ k_cam_data_d7_out_bit
Reconstructed byte bit for camera D7.
@ k_cam_long_line_pclk
Diagnostic threshold for long HREF lines.
@ k_cam_sync_samples
GPIO samples for live-sync diagnostic.
@ k_cam_data_d2_pin_bit
P405 bit position for camera D2.
@ k_cam_data_d5_out_bit
Reconstructed byte bit for camera D5.
static void cam_record_sync_sample(const cam_probe_ports_t *ports, uint32_t current, cam_sync_state_t *state, cam_ceu_sync_probe_t *probe)
Fold one masked sync sample into edge, timing, and data statistics.
ra8_err_t cam_probe_sync_activity(cam_ceu_sync_probe_t *out_probe)
Measure DVP sync, clock, and data activity before CEU routing.
App-specific GPIO diagnostic for the parallel DVP camera signals.
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.
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_hw_error
Generic hardware fault detected (error flag set, fault interrupt).
@ k_ra8_err_gpio_conflict
GPIO pin already owned by another peripheral or driver.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
ra8_port_t
Port indices for the RA8D2 IOPORT module.
@ k_ra8_port_9
RA8 port 9.
@ k_ra8_port_7
RA8 port 7.
@ k_ra8_port_11
RA8 port 11.
@ k_ra8_port_4
RA8 port 4.
#define RA8_PIN(port, pin)
Build a ra8_port_pin_t from explicit port / pin indices.
ra8_pin_t
Pin indices within an IOPORT port (0..15).
@ k_ra8_pull_none
No internal pull.
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_input_init(ra8_port_pin_t pin, ra8_pin_pull_t pull)
Configure a pin as a digital input.
ra8_err_t ra8_gpio_release(ra8_port_pin_t pin)
Release a GPIO pin claim.
Cortex-M85 SysTick + DWT cycle-counter timebase primitive.
uint32_t ra8_dwt_cyccnt_read(void)
Sample the DWT cycle counter (DWT_CYCCNT).
One CEU DVP pin: MCU port/pin routed to the CEU peripheral.
ra8_pin_t pin
MCU pin within the port.
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.
GPIO register banks used while sampling the parallel camera bus.
volatile r_port_regs_t * port9
D1 input bank.
volatile r_port_regs_t * port4
D0, D2, and D3 input bank.
volatile r_port_regs_t * port7
D4 through D7 input bank.
volatile r_port_regs_t * port11
VSYNC, HSYNC, and PCLK.
Accumulator for the bounded sync/data sampling pass.
uint32_t run_start_cycles
Cycle counter at HSYNC run start.
uint8_t data_min
Minimum sampled camera byte.
uint8_t prior_data
Previously sampled camera byte.
uint8_t data_and
AND reduction of camera bytes.
uint8_t data_or
OR reduction of camera bytes.
uint32_t low_min
Minimum low run in samples.
uint32_t high_max
Maximum high run in samples.
uint32_t high_cycles_max
Maximum high run in CPU cycles.
uint32_t low_max
Maximum low run in samples.
uint32_t high_min
Minimum high run in samples.
uint8_t data_max
Maximum sampled camera byte.
uint32_t run_samples
Samples in the current HSYNC run.
uint32_t high_cycles_min
Minimum high run in CPU cycles.
uint32_t prior_pclk_cycles
Cycle counter at prior PCLK edge.
uint32_t prior
Previous masked sync sample.
Per-port IOPORT register window.
volatile uint32_t PCNTR2
PCNTR2 – { EIDR[31:16], PIDR[15:0] } (read-only).