Common IO - basic v1.0.0
Common IO - basic v1.0.0 Library
 
Loading...
Searching...
No Matches
SDIO HAL APIs

Data Structures

struct  IotSdioCardDetectParam_t
 input parameter type for eSDIOSetCardDetectParams ioctl request More...
 
struct  IoTSdioPowerOnOffCard_t
 input parameter type for eSDIOPowerOnOffCard ioctl request More...
 
struct  IotSdioFuncBlkSize_t
 input parameter type for eSDIOSetFuncBlockSize ioctl request More...
 
struct  IotSdioPerFuncEnable_t
 input parameter type for eSDIOEnableIOFunctionIrq ioctl request and for eSDIOEnableIo ioctl request More...
 
struct  IotSdioReadCis_t
 input parameter type for eSDIOReadCis ioctl request More...
 

Macros

#define IOT_SDIO_SUCCESS   ( 0 )
 The return codes for the functions in SDIO.
 
#define IOT_SDIO_IOCTL_FAIL   ( 1 )
 
#define IOT_SDIO_HOST_INIT_FAIL   ( 2 )
 
#define IOT_SDIO_INVALID_VALUE   ( 3 )
 
#define IOT_SDIO_TRANSFER_FAIL   ( 4 )
 
#define IOT_SDIO_SWITCH_HIGH_SPEED_FAIL   ( 5 )
 
#define IOT_SDIO_LOW_SPEED_CARD   ( 6 )
 
#define IOT_SDIO_SELECT_BUS_TIMING_FAIL   ( 7 )
 
#define IOT_SDIO_SET_CARD_BLOCK_SIZE_FAIL   ( 8 )
 
#define IOT_SDIO_SWITCH_VOLTAGE_FAIL   ( 9 )
 
#define IOT_SDIO_HOST_NOT_READY   ( 10 )
 
#define IOT_SDIO_INVALID_CARD   ( 11 )
 
#define IOT_SDIO_SEND_RELATIVE_ADDRESS_FAIL   ( 12 )
 
#define IOT_SDIO_SELECT_CARD_FAIL   ( 13 )
 
#define IOT_SDIO_READ_CIS_FAIL   ( 14 )
 
#define IOT_SDIO_SET_DATA_BUS_WIDTH_FAIL   ( 15 )
 
#define IOT_SDIO_ASYNC_INT_NOT_SUPPORTED   ( 16 )
 
#define IOT_SDIO_GET_CARD_CAPABILITY_FAIL   ( 17 )
 
#define IOT_SDIO_FUNCTION_NOT_SUPPORTED   ( 18 )
 
#define IOT_SDIO_BUS_1BIT   ( 0 )
 sdio io bus width
 
#define IOT_SDIO_BUS_4BIT   ( 2 )
 
#define IOT_SDIO_BUS_8BIT   ( 3 )
 

Typedefs

typedef struct IotSdioSlotDescriptor * IotSdioSlotHandle_t
 IotSdioSlotHandle_t type is the SDIO slot handle returned by calling iot_sdio_open()
 
typedef void(* IotSdioCallback_t) (IotSdioSlotHandle_t const pxSdioHandle, IotSdioEventType_t eSdioEvent, void *pvUserContext)
 The callback function for sdio event operation. This callback is passed to driver by using iot_sdio_set_callback API. It's called when one of the events (IotSdioEventType_t) happens.
 
typedef void(* IotSdioIOFunctionCallback_t) (IotSdioSlotHandle_t const pxSdioHandle, IotSdioFunction_t eFunc, void *pvUserContext)
 SDIO I/O function callback type. User can call iot_sdio_set_io_function_callback() API to set one IOFunctionCallback per each standard SDIO function supported on a sdio card.
 

Enumerations

enum  IotSdioDirection_t { eIORead = 0U , eIOWrite = 1U }
 sdio io read/write direction More...
 
enum  IotSdioFunction_t {
  eSdioFunction0 , eSdioFunction1 , eSdioFunction2 , eSdioFunction3 ,
  eSdioFunction4 , eSdioFunction5 , eSdioFunction6 , eSdioFunction7 ,
  eSdioFunctionMemory
}
 SDIO I/O function number type Each SDIO card can support up to 7 I/O functions. Each I/O function can implement one of the following: More...
 
enum  IotSdioCardDetectType_t { eDetectCardByGpioCD , eDetectCardByHostCD , eDetectCardByHostDATA3 , eDetectCardNonStandard }
 card detect type More...
 
