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

Camera initialization and VGA UYVY to QVGA JPEG frame production. More...

#include <stdint.h>
#include "c6_camera_server.h"
#include "ra8_attributes.h"
#include "ra8_board_ek_ra8d2.h"
#include "ra8_camera.h"
#include "ra8_camera_codec_jpeg_sw.h"
#include "ra8_camera_source_ceu.h"
#include "ra8_ceu.h"
#include "ra8_ov5640.h"
#include "ra8_time.h"
Include dependency graph for c6_cam_camera.c:

Go to the source code of this file.

Enumerations

enum  sw_cam_cfg_t : uint32_t {
  k_sw_cam_source_width = 640U ,
  k_sw_cam_source_height = 480U ,
  k_sw_cam_source_stride = k_sw_cam_source_width * 2U ,
  k_sw_cam_source_bytes = k_sw_cam_source_stride * k_sw_cam_source_height ,
  k_sw_cam_stream_width = 320U ,
  k_sw_cam_stream_height = 240U ,
  k_sw_cam_rgb_bytes = k_sw_cam_stream_width * k_sw_cam_stream_height * 3U ,
  k_sw_cam_jpeg_bytes = k_sw_cam_rgb_bytes ,
  k_sw_cam_jpeg_quality = 65U ,
  k_sw_cam_xclk_hz = 24000000U ,
  k_sw_cam_mode_settle_ms = 100U ,
  k_sw_cam_poll_ms = 5U ,
  k_sw_cam_poll_attempts = 800U
}
 Software-camera backend geometry, buffers, and sensor timing. More...

Functions

static ra8_err_t internal_c6_cam_sensor_bind (void)
 Bind the software-JPEG sensor instance to board SCCB callbacks.
static ra8_camera_source_ceu_cfg_t internal_c6_cam_source_config (void)
 Build the CEU configuration for packed VGA capture.
ra8_err_t c6_cam_camera_init (void)
 Camera image and board-switch initialization, then one CEU capture.
ra8_err_t c6_cam_camera_capture_jpeg (const uint8_t **out_jpeg, uint32_t *out_bytes, c6_cam_frame_timing_t *out_timing)
const char * c6_cam_camera_description (void)
 Human-readable description of the selected camera backend.
void c6_cam_camera_report_last_error (void)
 Emit backend-specific diagnostics for the last capture failure.

Variables

static uint8_t s_capture [k_sw_cam_source_bytes]
 Caller-selected SDRAM buffers for capture, conversion, and JPEG.
static uint8_t s_rgb [k_sw_cam_rgb_bytes]
static uint8_t s_jpeg [k_sw_cam_jpeg_bytes]
static ra8_ov5640_t s_camera_sensor
 Transport-independent OV5640 instance bound to the EK-RA8D2 SCCB bus.
static ra8_camera_source_t s_source
static ra8_camera_source_ceu_state_t s_source_state
static ra8_camera_codec_t s_codec
static ra8_camera_codec_jpeg_sw_state_t s_codec_state

Detailed Description

Camera initialization and VGA UYVY to QVGA JPEG frame production.

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

The CEU keeps the bench-proven 640x480 packed UYVY configuration. Each browser request captures a complete frame, downsamples by two in both axes while converting BT.601 YCbCr to RGB888, then uses the repository's baseline software JPEG encoder. The CEU, RGB and JPEG buffers live in external SDRAM so the NetX working set fits in internal SRAM.

Since
0.1.0

Definition in file c6_cam_camera.c.

Enumeration Type Documentation

◆ sw_cam_cfg_t

enum sw_cam_cfg_t : uint32_t

Software-camera backend geometry, buffers, and sensor timing.

Enumerator
k_sw_cam_source_width 

OV5640 capture width.

k_sw_cam_source_height 

OV5640 capture height.

k_sw_cam_source_stride 

Packed UYVY row bytes.

k_sw_cam_source_bytes 

Packed UYVY frame bytes.

k_sw_cam_stream_width 

Encoded JPEG width.

k_sw_cam_stream_height 

Encoded JPEG height.

k_sw_cam_rgb_bytes 

RGB conversion workspace bytes.

k_sw_cam_jpeg_bytes 

Worst-case JPEG buffer bytes.

k_sw_cam_jpeg_quality 

Software JPEG quality.

k_sw_cam_xclk_hz 

OV5640 input clock.

k_sw_cam_mode_settle_ms 

Sensor routing settle delay.

k_sw_cam_poll_ms 

CEU completion poll period.

k_sw_cam_poll_attempts 

