PowerBlocks SDK
 
Loading...
Searching...
No Matches
sdio.h File Reference

IOS SDIO Interface. More...

#include <stdint.h>
#include <stddef.h>

Go to the source code of this file.

Macros

#define SDIO_DEVICE_STATUS_CARD_INSERTED   (1<<0)
 
#define SDIO_DEVICE_STATUS_NOT_INSERTED   (1<<1)
 
#define SDIO_DEVICE_STATUS_WRITE_PROTECT_SWITCH   (1<<2)
 
#define SDIO_DEVICE_STATUS_SD_INITIALIZED   (1<<16)
 
#define SDIO_DEVICE_STATUS_IS_SDHC   (1<<20)
 

Enumerations

enum  sdio_cmd_t {
  SD_CMD0_GO_IDLE_STATE = 0 , SD_CMD2_ALL_SEND_CID = 2 , SD_CMD3_SEND_RELATIVE_ADDR = 3 , SD_CMD7_SELECT_CARD = 7 ,
  SD_CMD8_SEND_IF_COND = 8 , SD_CMD9_SEND_CSD = 9 , SD_CMD12_STOP_TRANSMISSION = 12 , SD_CMD16_SET_BLOCKLEN = 16 ,
  SD_CMD17_READ_SINGLE_BLOCK = 17 , SD_CMD18_READ_MULTIPLE_BLOCK = 18 , SD_CMD24_WRITE_BLOCK = 24 , SD_CMD25_WRITE_MULTIPLE_BLOCK = 25 ,
  SD_CMD55_APP_CMD = 55 , SD_CMD56_GEN_CMD = 56 , SDIO_CMD5_IO_SEND_OP_COND = 5 , SDIO_CMD52_IO_RW_DIRECT = 52 ,
  SDIO_CMD53_IO_RW_EXTENDED = 53 , SDIO_ACMD6_SET_BUS_WIDTH = 6
}
 Standard SD Commands. More...
 
enum  sdio_cmdtype_t { SD_CMDTYPE_BC = 1 , SD_CMDTYPE_BCR = 2 , SD_CMDTYPE_AC = 3 , SD_CMDTYPE_ADTC = 4 }
 Standard SD Command Types.
 
enum  sdio_resptype_t {
  SD_RESP_NONE = 0 , SD_RESP_R1 , SD_RESP_R1b , SD_RESP_R2 ,
  SD_RESP_R3 , SD_RESP_R4 , SD_RESP_R5 , SD_RESP_R6 ,
  SD_RESP_R7
}
 Standard SD Response Types.
 

Functions

int sdio_initialize (const char *device)
 Opens the SDIO interface.
 
void sdio_close ()
 =Closes the driver.
 
int sdio_get_device_status (uint32_t *state)
 Returns the status of the SD card slot.
 
int sdio_reset_device (uint32_t *response)
 Resets the SDIO device, and returns RCA.
 
int sdio_set_clock (uint32_t divider)
 Sets the clock source for the SD card.
 
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 operating conditions.
 
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 arbitrary register of it using this.
 
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 arbitrary register of it using this.
 
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.
 

Detailed Description

IOS SDIO Interface.

The SD card slot on the wii goes to a SDIO interface accessible through IOS.

This driver is to interface with it.

Author
Samuel Fitzsimons (rainbain)
Date
2025 @license MIT (see LICENSE file)

Enumeration Type Documentation

◆ sdio_cmd_t

enum sdio_cmd_t

Standard SD Commands.

This list contains the standard SD commands + SDIO specific commands. This list does not contain all of them, just the common ones.

Function Documentation

◆ sdio_close()

void sdio_close ( )
extern

=Closes the driver.

Closes the driver and assisted IOS file handle.

◆ sdio_get_device_status()

int sdio_get_device_status ( uint32_t * state)
extern

Returns the status of the SD card slot.

Parameters
stateOutputted uint32_t state bitfield
Returns
Negative if error.

◆ sdio_initialize()

int sdio_initialize ( const char * device)
extern

Opens the SDIO interface.

Opens the SDIO interface on the wii.

Parameters
deviceSDIO device file to open, usually /dev/sdio/slot0 (front SD)
Returns
Negative if Error

◆ sdio_read_hc_register()

int sdio_read_hc_register ( uint32_t offset,
uint32_t * value )
extern

Reads a host controller register. The wii uses a standard SDIO host controller. You may read an arbitrary register of it using this.

Parameters
offsetRegister offset.
valueOutputted register value
Returns
Negative if error.

◆ sdio_read_oc_register()

int sdio_read_oc_register ( uint32_t * oc)
extern

Reads the OC register Reads the value of the SD cards OC register. This contains a bit feild of operating conditions.

Parameters
ocOutputted 32 bit bit feild
Returns
Negative if error.

◆ sdio_reset_device()

int sdio_reset_device ( uint32_t * response)
extern

Resets the SDIO device, and returns RCA.

Parameters
responseFirst 16 bits are the RCA, next 16 bits are stuff bits. Following the SDIO CMD3.
Returns
Negative if error

◆ sdio_send_cmd()

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 )
extern

Sends a SD card command. Sends a command and returns a 16 byte response.

Parameters
cmdWhat command for the card to carry out.
cmd_typeWhat is contained within the command, what to do.
resp_typeHow to interpret the cards response?
argArgument specific to the command.
dataFor commands with associated data, or NULL
block_countHow many blocks in the data
sector_sizeSize of a block in
responsePointer to put the SD response in
response_lengthLength of the response

◆ sdio_set_clock()

int sdio_set_clock ( uint32_t divider)
extern

Sets the clock source for the SD card.

Parameters
dividerPower of two, or zero, usually one.
Returns
Negative if error

◆ sdio_set_hc_register()

int sdio_set_hc_register ( uint32_t offset,
uint32_t value )
extern

Sets a host controller register. The wii uses a standard SDIO host controller. You may set an arbitrary register of it using this.

Parameters
offsetRegister offset.
valueOutputted register value
Returns
Negative if error.