PowerBlocks SDK
 
Loading...
Searching...
No Matches
sdio.h
Go to the documentation of this file.
1
14
15#pragma once
16
17#include <stdint.h>
18#include <stddef.h>
19
20// Implementation based on https://wiibrew.org/wiki//dev/sdio.
21
28typedef enum {
29 SD_CMD0_GO_IDLE_STATE = 0,
30 SD_CMD2_ALL_SEND_CID = 2,
31 SD_CMD3_SEND_RELATIVE_ADDR = 3,
32 SD_CMD7_SELECT_CARD = 7,
33 SD_CMD8_SEND_IF_COND = 8,
34 SD_CMD9_SEND_CSD = 9,
35 SD_CMD12_STOP_TRANSMISSION = 12,
36 SD_CMD16_SET_BLOCKLEN = 16,
37 SD_CMD17_READ_SINGLE_BLOCK = 17,
38 SD_CMD18_READ_MULTIPLE_BLOCK = 18,
39 SD_CMD24_WRITE_BLOCK = 24,
40 SD_CMD25_WRITE_MULTIPLE_BLOCK = 25,
41 SD_CMD55_APP_CMD = 55,
42 SD_CMD56_GEN_CMD = 56,
43
44 SDIO_CMD5_IO_SEND_OP_COND = 5,
45 SDIO_CMD52_IO_RW_DIRECT = 52,
46 SDIO_CMD53_IO_RW_EXTENDED = 53,
47
48 SDIO_ACMD6_SET_BUS_WIDTH = 6
50
54typedef enum {
55 SD_CMDTYPE_BC = 1, // Broadcast
56 SD_CMDTYPE_BCR = 2, // Broadcast with response
57 SD_CMDTYPE_AC = 3, // Addressed, no data
58 SD_CMDTYPE_ADTC = 4 // Addressed, data transfer
60
64typedef enum {
65 SD_RESP_NONE = 0, // No response
66 SD_RESP_R1, // Normal command response
67 SD_RESP_R1b, // With busy signal
68 SD_RESP_R2, // CID/CSD response
69 SD_RESP_R3, // OCR response
70 SD_RESP_R4, // IO_SEND_OP_COND response
71 SD_RESP_R5, // IO_RW_DIRECT response
72 SD_RESP_R6, // Published RCA response
73 SD_RESP_R7 // Interface condition
75
76#define SDIO_DEVICE_STATUS_CARD_INSERTED (1<<0)
77#define SDIO_DEVICE_STATUS_NOT_INSERTED (1<<1)
78#define SDIO_DEVICE_STATUS_WRITE_PROTECT_SWITCH (1<<2)
79#define SDIO_DEVICE_STATUS_SD_INITIALIZED (1<<16)
80#define SDIO_DEVICE_STATUS_IS_SDHC (1<<20)
81
91extern int sdio_initialize(const char* device);
92
98extern void sdio_close();
99
106extern int sdio_get_device_status(uint32_t *state);
107
114extern int sdio_reset_device(uint32_t* response);
115
122extern int sdio_set_clock(uint32_t divider);
123
132extern int sdio_read_oc_register(uint32_t* oc);
133
143extern int sdio_read_hc_register(uint32_t offset, uint32_t* value);
144
145
155extern int sdio_set_hc_register(uint32_t offset, uint32_t value);
156
171extern int sdio_send_cmd(sdio_cmd_t cmd, sdio_cmdtype_t type, sdio_resptype_t resptype, uint32_t arg, void* data, uint32_t block_count, uint32_t sector_size, void* response, size_t response_length);
int sdio_get_device_status(uint32_t *state)
Returns the status of the SD card slot.
Definition sdio.c:97
void sdio_close()
=Closes the driver.
Definition sdio.c:85
int sdio_send_cmd(sdio_cmd_t cmd, sdio_cmdtype_t type, sdio_resptype_t resptype, uint32_t arg, void *data, uint32_t block_count, uint32_t sector_size, void *response, size_t response_length)
Sends a SD card command. Sends a command and returns a 16 byte response.
Definition sdio.c:173
int sdio_reset_device(uint32_t *response)
Resets the SDIO device, and returns RCA.
Definition sdio.c:107
int sdio_read_oc_register(uint32_t *oc)
Reads the OC register Reads the value of the SD cards OC register. This contains a bit feild of opera...
Definition sdio.c:127
sdio_cmdtype_t
Standard SD Command Types.
Definition sdio.h:54
sdio_resptype_t
Standard SD Response Types.
Definition sdio.h:64
int sdio_set_hc_register(uint32_t offset, uint32_t value)
Sets a host controller register. The wii uses a standard SDIO host controller. You may set an arbitra...
Definition sdio.c:154
int sdio_initialize(const char *device)
Opens the SDIO interface.
Definition sdio.c:70
int sdio_set_clock(uint32_t divider)
Sets the clock source for the SD card.
Definition sdio.c:117
sdio_cmd_t
Standard SD Commands.
Definition sdio.h:28
int sdio_read_hc_register(uint32_t offset, uint32_t *value)
Reads a host controller register. The wii uses a standard SDIO host controller. You may read an arbit...
Definition sdio.c:137