GPS Device
Loading...
Searching...
No Matches
sd.c File Reference

SD card driver implementation file. More...

#include <stdbool.h>
#include <string.h>
#include "sd.h"
#include "common.h"
#include "err.h"
#include "init.h"
#include "io.h"
#include "log.h"
#include "modules.h"
#include "cmd.h"
#include "configuration.h"
#include "stm32f401re.h"
#include "stm32f401re_gpio.h"
#include "stm32f401re_rcc.h"
#include "stm32f401re_spi.h"
#include "arm_cortex_m4_systick.h"
Include dependency graph for sd.c:

Go to the source code of this file.

Classes

struct  CMD_RESPONSE_ts
 Holds the R1, R3, and R7 response bytes returned by the SD card after a command. More...
struct  SD_CSD_INFO_ts
 Decoded contents of the SD card CSD register. More...
struct  sd_handle_s
 Internal structure representing a single SD card handle instance. More...
struct  internal_state_s
 Internal state of the SysTick driver. More...

Enumerations

enum  OCR_te {
  OCR_1_7V_1_6V = 4 , OCR_1_8V_1_7V , OCR_1_9V_1_8V , OCR_2_0V_1_9V ,
  OCR_2_1V_2_0V , OCR_2_2V_2_1V , OCR_2_3V_2_2V , OCR_2_4V_2_3V ,
  OCR_2_5V_2_4V , OCR_2_6V_2_5V , OCR_2_7V_2_6V , OCR_2_8V_2_7V ,
  OCR_2_9V_2_8V , OCR_3_0V_2_9V , OCR_3_1V_3_0V , OCR_3_2V_3_1V ,
  OCR_3_3V_3_2V , OCR_3_4V_3_3V , OCR_3_5V_3_4V , OCR_3_6V_3_5V ,
  OCR_CAPACITY_STATUS = 30 , OCR_PWRUP_STATUS
}
 Bit positions within the 32-bit OCR register. More...
enum  SD_MIN_OPERATING_VOLTAGE_te {
  SD_MIN_OPERATING_VOLTAGE_3_5V , SD_MIN_OPERATING_VOLTAGE_3_4V , SD_MIN_OPERATING_VOLTAGE_3_3V , SD_MIN_OPERATING_VOLTAGE_3_2V ,
  SD_MIN_OPERATING_VOLTAGE_3_1V , SD_MIN_OPERATING_VOLTAGE_3_0V , SD_MIN_OPERATING_VOLTAGE_2_9V , SD_MIN_OPERATING_VOLTAGE_2_8V ,
  SD_MIN_OPERATING_VOLTAGE_2_7V , SD_MIN_OPERATING_VOLTAGE_2_6V , SD_MIN_OPERATING_VOLTAGE_2_5V , SD_MIN_OPERATING_VOLTAGE_2_4V ,
  SD_MIN_OPERATING_VOLTAGE_2_3V , SD_MIN_OPERATING_VOLTAGE_2_2V , SD_MIN_OPERATING_VOLTAGE_2_1V , SD_MIN_OPERATING_VOLTAGE_2_0V ,
  SD_MIN_OPERATING_VOLTAGE_1_9V , SD_MIN_OPERATING_VOLTAGE_1_8V , SD_MIN_OPERATING_VOLTAGE_1_7V , SD_MIN_OPERATING_VOLTAGE_1_6V
}
 Minimum allowed operating voltage of the SD card, decoded from the OCR register. More...