CEU completion poll limit.

Definition at line 32 of file c6_cam_camera.c.

Function Documentation

◆ c6_cam_camera_capture_jpeg()

ra8_err_t c6_cam_camera_capture_jpeg ( const uint8_t ** out_jpeg,
uint32_t * out_bytes,
c6_cam_frame_timing_t * out_timing )
nodiscard

Definition at line 196 of file c6_cam_camera.c.

◆ c6_cam_camera_description()

const char * c6_cam_camera_description ( void )
nodiscard

Human-readable description of the selected camera backend.

Definition at line 234 of file c6_cam_camera.c.

◆ c6_cam_camera_init()

ra8_err_t c6_cam_camera_init ( void )
nodiscard

Camera image and board-switch initialization, then one CEU capture.

Definition at line 149 of file c6_cam_camera.c.

◆ c6_cam_camera_report_last_error()

void c6_cam_camera_report_last_error ( void )

Emit backend-specific diagnostics for the last capture failure.

Writes retained sensor or CEU status through the shared bounded console helpers.

Precondition
The board console is initialized.
A camera capture was attempted or the backend has reset diagnostics.
Postcondition
A backend-specific diagnostic line is queued.
Camera and capture state remain unchanged.
Note
Intended for failure paths; output content depends on the selected backend.
Since
0.1.0

Definition at line 239 of file c6_cam_camera.c.

◆ internal_c6_cam_sensor_bind()

ra8_err_t internal_c6_cam_sensor_bind ( void )
static

Bind the software-JPEG sensor instance to board SCCB callbacks.

Constructs the transport used by the reusable OV5640 driver.

Returns
Repository error code.
Return values
k_ra8_okThe sensor instance was initialized.
k_ra8_err_null_ptrA required transport dependency was absent.
Precondition
Board camera support is linked into the application.
No capture concurrently uses s_camera_sensor.
Postcondition
On success, the sensor instance selects the primary SCCB address.
Binding performs no sensor register transfer.
Note
Probing occurs during camera initialization.
Since
0.1.0

Definition at line 85 of file c6_cam_camera.c.

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

Referenced by c6_cam_camera_init().

◆ internal_c6_cam_source_config()

ra8_camera_source_ceu_cfg_t internal_c6_cam_source_config ( void )
static

Build the CEU configuration for packed VGA capture.

Selects one-shot synchronous UYVY output into the static source buffer.

Returns
Generic CEU source configuration.
Return values
ra8_camera_source_ceu_cfg_tComplete packed-camera source configuration.
Precondition
Geometry constants match the configured OV5640 VGA mode.
The static capture buffer can hold the reported maximum frame bytes.
Postcondition
Returned configuration references no temporary storage.
Static source and codec state remain unchanged.
Note
Software conversion and JPEG encoding occur after CEU capture.
Since
0.1.0

Definition at line 108 of file c6_cam_camera.c.

References 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, k_sw_cam_poll_attempts, k_sw_cam_poll_ms, k_sw_cam_source_bytes, k_sw_cam_source_height, k_sw_cam_source_stride, k_sw_cam_source_width, and RA8_INTERNAL.

Referenced by c6_cam_camera_init().

Variable Documentation

◆ s_camera_sensor

ra8_ov5640_t s_camera_sensor
static

Transport-independent OV5640 instance bound to the EK-RA8D2 SCCB bus.

Definition at line 66 of file c6_cam_camera.c.

Referenced by c6_cam_camera_init(), cam_prepare_capture(), cam_run(), cam_sensor_bind(), and internal_c6_cam_sensor_bind().

◆ s_capture

uint8_t s_capture[k_sw_cam_source_bytes]
static

Caller-selected SDRAM buffers for capture, conversion, and JPEG.

Definition at line 62 of file c6_cam_camera.c.

◆ s_codec

◆ s_codec_state

ra8_camera_codec_jpeg_sw_state_t s_codec_state
static

Definition at line 70 of file c6_cam_camera.c.

Referenced by c6_cam_camera_init().

◆ s_jpeg

uint8_t s_jpeg[k_sw_cam_jpeg_bytes]
static

Definition at line 64 of file c6_cam_camera.c.

Referenced by c6_cam_camera_capture_jpeg().

◆ s_rgb

uint8_t s_rgb[k_sw_cam_rgb_bytes]
static

Definition at line 63 of file c6_cam_camera.c.

Referenced by c6_cam_camera_init().

◆ s_source

ra8_camera_source_t s_source
static

Definition at line 67 of file c6_cam_camera.c.

◆ s_source_state