|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
OV5640 hardware-JPEG camera backend for the C6 MJPEG example. 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_passthrough.h"#include "ra8_camera_source_ceu.h"#include "ra8_ceu.h"#include "ra8_ov5640.h"#include "ra8_time.h"Go to the source code of this file.
Functions | |
| static ra8_err_t | sensor_sccb_read (void *ctx, uint8_t address, uint16_t reg, uint8_t *out_value) |
| Forward one SCCB read while retaining bounded failure diagnostics. | |
| static ra8_err_t | sensor_sccb_write (void *ctx, uint8_t address, uint16_t reg, uint8_t value) |
| Forward one SCCB write while retaining bounded failure diagnostics. | |
| static ra8_err_t | sensor_bind (void) |
| Bind the hardware-JPEG sensor instance to board SCCB callbacks. | |
| static ra8_camera_source_ceu_cfg_t | sensor_ceu_config (void) |
| Build the CEU configuration for bounded hardware JPEG capture. | |
| static void | internal_reset_camera_diagnostics (void) |
| Reset every camera diagnostic and lifecycle flag to its cold state. | |
| static ra8_err_t | internal_bring_up_sensor (void) |
| Bring the OV5640 sensor up to streaming hardware-JPEG mode. | |
| static ra8_err_t | internal_bring_up_capture_pipeline (void) |
| Route the parallel capture pins and bind the CEU source and codec. | |
| ra8_err_t | c6_cam_camera_init (void) |
| Camera image and board-switch initialization, then one CEU capture. | |
| static uint32_t | jpeg_trim_to_eoi (const uint8_t *jpeg, uint32_t bytes) |
| Locate the first complete JPEG payload in a captured span. | |
| 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. | |
| static void | sensor_report_register (const char *label, uint16_t reg) |
| Emit one named OV5640 register value when it remains readable. | |
| static void | internal_report_sccb_state (void) |
| Report the most recent SCCB transfer direction, register, and result. | |
| static void | internal_report_sensor_registers (void) |
| Report the OV5640 clock and stream registers when the sensor bound. | |
| static void | internal_report_capture_events (void) |
| Report the CEU event mask observed by the most recent capture. | |
| static void | internal_report_jpeg_status_detail (void) |
| Report the OV5640 hardware-JPEG status block from the last capture. | |
| void | c6_cam_camera_report_last_error (void) |
| Emit backend-specific diagnostics for the last capture failure. | |
Variables | |
| static uint8_t | s_jpeg [k_sensor_jpeg_buffer_bytes] |
| static ra8_ov5640_t | s_sensor |
| 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_ov5640_jpeg_status_t | s_last_jpeg_status |
| static ra8_err_t | s_last_jpeg_status_err |
| static ra8_err_t | s_last_sccb_err |
| static uint16_t | s_last_sccb_reg |
| static sccb_operation_t | s_last_sccb_op |
| static bool | s_camera_initialized |
| static bool | s_sensor_bound |
| static bool | s_sensor_streaming |
OV5640 hardware-JPEG camera backend for the C6 MJPEG example.
Binds the reusable sensor and CEU source, captures one bounded JPEG, and exposes it through the shared C6 camera-server contract.
Definition in file c6_cam_camera.c.
| enum jpeg_marker_t : uint8_t |
| Enumerator | |
|---|---|
| k_jpeg_marker_prefix | JPEG marker prefix byte. |
| k_jpeg_marker_soi | JPEG start-of-image marker byte. |
| k_jpeg_marker_eoi | JPEG end-of-image marker byte. |
Definition at line 55 of file c6_cam_camera.c.
| enum sccb_operation_t : uint8_t |
Last SCCB operation retained for initialization diagnostics.
| Enumerator | |
|---|---|
| k_sccb_op_none | No SCCB transfer has run. |
| k_sccb_op_read | Last transfer was a read. |
| k_sccb_op_write | Last transfer was a write. |
Definition at line 62 of file c6_cam_camera.c.
| enum sensor_diagnostic_register_t : uint16_t |
OV5640 clock and stream registers emitted on initialization failure.
Definition at line 41 of file c6_cam_camera.c.
| enum sensor_jpeg_geometry_t : uint16_t |
| Enumerator | |
|---|---|
| k_sensor_jpeg_width | Encoded sensor JPEG width. |
| k_sensor_jpeg_height | Encoded sensor JPEG height. |
Definition at line 35 of file c6_cam_camera.c.
| enum sensor_jpeg_size_t : uint32_t |
Definition at line 27 of file c6_cam_camera.c.
|
nodiscard |
Definition at line 342 of file c6_cam_camera.c.
References ra8_camera_frame_t::bytes, c6_cam_frame_timing_t::capture_ms, ra8_camera_frame_t::data, c6_cam_frame_timing_t::encode_ms, jpeg_trim_to_eoi(), k_ra8_err_invalid_size, k_ra8_err_null_ptr, k_ra8_ok, ra8_camera_codec_encode(), ra8_camera_source_capture(), ra8_ov5640_jpeg_status_get(), ra8_ov5640_stream_set(), ra8_time_ms(), s_capture, s_codec, s_jpeg, s_last_jpeg_status, s_last_jpeg_status_err, s_sensor, s_sensor_streaming, s_source, and c6_cam_frame_timing_t::timestamp_ms.
Referenced by internal_c6_cam_http_frame(), internal_c6_cam_http_stream(), and internal_c6_cam_prepare_camera().
|
nodiscard |
Human-readable description of the selected camera backend.
Definition at line 389 of file c6_cam_camera.c.
Referenced by internal_c6_cam_prepare_camera().
|
nodiscard |
Camera image and board-switch initialization, then one CEU capture.
Definition at line 302 of file c6_cam_camera.c.
References internal_bring_up_capture_pipeline(), internal_bring_up_sensor(), internal_c6_cam_sensor_bind(), internal_c6_cam_source_config(), internal_reset_camera_diagnostics(), k_ra8_err_hw_init_failed, k_ra8_ok, k_ra8_ov5640_chip_id, k_ra8_ov5640_mode_vga_uyvy, k_sw_cam_jpeg_quality, k_sw_cam_mode_settle_ms, k_sw_cam_stream_height, k_sw_cam_stream_width, k_sw_cam_xclk_hz, ra8_board_camera_reset(), ra8_board_camera_route_parallel_pins(), ra8_board_camera_select_parallel(), ra8_board_camera_xclk_start(), ra8_camera_codec_jpeg_sw_init(), ra8_camera_source_ceu_init(), ra8_delay_ms(), ra8_ov5640_configure(), ra8_ov5640_probe(), s_camera_initialized, s_camera_sensor, s_codec, s_codec_state, s_rgb, s_source, and s_source_state.
Referenced by internal_c6_cam_prepare_camera().
| 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.
Definition at line 535 of file c6_cam_camera.c.
References c6_cam_put_u32(), c6_cam_puts(), internal_report_capture_events(), internal_report_jpeg_status_detail(), internal_report_sccb_state(), internal_report_sensor_registers(), k_ra8_ok, ra8_camera_source_ceu_get_last_events(), ra8_err_to_str(), s_camera_initialized, s_last_jpeg_status_err, and s_source_state.
Referenced by internal_c6_cam_http_frame(), internal_c6_cam_http_stream(), and internal_c6_cam_prepare_camera().
|
static |
Route the parallel capture pins and bind the CEU source and codec.
Runs after the sensor is streaming: routes the DVP pins away from their bring-up owner, then binds the CEU capture source and the passthrough JPEG codec.
| k_ra8_ok | The capture pipeline is bound and ready to capture. |
| other | The pin-routing, CEU, or codec step that failed reported this. |
Definition at line 289 of file c6_cam_camera.c.
References k_ra8_ok, ra8_board_camera_route_parallel_pins(), ra8_camera_codec_passthrough_init(), ra8_camera_source_ceu_init(), RA8_INTERNAL, s_codec, s_source, s_source_state, and sensor_ceu_config().
Referenced by c6_cam_camera_init().
|
static |
Bring the OV5640 sensor up to streaming hardware-JPEG mode.
Sequences clock start, board reset, SCCB bind, chip-id probe, and VGA-JPEG mode configuration, stopping at the first failure.
| k_ra8_ok | The sensor is bound, probed, and streaming VGA JPEG. |
| k_ra8_err_hw_init_failed | The probed chip id did not match OV5640. |
| other | The board or sensor step that failed reported this code. |
Definition at line 244 of file c6_cam_camera.c.
References k_ra8_err_hw_init_failed, k_ra8_ok, k_ra8_ov5640_chip_id, k_ra8_ov5640_mode_vga_jpeg, k_sensor_jpeg_settle_ms, k_sensor_jpeg_xclk_hz, ra8_board_camera_reset(), ra8_board_camera_select_parallel(), ra8_board_camera_xclk_start(), ra8_delay_ms(), RA8_INTERNAL, ra8_ov5640_configure(), ra8_ov5640_probe(), s_sensor, s_sensor_bound, s_sensor_streaming, and sensor_bind().
Referenced by c6_cam_camera_init().
|
static |
Report the CEU event mask observed by the most recent capture.
Silent when the CEU source cannot report an event mask, e.g. before any capture has run.
Definition at line 487 of file c6_cam_camera.c.
References c6_cam_put_u32(), c6_cam_puts(), k_ra8_ok, ra8_camera_source_ceu_get_last_events(), RA8_INTERNAL, and s_source_state.
Referenced by c6_cam_camera_report_last_error().
|
static |
Report the OV5640 hardware-JPEG status block from the last capture.
No-op unless the last ra8_ov5640_jpeg_status_get succeeded, since the status fields are undefined otherwise.
Definition at line 508 of file c6_cam_camera.c.
References c6_cam_put_u32(), c6_cam_puts(), k_ra8_ok, RA8_INTERNAL, s_last_jpeg_status, and s_last_jpeg_status_err.
Referenced by c6_cam_camera_report_last_error().
|
static |
Report the most recent SCCB transfer direction, register, and result.
Always emitted regardless of camera or sensor bring-up state, since a bring-up failure is exactly when this is most needed.
Definition at line 430 of file c6_cam_camera.c.
References c6_cam_put_u32(), c6_cam_puts(), k_sccb_op_read, k_sccb_op_write, ra8_err_to_str(), RA8_INTERNAL, s_last_sccb_err, s_last_sccb_op, and s_last_sccb_reg.
Referenced by c6_cam_camera_report_last_error().
|
static |
Report the OV5640 clock and stream registers when the sensor bound.
No-op when sensor_bind never succeeded, since the registers would not be readable.
Definition at line 458 of file c6_cam_camera.c.
References k_sensor_reg_clock_enable02, k_sensor_reg_clock_root, k_sensor_reg_pclk_divider, k_sensor_reg_pll_ctrl0, k_sensor_reg_pll_ctrl1, k_sensor_reg_pll_ctrl2, k_sensor_reg_pll_ctrl3, k_sensor_reg_system_ctrl0, k_sensor_reg_system_reset00, k_sensor_reg_system_reset02, k_sensor_reg_system_root, RA8_INTERNAL, s_sensor_bound, and sensor_report_register().
Referenced by c6_cam_camera_report_last_error().
|
static |
Reset every camera diagnostic and lifecycle flag to its cold state.
Runs first in c6_cam_camera_init so a re-init after a partial failure never reports stale SCCB or streaming state.
Definition at line 219 of file c6_cam_camera.c.
References k_ra8_ok, k_sccb_op_none, RA8_INTERNAL, s_camera_initialized, s_last_sccb_err, s_last_sccb_op, s_last_sccb_reg, s_sensor_bound, and s_sensor_streaming.
Referenced by c6_cam_camera_init().
|
static |
Locate the first complete JPEG payload in a captured span.
Validates the SOI prefix and returns the length through the first EOI marker.
| [in] | jpeg | Captured sensor byte span. |
| [in] | bytes | Available capture bytes. |
| 0 | The span lacks a valid SOI or complete EOI. |
Definition at line 327 of file c6_cam_camera.c.
References k_jpeg_marker_eoi, k_jpeg_marker_prefix, and k_jpeg_marker_soi.
Referenced by c6_cam_camera_capture_jpeg().
|
static |
Bind the hardware-JPEG sensor instance to board SCCB callbacks.
Constructs a transport over the EK-RA8D2 camera bus and delay service.
| k_ra8_ok | The sensor instance was initialized. |
| k_ra8_err_null_ptr | A required transport dependency was absent. |
Definition at line 143 of file c6_cam_camera.c.
References ra8_board_camera_delay_ms(), ra8_ov5640_init(), s_sensor, sensor_sccb_read(), and sensor_sccb_write().
Referenced by internal_bring_up_sensor().
|
static |
Build the CEU configuration for bounded hardware JPEG capture.
Selects data-enable capture into a fixed SDRAM buffer with VGA metadata.
| ra8_camera_source_ceu_cfg_t | Complete hardware-JPEG source configuration. |
Definition at line 166 of file c6_cam_camera.c.
References k_ra8_camera_format_jpeg, k_ra8_ceu_burst_256, 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_enable, k_ra8_ceu_input_cb0_y0_cr0_y1, k_ra8_ceu_output_ycbcr_422, k_ra8_ceu_pol_high_active, k_sensor_jpeg_buffer_bytes, k_sensor_jpeg_height, k_sensor_jpeg_poll_ms, k_sensor_jpeg_poll_tries, and k_sensor_jpeg_width.
Referenced by internal_bring_up_capture_pipeline().
|
static |
Emit one named OV5640 register value when it remains readable.
Keeps failed JPEG bring-up diagnostics bounded and heap-free.
| [in] | label | Console label including its leading separator. |
| [in] | reg | Sensor register address. |
Definition at line 406 of file c6_cam_camera.c.
References c6_cam_put_u32(), c6_cam_puts(), k_ra8_ok, ra8_err_to_str(), ra8_ov5640_read_reg(), and s_sensor.
Referenced by internal_report_sensor_registers().
|
static |
Forward one SCCB read while retaining bounded failure diagnostics.
Delegates transport ownership to the EK-RA8D2 board adapter.
| [in] | ctx | Opaque board context forwarded unchanged. |
| [in] | address | Sensor SCCB address. |
| [in] | reg | Sensor register address. |
| [out] | out_value | Destination byte. |
out_value points to writable storage. out_value contains the sensor register byte. Definition at line 97 of file c6_cam_camera.c.
References k_sccb_op_read, ra8_board_camera_sccb_read_reg(), s_last_sccb_err, s_last_sccb_op, and s_last_sccb_reg.
Referenced by sensor_bind().
|
static |
Forward one SCCB write while retaining bounded failure diagnostics.
Delegates transport ownership to the EK-RA8D2 board adapter.
| [in] | ctx | Opaque board context forwarded unchanged. |
| [in] | address | Sensor SCCB address. |
| [in] | reg | Sensor register address. |
| [in] | value | Register byte to write. |
value for reg. Definition at line 121 of file c6_cam_camera.c.
References k_sccb_op_write, ra8_board_camera_sccb_write_reg(), s_last_sccb_err, s_last_sccb_op, and s_last_sccb_reg.
Referenced by sensor_bind().
|
static |
Definition at line 78 of file c6_cam_camera.c.
Referenced by c6_cam_camera_init(), c6_cam_camera_report_last_error(), and internal_reset_camera_diagnostics().
|
static |
Definition at line 72 of file c6_cam_camera.c.
|
static |
Definition at line 68 of file c6_cam_camera.c.
|
static |
Definition at line 73 of file c6_cam_camera.c.
Referenced by c6_cam_camera_capture_jpeg(), and internal_report_jpeg_status_detail().
|
static |
Definition at line 74 of file c6_cam_camera.c.
Referenced by c6_cam_camera_capture_jpeg(), c6_cam_camera_report_last_error(), and internal_report_jpeg_status_detail().
|
static |
Definition at line 75 of file c6_cam_camera.c.
Referenced by internal_report_sccb_state(), internal_reset_camera_diagnostics(), sensor_sccb_read(), and sensor_sccb_write().
|
static |
Definition at line 77 of file c6_cam_camera.c.
Referenced by internal_report_sccb_state(), internal_reset_camera_diagnostics(), sensor_sccb_read(), and sensor_sccb_write().
|
static |
Definition at line 76 of file c6_cam_camera.c.
Referenced by internal_report_sccb_state(), internal_reset_camera_diagnostics(), sensor_sccb_read(), and sensor_sccb_write().
|
static |
Definition at line 69 of file c6_cam_camera.c.
Referenced by c6_cam_camera_capture_jpeg(), internal_bring_up_sensor(), sensor_bind(), and sensor_report_register().
|
static |
Definition at line 79 of file c6_cam_camera.c.
Referenced by internal_bring_up_sensor(), internal_report_sensor_registers(), and internal_reset_camera_diagnostics().
|
static |
Definition at line 80 of file c6_cam_camera.c.
Referenced by c6_cam_camera_capture_jpeg(), internal_bring_up_sensor(), and internal_reset_camera_diagnostics().
|
static |
Definition at line 70 of file c6_cam_camera.c.
|
static |
Definition at line 71 of file c6_cam_camera.c.