enum  SD_MAX_OPERATIING_VOLTAGE_te {
  SD_MAX_OPERATING_VOLTAGE_3_6V , SD_MAX_OPERATING_VOLTAGE_3_5V , SD_MAX_OPERATING_VOLTAGE_3_4V , SD_MAX_OPERATING_VOLTAGE_3_3V ,
  SD_MAX_OPERATING_VOLTAGE_3_2V , SD_MAX_OPERATING_VOLTAGE_3_1V , SD_MAX_OPERATING_VOLTAGE_3_0V , SD_MAX_OPERATING_VOLTAGE_2_9V ,
  SD_MAX_OPERATING_VOLTAGE_2_8V , SD_MAX_OPERATING_VOLTAGE_2_7V , SD_MAX_OPERATING_VOLTAGE_2_6V , SD_MAX_OPERATING_VOLTAGE_2_5V ,
  SD_MAX_OPERATING_VOLTAGE_2_4V , SD_MAX_OPERATING_VOLTAGE_2_3V , SD_MAX_OPERATING_VOLTAGE_2_2V , SD_MAX_OPERATING_VOLTAGE_2_1V ,
  SD_MAX_OPERATING_VOLTAGE_2_0V , SD_MAX_OPERATING_VOLTAGE_1_9V , SD_MAX_OPERATING_VOLTAGE_1_8V , SD_MAX_OPERATING_VOLTAGE_1_7V
}
 Maximum allowed operating voltage of the SD card, decoded from the OCR register. More...
enum  SD_ADDR_MODE_te { SD_ADDR_MODE_BYTE , SD_ADDR_MODE_BLOCK }
 Addressing mode used by the SD card for read/write sector addresses. More...
enum  SD_PWRUP_STATUS_te { SD_PWRUP_STATUS_BUSY , SD_PWRUP_STATUS_READY }
 Power-up completion status decoded from the OCR register. More...
enum  SD_TYPE_te { SDSC , SDHC }
 Card type decoded from the OCR Capacity Status bit. More...

Functions

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 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_cmd_list_handler (uint32_t argc, char **argv)
 CLI handler for the "list" command. Logs the names of all active SD card handles.
static ERR_te sd_cmd_info_handler (uint32_t argc, char **argv)
 CLI handler for the "info" command. Logs detailed information about a named SD card handle.
ERR_te sd_init_subsys (void)
 Initializes the SD card subsystem.
ERR_te sd_deinit_subsys (void)
 Deinitializes the SD card subsystem.
ERR_te sd_start_subsys (void)
 Starts the SD card subsystem.
ERR_te sd_stop_subsys (void)
 Stops the SD card subsystem.
ERR_te sd_init_handle (SD_CFG_ts *sd_cfg, SD_HANDLE_ts **sd_handle_o)
 Initializes an SD card handle and performs the full SPI-mode power-up sequence.
ERR_te sd_deinit_handle (SD_HANDLE_ts *sd_handle)
 Deinitializes an SD card handle and resets the SPI peripheral.
ERR_te sd_get_handle_init (SD_HANDLE_ts *sd_handle, bool *handle_init_o)
 Retrieves the initialization state of an SD card handle.
ERR_te sd_get_sector_count (SD_HANDLE_ts *sd_handle, uint32_t *sector_count_o)
 Retrieves the total sector (block) count of the SD card.
ERR_te sd_get_sector_size (SD_HANDLE_ts *sd_handle, uint32_t *sector_size_o)
 Retrieves the sector (block) size of the SD card in bytes.
ERR_te sd_read (SD_HANDLE_ts *sd_handle, uint8_t *read_buf, uint32_t start_sector, uint32_t num_sectors)
 Reads one or more sectors from the SD card.
ERR_te sd_write (SD_HANDLE_ts *sd_handle, uint8_t *write_buf, uint32_t start_sector, uint32_t num_sectors)
 Writes one or more sectors to the SD card.

Variables

struct internal_state_s internal_state
 Singleton instance of the SD card subsystem internal state.
CMD_INFO_ts sd_cmds []
 Table of CLI commands registered by the SD card subsystem.
CMD_CLIENT_INFO_ts sd_cmd_client_info
 Registration descriptor passed to the command subsystem.

Detailed Description

SD card driver implementation file.

Author
github.com/Baksi675
Version
0.1
Date
2026-02-05

Definition in file sd.c.

Enumeration Type Documentation

◆ OCR_te

enum OCR_te

Bit positions within the 32-bit OCR register.

Used to extract individual fields from the OCR value reconstructed from the R3 response of CMD58. Voltage range bits 4–23 each represent a 100 mV window; bit 30 is the Card Capacity Status (0 = SDSC, 1 = SDHC); bit 31 is the power-up completion flag.

Enumerator
OCR_1_7V_1_6V 

Voltage window 1.6–1.7 V supported.

OCR_1_8V_1_7V 

