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

Module-private cross-TU surface for the SPI-mode SD card driver. More...

#include <stdint.h>
#include "ra8_attributes.h"
#include "ra8_err.h"
#include "ra8_sdmmc_spi.h"
Include dependency graph for ra8_sdmmc_spi_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  sd_state_t
 Cached protocol state held across the driver public API. More...

Enumerations

enum  sd_cmd_t : uint8_t {
  k_sd_cmd_go_idle_state = 0x40U ,
  k_sd_cmd_send_if_cond = 0x40U | 8U ,
  k_sd_cmd_send_csd = 0x40U | 9U ,
  k_sd_cmd_send_cid = 0x40U | 10U ,
  k_sd_cmd_stop_transmission = 0x40U | 12U ,
  k_sd_cmd_set_blocklen = 0x40U | 16U ,
  k_sd_cmd_read_single_block = 0x40U | 17U ,
  k_sd_cmd_read_multi_block = 0x40U | 18U ,
  k_sd_cmd_write_single_block = 0x40U | 24U ,
  k_sd_cmd_write_multi_block = 0x40U | 25U ,
  k_sd_cmd_erase_wr_blk_start = 0x40U | 32U ,
  k_sd_cmd_erase_wr_blk_end = 0x40U | 33U ,
  k_sd_cmd_erase = 0x40U | 38U ,
  k_sd_cmd_app_cmd = 0x40U | 55U ,
  k_sd_cmd_read_ocr = 0x40U | 58U ,
  k_sd_acmd_sd_send_op_cond = 0x40U | 41U ,
  k_sd_acmd_set_wr_blk_erase_count = 0x40U | 23U
}
 Wire-byte for every command used by this driver. More...
enum  sd_data_token_t : uint8_t {
  k_sd_token_data_start_single = 0xFEU ,
  k_sd_token_data_start_multi = 0xFCU ,
  k_sd_token_stop_multi = 0xFDU ,
  k_sd_token_idle = 0xFFU
}
 Data tokens used for block I/O (SD spec PHY v9 section 7.3.3). More...
enum  sd_data_response_t : uint8_t {
  k_sd_data_response_mask = 0x1FU ,
  k_sd_data_response_accepted = 0x05U ,
  k_sd_data_response_crc_err = 0x0BU ,
  k_sd_data_response_write_err = 0x0DU
}
 Data-response token bit layout (SD spec PHY v9 section 7.3.3.1). More...
enum  sd_protocol_const_t : uint32_t {
  k_sd_crc7_cmd0_byte = 0x95U ,
  k_sd_cmd8_arg_check_pattern = 0x000001AAUL ,
  k_sd_crc7_cmd8_byte = 0x87U ,
  k_sd_acmd41_arg_hcs = 0x40000000UL ,
  k_sd_ocr_ccs_bit = 0x40000000UL ,
  k_sd_ocr_busy_bit = 0x80000000UL ,
  k_sd_max_r1_wait_bytes = 16U ,
  k_sd_max_data_token_polls = 50000U ,
  k_sd_max_busy_poll_bytes = 100000U ,
  k_sd_max_acmd41_attempts = 1000U ,
  k_sd_init_dummy_clocks = 80U ,
  k_sd_recover_flush_bytes = 530U ,
  k_sd_recover_idle_bytes = 64U ,
  k_sd_max_recover_attempts = 4U ,
  k_sd_max_erase_poll_bytes = 5000000U
}
 Magic argument values and retry budgets. More...
enum  sd_bit_shift_t : uint8_t {
  k_sd_bit_byte = 8U ,
  k_sd_bit_two_byte = 16U ,
  k_sd_bit_three_byte = 24U
}
 Bit-shift constants reused across byte packing. More...
enum  sd_byte_mask_t : uint32_t {
  k_sd_mask_byte = 0xFFU ,
  k_sd_mask_12bit = 0xFFFU
}
 Generic byte-extraction masks used across argument packing. More...

Functions

ra8_err_t priv_sdmmc_spi_xfer_one (uint8_t tx, uint8_t *rx)
 Shift out one byte and capture the response over the transport.
