Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
sdio.h File Reference

Public API for SDIO subsystem. More...

#include <zephyr/device.h>
#include <zephyr/drivers/sdhc.h>
#include <zephyr/sd/sd.h>

Go to the source code of this file.

Functions

int sdio_init_func (struct sd_card *card, struct sdio_func *func, enum sdio_func_num num)
 Initialize SDIO function.
 
int sdio_enable_func (struct sdio_func *func)
 Enable SDIO function.
 
int sdio_set_block_size (struct sdio_func *func, uint16_t bsize)
 Set block size of SDIO function.
 
int sdio_read_byte (struct sdio_func *func, uint32_t reg, uint8_t *val)
 Read byte from SDIO register.
 
int sdio_write_byte (struct sdio_func *func, uint32_t reg, uint8_t write_val)
 Write byte to SDIO register.
 
int sdio_rw_byte (struct sdio_func *func, uint32_t reg, uint8_t write_val, uint8_t *read_val)
 Write byte to SDIO register, and read result.
 
int sdio_read_fifo (struct sdio_func *func, uint32_t reg, uint8_t *data, uint32_t len)
 Read bytes from SDIO fifo.
 
int sdio_write_fifo (struct sdio_func *func, uint32_t reg, uint8_t *data, uint32_t len)
 Write bytes to SDIO fifo.
 
int sdio_read_blocks_fifo (struct sdio_func *func, uint32_t reg, uint8_t *data, uint32_t blocks)
 Read blocks from SDIO fifo.
 
int sdio_write_blocks_fifo (struct sdio_func *func, uint32_t reg, uint8_t *data, uint32_t blocks)
 Write blocks to SDIO fifo.
 
int sdio_read_addr (struct sdio_func *func, uint32_t reg, uint8_t *data, uint32_t len)
 Copy bytes from an SDIO card.
 
int sdio_write_addr (struct sdio_func *func, uint32_t reg, uint8_t *data, uint32_t len)
 Copy bytes to an SDIO card.
 

Detailed Description

Public API for SDIO subsystem.

Function Documentation

◆ sdio_enable_func()

int sdio_enable_func ( struct sdio_func * func)

Enable SDIO function.

Enables SDIO card function. sdio_init_func must be called to initialized the function structure before enabling it in the card.

Parameters
funcfunction to enable
Return values
0function was enabled successfully
-ETIMEDOUTcard I/O timed out
-EIOI/O error

◆ sdio_init_func()

int sdio_init_func ( struct sd_card * card,
struct sdio_func * func,
enum sdio_func_num num )

Initialize SDIO function.

Initializes SDIO card function. The card function will not be enabled, but after this call returns the SDIO function structure can be used to read and write data from the card.

Parameters
funcfunction structure to initialize
cardSD card to enable function on
numfunction number to initialize
Return values
0function was initialized successfully
-EIOI/O error

◆ sdio_read_addr()

int sdio_read_addr ( struct sdio_func * func,
uint32_t reg,
uint8_t * data,
uint32_t len )

Copy bytes from an SDIO card.

Copies bytes from an SDIO card, starting from provided address.

Parameters
funcfunction to read from
regregister address to start copy at
databuffer to copy data into
lenlength of data to read
Return values
0read succeeded
-EBUSYcard is busy with another request
-ETIMEDOUTcard read timed out
-EIOI/O error

◆ sdio_read_blocks_fifo()

int sdio_read_blocks_fifo ( struct sdio_func * func,
uint32_t reg,
uint8_t * data,
uint32_t blocks )

Read blocks from SDIO fifo.

Reads blocks from SDIO register, treating it as a fifo. Reads will all be done from same address.

Parameters
funcfunction to read from
regregister address of fifo
datafilled with data read from fifo
blocksnumber of blocks to read from fifo
Return values
0read succeeded
-EBUSYcard is busy with another request
-ETIMEDOUTcard read timed out
-EIOI/O error

◆ sdio_read_byte()

int sdio_read_byte ( struct sdio_func * func,
uint32_t reg,
uint8_t * val )

Read byte from SDIO register.

Reads byte from SDIO register

Parameters
funcfunction to read from
regregister address to read from
valfilled with byte value read from register
Return values
0read succeeded
-EBUSYcard is busy with another request
-ETIMEDOUTcard read timed out
-EIOI/O error

◆ sdio_read_fifo()

int sdio_read_fifo ( struct sdio_func * func,
uint32_t reg,
uint8_t * data,
uint32_t len )

Read bytes from SDIO fifo.

Reads bytes from SDIO register, treating it as a fifo. Reads will all be done from same address.

Parameters
funcfunction to read from
regregister address of fifo
datafilled with data read from fifo
lenlength of data to read from card
Return values
0read succeeded
-EBUSYcard is busy with another request
-ETIMEDOUTcard read timed out
-EIOI/O error

◆ sdio_rw_byte()

int sdio_rw_byte ( struct sdio_func * func,
uint32_t reg,
uint8_t write_val,
uint8_t * read_val )

Write byte to SDIO register, and read result.

Writes byte to SDIO register, and reads the register after write

Parameters
funcfunction to write to
regregister address to write to
write_valvalue to write to register
read_valfilled with value read from register
Return values
0write succeeded
-EBUSYcard is busy with another request
-ETIMEDOUTcard write timed out
-EIOI/O error

◆ sdio_set_block_size()

int sdio_set_block_size ( struct sdio_func * func,
uint16_t bsize )

Set block size of SDIO function.

Set desired block size for SDIO function, used by block transfers to SDIO registers.

Parameters
funcfunction to set block size for
bsizeblock size
Return values
0block size was set
-EINVALunsupported/invalid block size
-EIOI/O error

◆ sdio_write_addr()

int sdio_write_addr ( struct sdio_func * func,
uint32_t reg,
uint8_t * data,
uint32_t len )

Copy bytes to an SDIO card.

Copies bytes to an SDIO card, starting from provided address.

Parameters
funcfunction to write to
regregister address to start copy at
databuffer to copy data from
lenlength of data to write
Return values
0write succeeded
-EBUSYcard is busy with another request
-ETIMEDOUTcard write timed out
-EIOI/O error

◆ sdio_write_blocks_fifo()

int sdio_write_blocks_fifo ( struct sdio_func * func,
uint32_t reg,
uint8_t * data,
uint32_t blocks )

Write blocks to SDIO fifo.

Writes blocks from SDIO register, treating it as a fifo. Writes will all be done to same address.

Parameters
funcfunction to write to
regregister address of fifo
datadata to write to fifo
blocksnumber of blocks to write to fifo
Return values
0write succeeded
-EBUSYcard is busy with another request
-ETIMEDOUTcard write timed out
-EIOI/O error

◆ sdio_write_byte()

int sdio_write_byte ( struct sdio_func * func,
uint32_t reg,
uint8_t write_val )

Write byte to SDIO register.

Writes byte to SDIO register

Parameters
funcfunction to write to
regregister address to write to
write_valvalue to write to register
Return values
0write succeeded
-EBUSYcard is busy with another request
-ETIMEDOUTcard write timed out
-EIOI/O error

◆ sdio_write_fifo()

int sdio_write_fifo ( struct sdio_func * func,
uint32_t reg,
uint8_t * data,
uint32_t len )

Write bytes to SDIO fifo.

Writes bytes to SDIO register, treating it as a fifo. Writes will all be done to same address.

Parameters
funcfunction to write to
regregister address of fifo
datadata to write to fifo
lenlength of data to write to card
Return values
0write succeeded
-EBUSYcard is busy with another request
-ETIMEDOUTcard write timed out
-EIOI/O error