|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
SPI_B backend for the ra8_io SPI-bus facade – thin shim over ra8_spi. More...
#include "ra8_io_spi_bus_spi_b.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_spi.h"#include "ra8_spi_regs.h"Go to the source code of this file.
Functions | |
| static ra8_err_t | internal_spi_b_xfer8 (void *ctx, uint8_t tx, uint8_t *rx) |
| SPI_B backend: full-duplex single-byte exchange. | |
| static ra8_err_t | internal_spi_b_write_read (void *ctx, const void *tx, void *rx, uint32_t len, ra8_spi_bit_width_t width) |
| SPI_B backend: full-duplex multi-frame transfer. | |
| static ra8_err_t | internal_spi_b_set_clock (void *ctx, uint32_t baud_hz, uint32_t pclk_hz) |
| SPI_B backend: re-program the SPBR bit-rate divider. | |
| ra8_err_t | ra8_io_spi_bus_bind_spi_b (ra8_io_spi_bus_t *bus, uint8_t channel) |
| Bind bus to SPI_B channel channel. | |
Variables | |
| static const char *const | s_tag = "ra8_io_spi_bus_spi_b" |
| Module log tag. | |
| static const ra8_io_spi_bus_iface_t | s_spi_b_iface |
| SPI_B backend vtable – every row forwards to ra8_spi_*. | |
SPI_B backend for the ra8_io SPI-bus facade – thin shim over ra8_spi.
Implements ra8_io_spi_bus_iface by forwarding to the SPI_B driver (ra8_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. Argument validation (channel range, NULL buffers, divider limits) stays with the wrapped driver, which also carries every HUM citation – no raw MMIO is touched here.
Definition in file ra8_io_spi_bus_spi_b.c.
|
static |
SPI_B backend: re-program the SPBR bit-rate divider.
Forwards to ra8_spi_set_clock, which validates the channel and clock arguments and reprograms SPCR3.SPBR without tearing the channel down.
| [in] | ctx | Bound channel index, encoded as (void*)(uintptr_t). |
| [in] | baud_hz | Target bit-rate in Hz. |
| [in] | pclk_hz | Current PCLKA frequency in Hz. |
| k_ra8_ok | Divider reprogrammed. |
| k_ra8_err_invalid_arg | Channel or clock arguments invalid. |
Definition at line 131 of file ra8_io_spi_bus_spi_b.c.
References ra8_spi_set_clock().
|
static |
SPI_B backend: full-duplex multi-frame transfer.
Forwards straight to ra8_spi_write_read, which supports 8/16/32-bit frames, treats a single NULL buffer as write-only / read-with-idle-fill, and rejects both buffers NULL.
| [in] | ctx | Bound channel index, encoded as (void*)(uintptr_t). |
| [in] | tx | Source buffer or NULL. |
| [out] | rx | Destination buffer or NULL. |
| [in] | len | Number of frames. |
| [in] | width | Per-frame bit width. |
| k_ra8_ok | Every frame exchanged. |
| k_ra8_err_null_ptr | Both buffers NULL with len > 0. |
| k_ra8_err_invalid_arg | Channel or width invalid. |
| k_ra8_err_hw_timeout | SPSR polling expired. |
Definition at line 96 of file ra8_io_spi_bus_spi_b.c.
References RA8_INTERNAL, and ra8_spi_write_read().
|
static |
SPI_B backend: full-duplex single-byte exchange.
Decodes the channel from the handle context and forwards to ra8_spi_xfer8, which validates the channel and owns the SPSR 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 | SPSR.SPTEF / SPSR.SPRF never asserted. |
Definition at line 61 of file ra8_io_spi_bus_spi_b.c.
References RA8_INTERNAL, and ra8_spi_xfer8().
|
nodiscard |
Bind bus to SPI_B channel channel.
Installs the SPI_B trampoline vtable and records the channel in the handle context. No hardware is touched: initialise the channel with ra8_spi_init(channel, ...) (before or after binding) and route the pins yourself.
| [in,out] | bus | Caller-owned handle to bind (non-NULL). |
| [in] | channel | SPI_B channel index (0 or 1). |
| k_ra8_ok | bus now dispatches to ra8_spi_*. |
| k_ra8_err_null_ptr | bus was NULL. |
| k_ra8_err_invalid_arg | channel is out of range. |
Definition at line 143 of file ra8_io_spi_bus_spi_b.c.
References ra8_io_spi_bus_t::ctx, ra8_io_spi_bus_t::iface, k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_spi_b_channel_count, RA8_CHECK_NULL_PTR, s_spi_b_iface, and s_tag.
Referenced by ep_bringup_panel_bus().
|
static |
SPI_B backend vtable – every row forwards to ra8_spi_*.
Definition at line 137 of file ra8_io_spi_bus_spi_b.c.
Referenced by ra8_io_spi_bus_bind_spi_b().
|
static |
Module log tag.
Definition at line 33 of file ra8_io_spi_bus_spi_b.c.