ra8_err_t priv_sdmmc_spi_send_idle (uint32_t n)
 Shift n idle bytes (0xFF) and discard the response.
ra8_err_t priv_sdmmc_spi_cs_assert (void)
 Drive CS low and clock a single idle byte so CIPO is sampled.
ra8_err_t priv_sdmmc_spi_cs_release (void)
 Drive CS high after clocking one idle byte (SD spec section 7.2.4).
ra8_err_t priv_sdmmc_spi_send_command (sd_cmd_t cmd, uint32_t arg, uint8_t *out_r1)
 Send a command frame and capture the R1 response byte.
ra8_err_t priv_sdmmc_spi_send_acmd (sd_cmd_t acmd, uint32_t arg, uint8_t *out_r1)
 Send an ACMD by prefixing it with CMD55 (APP_CMD).
ra8_err_t priv_sdmmc_spi_send_stop_transmission (uint8_t *out_r1)
 Send CMD12 (STOP_TRANSMISSION) and capture its R1 response byte.
ra8_err_t priv_sdmmc_spi_wait_data_token (void)
 Poll for the data-start token (0xFE), bounded by a retry budget.
ra8_err_t priv_sdmmc_spi_wait_not_busy_bounded (uint32_t max_polls)
 Wait for the card to release busy (CIPO -> 0xFF), bounded by max_polls.
ra8_err_t priv_sdmmc_spi_wait_not_busy (void)
 Wait for the card to release the busy token (CIPO returns to 0xFF).
ra8_err_t priv_sdmmc_spi_validate_transport (const ra8_sdmmc_spi_transport_t *transport)
 Validate the transport descriptor: every callback non-NULL.
ra8_err_t priv_sdmmc_spi_run_init_sequence (void)
 Walk the full SD identification sequence and learn capacity / type.

Variables

