|
GPS Device
|
Functions | |
| static ERR_te | sd_send_cmd (SPI_REGDEF_ts *spi_instance, uint8_t index, uint32_t arg, bool acmd, CMD_RESPONSE_ts *cmd_response_o) |
| Transmits a single SPI-mode SD command and receives the response. | |
| static ERR_te | sd_cease_comms (SD_HANDLE_ts *sd_handle, bool deinit) |
| Raises CS, sends two dummy bytes, and disables SPI. Optionally deinitializes the handle. | |
| static ERR_te | sd_go_idle_state (SD_HANDLE_ts *sd_handle) |
| Issues CMD0 to reset the SD card into idle (SPI) mode. | |
| static ERR_te | sd_send_if_cond (SD_HANDLE_ts *sd_handle, bool *match_o, bool *no_resp_o) |
| Issues CMD8 to determine whether the card is SD Ver.2 or older. | |
| static ERR_te | sd_app_send_op_cond (SD_HANDLE_ts *sd_handle, uint32_t arg) |
| Issues ACMD41 to initiate SD card initialization (SD Ver.2 and Ver.1). | |
| static ERR_te | sd_read_ocr (SD_HANDLE_ts *sd_handle) |
| Reads the OCR register via CMD58 and stores power-up status, addressing mode, and voltage range. | |
| static ERR_te | sd_send_op_cond (SD_HANDLE_ts *sd_handle) |
| Issues CMD1 to initiate MMC Ver.3 card initialization. | |
| static ERR_te | sd_set_blocklen (SD_HANDLE_ts *sd_handle) |
| Issues CMD16 to set the block length to 512 bytes for byte-addressed cards. | |
| static ERR_te | sd_read_csd (SD_HANDLE_ts *sd_handle) |
| Issues CMD9 to read the CSD register and stores capacity information in the handle. | |
| static ERR_te | decode_csd_v1 (const uint8_t *csd_raw, SD_CSD_INFO_ts *csd_info_o) |
| Decodes a CSD v1.0 register (SDSC cards) into a SD_CSD_INFO_ts structure. | |
| static ERR_te | decode_csd_v2 (const uint8_t *csd_raw, SD_CSD_INFO_ts *csd_info_o) |
| Decodes a CSD v2.0 register (SDHC/SDXC cards) into a SD_CSD_INFO_ts structure. | |
|
static |
Transmits a single SPI-mode SD command and receives the response.
Builds the 6-byte command frame (start bit | index, 4-byte argument, CRC), transmits it over SPI, and receives the R1 response byte. For application- specific commands (ACMD), CMD55 is sent first automatically.
Trailing response bytes are handled per command:
CRC is required for CMD0 (0x95) and CMD8 (0x87); dummy CRC (0x00) is used for all other commands, as CRC checking is disabled after initialization.
| [in] | spi_instance | Pointer to the SPI peripheral to use. |
| [in] | index | Command index (0–63, without the 0x40 start bit). |
| [in] | arg | 32-bit command argument. |
| [in] | acmd | If true, CMD55 is sent before this command to prefix it as an application-specific command. |
| [out] | cmd_response_o | Pointer to the response structure to populate. |
acmd is true Definition at line 1131 of file sd.c.


|
static |
Raises CS, sends two dummy bytes, and disables SPI. Optionally deinitializes the handle.
Called after every completed or failed SPI transaction to return the bus to an idle state. When deinit is true, temporarily sets the handle's initialized flag to allow sd_deinit_handle to run, then calls it to release the pool slot.
| [in] | sd_handle | Pointer to the SD card handle. |
| [in] | deinit | If true, deinitializes the handle after ending communication. |
Definition at line 1256 of file sd.c.


|
static |
Issues CMD0 to reset the SD card into idle (SPI) mode.
Retries up to CONFIG_SD_CMD_SEND_ERROR_RETRY_NUM times with CONFIG_SD_CMD_SEND_ERROR_RETRY_LATENCY ms between attempts. Succeeds when R1 bit 0 (idle state) is set.
| [in] | sd_handle | Pointer to the SD card handle. |
Definition at line 1287 of file sd.c.


|
static |
Issues CMD8 to determine whether the card is SD Ver.2 or older.
Sends CMD8 with the standard voltage argument 0x000001AA.
match_o is set.no_resp_o is set.| [in] | sd_handle | Pointer to the SD card handle. |
| [out] | match_o | Set to true if R7 echoes 0x000001AA (SD Ver.2). |
| [out] | no_resp_o | Set to true if CMD8 produces no response (SD Ver.1 / MMC). |
Definition at line 1336 of file sd.c.


|
static |
Issues ACMD41 to initiate SD card initialization (SD Ver.2 and Ver.1).
Retries up to CONFIG_SD_INVALID_RESP_RETRY_NUM times while R1 equals 0x01 (still initializing). Pass arg = 0x40000000 for SD Ver.2 (HCS bit set) or arg = 0 for SD Ver.1.
| [in] | sd_handle | Pointer to the SD card handle. |
| [in] | arg | ACMD41 argument. Use 0x40000000 for SDHC support, 0x00000000 for SDSC only. |
Definition at line 1383 of file sd.c.


|
static |
Reads the OCR register via CMD58 and stores power-up status, addressing mode, and voltage range.
Reconstructs the 32-bit OCR value from the 4-byte R3 response and extracts: power-up completion flag (SD_PWRUP_STATUS_te), Card Capacity Status (block vs byte addressing), and the supported voltage window (stored but not currently used for filtering).
| [in] | sd_handle | Pointer to the SD card handle. |
Definition at line 1440 of file sd.c.


|
static |
Issues CMD1 to initiate MMC Ver.3 card initialization.
Used as a fallback when ACMD41 fails (card is MMC, not SD). Retries while R1 equals 0x01 (still initializing).
| [in] | sd_handle | Pointer to the SD card handle. |
Definition at line 1495 of file sd.c.


|
static |
Issues CMD16 to set the block length to 512 bytes for byte-addressed cards.
Only called for SDSC (byte-addressed) cards. SDHC cards always use a fixed 512-byte block length and do not require this command.
| [in] | sd_handle | Pointer to the SD card handle. |
Definition at line 1540 of file sd.c.


|
static |
Issues CMD9 to read the CSD register and stores capacity information in the handle.
Waits for the data token (0xFE), reads the 16-byte CSD register, and dispatches to decode_csd_v1 or decode_csd_v2 based on the CSD structure version field. CSD version 3 is treated as v2. The resulting sd_handle_s::capacity_mb, sd_handle_s::block_count, and sd_handle_s::block_len fields are populated from the decoded data.
| [in] | sd_handle | Pointer to the SD card handle. |
Definition at line 1577 of file sd.c.


|
static |
Decodes a CSD v1.0 register (SDSC cards) into a SD_CSD_INFO_ts structure.
Extracts all fields from the 16-byte big-endian CSD register using extract_bits and computes derived values:
| [in] | csd_raw | Pointer to the 16-byte raw CSD register data. |
| [out] | csd_info_o | Pointer to the structure that will receive the decoded fields. |
Definition at line 1652 of file sd.c.


|
static |
Decodes a CSD v2.0 register (SDHC/SDXC cards) into a SD_CSD_INFO_ts structure.
Extracts all fields from the 16-byte big-endian CSD register using extract_bits and computes derived values:
| [in] | csd_raw | Pointer to the 16-byte raw CSD register data. |
| [out] | csd_info_o | Pointer to the structure that will receive the decoded fields. |
Definition at line 1706 of file sd.c.