enum  IotSdioEventType_t {
  eSdioCardInterruptEvent , eSdioCardInsertedEvent , eSdioCardRemovedEvent , eSdioCardPowerOnEvent ,
  eSdioCardPowerOffEvent
}
 common notify event types in sdio callback More...
 
enum  IotSdioIoctlRequest_t {
  eSDIOSetDriverStrength , eSDIOSetCardInactive , eSDIOSwitchToHighSpeed , eSDIOSetDataBusWidth ,
  eSDIOGetCardCapabilities , eSDIOSetCardDetectParams , eSDIOSetFuncBlockSize , eSDIOEnableIOFunctionIrq ,
  eSDIOEnableAsyncIrqMode , eSDIOEnableIo , eSDIOSelectIo , eSDIOAbortIo ,
  eSDIOReadCis , eSDIOPowerOnOffCard , eSDIOCheckCardPresence
}
 IOCTL request types. More...
 
enum  IotSdioBusWidth_t { eDataBus1Bit = IOT_SDIO_BUS_1BIT , eDataBus4Bit = IOT_SDIO_BUS_4BIT , eDataBus8Bit = IOT_SDIO_BUS_8BIT }
 sdio bus width, input parameter type for eSDIOSetDataBusWidth ioctl request More...
 
enum  IotSdioSdDriverStrength_t { eSdDriverStrengthTypeB = 0U , eSdDriverStrengthTypeA = 1U , eSdDriverStrengthTypeC = 2U , eSdDriverStrengthTypeD = 3U }
 SDIO card driver strength, input parameter type for eSDIOSetDriverStrength ioctl request. More...
 

Functions

IotSdioSlotHandle_t iot_sdio_open (uint8_t ucHostIdx, uint8_t ucSlotIdx)
 iot_sdio_open() is used to open a handle to a sdio card slot.
 
int32_t iot_sdio_close (IotSdioSlotHandle_t const pxSdioHandle)
 iot_sdio_close() is used to close the sdio card slot handle. IO operation initiated through this handle before will not be aborted. Caller should call iot_sdio_abort_io() to abort IO operation.
 
int32_t iot_sdio_card_connect (IotSdioSlotHandle_t const pxSdioHandle)
 iot_sdio_card_connect() is used to connect SDIO card.
 
int32_t iot_sdio_card_disconnect (IotSdioSlotHandle_t const pxSdioHandle)
 iot_sdio_card_disconnect() is used to disconnect SDIO card.
 
int32_t iot_sdio_card_reset (IotSdioSlotHandle_t const pxSdioHandle)
 iot_sdio_card_reset() is used to reset the sdio card in the target slot. This API should soft reset all I/O functions in sdio card.
 
int32_t iot_sdio_io_write_direct (IotSdioSlotHandle_t const pxSdioHandle, IotSdioFunction_t eFunc, uint32_t ulRegAddr, uint8_t *pucData, bool bRaw)
 iot_sdio_io_write_direct() implements the write portion of CMD52. It is used to write 1 byte to a single register within the register space of a card I/O function.
 
int32_t iot_sdio_io_read_direct (IotSdioSlotHandle_t const pxSdioHandle, IotSdioFunction_t eFunc, uint32_t ulRegAddr, uint8_t *pucData)
 iot_sdio_io_read_direct() implements the read portion of CMD52. It is used to read 1 byte from a single register within the register space of a card I/O function.
 
int32_t iot_sdio_io_write_extended (IotSdioSlotHandle_t const pxSdioHandle, IotSdioFunction_t eFunc, bool bBlockMode, bool bOpcode, uint32_t ulRegAddr, uint8_t *pucBuf, uint32_t ulCount)
 iot_sdio_io_write_extended() implements the write portion of CMD53. It is used to write multiple bytes or blocks to a single address or incremental addresses within the register space in a I/O function. It provides highest transfer rate possible.
 
int32_t iot_sdio_io_read_extended (IotSdioSlotHandle_t const pxSdioHandle, IotSdioFunction_t eFunc, bool bBlockMode, bool bOpcode, uint32_t ulRegAddr, uint8_t *pucBuf, uint32_t ulCount)
 iot_sdio_io_read_extended() implements the read portion of CMD53. It is used to read multiple bytes or blocks from a single address or incremental addresses within the register space in a I/O function. It provides highest transfer rate possible.
 