sd_state_t g_sdmmc_spi_state
 Single driver instance (the module's one external definition).

Detailed Description

Module-private cross-TU surface for the SPI-mode SD card driver.

Tag
[Ring 3 / HAL] {World: NS}

Shared between the core/init translation unit (ra8_sdmmc_spi.c) and the block-I/O translation unit (ra8_sdmmc_spi_io.c) of the ra8_sdmmc_spi library. It carries the protocol enums both units use, the single mutable driver-state definition, and the prototypes of the low-level transport / framing helpers that the block-I/O unit calls.

This header is private to the ra8_sdmmc_spi module; no other library includes it. All enum values and helper contracts mirror SD Specification Part 1 Physical Layer Simplified Specification v9.10 section 7 ("SPI Mode") – the same references documented inline at each symbol's original definition site.

Since
0.1.0

Definition in file ra8_sdmmc_spi_internal.h.

Enumeration Type Documentation

◆ sd_bit_shift_t

enum sd_bit_shift_t : uint8_t

Bit-shift constants reused across byte packing.

Enumerator
k_sd_bit_byte 

SD bit byte.

k_sd_bit_two_byte 

SD bit two byte.

k_sd_bit_three_byte 

SD bit three byte.

Definition at line 133 of file ra8_sdmmc_spi_internal.h.

◆ sd_byte_mask_t

enum sd_byte_mask_t : uint32_t

Generic byte-extraction masks used across argument packing.

k_sd_mask_byte isolates the low 8 bits when packing a 32-bit command argument into the 4 big-endian frame bytes (SD spec PHY v9 section 7.3.1.1 "Command Format") or splitting a 16-bit CRC16 into its two on-wire bytes. k_sd_mask_12bit is the CMD8 echo-check mask (SD spec PHY v9 section 7.3.2.6: bits [11:0] of the R7 echo carry the voltage-range code (bits 11:8) and the host check pattern (bits 7:0)).

Enumerator
k_sd_mask_byte 

Low 8 bits of a wider value.

k_sd_mask_12bit 

CMD8 R7 echo voltage-range + check pattern.

Definition at line 152 of file ra8_sdmmc_spi_internal.h.

◆ sd_cmd_t

enum sd_cmd_t : uint8_t

Wire-byte for every command used by this driver.

The wire byte is 0x40 | cmd_index per SD spec PHY v9 section 7.3.1.1 "Command Format" (bit 7 = 0, bit 6 = 1, bits 5..0 = command index).

Enumerator
k_sd_cmd_go_idle_state 

CMD0.

k_sd_cmd_send_if_cond 

CMD8.

k_sd_cmd_send_csd 

CMD9.

k_sd_cmd_send_cid 

CMD10.

k_sd_cmd_stop_transmission 

CMD12.

k_sd_cmd_set_blocklen 

CMD16.

k_sd_cmd_read_single_block 

CMD17.

k_sd_cmd_read_multi_block 

CMD18.

k_sd_cmd_write_single_block 

CMD24.

k_sd_cmd_write_multi_block 

CMD25.

k_sd_cmd_erase_wr_blk_start 

CMD32.

k_sd_cmd_erase_wr_blk_end 

CMD33.

k_sd_cmd_erase 

CMD38.

k_sd_cmd_app_cmd 

CMD55.

k_sd_cmd_read_ocr 

CMD58.

k_sd_acmd_sd_send_op_cond 

ACMD41.

k_sd_acmd_set_wr_blk_erase_count 

ACMD23.

Definition at line 52 of file ra8_sdmmc_spi_internal.h.

◆ sd_data_response_t

enum sd_data_response_t : uint8_t

Data-response token bit layout (SD spec PHY v9 section 7.3.3.1).

Wire layout xxx0sss1 where sss = 010 "accepted", 101 "CRC error", 110 "write error". Mask with k_sd_data_response_mask first.

Enumerator
k_sd_data_response_mask 

SD data response mask.

k_sd_data_response_accepted 

0b00101 – data accepted.

k_sd_data_response_crc_err 

0b01011 – CRC error.

k_sd_data_response_write_err 

0b01101 – write error.

Definition at line 91 of file ra8_sdmmc_spi_internal.h.

◆ sd_data_token_t

enum sd_data_token_t : uint8_t

Data tokens used for block I/O (SD spec PHY v9 section 7.3.3).

Enumerator
k_sd_token_data_start_single 

Single-block start.

k_sd_token_data_start_multi 

Multi-block start.

k_sd_token_stop_multi 

Multi-block stop.

k_sd_token_idle 

Idle bus.

Definition at line 76 of file ra8_sdmmc_spi_internal.h.

◆ sd_protocol_const_t

enum sd_protocol_const_t : uint32_t

Magic argument values and retry budgets.

Enumerator
k_sd_crc7_cmd0_byte 

SD crc7 cmd0 byte.

k_sd_cmd8_arg_check_pattern 

SD cmd8 arg check pattern.

k_sd_crc7_cmd8_byte 

SD crc7 cmd8 byte.

k_sd_acmd41_arg_hcs 

SD acmd41 arg hcs.

k_sd_ocr_ccs_bit 

SD ocr ccs bit.

k_sd_ocr_busy_bit 

SD ocr busy bit.

k_sd_max_r1_wait_bytes 

R1 must appear within 8 bytes per spec; 2x slack.

k_sd_max_data_token_polls 

~500 ms at 100 us / poll.

k_sd_max_busy_poll_bytes 

Worst-case write timeout.

k_sd_max_acmd41_attempts 

1 s at 1 ms / attempt.

k_sd_init_dummy_clocks 

80 clocks = 10 bytes of 0xFF (>=74 required).

k_sd_recover_flush_bytes 

>= 512 data + 2 CRC + token to flush a stuck write.

k_sd_recover_idle_bytes 

512 CS-released clocks drain busy + reset framing.

k_sd_max_recover_attempts 

Re-flush + retry CMD0 before failing.

k_sd_max_erase_poll_bytes 

Busy ceiling for a bulk CMD38 erase (seconds).

Definition at line 102 of file ra8_sdmmc_spi_internal.h.

Function Documentation

◆ priv_sdmmc_spi_cs_assert()

ra8_err_t priv_sdmmc_spi_cs_assert ( void )

Drive CS low and clock a single idle byte so CIPO is sampled.

Selects the card and emits one idle byte to align framing.

Returns
ra8_err_t Error code.
Return values
k_ra8_okCS asserted and one idle byte clocked.
otherPropagated from the transport cs / xfer callbacks.
Precondition
The transport is bound.
The transport cs callback is non-NULL.
Postcondition
On success CS is asserted (low).
One idle byte has been clocked on success.
Note
Not thread-safe.
Since
0.1.0

Definition at line 249 of file ra8_sdmmc_spi.c.

References g_sdmmc_spi_state, k_ra8_ok, priv_sdmmc_spi_send_idle(), and RA8_PRIV.

Referenced by internal_acmd41_loop(), internal_cmd_require_ready(), internal_erase_range(), internal_read_csd(), internal_read_ocr(), internal_send_cmd0(), internal_send_cmd8(), internal_set_block_len(), ra8_sdmmc_spi_read_block(), ra8_sdmmc_spi_read_blocks(), ra8_sdmmc_spi_write_block(), and ra8_sdmmc_spi_write_blocks().

◆ priv_sdmmc_spi_cs_release()

ra8_err_t priv_sdmmc_spi_cs_release ( void )

Drive CS high after clocking one idle byte (SD spec section 7.2.4).

Releases the card and emits trailing idle clocks so the card can finish any pending internal state transition.

Returns
ra8_err_t Error code.
Return values
k_ra8_okCS released and one idle byte clocked.
otherPropagated from the transport cs / xfer callbacks.
Precondition
The transport is bound.
The transport cs callback is non-NULL.
Postcondition
On success CS is released (high).
One idle byte has been clocked on success.
Note
Not thread-safe.
Since
0.1.0

Definition at line 260 of file ra8_sdmmc_spi.c.

References g_sdmmc_spi_state, k_ra8_ok, priv_sdmmc_spi_send_idle(), and RA8_PRIV.

Referenced by internal_acmd41_loop(), internal_cmd_require_ready(), internal_erase_range(), internal_read_csd(), internal_read_ocr(), internal_send_cmd0(), internal_send_cmd8(), internal_set_block_len(), ra8_sdmmc_spi_read_block(), ra8_sdmmc_spi_read_blocks(), ra8_sdmmc_spi_write_block(), and ra8_sdmmc_spi_write_blocks().

◆ priv_sdmmc_spi_run_init_sequence()

ra8_err_t priv_sdmmc_spi_run_init_sequence ( void )

Walk the full SD identification sequence and learn capacity / type.

Runs the CMD0/CMD8/ACMD41/CMD58/CMD9/CMD16 probe and records the card type and capacity into g_sdmmc_spi_state.

Returns
ra8_err_t Error code.
Return values
k_ra8_okCard identified; type and capacity cached.
k_ra8_err_protocol_errorA response was malformed.
otherPropagated from the probe steps.
Precondition
The transport is bound and the init clock is set.
CS is released on entry.
Postcondition
On success ::g_sdmmc_spi_state.card_type and .capacity_blocks are set.
CS is released.
Note
Not thread-safe; single-threaded init.
Since
0.1.0

Definition at line 777 of file ra8_sdmmc_spi.c.

References g_sdmmc_spi_state, internal_classify_card(), internal_probe_card(), internal_read_csd(), internal_set_block_len(), k_ra8_ok, RA8_PRIV, RA8_RETURN_ON_ERROR, and s_tag.

Referenced by ra8_sdmmc_spi_init().

◆ priv_sdmmc_spi_send_acmd()

ra8_err_t priv_sdmmc_spi_send_acmd ( sd_cmd_t acmd,
uint32_t arg,
uint8_t * out_r1 )

Send an ACMD by prefixing it with CMD55 (APP_CMD).

Issues CMD55 then the application command, returning the application command's R1.

Parameters
[in]acmdApplication command wire byte.
[in]arg32-bit command argument.
[out]out_r1Captured R1 response byte of the application command.
Returns
ra8_err_t Error code.
Return values
k_ra8_okBoth commands sent and R1 captured.
otherPropagated from the transport callbacks.
Precondition
The transport is bound.
out_r1 is non-NULL.
Postcondition
On success out_r1 holds the application command R1.
No driver state beyond out_r1 is modified.
Note
Not thread-safe.
Since
0.1.0

Definition at line 333 of file ra8_sdmmc_spi.c.

References k_ra8_ok, k_sd_cmd_app_cmd, priv_sdmmc_spi_send_command(), and RA8_PRIV.

Referenced by internal_acmd41_loop(), and ra8_sdmmc_spi_write_blocks().

◆ priv_sdmmc_spi_send_command()

ra8_err_t priv_sdmmc_spi_send_command ( sd_cmd_t cmd,
uint32_t arg,
uint8_t * out_r1 )

Send a command frame and capture the R1 response byte.

Builds the 6-byte frame (CRC7 included), clocks it out, then polls for the R1 token.

Parameters
[in]cmdCommand wire byte.
[in]arg32-bit command argument.
[out]out_r1Captured R1 response byte.
Returns
ra8_err_t Error code.
Return values
k_ra8_okCommand sent and R1 captured.
k_ra8_err_hw_timeoutR1 did not appear within budget.
otherPropagated from the transport callbacks.
Precondition
The transport is bound.
out_r1 is non-NULL.
Postcondition
On success out_r1 holds the R1 byte.
No driver state beyond out_r1 is modified.
Note
Not thread-safe.
Since
0.1.0

Definition at line 316 of file ra8_sdmmc_spi.c.

References g_sdmmc_spi_state, internal_build_frame(), internal_read_r1(), k_ra8_ok, k_ra8_sdmmc_spi_cmd_frame_bytes, and RA8_PRIV.

Referenced by internal_cmd_require_ready(), internal_erase_range(), internal_read_csd(), internal_read_data_phase(), internal_read_ocr(), internal_recover_stuck_card(), internal_send_cmd0(), internal_send_cmd8(), internal_set_block_len(), priv_sdmmc_spi_send_acmd(), ra8_sdmmc_spi_read_blocks(), ra8_sdmmc_spi_write_block(), and ra8_sdmmc_spi_write_blocks().

◆ priv_sdmmc_spi_send_idle()

ra8_err_t priv_sdmmc_spi_send_idle ( uint32_t n)

Shift n idle bytes (0xFF) and discard the response.

Bounded by n; clocks the bus idle to advance card timers.

Parameters
[in]nNumber of idle bytes to clock.
Returns
ra8_err_t Error code.
Return values
k_ra8_okAll n bytes clocked.
otherPropagated from the transport xfer callback.
Precondition
The transport is bound.
The transport xfer callback is non-NULL.
Postcondition
Exactly n idle bytes were clocked on success.
No driver state is modified.
Note
Not thread-safe.
Since
0.1.0

Definition at line 235 of file ra8_sdmmc_spi.c.

References k_ra8_ok, k_sd_token_idle, priv_sdmmc_spi_xfer_one(), and RA8_PRIV.

Referenced by internal_recover_stuck_card(), internal_wake_card(), internal_write_data_block(), internal_write_multi_stream(), priv_sdmmc_spi_cs_assert(), priv_sdmmc_spi_cs_release(), and priv_sdmmc_spi_send_stop_transmission().

◆ priv_sdmmc_spi_send_stop_transmission()

ra8_err_t priv_sdmmc_spi_send_stop_transmission ( uint8_t * out_r1)

Send CMD12 (STOP_TRANSMISSION) and capture its R1 response byte.

Builds and clocks the 6-byte CMD12 frame, discards the one stuff byte that follows it (the tail of the interrupted read stream – its value is undefined, and a bit7-clear garbage byte would be misread as R1), then polls for the R1 token. Terminates a CMD18 READ_MULTIPLE_BLOCK stream; the plain priv_sdmmc_spi_send_command cannot be used because it polls for R1 straight after the frame.

Parameters
[out]out_r1Captured R1 response byte.
Returns
ra8_err_t Error code.
Return values
k_ra8_okCMD12 sent and R1 captured.
k_ra8_err_hw_timeoutR1 did not appear within budget.
otherPropagated from the transport callbacks.
Precondition
The transport is bound.
out_r1 is non-NULL.
Postcondition
On success out_r1 holds the CMD12 R1 byte.
No driver state beyond out_r1 is modified.
Note
Not thread-safe.
Since
0.1.0

Definition at line 346 of file ra8_sdmmc_spi.c.

References g_sdmmc_spi_state, internal_build_frame(), internal_read_r1(), k_ra8_ok, k_ra8_sdmmc_spi_cmd_frame_bytes, k_sd_cmd_stop_transmission, priv_sdmmc_spi_send_idle(), and RA8_PRIV.

Referenced by internal_read_multi_stop().

◆ priv_sdmmc_spi_validate_transport()

ra8_err_t priv_sdmmc_spi_validate_transport ( const ra8_sdmmc_spi_transport_t * transport)

Validate the transport descriptor: every callback non-NULL.

Rejects a NULL descriptor or any NULL callback before bind.

Parameters
[in]transportTransport descriptor to check.
Returns
ra8_err_t Error code.
Return values
k_ra8_okDescriptor and all callbacks are non-NULL.
k_ra8_err_null_ptrtransport is NULL.
k_ra8_err_invalid_argA callback is NULL.
Precondition
None.
None.
Postcondition
No driver state is modified.
Return reflects only the descriptor contents.
Note
Not thread-safe.
Since
0.1.0

Definition at line 488 of file ra8_sdmmc_spi.c.

References k_ra8_err_invalid_arg, k_ra8_err_null_ptr, k_ra8_ok, and RA8_PRIV.

Referenced by ra8_sdmmc_spi_init().

◆ priv_sdmmc_spi_wait_data_token()

ra8_err_t priv_sdmmc_spi_wait_data_token ( void )

Poll for the data-start token (0xFE), bounded by a retry budget.

Clocks idle bytes until the single-block data-start token appears or the poll budget is exhausted.

Returns
ra8_err_t Error code.
Return values
k_ra8_okData-start token observed.
k_ra8_err_hw_timeoutToken did not appear within budget.
otherPropagated from the transport callbacks.
Precondition
The transport is bound.
CS is asserted by the caller.
Postcondition
On success the next byte clocked is the first payload byte.
No driver state is modified.
Note
Not thread-safe.
Since
0.1.0

Definition at line 404 of file ra8_sdmmc_spi.c.

References k_ra8_err_hw_timeout, k_ra8_ok, k_sd_max_data_token_polls, k_sd_token_data_start_single, k_sd_token_idle, priv_sdmmc_spi_xfer_one(), and RA8_PRIV.

Referenced by internal_read_csd(), internal_read_data_phase(), and internal_read_multi_stream().

◆ priv_sdmmc_spi_wait_not_busy()

ra8_err_t priv_sdmmc_spi_wait_not_busy ( void )

Wait for the card to release the busy token (CIPO returns to 0xFF).

Convenience wrapper over priv_sdmmc_spi_wait_not_busy_bounded with the default worst-case write timeout.

Returns
ra8_err_t Error code.
Return values
k_ra8_okCard released busy.
k_ra8_err_hw_timeoutCard stayed busy beyond the default budget.
otherPropagated from the transport callbacks.
Precondition
The transport is bound.
CS is asserted by the caller.
Postcondition
On success the card is no longer busy.
No driver state is modified.
Note
Not thread-safe.
Since
0.1.0

Definition at line 438 of file ra8_sdmmc_spi.c.

References k_sd_max_busy_poll_bytes, priv_sdmmc_spi_wait_not_busy_bounded(), and RA8_PRIV.

Referenced by internal_read_multi_stop(), internal_recover_stuck_card(), internal_write_data_block(), and internal_write_multi_stream().

◆ priv_sdmmc_spi_wait_not_busy_bounded()

ra8_err_t priv_sdmmc_spi_wait_not_busy_bounded ( uint32_t max_polls)

Wait for the card to release busy (CIPO -> 0xFF), bounded by max_polls.

Clocks idle bytes until the card stops holding CIPO low or the poll budget is exhausted.

Parameters
[in]max_pollsMaximum idle bytes to clock before timing out.
Returns
ra8_err_t Error code.
Return values
k_ra8_okCard released busy.
k_ra8_err_hw_timeoutCard stayed busy beyond max_polls.
otherPropagated from the transport callbacks.
Precondition
The transport is bound.
CS is asserted by the caller.
Postcondition
On success the card is no longer busy.
No driver state is modified.
Note
Not thread-safe.
Since
0.1.0

Definition at line 421 of file ra8_sdmmc_spi.c.

References k_ra8_err_hw_timeout, k_ra8_ok, k_sd_token_idle, priv_sdmmc_spi_xfer_one(), and RA8_PRIV.

Referenced by internal_erase_range(), and priv_sdmmc_spi_wait_not_busy().

◆ priv_sdmmc_spi_xfer_one()

ra8_err_t priv_sdmmc_spi_xfer_one ( uint8_t tx,
uint8_t * rx )

Shift out one byte and capture the response over the transport.

Wraps a single-byte full-duplex transfer through the bound g_sdmmc_spi_state.transport so callers need not stage 1-byte buffers themselves.

Parameters
[in]txByte to clock out.
[out]rxReceived byte, or NULL to discard.
Returns
ra8_err_t Error code.
Return values
k_ra8_okByte exchanged.
otherPropagated from the transport xfer callback.
Precondition
The transport is bound (driver init has begun).
The transport xfer callback is non-NULL.
Postcondition
On success rx holds the received byte when non-NULL.
No driver state beyond rx is modified.
Note
Not thread-safe.
Since
0.1.0

Definition at line 218 of file ra8_sdmmc_spi.c.

References g_sdmmc_spi_state, k_ra8_ok, and RA8_PRIV.

Referenced by internal_read_block_crc_check(), internal_read_block_payload(), internal_read_csd(), internal_read_r1(), internal_read_r3_or_r7_tail(), internal_recover_stuck_card(), internal_write_data_block(), internal_write_multi_stream(), priv_sdmmc_spi_send_idle(), priv_sdmmc_spi_wait_data_token(), and priv_sdmmc_spi_wait_not_busy_bounded().

Variable Documentation

◆ g_sdmmc_spi_state

sd_state_t g_sdmmc_spi_state
extern

Single driver instance (the module's one external definition).

Single driver instance, defined in ra8_sdmmc_spi.c.

Shared with the block-I/O TU through ra8_sdmmc_spi_internal.h; this file owns the sole definition.

Note
Internal mutable state; access from a single thread only.
Since
0.1.0

Mutable protocol state shared between the core/init TU and the block-I/O TU. Renamed with the module infix so it is link-unique.

Note
Internal mutable state; access from a single thread only.
Warning
Do not duplicate; exactly one definition exists in ra8_sdmmc_spi.c.
Since
0.1.0

Definition at line 164 of file ra8_sdmmc_spi.c.

Referenced by internal_finalize_init(), internal_fs_get_capacity(), internal_lba_to_arg(), internal_prepare_init(), internal_read_r3_or_r7_tail(), internal_recover_stuck_card(), internal_wake_card(), internal_write_data_block(), priv_sdmmc_spi_cs_assert(), priv_sdmmc_spi_cs_release(), priv_sdmmc_spi_run_init_sequence(), priv_sdmmc_spi_send_command(), priv_sdmmc_spi_send_stop_transmission(), priv_sdmmc_spi_xfer_one(), ra8_sdmmc_spi_bind_fs_backend(), ra8_sdmmc_spi_deinit(), ra8_sdmmc_spi_erase_blocks(), ra8_sdmmc_spi_get_capacity(), ra8_sdmmc_spi_get_card_type(), ra8_sdmmc_spi_read_block(), ra8_sdmmc_spi_read_blocks(), ra8_sdmmc_spi_write_block(), and ra8_sdmmc_spi_write_blocks().