Voltage window 1.7–1.8 V supported.

OCR_1_9V_1_8V 

Voltage window 1.8–1.9 V supported.

OCR_2_0V_1_9V 

Voltage window 1.9–2.0 V supported.

OCR_2_1V_2_0V 

Voltage window 2.0–2.1 V supported.

OCR_2_2V_2_1V 

Voltage window 2.1–2.2 V supported.

OCR_2_3V_2_2V 

Voltage window 2.2–2.3 V supported.

OCR_2_4V_2_3V 

Voltage window 2.3–2.4 V supported.

OCR_2_5V_2_4V 

Voltage window 2.4–2.5 V supported.

OCR_2_6V_2_5V 

Voltage window 2.5–2.6 V supported.

OCR_2_7V_2_6V 

Voltage window 2.6–2.7 V supported.

OCR_2_8V_2_7V 

Voltage window 2.7–2.8 V supported.

OCR_2_9V_2_8V 

Voltage window 2.8–2.9 V supported.

OCR_3_0V_2_9V 

Voltage window 2.9–3.0 V supported.

OCR_3_1V_3_0V 

Voltage window 3.0–3.1 V supported.

OCR_3_2V_3_1V 

Voltage window 3.1–3.2 V supported.

OCR_3_3V_3_2V 

Voltage window 3.2–3.3 V supported.

OCR_3_4V_3_3V 

Voltage window 3.3–3.4 V supported.

OCR_3_5V_3_4V 

Voltage window 3.4–3.5 V supported.

OCR_3_6V_3_5V 

Voltage window 3.5–3.6 V supported.

OCR_CAPACITY_STATUS 

Card Capacity Status: 0 = SDSC (byte addressing), 1 = SDHC (block addressing).

OCR_PWRUP_STATUS 

Power-up status: 0 = still powering up, 1 = power-up complete.

Definition at line 54 of file sd.c.

54 {
55 OCR_1_7V_1_6V = 4,
77} OCR_te;
OCR_te
Bit positions within the 32-bit OCR register.
Definition sd.c:54
@ OCR_3_4V_3_3V
Definition sd.c:72
@ OCR_3_0V_2_9V
Definition sd.c:68
@ OCR_2_3V_2_2V
Definition sd.c:61
@ OCR_3_2V_3_1V
Definition sd.c:70
@ OCR_3_1V_3_0V
Definition sd.c:69
@ OCR_1_8V_1_7V
Definition sd.c:56
@ OCR_3_3V_3_2V
Definition sd.c:71
@ OCR_2_0V_1_9V
Definition sd.c:58
@ OCR_2_2V_2_1V
Definition sd.c:60
@ OCR_1_9V_1_8V
Definition sd.c:57
@ OCR_3_6V_3_5V
Definition sd.c:74
@ OCR_PWRUP_STATUS
Definition sd.c:76
@ OCR_2_8V_2_7V
Definition sd.c:66
@ OCR_2_9V_2_8V
Definition sd.c:67
@ OCR_2_1V_2_0V
Definition sd.c:59
@ OCR_2_4V_2_3V
Definition sd.c:62
@ OCR_1_7V_1_6V
Definition sd.c:55
@ OCR_2_5V_2_4V
Definition sd.c:63
@ OCR_CAPACITY_STATUS
Definition sd.c:75
@ OCR_2_6V_2_5V
Definition sd.c:64
@ OCR_3_5V_3_4V
Definition sd.c:73
@ OCR_2_7V_2_6V
Definition sd.c:65

◆ SD_MIN_OPERATING_VOLTAGE_te

Minimum allowed operating voltage of the SD card, decoded from the OCR register.

Enumerator
SD_MIN_OPERATING_VOLTAGE_3_5V 

Minimum operating voltage: 3.5 V.

SD_MIN_OPERATING_VOLTAGE_3_4V 

Minimum operating voltage: 3.4 V.

SD_MIN_OPERATING_VOLTAGE_3_3V 

Minimum operating voltage: 3.3 V.

SD_MIN_OPERATING_VOLTAGE_3_2V 

Minimum operating voltage: 3.2 V.

SD_MIN_OPERATING_VOLTAGE_3_1V 