int32_t iot_sdio_set_io_function_callback (IotSdioSlotHandle_t const pxSdioHandle, IotSdioFunction_t eFunc, IotSdioIOFunctionCallback_t xIOFunctionCallback, void *pvIOFunctionCallbackUserContext)
 iot_sdio_set_io_function_callback() is used to set IOFunctionCallback for each I/O function the card supports.
 
int32_t iot_sdio_set_sdio_callback (IotSdioSlotHandle_t const pxSdioHandle, IotSdioCallback_t xSdioCallback, void *pvSdioCallbackUserContext)
 iot_sdio_set_sdio_callback() is used to set sdio card interrupt callback.
 
int32_t iot_sdio_ioctl (IotSdioSlotHandle_t const pxSdioHandle, IotSdioIoctlRequest_t xSdioIoctlRequest, void *const pvBuffer)
 iot_sdio_ioctl() is Used for various sdio control function.
 

Detailed Description

Macro Definition Documentation

◆ IOT_SDIO_SUCCESS

#define IOT_SDIO_SUCCESS   ( 0 )

The return codes for the functions in SDIO.

SDIO operation completed successfully.

◆ IOT_SDIO_IOCTL_FAIL

#define IOT_SDIO_IOCTL_FAIL   ( 1 )

SDIO ioctl failed.

◆ IOT_SDIO_HOST_INIT_FAIL

#define IOT_SDIO_HOST_INIT_FAIL   ( 2 )

SDIO host controller initialization failed.

◆ IOT_SDIO_INVALID_VALUE

#define IOT_SDIO_INVALID_VALUE   ( 3 )

At least one parameter is invalid.

◆ IOT_SDIO_TRANSFER_FAIL

#define IOT_SDIO_TRANSFER_FAIL   ( 4 )

Sending command to or receive response from card failed.

◆ IOT_SDIO_SWITCH_HIGH_SPEED_FAIL

#define IOT_SDIO_SWITCH_HIGH_SPEED_FAIL   ( 5 )

If the card is initialized in 3.3V signaling, and card support high speed mode (SHS ==1), host can issue CMD52 in RAW mode, setting EHS bit in CCCR to one to switch to high speed mode. This error code indicates that the sdio card supports high speed mode but failed to switch to high speed mode. The bus clock rate remains unchanged in this case.

◆ IOT_SDIO_LOW_SPEED_CARD

#define IOT_SDIO_LOW_SPEED_CARD   ( 6 )

If the card is initialized in 3.3V signaling, and card support high speed mode (SHS ==1), host can issue CMD52 in RAW mode, setting EHS bit in CCCR to one to switch to high speed mode. This error code indicates that the sdio card does not supports high speed mode. The bus clock rate will be set to the default 25MHz in this case.

◆ IOT_SDIO_SELECT_BUS_TIMING_FAIL

#define IOT_SDIO_SELECT_BUS_TIMING_FAIL   ( 7 )

If the card is initialized in 1.8V signaling, and card support UHS-I, host will try to set card's bus timing mode to the highest mode the card supports using CMD52, and set the max clock frequency for that mode. This error code indicates a failure of such operation.

◆ IOT_SDIO_SET_CARD_BLOCK_SIZE_FAIL

#define IOT_SDIO_SET_CARD_BLOCK_SIZE_FAIL   ( 8 )

Setting block size for block transfer mode failed.

◆ IOT_SDIO_SWITCH_VOLTAGE_FAIL

#define IOT_SDIO_SWITCH_VOLTAGE_FAIL   ( 9 )

During card initialization, A host that supports UHS-I use CMD5 to probe if card also supports UHS-I and ready to switch from 3.3v to 1.8v. Once voltage switch request is accepted, host sends CMD11 to initiate voltage switch sequence. This error code indicates either card failed to respond to CMD11 or card responded to CMD11 but failed to switch voltage.

◆ IOT_SDIO_HOST_NOT_READY

#define IOT_SDIO_HOST_NOT_READY   ( 10 )

host controller not ready.

◆ IOT_SDIO_INVALID_CARD

#define IOT_SDIO_INVALID_CARD   ( 11 )

Not a valid SDIO card.

◆ IOT_SDIO_SEND_RELATIVE_ADDRESS_FAIL

#define IOT_SDIO_SEND_RELATIVE_ADDRESS_FAIL   ( 12 )

Send Relative Address (CMD3) failed.

◆ IOT_SDIO_SELECT_CARD_FAIL

#define IOT_SDIO_SELECT_CARD_FAIL   ( 13 )

Select Card (CMD7) failed.

◆ IOT_SDIO_READ_CIS_FAIL

