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

ra8_io block-device backend over the micro-SD-in-SPI-mode driver. More...

#include "ra8_err.h"
#include "ra8_io_blockdev.h"
Include dependency graph for ra8_io_blockdev_sdspi.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ra8_err_t ra8_io_blockdev_sdspi_init (ra8_io_blockdev_t *bd)
 Bind the micro-SD-over-SPI backend into a caller-owned handle.

Detailed Description

ra8_io block-device backend over the micro-SD-in-SPI-mode driver.

Tag
[Ring 4 / PAL] {World: NS}

This backend wraps the ra8_sdmmc_spi singleton driver so a micro-SD card on the SPI bus appears to the fabric as a plain 512-byte logical block device. Reads and writes forward straight to the driver's CMD17 / CMD25 paths; erase uses the driver's verified-zero CMD32/CMD33/CMD38 sequence, and the reported erase value is therefore k_ra8_io_erase_value_zero. Because the underlying driver keeps a single global instance, this backend is stateless: the bound ra8_io_blockdev_t carries a NULL context and the vtable dispatches to the one driver singleton.

The application must bring the card up with ra8_sdmmc_spi_init(transport) before binding or using this device; the bind helper only wires the vtable and does not touch the bus.

Since
0.1.0

Definition in file ra8_io_blockdev_sdspi.h.

Function Documentation

◆ ra8_io_blockdev_sdspi_init()

ra8_err_t ra8_io_blockdev_sdspi_init ( ra8_io_blockdev_t * bd)
nodiscard

Bind the micro-SD-over-SPI backend into a caller-owned handle.

Points bd at the SD-SPI vtable with a NULL context (the ra8_sdmmc_spi driver is a single global instance, so no per-device state is needed). No allocation and no bus traffic occur; the caller owns bd. The card itself must already be initialised with ra8_sdmmc_spi_init before any I/O call is made through the bound device.

Parameters
[out]bdHandle to bind (zero-initialised by the caller).
Returns
ra8_err_t Error code.
Return values
k_ra8_okBackend bound; bd is usable once the card is up.
k_ra8_err_null_ptrbd was NULL.
Precondition
bd is non-NULL and out-lives every call made through the device.
The application calls ra8_sdmmc_spi_init before issuing I/O.
Postcondition
On success bd dispatches to the SD-SPI singleton driver.
On any non-ok return bd is left unbound/untouched.
Note
Not thread-safe with respect to the same device or the driver singleton.
Since
0.1.0

Definition at line 206 of file ra8_io_blockdev_sdspi.c.

References ra8_io_blockdev_t::ctx, ra8_io_blockdev_t::iface, k_ra8_ok, RA8_CHECK_NULL_PTR, s_sdspi_iface, and s_tag.

Referenced by internal_sd_demo_roundtrip().