Minimum operating voltage: 3.1 V.

SD_MIN_OPERATING_VOLTAGE_3_0V 

Minimum operating voltage: 3.0 V.

SD_MIN_OPERATING_VOLTAGE_2_9V 

Minimum operating voltage: 2.9 V.

SD_MIN_OPERATING_VOLTAGE_2_8V 

Minimum operating voltage: 2.8 V.

SD_MIN_OPERATING_VOLTAGE_2_7V 

Minimum operating voltage: 2.7 V.

SD_MIN_OPERATING_VOLTAGE_2_6V 

Minimum operating voltage: 2.6 V.

SD_MIN_OPERATING_VOLTAGE_2_5V 

Minimum operating voltage: 2.5 V.

SD_MIN_OPERATING_VOLTAGE_2_4V 

Minimum operating voltage: 2.4 V.

SD_MIN_OPERATING_VOLTAGE_2_3V 

Minimum operating voltage: 2.3 V.

SD_MIN_OPERATING_VOLTAGE_2_2V 

Minimum operating voltage: 2.2 V.

SD_MIN_OPERATING_VOLTAGE_2_1V 

Minimum operating voltage: 2.1 V.

SD_MIN_OPERATING_VOLTAGE_2_0V 

Minimum operating voltage: 2.0 V.

SD_MIN_OPERATING_VOLTAGE_1_9V 

Minimum operating voltage: 1.9 V.

SD_MIN_OPERATING_VOLTAGE_1_8V 

Minimum operating voltage: 1.8 V.

SD_MIN_OPERATING_VOLTAGE_1_7V 

Minimum operating voltage: 1.7 V.

SD_MIN_OPERATING_VOLTAGE_1_6V 

Minimum operating voltage: 1.6 V.

Definition at line 82 of file sd.c.

