SDIOWFF3.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2025, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*
33  * ======== SDIOWFF3.h ========
34  */
35 /*
36  * @file SDIOWFF3.h
37  * @brief SDIO driver implementation for a Wi-Fi F3 device.
38  * SDIOWFF3 peripheral using the DMA controller or Core.
39  *
40  * # Driver include #
41  * The SDIOWFF3 header file should be included in an application as follows:
42  * @code
43  * #include <ti/drivers/SDIO.h>
44  * #include <ti/drivers/sdio/SDIOWFF3.h>
45  * @endcode
46  *
47  * Refer to @ref SDIO.h for a complete description of APIs.
48  *
49  * # Overview #
50  * The general SDIO API should be used in application code, i.e. #SDIO_open()
51  * should be used instead of #SDIO_open(). The board file will define the
52  * device specific config, and casting in the general API will ensure that the
53  * correct device specific functions are called.
54  *
55  * # General Behavior #
56  * Before using SDIOWFF3 on Wi-Fi F3 devices:
57  * - The SDIOWFF3 driver is initialized by calling #SDIO_init().
58  * - The SDIOWFF3 HW is configured and flags system dependencies (e.g. IOs, power,
59  * etc.) by calling #SDIO_open().
60  * - The SDWFF3 driver makes use of DMA in order to optimize throughput. This is
61  * handled directly by the SDIOWFF3 driver, so the application should never make
62  * any calls directly to the DMAWFF3.h driver.
63  * - After SDIOWFF3 HW IP initialized, SDIO peripheral must be initialized by SDIO
64  * controller before read and write.
65  * It is recommended to check with #SDIOWFF3_isSdioInitialized() if the host
66  * already initialized the peripheral.
67  * note: The driver will indicate to the application if the SDIO
68  * peripheral is initialized, using callback function that define
69  * in the Parameters of #SDIO_open().
70  *
71  * After SDIOWFF3 operation has ended:
72  * - Release system dependencies for SDIO by calling #SDIO_close().
73  *
74  * The SDIOWFF3.h driver is setting a power constraint during transfers to
75  * keep the device out of sleep. When the transfer has finished, the power
76  * constraint is released.
77  *
78  * # Data Frames #
79  * SDIOWFF3 data frames is fixed on 32-bits (4-bytes)
80  *
81  * # Transfer Size Limit #
82  * The DMA controller only supports data transfers of up to 16383 bytes.
83  * A transfer with more than 16383 bytes will be transmitted/received in
84  * multiple 16383 sized portions until all data has been transmitted/received.
85  *
86  * # Supported Functions #
87  *
88  * API function | Description
89  * ------------------------------ |------------------------------------------------------------
90  * #SDIO_init() | This function initializes the SDIO driver
91  * #SDIO_open() | Function to open the SDIO peripheral with the parameters specified
92  * #SDIO_close() | Function to close a SDIO peripheral
93  * #SDIO_write() | Function that writes data to Tx FIFO
94  * #SDIO_read() | Function that reads the transmitted data from Rx FIFO
95  * #SDIOWFF3_isSdioInitialized() | Check if SDIO host init SDIO peripheral
96  *
97  * #SDIO Header#
98  * To provide transaction parameters (such as: Direction, number of bytes etc.)
99  * Host SDIO must send header on the data line.
100  * The header length must be divided by 4 bytes.
101  * Threshold on the Rx FIFO inside SDIO peripheral, could generate an
102  * IRQ to indicate that the host sent a header.
103  * Once the threshold IRQ rose, application should read the header.
104  * note: SDIOWFF3 doesn't familiar with the header protocol.
105  *
106  * **Important**
107  * With getting a new header the driver mask the threshold IRQ.
108  * The masking will be removed in the end of #SDIO_read().
109  * - If the header define writing from the host to peripheral then the masking
110  * will be removed by #SDIO_read()
111  *
112  * # SDIO callback Function #
113  * With using #SDIO_open(), the application must provide a pointer to a
114  * call-back function.
115  * The driver will call the function from IRQ function, the implementation of
116  * the function must be shortest as possible SDIOWFF3 can indicate the
117  * application about various events:
118  *
119  * Event enumeration |IDX| Description
120  * -------------------------- |---|------------------------------------------------------------
121  * SDIOWFF3_DATA_IN_RX_FIFO | 1 | Received new SDIO header
122  * SDIOWFF3_CARD_INIT | 2 | SDIO host initialized SDIO peripheral
123  * SDIOWFF3_CARD_DEINIT | 3 | SDIO host reset SDIO peripheral
124  * SDIOWFF3_RX_CRC_ERROR | 4 | Received command or data from host with CRC error
125  * SDIOWFF3_RX_BUFF_OVERRUN | 5 | Overrun error on Rx FIFO
126  * SDIOWFF3_RX_BUFF_UNDERRUN | 6 | Underrun error on Rx FIFO
127  * SDIOWFF3_TX_BUFF_OVERRUN | 7 | Overrun error on Tx FIFO
128  * SDIOWFF3_TX_BUFF_UNDERRUN | 8 | Underrun error on Tx FIFO
129  * SDIOWFF3_HOST_WRONG_ACCESS | 9 | Host tried to access to wrong address
130  * SDIOWFF3_HOST_SENT_MSG |10 | Host sent a new message
131  *
132  * # Sys-Config #
133  * The output of the sysconfig will supply #SDIO_Config, #SDIOWFF3_Object and #SDIOWFF3_HwAttrs
134  * for the driver usage.
135  * A sample #SDIOWFF3_HwAttrs structure is shown below:
136  *
137  * SDIOWFF3_HwAttrs SDIOWFF3_hwAttrs[CONFIG_SDIO_COUNT] = {
138  * {
139  * .FN0baseAddr = SDIO_CORE_BASE,
140  * .FN1baseAddr = SDIO_CARD_FN1_BASE,
141  * .intNum = INT_SDIO_CARD_IRQ_REQ,
142  * .intPriority = (~0),
143  * .powerID = PowerWFF3_PERIPH_SDIO,
144  * .rxDmaChannel = 6,
145  * .txDmaChannel = 5,
146  * .headerLen = 4,
147  * .clkPin = 12,
148  * .clkPinMux = 19,
149  * .cmdPin = 13,
150  * .cmdPinMux = 19,
151  * .data0Pin = 33,
152  * .data0PinMux = 30,
153  * .data1Pin = 32,
154  * .data1PinMux = 30,
155  * .data2Pin = 31,
156  * .data2PinMux = 30,
157  * .data3Pin = 10,
158  * .data3PinMux = 19,
159  * .irqPin = 17,
160  * .irqPinMux = 17
161  * },
162  *};
163  *
164  * function scratch
165  * void SDIOWFF3_callBack(SDIO_Handle handle, uint8_t eventIDX, uint32_t *transHeader, uint32_t headerLen)
166  * {
167  * if(eventIDX == SSDIOWFF3_DATA_IN_RX_FIFO
168  * {
169  * ...
170  * }
171  * else if(eventIDX == SDIOWFF3_CARD_INIT)
172  * {
173  * ...
174  * }
175  * else if(eventIDX == SDIOWFF3_CRC_ERROR)
176  * {
177  * ...
178  * }
179  * }
180  *
181  *---------------------------------------------------------------------*
182  * An example for using SDIOWFF3 driver correctly on Wi-Fi F3 devices
183  *---------------------------------------------------------------------*
184  *
185  * @code
186  * Firstly the application must generate a SDIOWFF3_Param struct and define the callback function.
187  *
188  * //Variable declaration for driver usage - can be declare with any name
189  * SDIOWFF3_Param SDIOWFF3_param;
190  *
191  * //Initiate SDWFF3_Param
192  * SDIOWFF3_param.SDIOWFF3_CallbackFxn = SDIOWFF3_callBack;
193  *
194  * //To start using SDIO driver, the driver must be initialized
195  * //SDIO_config variable is generated as output by SysConfig
196  * SDIO_init(&SDIO_config);
197  *
198  * //Then the SDIO peripheral must be open using *SDIOWFF3_param
199  * int_fast16_t ret = SDIO_open(0, (SDIO_Params *)&SDIOWFF3_param);
200  *
201  *
202  */
203 
204 #ifndef ti_drivers_sdio_SDIOWFF3__include
205 #define ti_drivers_sdio_SDIOWFF3__include
206 
207 #include <stdint.h>
208 #include <string.h>
209 #include <stdbool.h>
210 #include <stdlib.h>
211 
212 #include <ti/devices/DeviceFamily.h>
213 #include DeviceFamily_constructPath(inc/hw_types.h)
214 #include DeviceFamily_constructPath(inc/hw_sdio_card_fn1.h)
215 #include DeviceFamily_constructPath(inc/hw_sdio_core.h)
216 #include DeviceFamily_constructPath(inc/hw_memmap.h)
217 #include DeviceFamily_constructPath(inc/hw_iomux.h)
218 #include DeviceFamily_constructPath(inc/hw_ints.h)
219 
220 #include <ti/drivers/dpl/HwiP.h>
221 #include <ti/drivers/dpl/ClockP.h>
222 
223 #include <ti/drivers/SDIO.h>
224 
225 #ifdef __cplusplus
226 extern "C" {
227 #endif
228 
229 //------------------------------------------------------------------//
230 
231 typedef void (*SDIOWFF3EventCB)(SDIO_Handle handle, uint8_t eventIDX);
232 
233 typedef enum
234 {
246 
250 typedef struct
251 {
253  bool isInit;
254 
256  bool isOpen;
257 
260 
262 
263 typedef struct
264 {
266  uint32_t FN0baseAddr;
267 
269  uint32_t FN1baseAddr;
270 
272  uint32_t intNum;
273 
275  uint32_t intPriority;
276 
278  uint32_t powerID;
279 
281  uint32_t rxDmaChannel;
282 
284  uint32_t txDmaChannel;
285 
287  uint32_t thresholdLen;
288 
290  uint32_t clkPin;
291 
293  uint32_t clkPinMux;
294 
296  uint32_t cmdPin;
297 
299  uint32_t cmdPinMux;
300 
302  uint32_t data0Pin;
303 
305  uint32_t data0PinMux;
306 
308  uint32_t data1Pin;
309 
311  uint32_t data1PinMux;
312 
314  uint32_t data2Pin;
315 
317  uint32_t data2PinMux;
318 
320  uint32_t data3Pin;
321 
323  uint32_t data3PinMux;
324 
326  uint32_t irqPin;
327 
329  uint32_t irqPinMux;
330 
333 
336 
339 
341 
342 typedef struct
343 {
346 
348 
359 bool SDIOWFF3_isSdioInitialized(void);
360 
361 #ifdef __cplusplus
362 }
363 #endif
364 
365 #endif /* ti_drivers_sdio_SDIOWFF3__include */
Definition: SDIOWFF3.h:239
HwiP structure.
Definition: HwiP.h:166
Definition: SDIOWFF3.h:243
Definition: SDIOWFF3.h:238
Definition: SDIOWFF3.h:242
uint32_t data3PinMux
Definition: SDIOWFF3.h:323
Clock interface for the RTOS Porting Interface.
uint32_t data1Pin
Definition: SDIOWFF3.h:308
Definition: SDIOWFF3.h:244
uint32_t data3Pin
Definition: SDIOWFF3.h:320
Definition: SDIOWFF3.h:263
Definition: SDIOWFF3.h:342
uint32_t FN1baseAddr
Definition: SDIOWFF3.h:269
Definition: SDIOWFF3.h:237
uint32_t cmdPinMux
Definition: SDIOWFF3.h:299
HwiP_Struct hwiStruct
Definition: SDIOWFF3.h:335
uint32_t FN0baseAddr
Definition: SDIOWFF3.h:266
uint32_t data0Pin
Definition: SDIOWFF3.h:302
Definition: SDIOWFF3.h:235
uint32_t data1PinMux
Definition: SDIOWFF3.h:311
HwiP_Params hwiPrms
Definition: SDIOWFF3.h:332
Secure Digital Input Output (SDIO) Driver.
bool isOpen
Definition: SDIOWFF3.h:256
uint32_t irqPin
Definition: SDIOWFF3.h:326
SDIOWFF3EventCB SDIOWFF3_CallbackFxn
Definition: SDIOWFF3.h:345
SDIOWFF_eventIDX
Definition: SDIOWFF3.h:233
bool SDIOWFF3_isSdioInitialized(void)
Function to check if SDIO host already initialize SDIO peripheral SDIO initialize definition is: TRUE...
uint32_t cmdPin
Definition: SDIOWFF3.h:296
void(* SDIOWFF3EventCB)(SDIO_Handle handle, uint8_t eventIDX)
Definition: SDIOWFF3.h:231
bool isInit
Definition: SDIOWFF3.h:253
uint32_t data2Pin
Definition: SDIOWFF3.h:314
uint32_t clkPinMux
Definition: SDIOWFF3.h:293
uint32_t intPriority
Definition: SDIOWFF3.h:275
uint32_t irqPinMux
Definition: SDIOWFF3.h:329
uint32_t txDmaChannel
Definition: SDIOWFF3.h:284
SDIOWFF3 driver object.
Definition: SDIOWFF3.h:250
uint32_t rxDmaChannel
Definition: SDIOWFF3.h:281
bool cardInitiated
Definition: SDIOWFF3.h:259
uint32_t thresholdLen
Definition: SDIOWFF3.h:287
uint32_t data0PinMux
Definition: SDIOWFF3.h:305
Definition: SDIOWFF3.h:236
Definition: SDIOWFF3.h:240
uint32_t powerID
Definition: SDIOWFF3.h:278
SDIO Global configuration.
Definition: SDIO.h:124
uint32_t clkPin
Definition: SDIOWFF3.h:290
Basic HwiP Parameters.
Definition: HwiP.h:205
Hardware Interrupt module for the RTOS Porting Interface.
uint32_t intNum
Definition: SDIOWFF3.h:272
SDIOWFF3EventCB SDIOWFF3_CBFunction
Definition: SDIOWFF3.h:338
uint32_t data2PinMux
Definition: SDIOWFF3.h:317
Definition: SDIOWFF3.h:241
© Copyright 1995-2026, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale