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

EK-RA8D2 J35 camera clock, routing, reset, and SCCB adapter. More...

#include <stdint.h>
#include "ra8_board_ek_ra8d2.h"
#include "ra8_cgc.h"
#include "ra8_check.h"
#include "ra8_gpt.h"
#include "ra8_i2c.h"
#include "ra8_port_utils.h"
#include "ra8_time.h"
Include dependency graph for ra8_board_ek_ra8d2_camera.c:

Go to the source code of this file.

Enumerations

enum  ra8_board_camera_protocol_t : uint8_t {
  k_camera_reg_address_bytes = 2U ,
  k_camera_write_bytes = 3U ,
  k_camera_high_byte_shift = 8U ,
  k_camera_xclk_gpt_channel = 12U ,
  k_camera_sw46_output = 0xDFU ,
  k_camera_sw46_mask = 0x20U
}
enum  ra8_board_camera_delay_t : uint32_t {
  k_camera_reset_low_ms = 20U ,
  k_camera_reset_high_ms = 20U
}
enum  ra8_board_camera_limit_t : uint32_t { k_camera_gpt_period_max = 0xFFFFU }

Functions

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_camera_select_parallel (void)
 Drive only SW4-6 ON through U15, selecting J35 parallel DVP.
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_reset (void)
 Pulse the J35 camera reset input and leave the sensor released.
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.
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.
void ra8_board_camera_delay_ms (void *ctx, uint32_t milliseconds)
 Millisecond delay adapter for transport-independent camera drivers.

Variables

static const ra8_port_pin_t s_camera_parallel_pins []

Detailed Description

EK-RA8D2 J35 camera clock, routing, reset, and SCCB adapter.

Owns only board-specific GPT, U15, pin-mux, reset, and RIIC wiring; sensor protocol and capture policy remain in reusable libraries.

Tag
[Ring 5 / BSP] {World: S}
Since
0.1.0

Definition in file ra8_board_ek_ra8d2_camera.c.

Enumeration Type Documentation

◆ ra8_board_camera_delay_t

enum ra8_board_camera_delay_t : uint32_t
Enumerator
k_camera_reset_low_ms 

Reset assertion interval.

k_camera_reset_high_ms 

Reset release interval.

Definition at line 35 of file ra8_board_ek_ra8d2_camera.c.

◆ ra8_board_camera_limit_t

enum ra8_board_camera_limit_t : uint32_t
Enumerator
k_camera_gpt_period_max 

Maximum GPT period register value.

Definition at line 40 of file ra8_board_ek_ra8d2_camera.c.

◆ ra8_board_camera_protocol_t

Enumerator
k_camera_reg_address_bytes 

SCCB register-address bytes.

k_camera_write_bytes 

Address plus value bytes.

k_camera_high_byte_shift 

Register high-byte shift.

k_camera_xclk_gpt_channel 

GPT channel driving XCLK.

k_camera_sw46_output 

U15 latch with SW4-6 ON.

k_camera_sw46_mask 

U15 SW4-6 override bit.

Definition at line 26 of file ra8_board_ek_ra8d2_camera.c.

Function Documentation

◆ ra8_board_camera_delay_ms()

void ra8_board_camera_delay_ms ( void * ctx,
uint32_t milliseconds )

Millisecond delay adapter for transport-independent camera drivers.

Ignores ctx and delegates the bounded delay to ra8_delay_ms.

Parameters
[in]ctxUnused transport context; may be nullptr.
[in]millisecondsDelay duration.
Precondition
The SysTick timebase is initialized.
milliseconds is acceptable to the platform delay service.
Postcondition
At least the requested delay interval has elapsed.
No camera or transport state is modified directly.
Note
Blocking and not suitable for interrupt context.
Since
0.1.0

Definition at line 179 of file ra8_board_ek_ra8d2_camera.c.

References ra8_delay_ms().

Referenced by cam_sensor_bind(), internal_c6_cam_sensor_bind(), and sensor_bind().

◆ ra8_board_camera_reset()

ra8_err_t ra8_board_camera_reset ( void )
nodiscard

Pulse the J35 camera reset input and leave the sensor released.

Claims P709 as an output, holds reset low, then releases it high.

Returns
ra8_err_t Error code.
Return values
k_ra8_okP709 was driven low, then high.
otherForwarded GPIO initialization/write error.
Precondition
The IOPORT module is powered.
P709 is available for the camera reset function.
Postcondition
CAM_RST is high after two 20 ms settle intervals.
On success the reset pin remains claimed as a GPIO output.
Note
Not thread-safe; call from camera initialization context.
Since
0.1.0

Definition at line 128 of file ra8_board_ek_ra8d2_camera.c.

References k_camera_reset_high_ms, k_camera_reset_low_ms, k_ra8_board_cam_rst, k_ra8_level_high, k_ra8_level_low, k_ra8_ok, ra8_delay_ms(), ra8_gpio_output_init(), and ra8_gpio_write().

Referenced by c6_cam_camera_init(), cam_run(), and internal_bring_up_sensor().

◆ ra8_board_camera_route_parallel_pins()

ra8_err_t ra8_board_camera_route_parallel_pins ( void )
nodiscard

Route J35 D[7:0], VSYNC, HSYNC and PCLK to the CEU peripheral.

Claims and muxes the eleven parallel-camera pads in board order.

Returns
Error code.
Return values
k_ra8_okEvery parallel-camera pin was routed.
otherFirst propagated PFS routing error.
Precondition
SW4-6 selects the parallel-camera path.
The eleven J35 CEU pins are not claimed by another peripheral.
Postcondition
On success every listed pin uses the CEU peripheral function.
On failure no later pin in the routing list is touched.
Note
Init-context only; partial routing may remain after an error.
Since
0.1.0

Definition at line 113 of file ra8_board_ek_ra8d2_camera.c.

References k_ra8_ok, k_ra8_psel_ceu, ra8_pfs_route_peripheral(), and s_camera_parallel_pins.

Referenced by c6_cam_camera_init(), cam_prepare_capture(), and internal_bring_up_capture_pipeline().

◆ ra8_board_camera_sccb_read_reg()

ra8_err_t ra8_board_camera_sccb_read_reg ( void * ctx,
uint8_t address,
uint16_t reg,
uint8_t * out_value )
nodiscard

Read one 16-bit-addressed SCCB register on the J35 camera bus.

Signature intentionally matches the transport callback used by ra8_ov5640; the BSP remains independent of that optional sensor library.

Parameters
[in]ctxUnused transport context; may be nullptr.
[in]address7-bit SCCB target address.
[in]reg16-bit sensor register address.
[out]out_valueRegister value on success.
Returns
ra8_err_t Forwarded RIIC result.
Return values
k_ra8_okOne register byte was read.
k_ra8_err_null_ptrout_value was nullptr.
otherPropagated RIIC transfer error.
Precondition
RIIC1 is initialized for the J35 SCCB bus.
The sensor is clocked and released from reset.
Postcondition
On success out_value contains the addressed register byte.
The RIIC bus is idle after the completed transfer.
Note
Not thread-safe with respect to RIIC1.
Since
0.1.0

Definition at line 146 of file ra8_board_ek_ra8d2_camera.c.

References k_camera_high_byte_shift, k_camera_reg_address_bytes, k_ra8_board_camera_i2c_channel, RA8_CHECK_NULL_PTR, and ra8_i2c_transfer().

Referenced by cam_sensor_bind(), internal_c6_cam_sensor_bind(), and sensor_sccb_read().

◆ ra8_board_camera_sccb_write_reg()

ra8_err_t ra8_board_camera_sccb_write_reg ( void * ctx,
uint8_t address,
uint16_t reg,
uint8_t value )
nodiscard

Write one 16-bit-addressed SCCB register on the J35 camera bus.

Parameters
[in]ctxUnused transport context; may be nullptr.
[in]address7-bit SCCB target address.
[in]reg16-bit sensor register address.
[in]valueRegister value to write.
Returns
ra8_err_t Forwarded RIIC result.
Return values
k_ra8_okThe complete address and value payload was written.
otherPropagated RIIC write error.
Precondition
RIIC1 is initialized for the J35 SCCB bus.
The sensor is clocked and released from reset.
Postcondition
On success the target accepted the addressed register byte.
The RIIC bus is idle after the completed transfer.
Note
Not thread-safe with respect to RIIC1.
Since
0.1.0

Definition at line 163 of file ra8_board_ek_ra8d2_camera.c.

References k_camera_high_byte_shift, k_camera_write_bytes, k_ra8_board_camera_i2c_channel, and ra8_i2c_write().

Referenced by cam_sensor_bind(), internal_c6_cam_sensor_bind(), and sensor_sccb_write().

◆ ra8_board_camera_select_parallel()

ra8_err_t ra8_board_camera_select_parallel ( void )
nodiscard

Drive only SW4-6 ON through U15, selecting J35 parallel DVP.

Applies a masked U15 override without changing unrelated switches.

Returns
Error code.
Return values
k_ra8_okU15 selected the parallel-camera path.
otherPropagated expander or RIIC error.
Precondition
Board I/O-expander services and RIIC1 are available.
The Camera Expansion Board is connected at J35.
Postcondition
On success SW4-6 is overridden to its ON state.
Other U15 SW4 override bits retain their prior values.
Note
Init-context only; this changes shared physical routing.
Since
0.1.0

Definition at line 106 of file ra8_board_ek_ra8d2_camera.c.

References k_camera_sw46_mask, k_camera_sw46_output, and ra8_board_io_expander_apply_sw4_mask().

Referenced by c6_cam_camera_init(), cam_bringup(), and internal_bring_up_sensor().

◆ ra8_board_camera_xclk_start()

ra8_err_t ra8_board_camera_xclk_start ( uint32_t frequency_hz)
nodiscard

Start the J35 camera sensor input clock (XCLK) on P501/GTIOC12A.

Configures GPT12 saw-PWM from PCLKD and routes its A output to P501.

Parameters
[in]frequency_hzRequested non-zero camera input-clock frequency.
Returns
Error code.
Return values
k_ra8_okGPT12 is running and P501 is routed.
k_ra8_err_invalid_argThe requested divisor is not representable.
otherPropagated clock, GPT, or pin-routing error.
Precondition
CGC and module-stop services are initialized.
P501 is available for the camera clock function.
Postcondition
On success GPT12 runs continuously at the nearest integer divisor.
On success P501 uses the high-speed GPT peripheral drive setting.
Note
Init-context only; this claims shared board resources.
Since
0.1.0

Definition at line 59 of file ra8_board_ek_ra8d2_camera.c.

References k_camera_gpt_period_max, k_camera_xclk_gpt_channel, k_ra8_board_cam_xclk, k_ra8_clock_id_pclkd, k_ra8_err_invalid_arg, k_ra8_gpt_disable_none, k_ra8_gpt_mode_saw_pwm, k_ra8_gpt_pin_a, k_ra8_gpt_pol_active_high, k_ra8_gpt_ps_div_1, k_ra8_gpt_stop_low, k_ra8_ok, k_ra8_pfs_dscr_high_speed_high, k_ra8_psel_gpt0, ra8_cgc_get_clock_hz(), ra8_gpt_init(), ra8_gpt_pwm_pin_configure(), ra8_pfs_route_peripheral(), and ra8_pfs_set_drive_strength().

Referenced by c6_cam_camera_init(), cam_bringup(), and internal_bring_up_sensor().

Variable Documentation

◆ s_camera_parallel_pins

const ra8_port_pin_t s_camera_parallel_pins[]
static
Initial value:
= {
}
@ k_ra8_board_cam_d3
CAM D3, P406 (J41).
@ k_ra8_board_cam_pclk
CAM PCLK, PB04.
@ k_ra8_board_cam_vsync
CAM VSYNC, PB02.
@ k_ra8_board_cam_d7
CAM D7, P703.
@ k_ra8_board_cam_d0
CAM D0, P400.
@ k_ra8_board_cam_hsync
CAM HSYNC, PB03.
@ k_ra8_board_cam_d2
CAM D2, P405 (J41).
@ k_ra8_board_cam_d1
CAM D1, P902.
@ k_ra8_board_cam_d5
CAM D5, P701.
@ k_ra8_board_cam_d6
CAM D6, P702.
@ k_ra8_board_cam_d4
CAM D4, P700.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.

Definition at line 44 of file ra8_board_ek_ra8d2_camera.c.

Referenced by ra8_board_camera_route_parallel_pins().