Common IO - basic v1.0.0
Common IO - basic v1.0.0 Library
 
Loading...
Searching...
No Matches
iot_sdio.h
Go to the documentation of this file.
1/*
2 * Common IO - basic V1.0.0
3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * http://aws.amazon.com/freertos
23 * http://www.FreeRTOS.org
24 */
25
26
70#ifndef _IOT_SDIO_H_
71#define _IOT_SDIO_H_
72
73#include <stdint.h>
74#include <stdbool.h>
75
76
86#define IOT_SDIO_SUCCESS ( 0 )
87
89#define IOT_SDIO_IOCTL_FAIL ( 1 )
90
92#define IOT_SDIO_HOST_INIT_FAIL ( 2 )
93
95#define IOT_SDIO_INVALID_VALUE ( 3 )
96
98#define IOT_SDIO_TRANSFER_FAIL ( 4 )
99
105#define IOT_SDIO_SWITCH_HIGH_SPEED_FAIL ( 5 )
106
112#define IOT_SDIO_LOW_SPEED_CARD ( 6 )
113
118#define IOT_SDIO_SELECT_BUS_TIMING_FAIL ( 7 )
119
121#define IOT_SDIO_SET_CARD_BLOCK_SIZE_FAIL ( 8 )
122
128#define IOT_SDIO_SWITCH_VOLTAGE_FAIL ( 9 )
129
131#define IOT_SDIO_HOST_NOT_READY ( 10 )
132
134#define IOT_SDIO_INVALID_CARD ( 11 )
135
137#define IOT_SDIO_SEND_RELATIVE_ADDRESS_FAIL ( 12 )
138
140#define IOT_SDIO_SELECT_CARD_FAIL ( 13 )
141
144#define IOT_SDIO_READ_CIS_FAIL ( 14 )
145
147#define IOT_SDIO_SET_DATA_BUS_WIDTH_FAIL ( 15 )
148
150#define IOT_SDIO_ASYNC_INT_NOT_SUPPORTED ( 16 )
151
153#define IOT_SDIO_GET_CARD_CAPABILITY_FAIL ( 17 )
154
156#define IOT_SDIO_FUNCTION_NOT_SUPPORTED ( 18 )
157
162#define IOT_SDIO_BUS_1BIT ( 0 )
163/* 1 is reserved per SDIO specification */
165#define IOT_SDIO_BUS_4BIT ( 2 )
167#define IOT_SDIO_BUS_8BIT ( 3 )
168
172typedef enum IotSdioDirection
173{
174 eIORead = 0U,
175 eIOWrite = 1U,
177
193typedef enum IotSdioFunction
194{
205
209typedef enum IotSdioCardDetectType
210{
217
221typedef enum IotSdioEventType
222{
229
233typedef enum IotSdioIoctlRequest
234{
273
277typedef enum IotSdioBusWidth
278{
283
287typedef struct IoTSdioCardDetectParam
288{
293
297typedef struct IoTSdioPowerOnOffCard
298{
299 bool bPowerOn;
302
306typedef struct IotSdioFuncBlkSize
307{
309 uint32_t ulBlockSize;
312
317typedef struct IotSdioPerFuncEnable
318{
320 bool bEnable;
322
326typedef struct IotSdioReadCis
327{
329 const uint32_t * pulTupleList;
331 uint32_t ulTupleNum;
333
337typedef enum IotSdioSdDriverStrength
338{
344
348struct IotSdioSlotDescriptor;
349
353typedef struct IotSdioSlotDescriptor * IotSdioSlotHandle_t;
354
368typedef void (* IotSdioCallback_t) ( IotSdioSlotHandle_t const pxSdioHandle,
369 IotSdioEventType_t eSdioEvent,
370 void * pvUserContext );
371
396typedef void (* IotSdioIOFunctionCallback_t) ( IotSdioSlotHandle_t const pxSdioHandle,
397 IotSdioFunction_t eFunc,
398 void * pvUserContext );
399
422 uint8_t ucSlotIdx );
423
441int32_t iot_sdio_close( IotSdioSlotHandle_t const pxSdioHandle );
442
466int32_t iot_sdio_card_connect( IotSdioSlotHandle_t const pxSdioHandle );
467
483int32_t iot_sdio_card_disconnect( IotSdioSlotHandle_t const pxSdioHandle );
484
497int32_t iot_sdio_card_reset( IotSdioSlotHandle_t const pxSdioHandle );
498
526 IotSdioFunction_t eFunc,
527 uint32_t ulRegAddr,
528 uint8_t * pucData,
529 bool bRaw );
530
552 IotSdioFunction_t eFunc,
553 uint32_t ulRegAddr,
554 uint8_t * pucData );
555
591 IotSdioFunction_t eFunc,
592 bool bBlockMode,
593 bool bOpcode,
594 uint32_t ulRegAddr,
595 uint8_t * pucBuf,
596 uint32_t ulCount );
597
633 IotSdioFunction_t eFunc,
634 bool bBlockMode,
635 bool bOpcode,
636 uint32_t ulRegAddr,
637 uint8_t * pucBuf,
638 uint32_t ulCount );
639
669 IotSdioFunction_t eFunc,
670 IotSdioIOFunctionCallback_t xIOFunctionCallback,
671 void * pvIOFunctionCallbackUserContext );
672
686 IotSdioCallback_t xSdioCallback,
687 void * pvSdioCallbackUserContext );
688
710int32_t iot_sdio_ioctl( IotSdioSlotHandle_t const pxSdioHandle,
711 IotSdioIoctlRequest_t xSdioIoctlRequest,
712 void * const pvBuffer );
713
718#endif /* _IOT_SDIO_H_ */
IotSdioSdDriverStrength_t
SDIO card driver strength, input parameter type for eSDIOSetDriverStrength ioctl request.
Definition: iot_sdio.h:338
int32_t iot_sdio_card_connect(IotSdioSlotHandle_t const pxSdioHandle)
iot_sdio_card_connect() is used to connect SDIO card.
#define IOT_SDIO_BUS_1BIT
sdio io bus width
Definition: iot_sdio.h:162
#define IOT_SDIO_BUS_4BIT
Definition: iot_sdio.h:165
IotSdioIoctlRequest_t
IOCTL request types.
Definition: iot_sdio.h:234
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 IOF...
Definition: iot_sdio.h:396
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 a...
IotSdioCardDetectType_t
card detect type
Definition: iot_sdio.h:210
IotSdioFunction_t
SDIO I/O function number type Each SDIO card can support up to 7 I/O functions. Each I/O function can...
Definition: iot_sdio.h:194
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 byte...
int32_t iot_sdio_card_disconnect(IotSdioSlotHandle_t const pxSdioHandle)
iot_sdio_card_disconnect() is used to disconnect SDIO card.
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 sing...
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 ...
IotSdioEventType_t
common notify event types in sdio callback
Definition: iot_sdio.h:222
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.
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.
#define IOT_SDIO_BUS_8BIT
Definition: iot_sdio.h:167
IotSdioBusWidth_t
sdio bus width, input parameter type for eSDIOSetDataBusWidth ioctl request
Definition: iot_sdio.h:278
IotSdioDirection_t
sdio io read/write direction
Definition: iot_sdio.h:173
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_s...
Definition: iot_sdio.h:368
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 o...
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 sin...
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 hand...
struct IotSdioSlotDescriptor * IotSdioSlotHandle_t
IotSdioSlotHandle_t type is the SDIO slot handle returned by calling iot_sdio_open()
Definition: iot_sdio.h:353
@ eSdDriverStrengthTypeB
Definition: iot_sdio.h:339
@ eSdDriverStrengthTypeC
Definition: iot_sdio.h:341
@ eSdDriverStrengthTypeD
Definition: iot_sdio.h:342
@ eSdDriverStrengthTypeA
Definition: iot_sdio.h:340
@ eSDIOSetDriverStrength
Definition: iot_sdio.h:235
@ eSDIOCheckCardPresence
Definition: iot_sdio.h:270
@ eSDIOSwitchToHighSpeed
Definition: iot_sdio.h:239
@ eSDIOSetCardDetectParams
Definition: iot_sdio.h:244
@ eSDIOEnableAsyncIrqMode
Definition: iot_sdio.h:253
@ eSDIOPowerOnOffCard
Definition: iot_sdio.h:265
@ eSDIOEnableIOFunctionIrq
Definition: iot_sdio.h:250
@ eSDIOEnableIo
Definition: iot_sdio.h:255
@ eSDIOReadCis
Definition: iot_sdio.h:262
@ eSDIOSetFuncBlockSize
Definition: iot_sdio.h:247
@ eSDIOGetCardCapabilities
Definition: iot_sdio.h:242
@ eSDIOSetCardInactive
Definition: iot_sdio.h:238
@ eSDIOSetDataBusWidth
Definition: iot_sdio.h:240
@ eSDIOSelectIo
Definition: iot_sdio.h:258
@ eSDIOAbortIo
Definition: iot_sdio.h:260
@ eDetectCardByHostDATA3
Definition: iot_sdio.h:213
@ eDetectCardByGpioCD
Definition: iot_sdio.h:211
@ eDetectCardByHostCD
Definition: iot_sdio.h:212
@ eDetectCardNonStandard
Definition: iot_sdio.h:214
@ eSdioFunction1
Definition: iot_sdio.h:196
@ eSdioFunction4
Definition: iot_sdio.h:199
@ eSdioFunction7
Definition: iot_sdio.h:202
@ eSdioFunction2
Definition: iot_sdio.h:197
@ eSdioFunction6
Definition: iot_sdio.h:201
@ eSdioFunctionMemory
Definition: iot_sdio.h:203
@ eSdioFunction0
Definition: iot_sdio.h:195
@ eSdioFunction5
Definition: iot_sdio.h:200
@ eSdioFunction3
Definition: iot_sdio.h:198
@ eSdioCardPowerOnEvent
Definition: iot_sdio.h:226
@ eSdioCardRemovedEvent
Definition: iot_sdio.h:225
@ eSdioCardPowerOffEvent
Definition: iot_sdio.h:227
@ eSdioCardInterruptEvent
Definition: iot_sdio.h:223
@ eSdioCardInsertedEvent
Definition: iot_sdio.h:224
@ eDataBus4Bit
Definition: iot_sdio.h:280
@ eDataBus8Bit
Definition: iot_sdio.h:281
@ eDataBus1Bit
Definition: iot_sdio.h:279
@ eIORead
Definition: iot_sdio.h:174
@ eIOWrite
Definition: iot_sdio.h:175
input parameter type for eSDIOPowerOnOffCard ioctl request
Definition: iot_sdio.h:298
bool bPowerOn
Definition: iot_sdio.h:299
bool bUseCallback
Definition: iot_sdio.h:300
input parameter type for eSDIOSetCardDetectParams ioctl request
Definition: iot_sdio.h:288
IotSdioCardDetectType_t eCardDetectType
Definition: iot_sdio.h:289
bool bCallbackOnInsert
Definition: iot_sdio.h:290
bool bCallbackOnRemoval
Definition: iot_sdio.h:291
input parameter type for eSDIOSetFuncBlockSize ioctl request
Definition: iot_sdio.h:307
IotSdioFunction_t eFunc
Definition: iot_sdio.h:308
uint32_t ulBlockSize
Definition: iot_sdio.h:309
input parameter type for eSDIOEnableIOFunctionIrq ioctl request and for eSDIOEnableIo ioctl request
Definition: iot_sdio.h:318
IotSdioFunction_t eFunc
Definition: iot_sdio.h:319
bool bEnable
Definition: iot_sdio.h:320
input parameter type for eSDIOReadCis ioctl request
Definition: iot_sdio.h:327
IotSdioFunction_t eFunc
Definition: iot_sdio.h:328
uint32_t ulTupleNum
Definition: iot_sdio.h:331
const uint32_t * pulTupleList
Definition: iot_sdio.h:329