#define IOT_SDIO_READ_CIS_FAIL   ( 14 )

Read (via CMD52) CIS (Card Information Structure failed.

◆ IOT_SDIO_SET_DATA_BUS_WIDTH_FAIL

#define IOT_SDIO_SET_DATA_BUS_WIDTH_FAIL   ( 15 )

Set (via CMD52) data bus width failed.

◆ IOT_SDIO_ASYNC_INT_NOT_SUPPORTED

#define IOT_SDIO_ASYNC_INT_NOT_SUPPORTED   ( 16 )

Card does not support Asynchronous Interrupt.

◆ IOT_SDIO_GET_CARD_CAPABILITY_FAIL

#define IOT_SDIO_GET_CARD_CAPABILITY_FAIL   ( 17 )

Reading CCCR (function 0) or FBR (function 1-7) failed.

◆ IOT_SDIO_FUNCTION_NOT_SUPPORTED

#define IOT_SDIO_FUNCTION_NOT_SUPPORTED   ( 18 )

API function is not supported by platform.

◆ IOT_SDIO_BUS_1BIT

#define IOT_SDIO_BUS_1BIT   ( 0 )

sdio io bus width

1 bit bus mode

◆ IOT_SDIO_BUS_4BIT

#define IOT_SDIO_BUS_4BIT   ( 2 )

4 bit bus mode

◆ IOT_SDIO_BUS_8BIT

#define IOT_SDIO_BUS_8BIT   ( 3 )

8 bit bus mode

Typedef Documentation

◆ IotSdioCallback_t

typedef void(* IotSdioCallback_t) (IotSdioSlotHandle_t const pxSdioHandle, IotSdioEventType_t eSdioEvent, void *pvUserContext)

The callback function for sdio event operation. This callback is passed to driver by using iot_sdio_set_callback API. It's called when one of the events (IotSdioEventType_t) happens.

Parameters
[in]pxSdioHandleHandle to sdio card slot instance returned in iot_sdio_open().
[in]eSdioEventsdio asynchronous event.
[in]pvUserContextUser Context passed when setting the callback. This is not used or modified by the driver. The context is provided by the caller when setting the callback, and is passed back to the caller in the callback.

◆ IotSdioIOFunctionCallback_t

typedef void(* IotSdioIOFunctionCallback_t) (IotSdioSlotHandle_t const pxSdioHandle, IotSdioFunction_t eFunc, void *pvUserContext)

SDIO I/O function callback type. User can call iot_sdio_set_io_function_callback() API to set one IOFunctionCallback per each standard SDIO function supported on a sdio card.

Since the I/O function number is parameter to IOFunctionCallback, user can implement one single IOFunctionCallback and set it for all I/O functions. Inside the IOFunctionCallback, different action can be taken according the I/O function number.

When there is a sdio card interrupt (eSdioCardInterruptEvent). The host should checks the interrupt pending status of each card I/O function and call that function's user defined IOFunctionCallback as needed.

The job of a IOFunctionCallback is to service the interrupt condition caused by the corresponding I/O function. It should read/write to the function unique area on the card to clear pending interrupt. The specific implementation for each IOFunctionCallback should be according to the specification of SDIO function it is written for.

Parameters
[in]pxSdioHandleHandle to sdio card slot instance returned in iot_sdio_open().
[in]eFuncI/O Function number that are associated with IRQ.
[in]pvUserContextUser context passed when setting the callback This is not used by the driver, but just passed back to the user in the callback.

Enumeration Type Documentation

◆ IotSdioDirection_t

sdio io read/write direction

Enumerator
eIORead 

io read

eIOWrite 

io write

◆ IotSdioFunction_t

SDIO I/O function number type Each SDIO card can support up to 7 I/O functions. Each I/O function can implement one of the following:

  • SDIO Standard UART
  • SDIO Bluetooth Type-B standard interface
  • SDIO GPS standard interface
  • SDIO Camera standard interface
  • SDIO PHS standard interface
  • SDIO WLAN interface
  • Embedded SDIO-ATA standard interface
  • SDIO Bluetooth Type-A AMP standard interface
  • Other SDIO standard interface type identified by Extended SDIO Standard Function interface code
Enumerator
eSdioFunction0 

refer to common register area present on all I/O cards

eSdioFunction1 

refer to register area of 1st I/O function if card supports it

eSdioFunction2 

refer to register area of 2nd I/O function if card supports it

eSdioFunction3 

refer to register area of 3rd I/O function if card supports it

eSdioFunction4 

refer to register area of 4th I/O function if card supports it

eSdioFunction5 

refer to register area of 5th I/O function if card supports it

eSdioFunction6 

refer to register area of 6th I/O function if card supports it

eSdioFunction7 

refer to register area of 7th I/O function if card supports it

eSdioFunctionMemory 

refer to register area of memory function of a combo card

◆ IotSdioCardDetectType_t

card detect type

Enumerator
eDetectCardByGpioCD 

sdio card detect by CD pin through GPIO

eDetectCardByHostCD 

sdio card detect by CD pin through host

eDetectCardByHostDATA3 

sdio card detect by DAT3 pin through host

eDetectCardNonStandard 

sdio card detect by non standard method certain sdio host may support

◆ IotSdioEventType_t

common notify event types in sdio callback

Enumerator
eSdioCardInterruptEvent 

Interrupt received from sdio card

eSdioCardInsertedEvent 

Sdio card insertion is detected

eSdioCardRemovedEvent 

Sdio card removal is detected

eSdioCardPowerOnEvent 

Powering on sdio card

eSdioCardPowerOffEvent 

Powering off sdio card

◆ IotSdioIoctlRequest_t

IOCTL request types.

Enumerator
eSDIOSetDriverStrength 

Set driver strength type input: SDIO card driver strength. input data type IotSdioSdDriverStrength_t

eSDIOSetCardInactive 

put card in inactive state

eSDIOSwitchToHighSpeed 

switch to high speed mode if card supports it

eSDIOSetDataBusWidth 

set sdio card data bus width and change host setting to support it input: sdio bus width, input data type IotSdioBusWidth_t

eSDIOGetCardCapabilities 

request host to learn capabilities of specified card function input: I/O function number, of type IotSdioFunction_t

eSDIOSetCardDetectParams 

Set card detect parameters input: card detect parameters. input data type IotSdioCardDetectParam_t

eSDIOSetFuncBlockSize 

Set transfer block size for a function input: I/O function and block size. input data type IotSdioFuncBlkSize_t

eSDIOEnableIOFunctionIrq 

enable/disable irq for individual io functions input: I/O function number and enable or disable, input data type IotSdioPerFuncEnable

eSDIOEnableAsyncIrqMode 

enable/disable asynchronous interrupt mode input: boolean to indicate enable or disable

eSDIOEnableIo 

enable/disable an I/O function on card input: I/O function number and boolean to indicate enable or disable, input data type IotSdioPerFuncEnable_t

eSDIOSelectIo 

Select an I/O function for suspend/resume input: I/O function number, input data type IotSdioFunction_t

eSDIOAbortIo 

Abort an ongoing transfer initiated by the specified I/O function input: I/O function number. Input data type IotSdioFunction_t

eSDIOReadCis 

Host read list of tuples from card CIS input: I/O function number and tuple list to read, input data type IotSdioReadCis_t

eSDIOPowerOnOffCard 

Power on/off card input: boolean true for power on, false for power off boolean true to use board's default power method, false to use user defined power method via callback. input data type IoTSdioPowerOnOffCard_t

eSDIOCheckCardPresence 

check card presence output: boolean to indicate card present or not present

◆ IotSdioBusWidth_t

sdio bus width, input parameter type for eSDIOSetDataBusWidth ioctl request

Enumerator
eDataBus1Bit 

1 bit bus mode

eDataBus4Bit 

4 bit bus mode

eDataBus8Bit 

8 bit bus mode

◆ IotSdioSdDriverStrength_t

SDIO card driver strength, input parameter type for eSDIOSetDriverStrength ioctl request.

Enumerator
eSdDriverStrengthTypeB 

default driver strength (50 ohm x1)

eSdDriverStrengthTypeA 

driver strength TYPE A (33 ohm x1.5)

eSdDriverStrengthTypeC 

driver strength TYPE C (66 ohm x0.75)

eSdDriverStrengthTypeD 

driver strength TYPE D (100 ohm x0.5)

Function Documentation

◆ iot_sdio_open()

IotSdioSlotHandle_t iot_sdio_open ( uint8_t  ucHostIdx,
uint8_t  ucSlotIdx 
)

iot_sdio_open() is used to open a handle to a sdio card slot.

     This API must be called before using any other iot_sdio APIs.
     Upon successful return, the underline SDIO host controller should have
     been initialized properly.
Parameters
[in]ucHostIdxSDIO host controller index. Must be 0 if only single host available. Range from 0 to n-1 if n hosts available.
[in]ucSlotIdxCard slot index. Must be 0 if only single slot is supported. Range from 0 to n-1 if n card slots is supported.
Returns
  • returns the handle IotSdioSlotHandle_t on success
  • NULL if
    • host index number is invalid
    • slot index number is invalid
    • if a handle on this card slot instance is already open.

◆ iot_sdio_close()

int32_t iot_sdio_close ( IotSdioSlotHandle_t const  pxSdioHandle)

iot_sdio_close() is used to close the sdio card slot handle. IO operation initiated through this handle before will not be aborted. Caller should call iot_sdio_abort_io() to abort IO operation.

Up on a successful return of the API, the SDIO host controller should be regarded as uninitialized. All cards on this host should be regarded as disconnected.

Parameters
[in]pxSdioHandleHandle to sdio card slot instance returned in iot_sdio_open()
Returns
  • IOT_SDIO_SUCCESS on success close
  • IOT_SDIO_INVALID_VALUE on NULL pxSdioHandle or already closed handle.

◆ iot_sdio_card_connect()

int32_t iot_sdio_card_connect ( IotSdioSlotHandle_t const  pxSdioHandle)

iot_sdio_card_connect() is used to connect SDIO card.

     This API should perform card connection sequence as specified in
     section 3.1.2 in "SD Specification Part E1 SDIO"
Parameters
[in]pxSdioHandleHandle to sdio card slot instance returned in iot_sdio_open()
Returns
  • IOT_SDIO_SUCCESS if card if successfully connected.
  • IOT_SDIO_INVALID_VALUE if any parameter is invalid.
  • IOT_SDIO_HOST_NOT_READY if host controller is not initialized.
  • IOT_SDIO_SWITCH_VOLTAGE_FAIL if card failed to respond to voltage switch command (CMD11) or card responded to CMD11 but failed to switch voltage.
  • IOT_SDIO_INVALID_CARD if card is invalid (memory only card)
  • IOT_SDIO_SEND_RELATIVE_ADDRESS_FAIL if Send Relative Address (CMD3) failed.
  • IOT_SDIO_SELECT_CARD_FAIL if Select Card (CMD7) failed.
  • IOT_SDIO_GET_CARD_CAPABILITY_FAIL if failed to get card capability (CCCR).
  • IOT_SDIO_READ_CIS_FAIL if failed to read common CIS tuples from card.
  • IOT_SDIO_SET_DATA_BUS_WIDTH_FAIL if failed to set maximum data bus width.
  • IOT_SDIO_SELECT_BUS_TIMING_FAIL if failed to switch to card supported timing mode.

◆ iot_sdio_card_disconnect()

int32_t iot_sdio_card_disconnect ( IotSdioSlotHandle_t const  pxSdioHandle)

iot_sdio_card_disconnect() is used to disconnect SDIO card.

     This API should soft reset all I/O functions in sdio card and de-select the
     the card.
     User is not required to call this api before trying to re-connect the card.
Parameters
[in]pxSdioHandleHandle to sdio card slot instance returned in iot_sdio_open()
Returns
  • IOT_SDIO_SUCCESS if sdio card is successfully reset and de-selected.
  • IOT_SDIO_INVALID_VALUE if any parameter is invalid.
  • IOT_SDIO_TRANSFER_FAIL is failed to reset(write CCCR reg) or de-select(CMD7) card.

◆ iot_sdio_card_reset()

int32_t iot_sdio_card_reset ( IotSdioSlotHandle_t const  pxSdioHandle)

iot_sdio_card_reset() is used to reset the sdio card in the target slot. This API should soft reset all I/O functions in sdio card.

Parameters
[in]pxSdioHandleHandle to sdio card slot instance returned in iot_sdio_open()
Returns
  • IOT_SDIO_SUCCESS if sdio card is successfully reset.
  • IOT_SDIO_INVALID_VALUE if any parameter is invalid.
  • IOT_SDIO_TRANSFER_FAIL is failed to reset(write CCCR reg) card.

◆ iot_sdio_io_write_direct()

int32_t iot_sdio_io_write_direct ( IotSdioSlotHandle_t const  pxSdioHandle,
IotSdioFunction_t  eFunc,
uint32_t  ulRegAddr,
uint8_t *  pucData,
bool  bRaw 
)

iot_sdio_io_write_direct() implements the write portion of CMD52. It is used to write 1 byte to a single register within the register space of a card I/O function.

Parameters
[in]pxSdioHandleHandle to sdio card slot instance returned in iot_sdio_open().
[in]eFuncIO function number range from eSdioFunction0 to eSdioFunction7.
[in]ulRegAddrThe address of the byte of data inside of the selected function to write. Range is 0 - 0x1ffff.
[in,out]pucDataIn: data to be written to selected address Out: If bRaw (read after write) is == false, it is same as the input data. If bRaw (read after write) is == true, it contains value read from the same address after write.
[in]bRawThe read after write flag.
Returns
  • IOT_SDIO_SUCCESS on success.
  • IOT_SDIO_INVALID_VALUE if any parameter is invalid.
  • IOT_SDIO_TRANSFER_FAIL if failed to send command to for receive response from card.

◆ iot_sdio_io_read_direct()

int32_t iot_sdio_io_read_direct ( IotSdioSlotHandle_t const  pxSdioHandle,
IotSdioFunction_t  eFunc,
uint32_t  ulRegAddr,
uint8_t *  pucData 
)

iot_sdio_io_read_direct() implements the read portion of CMD52. It is used to read 1 byte from a single register within the register space of a card I/O function.

Parameters
[in]pxSdioHandleHandle to sdio card slot instance returned in iot_sdio_open().
[in]eFuncIO function number range from eSdioFunction0 to eSdioFunction7.
[in]ulRegAddrThe address of the byte of data inside of the selected function to read. Range is 0 - 0x1ffff.
[out]pucDataContains data read when command succeeded.
Returns
  • IOT_SDIO_SUCCESS on success.
  • IOT_SDIO_INVALID_VALUE if any parameter is invalid.
  • IOT_SDIO_TRANSFER_FAIL if failed to send command or receive response from card.

◆ iot_sdio_io_write_extended()

int32_t iot_sdio_io_write_extended ( IotSdioSlotHandle_t const  pxSdioHandle,
IotSdioFunction_t  eFunc,
bool  bBlockMode,
bool  bOpcode,
uint32_t  ulRegAddr,
uint8_t *  pucBuf,
uint32_t  ulCount 
)

iot_sdio_io_write_extended() implements the write portion of CMD53. It is used to write multiple bytes or blocks to a single address or incremental addresses within the register space in a I/O function. It provides highest transfer rate possible.

Parameters
[in]pxSdioHandleHandle to sdio card slot instance returned in iot_sdio_open().
[in]eFuncIO function number range from eSdioFunction0 to eSdioFunction7.
[in]bBlockModeSet true to transfer on block basis. Set false to transfer on byte basis.
[in]bOpcodeSet true to write multiple bytes to incrementing addresses. Set false to write multiple bytes to a fixed address.
[in]ulRegAddrStart Address of I/O register to write. Range is 0 - 0x1ffff.
[in]pucBufBuffer that contains data to write.
[in]ulCountNumber of bytes to write if bBlockMode is false. Number of blocks to write if bBlockMode is true. Range is 0 - 0x1ff When bBlockMode is false, a value of 0 shall cause 512 bytes to be written. When bBlockMode is true, a value of 0 shall cause infinite blocks to be written until iot_sdio_abort_io is called.
Returns
  • IOT_SDIO_SUCCESS on success.
  • IOT_SDIO_INVALID_VALUE if any parameter is invalid.
  • IOT_SDIO_TRANSFER_FAIL if failed to send command or receive response from card.

◆ iot_sdio_io_read_extended()

int32_t iot_sdio_io_read_extended ( IotSdioSlotHandle_t const  pxSdioHandle,
IotSdioFunction_t  eFunc,
bool  bBlockMode,
bool  bOpcode,
uint32_t  ulRegAddr,
uint8_t *  pucBuf,
uint32_t  ulCount 
)

iot_sdio_io_read_extended() implements the read portion of CMD53. It is used to read multiple bytes or blocks from a single address or incremental addresses within the register space in a I/O function. It provides highest transfer rate possible.

Parameters
[in]pxSdioHandleHandle to sdio card slot instance returned in iot_sdio_open().
[in]eFuncIO function number range from eSdioFunction0 to eSdioFunction7.
[in]bBlockModeSet true to transfer on block basis. Set false to transfer on byte basis.
[in]bOpcodeSet true to read multiple bytes from incrementing addresses. Set false to read multiple bytes from a fixed address.
[in]ulRegAddrStart Address of I/O register to read. Range is 0 - 0x1ffff.
[out]pucBufBuffer to receive read data.
[in]ulCountNumber of bytes to read if bBlockMode is false. Number of blocks to read if bBlockMode is true. Range is 0 - 0x1ff When bBlockMode is false, a value of 0 shall cause 512 bytes to be read. When bBlockMode is true, a value of 0 shall cause infinite blocks to be read until iot_sdio_abort_io is called.
Returns
  • IOT_SDIO_SUCCESS on success.
  • IOT_SDIO_INVALID_VALUE if any parameter is invalid.
  • IOT_SDIO_TRANSFER_FAIL if failed to send command or receive response from card.

◆ iot_sdio_set_io_function_callback()

int32_t iot_sdio_set_io_function_callback ( IotSdioSlotHandle_t const  pxSdioHandle,
IotSdioFunction_t  eFunc,
IotSdioIOFunctionCallback_t  xIOFunctionCallback,
void *  pvIOFunctionCallbackUserContext 
)

iot_sdio_set_io_function_callback() is used to set IOFunctionCallback for each I/O function the card supports.

IOFunctionCallback for an card I/O function is invoked when the corresponding I/O function pending interrupt bit is set in the Card's CCCR. Since the I/O function number is parameter to IOFunctionCallback, user can also implement one single IOFunctionCallback and set it for all I/O functions. Inside the IOFunctionCallback, different action can be taken according the I/O function number.

The job of a IOFunctionCallback is to service the interrupt condition caused by the corresponding I/O function. It should read/write to the function unique area on the card to clear pending interrupt. The specific implementation for each IOFunctionCallback should be according to the specification of SDIO function it is written for.

Parameters
[in]pxSdioHandleHandle to sdio card slot instance returned in iot_sdio_open().
[in]eFuncIO function number range from eSdioFunction0 to eSdioFunction7.
[in]xIOFunctionCallbackIOFunctionCallback to be set for I/O function eFunc.
[in]pvIOFunctionCallbackUserContextUser context to be passed when IOFunctionCallback is invoked.
Returns
  • IOT_SDIO_SUCCESS on success.
  • IOT_SDIO_INVALID_VALUE if any parameter is invalid.

◆ iot_sdio_set_sdio_callback()

int32_t iot_sdio_set_sdio_callback ( IotSdioSlotHandle_t const  pxSdioHandle,
IotSdioCallback_t  xSdioCallback,
void *  pvSdioCallbackUserContext 
)

iot_sdio_set_sdio_callback() is used to set sdio card interrupt callback.

Parameters
[in]pxSdioHandleHandle to sdio card slot instance returned in iot_sdio_open().
[in]xSdioCallbackCallback function to be called from driver.
[in]pvSdioCallbackUserContextUser context to be passed when callback is called.
Returns
  • IOT_SDIO_SUCCESS on success.
  • IOT_SDIO_INVALID_VALUE if any parameter is invalid.

◆ iot_sdio_ioctl()

int32_t iot_sdio_ioctl ( IotSdioSlotHandle_t const  pxSdioHandle,
IotSdioIoctlRequest_t  xSdioIoctlRequest,
void *const  pvBuffer 
)

iot_sdio_ioctl() is Used for various sdio control function.

Parameters
[in]pxSdioHandleHandle to sdio card slot instance returned in iot_sdio_open().
[in]xSdioIoctlRequestShould be one of IotSdioIoctlRequest_t.
[in,out]pvBufferThe configuration values for the IOCTL request.
Returns
  • IOT_SDIO_SUCCESS on success.
  • IOT_SDIO_INVALID_VALUE if any parameter is invalid or not supported by host or card.
  • IOT_SDIO_TRANSFER_FAIL if failed to send command to or receive response from card.
  • IOT_SDIO_SET_CARD_BLOCK_SIZE_FAIL if eSDIOSetFuncBlockSize ioctl request failed.
  • IOT_SDIO_LOW_SPEED_CARD if switching speed failed due low speed only card. (for eSDIOSwitchToHighSpeed request only).
  • IOT_SDIO_SWITCH_HIGH_SPEED_FAIL if sdio card supports high speed mode but failed to switch to high speed mode. (for eSDIOSwitchToHighSpeed only).
  • IOT_SDIO_ASYNC_INT_NOT_SUPPORTED if card doesn't support async interrupt mode. (for eSDIOEnableAsyncIrqMode only).
  • IOT_SDIO_READ_CIS_FAIL if read cis command execution failed. (for eSDIOReadCis only)
  • IOT_SDIO_FAIL other failures that is unrelated to command execution.