82 {
SD_MIN_OPERATING_VOLTAGE_te
Minimum allowed operating voltage of the SD card, decoded from the OCR register.
Definition sd.c:82
@ SD_MIN_OPERATING_VOLTAGE_2_6V
Definition sd.c:92
@ SD_MIN_OPERATING_VOLTAGE_2_2V
Definition sd.c:96
@ SD_MIN_OPERATING_VOLTAGE_1_8V
Definition sd.c:100
@ SD_MIN_OPERATING_VOLTAGE_3_5V
Definition sd.c:83
@ SD_MIN_OPERATING_VOLTAGE_1_7V
Definition sd.c:101
@ SD_MIN_OPERATING_VOLTAGE_3_3V
Definition sd.c:85
@ SD_MIN_OPERATING_VOLTAGE_1_6V
Definition sd.c:102
@ SD_MIN_OPERATING_VOLTAGE_3_2V
Definition sd.c:86
@ SD_MIN_OPERATING_VOLTAGE_2_9V
Definition sd.c:89
@ SD_MIN_OPERATING_VOLTAGE_2_8V
Definition sd.c:90
@ SD_MIN_OPERATING_VOLTAGE_2_3V
Definition sd.c:95
@ SD_MIN_OPERATING_VOLTAGE_2_5V
Definition sd.c:93
@ SD_MIN_OPERATING_VOLTAGE_2_0V
Definition sd.c:98
@ SD_MIN_OPERATING_VOLTAGE_3_1V
Definition sd.c:87
@ SD_MIN_OPERATING_VOLTAGE_3_4V
Definition sd.c:84
@ SD_MIN_OPERATING_VOLTAGE_2_4V
Definition sd.c:94
@ SD_MIN_OPERATING_VOLTAGE_3_0V
Definition sd.c:88
@ SD_MIN_OPERATING_VOLTAGE_2_1V
Definition sd.c:97
@ SD_MIN_OPERATING_VOLTAGE_1_9V
Definition sd.c:99
@ SD_MIN_OPERATING_VOLTAGE_2_7V
Definition sd.c:91

◆ SD_MAX_OPERATIING_VOLTAGE_te

Maximum allowed operating voltage of the SD card, decoded from the OCR register.

Enumerator
SD_MAX_OPERATING_VOLTAGE_3_6V 

Maximum operating voltage: 3.6 V.

SD_MAX_OPERATING_VOLTAGE_3_5V 

Maximum operating voltage: 3.5 V.

SD_MAX_OPERATING_VOLTAGE_3_4V 

Maximum operating voltage: 3.4 V.

SD_MAX_OPERATING_VOLTAGE_3_3V 

Maximum operating voltage: 3.3 V.

SD_MAX_OPERATING_VOLTAGE_3_2V 

Maximum operating voltage: 3.2 V.

SD_MAX_OPERATING_VOLTAGE_3_1V 

Maximum operating voltage: 3.1 V.

SD_MAX_OPERATING_VOLTAGE_3_0V 

Maximum operating voltage: 3.0 V.

SD_MAX_OPERATING_VOLTAGE_2_9V 

Maximum operating voltage: 2.9 V.

SD_MAX_OPERATING_VOLTAGE_2_8V 

Maximum operating voltage: 2.8 V.

SD_MAX_OPERATING_VOLTAGE_2_7V 

Maximum operating voltage: 2.7 V.

SD_MAX_OPERATING_VOLTAGE_2_6V 

Maximum operating voltage: 2.6 V.

SD_MAX_OPERATING_VOLTAGE_2_5V 

Maximum operating voltage: 2.5 V.

SD_MAX_OPERATING_VOLTAGE_2_4V 

Maximum operating voltage: 2.4 V.

SD_MAX_OPERATING_VOLTAGE_2_3V 

Maximum operating voltage: 2.3 V.

SD_MAX_OPERATING_VOLTAGE_2_2V 

Maximum operating voltage: 2.2 V.

SD_MAX_OPERATING_VOLTAGE_2_1V 

Maximum operating voltage: 2.1 V.

SD_MAX_OPERATING_VOLTAGE_2_0V 

Maximum operating voltage: 2.0 V.

SD_MAX_OPERATING_VOLTAGE_1_9V 

Maximum operating voltage: 1.9 V.

SD_MAX_OPERATING_VOLTAGE_1_8V 

Maximum operating voltage: 1.8 V.

SD_MAX_OPERATING_VOLTAGE_1_7V 

Maximum operating voltage: 1.7 V.

Definition at line 108 of file sd.c.

108 {
SD_MAX_OPERATIING_VOLTAGE_te
Maximum allowed operating voltage of the SD card, decoded from the OCR register.
Definition sd.c:108
@ SD_MAX_OPERATING_VOLTAGE_1_9V
Definition sd.c:126
@ SD_MAX_OPERATING_VOLTAGE_2_2V
Definition sd.c:123
@ SD_MAX_OPERATING_VOLTAGE_2_8V
Definition sd.c:117
@ SD_MAX_OPERATING_VOLTAGE_1_8V
Definition sd.c:127
@ SD_MAX_OPERATING_VOLTAGE_3_2V
Definition sd.c:113
@ SD_MAX_OPERATING_VOLTAGE_2_3V
Definition sd.c:122
@ SD_MAX_OPERATING_VOLTAGE_2_4V
Definition sd.c:121
@ SD_MAX_OPERATING_VOLTAGE_3_3V
Definition sd.c:112
@ SD_MAX_OPERATING_VOLTAGE_1_7V
Definition sd.c:128
@ SD_MAX_OPERATING_VOLTAGE_3_5V
Definition sd.c:110
@ SD_MAX_OPERATING_VOLTAGE_3_4V
Definition sd.c:111
@ SD_MAX_OPERATING_VOLTAGE_2_1V
Definition sd.c:124
@ SD_MAX_OPERATING_VOLTAGE_2_6V
Definition sd.c:119
@ SD_MAX_OPERATING_VOLTAGE_3_6V
Definition sd.c:109
@ SD_MAX_OPERATING_VOLTAGE_2_7V
Definition sd.c:118
@ SD_MAX_OPERATING_VOLTAGE_2_0V
Definition sd.c:125
@ SD_MAX_OPERATING_VOLTAGE_2_9V
Definition sd.c:116
@ SD_MAX_OPERATING_VOLTAGE_2_5V
Definition sd.c:120
@ SD_MAX_OPERATING_VOLTAGE_3_0V
Definition sd.c:115
@ SD_MAX_OPERATING_VOLTAGE_3_1V
Definition sd.c:114

◆ SD_ADDR_MODE_te

Addressing mode used by the SD card for read/write sector addresses.

Enumerator
SD_ADDR_MODE_BYTE 

Byte addressing (SDSC cards). Address = sector × block length.

SD_ADDR_MODE_BLOCK 

Block addressing (SDHC/SDXC cards). Address = sector number directly.

Definition at line 134 of file sd.c.

134 {
SD_ADDR_MODE_te
Addressing mode used by the SD card for read/write sector addresses.
Definition sd.c:134
@ SD_ADDR_MODE_BYTE
Definition sd.c:135
@ SD_ADDR_MODE_BLOCK
Definition sd.c:136

◆ SD_PWRUP_STATUS_te

Power-up completion status decoded from the OCR register.

Enumerator
SD_PWRUP_STATUS_BUSY 

Card is still completing its power-up sequence.

SD_PWRUP_STATUS_READY 

Card has completed power-up and is ready for commands.

Definition at line 142 of file sd.c.

142 {
SD_PWRUP_STATUS_te
Power-up completion status decoded from the OCR register.
Definition sd.c:142
@ SD_PWRUP_STATUS_BUSY
Definition sd.c:143
@ SD_PWRUP_STATUS_READY
Definition sd.c:144

◆ SD_TYPE_te

enum SD_TYPE_te

Card type decoded from the OCR Capacity Status bit.

Enumerator
SDSC 

Standard Capacity SD card (byte addressing, ≤ 2 GB).

SDHC 

High Capacity SD card (block addressing, > 2 GB).

Definition at line 150 of file sd.c.

150 {
151 SDSC,
152 SDHC
153} SD_TYPE_te;
SD_TYPE_te
Card type decoded from the OCR Capacity Status bit.
Definition sd.c:150
@ SDSC
Definition sd.c:151
@ SDHC
Definition sd.c:152

Variable Documentation

◆ internal_state

struct internal_state_s internal_state

Singleton instance of the SD card subsystem internal state.

Definition at line 266 of file sd.c.

◆ sd_cmds

CMD_INFO_ts sd_cmds[]
Initial value:
= {
{
.name = "list",
.help = "Lists active sd objects, usage: sd list",
},
{
.name = "info",
.help = "Shows sd object info, usage: sd info <sd object>",
}
}
static ERR_te sd_cmd_info_handler(uint32_t argc, char **argv)
CLI handler for the "info" command. Logs detailed information about a named SD card handle.
Definition sd.c:1803
static ERR_te sd_cmd_list_handler(uint32_t argc, char **argv)
CLI handler for the "list" command. Logs the names of all active SD card handles.
Definition sd.c:1761

Table of CLI commands registered by the SD card subsystem.

Registered with the command subsystem via sd_cmd_client_info during sd_init_subsys.

Definition at line 292 of file sd.c.

292 {
293 {
294 .name = "list",
295 .help = "Lists active sd objects, usage: sd list",
296 .handler = sd_cmd_list_handler
297 },
298 {
299 .name = "info",
300 .help = "Shows sd object info, usage: sd info <sd object>",
301 .handler = sd_cmd_info_handler
302 }
303};

◆ sd_cmd_client_info

CMD_CLIENT_INFO_ts sd_cmd_client_info
Initial value:
= {
.cmds_ptr = sd_cmds,
.num_cmds = sizeof(sd_cmds) / sizeof(sd_cmds[0]),
.log_level_ptr = &internal_state.log_level,
.name = "sd"
}
static struct internal_state_s internal_state
Singleton instance of the SysTick driver internal state.
CMD_INFO_ts sd_cmds[]
Table of CLI commands registered by the SD card subsystem.
Definition sd.c:292

Registration descriptor passed to the command subsystem.

Bundles the command table, its size, the subsystem name prefix used on the CLI, and a pointer to the runtime log-level variable.

Definition at line 312 of file sd.c.

312 {
313 .cmds_ptr = sd_cmds,
314 .num_cmds = sizeof(sd_cmds) / sizeof(sd_cmds[0]),
315 .log_level_ptr = &internal_state.log_level,
316 .name = "sd"
317};