|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
MIPI CSI-2 receiver HAL driver – FIFO, ISR dispatch, framing, power. More...
#include <stdint.h>#include "ra8_err.h"#include "ra8_mipi_csi_regs.h"#include "ra8_mipi_csi_types.h"Go to the source code of this file.
Functions | |
| ra8_err_t | ra8_mipi_csi_short_packet_configure (uint8_t threshold, bool store_enable) |
| Programme GSCT (short-packet FIFO threshold + store flag). | |
| ra8_err_t | ra8_mipi_csi_short_packet_set_irq_enable (uint32_t mask) |
| Programme GSIE (short-packet IRQ enable). | |
| ra8_err_t | ra8_mipi_csi_short_packet_get_status (uint32_t *out_mask) |
| Read GSST (short-packet status). | |
| ra8_err_t | ra8_mipi_csi_short_packet_clear_status (uint32_t mask) |
| W1C-clear GSST.GOV (FIFO overflow) via GSSC. | |
| ra8_err_t | ra8_mipi_csi_read_short_packet (ra8_mipi_csi_short_packet_t *out) |
| Drain one stored short-packet header from the FIFO. | |
| ra8_err_t | ra8_mipi_csi_short_packet_clear_fifo (void) |
| Request a clear of the entire short-packet FIFO (GSIU.GFCLR). | |
| ra8_err_t | ra8_mipi_csi_short_packet_re_enable_store (void) |
| Re-enable storing into the FIFO after a GOV overflow (GSIU.GFEN). | |
| ra8_err_t | ra8_mipi_csi_attach_handler (ra8_mipi_csi_event_fn_t fn, void *ctx) |
| Attach the receive-status callback (MIPI CSI RX vector). | |
| ra8_err_t | ra8_mipi_csi_attach_dl_handler (ra8_mipi_csi_dl_event_fn_t fn, void *ctx) |
| Attach the per-data-lane callback (MIPI CSI DL vector). | |
| ra8_err_t | ra8_mipi_csi_attach_vc_handler (ra8_mipi_csi_vc_event_fn_t fn, void *ctx) |
| Attach the per-VC callback (MIPI CSI VC vector). | |
| ra8_err_t | ra8_mipi_csi_attach_pm_handler (ra8_mipi_csi_pm_event_fn_t fn, void *ctx) |
| Attach the power-management callback (MIPI CSI PM vector). | |
| ra8_err_t | ra8_mipi_csi_attach_short_packet_handler (ra8_mipi_csi_short_event_fn_t fn, void *ctx) |
| Attach the short-packet FIFO callback (MIPI CSI GST vector). | |
| void | ra8_mipi_csi_dispatch (void) |
| ISR-side dispatcher for the receive vector. | |
| void | ra8_mipi_csi_dispatch_dl (void) |
| ISR-side dispatcher for the data-lane vector. | |
| void | ra8_mipi_csi_dispatch_vc (void) |
| ISR-side dispatcher for the per-VC vector. | |
| void | ra8_mipi_csi_dispatch_pm (void) |
| ISR-side dispatcher for the power-management vector. | |
| void | ra8_mipi_csi_dispatch_short_packet (void) |
| ISR-side dispatcher for the generic-short-packet vector. | |
| ra8_err_t | ra8_mipi_csi_set_virtual_channels (uint16_t vc_mask) |
| Filter which CSI-2 virtual channels the receiver will surface. | |
| ra8_err_t | ra8_mipi_csi_set_data_format (uint8_t vc, ra8_mipi_csi_data_format_t format) |
| Select the CSI-2 payload format the receiver should accept on a specific virtual channel. | |
| ra8_err_t | ra8_mipi_csi_attach_error_handler (ra8_mipi_csi_error_fn_t fn, void *ctx) |
| Register a callback invoked on ECC / CRC error reports. | |
| ra8_err_t | ra8_mipi_csi_enter_stop (void) |
| Gate the peripheral via MSTP (low-power entry helper). | |
| ra8_err_t | ra8_mipi_csi_exit_stop (void) |
| Ungate the peripheral via MSTP (low-power exit helper). | |
MIPI CSI-2 receiver HAL driver – FIFO, ISR dispatch, framing, power.
Generic short-packet FIFO control, the ISR-side dispatchers, the per-VC framing helpers + error-reporting attach, and the low-power MSTP transition helpers for the RA8D2 MIPI CSI-2 receiver HAL. Split out of ra8_mipi_csi.h to keep each header within the per-file line budget; consumers continue to include ra8_mipi_csi.h.
Definition in file ra8_mipi_csi_isr.h.
|
nodiscard |
Attach the per-data-lane callback (MIPI CSI DL vector).
| [in] | fn | Callback fired by ra8_mipi_csi_dispatch_dl. |
| [in] | ctx | Caller context forwarded to fn. |
| k_ra8_ok | Always. |
Definition at line 199 of file ra8_mipi_csi_irq.c.
References k_ra8_ok, s_mipi_csi_dl_ctx, and s_mipi_csi_dl_fn.
|
nodiscard |
Register a callback invoked on ECC / CRC error reports.
The CSI VC dispatcher already surfaces VCST contents. This helper filters those events down to the ECC + CRC error subset and decodes them into a ra8_mipi_csi_error_report_t for the caller. Pass fn = nullptr to detach.
| [in] | fn | Callback to invoke (or NULL to detach). |
| [in] | ctx | Caller-owned context forwarded to fn. |
| k_ra8_ok | Always. |
Definition at line 489 of file ra8_mipi_csi_irq.c.
References k_ra8_ok, s_mipi_csi_err_ctx, and s_mipi_csi_err_fn.
|
nodiscard |
Attach the receive-status callback (MIPI CSI RX vector).
| [in] | fn | Callback fired by ra8_mipi_csi_dispatch. |
| [in] | ctx | Caller context forwarded to fn. |
Attach the receive-status callback (MIPI CSI RX vector).
Stores the supplied callback and opaque context for later invocation by ra8_mipi_csi_dispatch when a module-level event fires.
| [in] | fn | Event-callback function pointer (NULL to detach). |
| [in] | ctx | Opaque context passed back to the callback. |
| k_ra8_ok | Always returned in the current implementation. |
Definition at line 192 of file ra8_mipi_csi_irq.c.
References k_ra8_ok, s_mipi_csi_ctx, and s_mipi_csi_fn.
|
nodiscard |
Attach the power-management callback (MIPI CSI PM vector).
| [in] | fn | Callback fired by ra8_mipi_csi_dispatch_pm. |
| [in] | ctx | Caller context forwarded to fn. |
| k_ra8_ok | Always. |
Definition at line 213 of file ra8_mipi_csi_irq.c.
References k_ra8_ok, s_mipi_csi_pm_ctx, and s_mipi_csi_pm_fn.
|
nodiscard |
Attach the short-packet FIFO callback (MIPI CSI GST vector).
| [in] | fn | Callback fired by ra8_mipi_csi_dispatch_short_packet. |
| [in] | ctx | Caller context forwarded to fn. |
| k_ra8_ok | Always. |
Definition at line 220 of file ra8_mipi_csi_irq.c.
References k_ra8_ok, s_mipi_csi_gst_ctx, and s_mipi_csi_gst_fn.
|
nodiscard |
Attach the per-VC callback (MIPI CSI VC vector).
| [in] | fn | Callback fired by ra8_mipi_csi_dispatch_vc. |
| [in] | ctx | Caller context forwarded to fn. |
| k_ra8_ok | Always. |
Definition at line 206 of file ra8_mipi_csi_irq.c.
References k_ra8_ok, s_mipi_csi_vc_ctx, and s_mipi_csi_vc_fn.
| void ra8_mipi_csi_dispatch | ( | void | ) |
ISR-side dispatcher for the receive vector.
Designed to be called from the wired-up MIPI CSI receive ISR (mipi_csi_rx_isr in the FSP layout). Reads RXST once, writes RACTDETC to RXSC to clear the sticky detect bit, then forwards the RXST snapshot to the registered callback.
Definition at line 228 of file ra8_mipi_csi_irq.c.
References k_ra8_mipi_csi_off_rxsc, k_ra8_mipi_csi_off_rxst, k_ra8_mipi_csi_rxsc_ractdetc_mask, ra8_mipi_csi_reg32(), s_mipi_csi_ctx, and s_mipi_csi_fn.
| void ra8_mipi_csi_dispatch_dl | ( | void | ) |
ISR-side dispatcher for the data-lane vector.
Reads MIST + DLST0 + DLST1, W1C-clears DLSC0/DLSC1 (preserving the RO ULP bit), and invokes the data-lane callback once per lane that showed up in MIST.
Definition at line 244 of file ra8_mipi_csi_irq.c.
References k_ra8_mipi_csi_dlsc_all_mask, k_ra8_mipi_csi_mist_dl0s_mask, k_ra8_mipi_csi_mist_dl1s_mask, k_ra8_mipi_csi_off_dlsc0, k_ra8_mipi_csi_off_dlsc1, k_ra8_mipi_csi_off_dlst0, k_ra8_mipi_csi_off_dlst1, k_ra8_mipi_csi_off_mist, ra8_mipi_csi_reg32(), s_mipi_csi_dl_ctx, and s_mipi_csi_dl_fn.
| void ra8_mipi_csi_dispatch_pm | ( | void | ) |
ISR-side dispatcher for the power-management vector.
Reads PMST, W1C-clears the lower 8 bits via PMSC, then invokes the PM callback.
Definition at line 330 of file ra8_mipi_csi_irq.c.
References k_ra8_mipi_csi_off_pmsc, k_ra8_mipi_csi_off_pmst, k_ra8_mipi_csi_pmst_w1c_mask, ra8_mipi_csi_reg32(), s_mipi_csi_pm_ctx, and s_mipi_csi_pm_fn.
| void ra8_mipi_csi_dispatch_short_packet | ( | void | ) |
ISR-side dispatcher for the generic-short-packet vector.
Reads GSST, W1C-clears GOV via GSSC, then invokes the GST callback. The handler is expected to drain the FIFO via ra8_mipi_csi_read_short_packet.
Definition at line 346 of file ra8_mipi_csi_irq.c.
References k_ra8_mipi_csi_gssc_govc_mask, k_ra8_mipi_csi_off_gssc, k_ra8_mipi_csi_off_gsst, ra8_mipi_csi_reg32(), s_mipi_csi_gst_ctx, and s_mipi_csi_gst_fn.
| void ra8_mipi_csi_dispatch_vc | ( | void | ) |
ISR-side dispatcher for the per-VC vector.
Reads MIST, then for every VC bit that is set walks the per-channel registers, clears each VCSC(M), and invokes the per-VC callback. Generic errors (MLF + ECD) are accumulated and delivered as a final callback with vc = 0xFF.
Definition at line 273 of file ra8_mipi_csi_irq.c.
References k_ra8_mipi_csi_mist_vc_mask, k_ra8_mipi_csi_mist_vc_shift, k_ra8_mipi_csi_off_mist, k_ra8_mipi_csi_off_vcsc0, k_ra8_mipi_csi_off_vcst0, k_ra8_mipi_csi_vc_count, k_ra8_mipi_csi_vc_invalid_idx, k_ra8_mipi_csi_vcsc_per_vc_mask, k_ra8_mipi_csi_vcst_crc_mask, k_ra8_mipi_csi_vcst_ecc_mask, k_ra8_mipi_csi_vcst_ecd_mask, k_ra8_mipi_csi_vcst_generic_err_mask, ra8_mipi_csi_reg32(), ra8_mipi_csi_vc_off(), s_mipi_csi_err_ctx, s_mipi_csi_err_fn, s_mipi_csi_vc_ctx, and s_mipi_csi_vc_fn.
|
nodiscard |
Gate the peripheral via MSTP (low-power entry helper).
| k_ra8_ok | Peripheral gated. |
| k_ra8_err_invalid_state | ra8_mstp ref-count was already 0. |
Definition at line 759 of file ra8_mipi_csi.c.
References k_ra8_mstp_mipi_csi, and ra8_mstp_disable().
|
nodiscard |
Ungate the peripheral via MSTP (low-power exit helper).
| k_ra8_ok | Peripheral clocked. |
| k_ra8_err_hw_init_failed | MSTP enable failed. |
Definition at line 765 of file ra8_mipi_csi.c.
References k_ra8_mstp_mipi_csi, and ra8_mstp_enable().
|
nodiscard |
Drain one stored short-packet header from the FIFO.
Reads GSST.PNUM first; if non-zero, sets GSIU.FINC (advance read pointer) then reads GSHT to retrieve the next header. The returned raw field is the unprocessed GSHT snapshot and the other fields are decoded for caller convenience.
| [out] | out | On success, the decoded short-packet header. |
| k_ra8_ok | Header drained into *out. |
| k_ra8_err_null_ptr | out was nullptr. |
| k_ra8_err_empty | FIFO had no stored packets. |
Definition at line 700 of file ra8_mipi_csi.c.
References ra8_mipi_csi_short_packet_t::data_type, k_ra8_err_empty, k_ra8_mipi_csi_gsht_dtyp_mask, k_ra8_mipi_csi_gsht_dtyp_shift, k_ra8_mipi_csi_gsht_spdt_mask, k_ra8_mipi_csi_gsht_spdt_shift, k_ra8_mipi_csi_gsht_spvc_mask, k_ra8_mipi_csi_gsht_spvc_shift, k_ra8_mipi_csi_gsiu_finc_mask, k_ra8_mipi_csi_gsst_pnum_mask, k_ra8_mipi_csi_gsst_pnum_shift, k_ra8_mipi_csi_off_gsht, k_ra8_mipi_csi_off_gsiu, k_ra8_mipi_csi_off_gsst, k_ra8_ok, ra8_mipi_csi_short_packet_t::payload, RA8_CHECK_NULL_PTR, ra8_mipi_csi_reg32(), ra8_mipi_csi_short_packet_t::raw, s_tag, and ra8_mipi_csi_short_packet_t::vc.
|
nodiscard |
Select the CSI-2 payload format the receiver should accept on a specific virtual channel.
The hardware filter (DTEL/DTEH) is global across virtual channels – selecting a format on one VC therefore enables the matching DT bit for the entire receiver. The driver records the per-VC selection in a software shadow so a subsequent call with k_ra8_mipi_csi_format_off can re-compute the union and clear the DT bit if no other VC still wants it. HUM Ch 66.3.10/66.3.11 pp 3943-3944.
| [in] | vc | Virtual channel index (0..15). |
| [in] | format | Payload format to accept (or _off to disable). |
| k_ra8_ok | Filter updated. |
| k_ra8_err_invalid_arg | vc > 15 or unknown format value. |
Definition at line 473 of file ra8_mipi_csi_irq.c.
References internal_format_to_bit(), internal_recompute_dt_filter(), k_ra8_err_invalid_arg, k_ra8_mipi_csi_vc_count, k_ra8_ok, and s_mipi_csi_vc_format.
|
nodiscard |
Filter which CSI-2 virtual channels the receiver will surface.
Each bit i of vc_mask enables VCi (i = 0..15). The driver disables VCIE on every channel whose bit is clear (so spurious traffic does not raise IRQs) and restores the previous IRQ mask on channels that are re-enabled. HUM Ch 66.3.20 "VCIE(M)" p 3952.
| [in] | vc_mask | Bitmap of accepted virtual channels (bit 0 = VC0). |
| k_ra8_ok | VCIE updated for every channel. |
| k_ra8_err_invalid_arg | vc_mask == 0 (would silence the receiver). |
Definition at line 444 of file ra8_mipi_csi_irq.c.
References k_ra8_err_invalid_arg, k_ra8_mipi_csi_off_vcie0, k_ra8_mipi_csi_vc_count, k_ra8_ok, ra8_log_error, ra8_mipi_csi_reg32(), ra8_mipi_csi_vc_off(), s_mipi_csi_vcie_saved, and s_tag.
|
nodiscard |
Request a clear of the entire short-packet FIFO (GSIU.GFCLR).
Writes 1 to GSIU.GFCLR, then waits for GSST.GCD to read 1 (clear complete) and writes 0 to GSIU.GFCLR to release the request line.
| k_ra8_ok | Cleared. |
| k_ra8_err_hw_timeout | GCD did not assert within budget. |
Definition at line 725 of file ra8_mipi_csi.c.
References k_ra8_err_hw_timeout, k_ra8_mipi_csi_gfclr_spin_max, k_ra8_mipi_csi_gsiu_gfclr_mask, k_ra8_mipi_csi_gsst_gcd_mask, k_ra8_mipi_csi_off_gsiu, k_ra8_mipi_csi_off_gsst, k_ra8_ok, and ra8_mipi_csi_reg32().
|
nodiscard |
W1C-clear GSST.GOV (FIFO overflow) via GSSC.
| [in] | mask | Bits to clear (only GOV bit is W1C). |
| k_ra8_ok | Always. |
Definition at line 692 of file ra8_mipi_csi.c.
References k_ra8_mipi_csi_gssc_govc_mask, k_ra8_mipi_csi_off_gssc, k_ra8_ok, and ra8_mipi_csi_reg32().
|
nodiscard |
Programme GSCT (short-packet FIFO threshold + store flag).
| [in] | threshold | FIFO depth-1 reported in GSST.PNUM that asserts the GTH IRQ. Range 0..15. |
| [in] | store_enable | 1 = store incoming short packets in FIFO. |
| k_ra8_ok | Updated. |
| k_ra8_err_invalid_arg | threshold > 15. |
Definition at line 663 of file ra8_mipi_csi.c.
References k_ra8_err_invalid_arg, k_ra8_mipi_csi_gsct_gfif_mask, k_ra8_mipi_csi_gsct_shth_mask, k_ra8_mipi_csi_gsct_shth_max, k_ra8_mipi_csi_off_gsct, k_ra8_ok, and ra8_mipi_csi_reg32().
|
nodiscard |
Read GSST (short-packet status).
| [out] | out_mask | Live GSST value. |
| k_ra8_ok | Status returned. |
| k_ra8_err_null_ptr | out_mask was nullptr. |
Definition at line 684 of file ra8_mipi_csi.c.
References k_ra8_mipi_csi_off_gsst, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_mipi_csi_reg32(), and s_tag.
|
nodiscard |
Re-enable storing into the FIFO after a GOV overflow (GSIU.GFEN).
| k_ra8_ok | Always. |
Definition at line 747 of file ra8_mipi_csi.c.
References k_ra8_mipi_csi_gsiu_gfen_mask, k_ra8_mipi_csi_off_gsiu, k_ra8_ok, and ra8_mipi_csi_reg32().
|
nodiscard |
Programme GSIE (short-packet IRQ enable).
| [in] | mask | Bits to set in GSIE. |
| k_ra8_ok | Always. |
Definition at line 677 of file ra8_mipi_csi.c.
References k_ra8_mipi_csi_gsie_all_mask, k_ra8_mipi_csi_off_gsie, k_ra8_ok, and ra8_mipi_csi_reg32().