|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
SCI Simple-SPI backend for the ra8_io SPI-bus facade – thin shim over ra8_sci_spi. More...
#include "ra8_io_spi_bus_sci_spi.h"#include <stdint.h>#include "ra8_attributes.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_io_spi_bus.h"#include "ra8_io_spi_bus_internal.h"#include "ra8_sci_regs.h"#include "ra8_sci_spi.h"#include "ra8_spi.h"Go to the source code of this file.
Functions | |
| static ra8_err_t | internal_sci_spi_xfer8 (void *ctx, uint8_t tx, uint8_t *rx) |
| SCI backend: full-duplex single-byte exchange. | |
| static ra8_err_t | internal_sci_spi_write_read (void *ctx, const void *tx, void *rx, uint32_t len, ra8_spi_bit_width_t width) |
| SCI backend: full-duplex multi-byte transfer (8-bit frames only). | |
| static ra8_err_t | internal_sci_spi_set_clock (void *ctx, uint32_t baud_hz, uint32_t pclk_hz) |
| SCI backend: re-program the CCR2 bit-rate divider. | |
| ra8_err_t | ra8_io_spi_bus_bind_sci_spi (ra8_io_spi_bus_t *bus, uint8_t channel) |
| Bind bus to SCI Simple-SPI channel channel. | |
Variables | |
| static const char *const | s_tag = "ra8_io_spi_bus_sci_spi" |
| Module log tag. | |
| static const ra8_io_spi_bus_iface_t | s_sci_spi_iface |
| SCI Simple-SPI backend vtable – every row forwards to ra8_sci_spi_*. | |
SCI Simple-SPI backend for the ra8_io SPI-bus facade – thin shim over ra8_sci_spi.
Implements ra8_io_spi_bus_iface by forwarding to the SCI Simple-SPI driver (ra8_sci_spi.h), unmodified. The bound channel index travels in the handle context ((void*)(uintptr_t)channel), so the backend keeps no static state and multiple bound buses coexist. The SCI block clocks 8-bit frames only, so the multi-frame row rejects wider widths with k_ra8_err_not_supported instead of silently mis-framing. No raw MMIO is touched here; the driver carries every HUM citation.
Definition in file ra8_io_spi_bus_sci_spi.c.
|
static |
SCI backend: re-program the CCR2 bit-rate divider.
Forwards to ra8_sci_spi_set_clock, which validates the arguments and picks the smallest CKS keeping BRR in range.
| [in] | ctx | Bound channel index, encoded as (void*)(uintptr_t). |
| [in] | baud_hz | Target bit-rate in Hz. |
| [in] | pclk_hz | SCI baud-clock source (PCLKA) in Hz. |
| k_ra8_ok | Divider reprogrammed. |
| k_ra8_err_invalid_arg | Channel out of range or baud_hz zero. |
Definition at line 139 of file ra8_io_spi_bus_sci_spi.c.
References ra8_sci_spi_set_clock().
|
static |
SCI backend: full-duplex multi-byte transfer (8-bit frames only).
The SCI Simple-SPI data register clocks one byte per frame, so any width other than k_ra8_spi_width_8 is rejected up-front with k_ra8_err_not_supported. Valid requests forward to ra8_sci_spi_xfer, which treats a NULL tx as idle (0xFF) fill and a NULL rx as discard.
| [in] | ctx | Bound channel index, encoded as (void*)(uintptr_t). |
| [in] | tx | Source bytes or NULL for idle fill. |
| [out] | rx | Destination bytes or NULL to discard. |
| [in] | len | Number of bytes. |
| [in] | width | Per-frame bit width; only k_ra8_spi_width_8. |
| k_ra8_ok | Every byte exchanged. |
| k_ra8_err_not_supported | width is not 8-bit. |
| k_ra8_err_invalid_arg | Channel out of range. |
| k_ra8_err_hw_timeout | A per-frame poll expired. |
Definition at line 101 of file ra8_io_spi_bus_sci_spi.c.
References k_ra8_err_not_supported, k_ra8_spi_width_8, RA8_INTERNAL, and ra8_sci_spi_xfer().
|
static |
SCI backend: full-duplex single-byte exchange.
Decodes the channel from the handle context and forwards to ra8_sci_spi_xfer8, which validates the channel and owns the CSR polling.
| [in] | ctx | Bound channel index, encoded as (void*)(uintptr_t). |
| [in] | tx | Byte to transmit. |
| [out] | rx | Receive slot; may be NULL to discard. |
| k_ra8_ok | Frame exchanged. |
| k_ra8_err_null_ptr | Channel out of range (driver reports it). |
| k_ra8_err_hw_timeout | The TX-empty or RX-full poll expired. |
Definition at line 65 of file ra8_io_spi_bus_sci_spi.c.
References RA8_INTERNAL, and ra8_sci_spi_xfer8().
|
nodiscard |
Bind bus to SCI Simple-SPI channel channel.
Installs the SCI Simple-SPI trampoline vtable and records the channel in the handle context. No hardware is touched: initialise the channel with ra8_sci_spi_init(channel, ...) (before or after binding) and own the chip-select as a GPIO yourself.
| [in,out] | bus | Caller-owned handle to bind (non-NULL). |
| [in] | channel | SCI channel index (0..9). |
| k_ra8_ok | bus now dispatches to ra8_sci_spi_*. |
| k_ra8_err_null_ptr | bus was NULL. |
| k_ra8_err_invalid_arg | channel is out of range. |
Definition at line 151 of file ra8_io_spi_bus_sci_spi.c.
References ra8_io_spi_bus_t::ctx, ra8_io_spi_bus_t::iface, k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_sci_channel_count, RA8_CHECK_NULL_PTR, s_sci_spi_iface, and s_tag.
Referenced by priv_ra8_esp_hosted_spi_open().
|
static |
SCI Simple-SPI backend vtable – every row forwards to ra8_sci_spi_*.
Definition at line 145 of file ra8_io_spi_bus_sci_spi.c.
Referenced by ra8_io_spi_bus_bind_sci_spi().
|
static |
Module log tag.
Definition at line 36 of file ra8_io_spi_bus_sci_spi.c.