LPCOpen Platform for LPC18XX/43XX microcontrollers: C:/w/lpcopen_docs/software/lpc_core/lpc_chip/chip_18xx_43xx/sdio_18xx_43xx.h Source File

| LPCOpen Platform for LPC18XX/43XX microcontrollers 18XX43XX LPCOpen Platform for the NXP LPC18XX/43XX family of Microcontrollers

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

sdio_18xx_43xx.h
Go to the documentation of this file.
1 /*
2 * @brief LPC18xx/43xx SD/MMC card driver
3 *
4 * @note
5 * Copyright(C) NXP Semiconductors, 2012
6 * All rights reserved.
7 *
8 * @par
9 * Software that is described herein is for illustrative purposes only
10 * which provides customers with programming information regarding the
11 * LPC products. This software is supplied "AS IS" without any warranties of
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
13 * all warranties, express or implied, including all implied warranties of
14 * merchantability, fitness for a particular purpose and non-infringement of
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
16 * or liability for the use of the software, conveys no license or rights under any
17 * patent, copyright, mask work right, or any other intellectual property rights in
18 * or to any products. NXP Semiconductors reserves the right to make changes
19 * in the software without notification. NXP Semiconductors also makes no
20 * representation or warranty that such application will be suitable for the
21 * specified use without further testing or modification.
22 *
23 * @par
24 * Permission to use, copy, modify, and distribute this software and its
25 * documentation is hereby granted, under NXP Semiconductors' and its
26 * licensor's relevant copyrights in the software, without fee, provided that it
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
28 * copyright, permission, and disclaimer notice must appear in all copies of
29 * this code.
30 */
31
32 #ifndef __SDIO_18XX_43XX_H_
33 #define __SDIO_18XX_43XX_H_
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
45 enum SDIO_EVENT
46 {
47 SDIO_START_COMMAND,
48 SDIO_START_DATA,
49 SDIO_WAIT_DELAY,
50 SDIO_WAIT_COMMAND,
51 SDIO_WAIT_DATA,
53 SDIO_CARD_DETECT,
54 SDIO_CMD_ERR,
55 SDIO_CMD_DONE,
56 SDIO_DATA_ERR,
57 SDIO_DATA_DONE,
58 SDIO_CARD_INT,
59 };
60
62 #define SDIO_CMD_RESP_R1 (1UL << 6)
63 #define SDIO_CMD_RESP_R2 (3UL << 6)
64 #define SDIO_CMD_RESP_R3 (1UL << 6)
65 #define SDIO_CMD_RESP_R4 (1UL << 6)
66 #define SDIO_CMD_RESP_R5 (1UL << 6)
67 #define SDIO_CMD_RESP_R6 (1UL << 6)
68
70 #define SDIO_CMD_CRC (1UL << 8)
71 #define SDIO_CMD_DATA (1UL << 9)
74 #define CMD0 (0 | (1 << 15))
75 #define CMD5 (5 | SDIO_CMD_RESP_R4)
76 #define CMD3 (3 | SDIO_CMD_RESP_R6)
77 #define CMD7 (7 | SDIO_CMD_RESP_R1)
78 #define CMD52 (52 | SDIO_CMD_RESP_R5 | SDIO_CMD_CRC)
79 #define CMD53 (53 | SDIO_CMD_RESP_R5 | SDIO_CMD_DATA | SDIO_CMD_CRC)
80
82 #define SDIO_ERROR -1
83 #define SDIO_ERR_FNUM -2
84 #define SDIO_ERR_READWRITE -3
85 #define SDIO_ERR_VOLT -4
86 #define SDIO_ERR_RCA -5
87 #define SDIO_ERR_INVFUNC -6
88 #define SDIO_ERR_INVARG -7
90 #define SDIO_VOLT_3_3 0x00100000UL /* for CMD5 */
91
92 /* SDIO Data transfer modes */
99 #define SDIO_MODE_BLOCK (1UL << 27)
100
111 #define SDIO_MODE_BUFFER (1UL << 26)
112
113 /* ---- SDIO Internal map ---- */
114 #define SDIO_AREA_CIA 0 /* function 0 */
115
116 /* ---- Card Capability(0x08) register ---- */
117 #define SDIO_CCCR_LSC 0x40u /* card is low-speed cards */
118 #define SDIO_CCCR_4BLS 0x80u /* 4-bit support for low-speed cards */
119
120 #define SDIO_POWER_INIT 1
121
122 #define SDIO_CLK_HISPEED 33000000UL /* High-Speed Clock */
123 #define SDIO_CLK_FULLSPEED 16000000UL /* Full-Speed Clock */
124 #define SDIO_CLK_LOWSPEED 400000 /* Low-Speed Clock */
125
132 int SDIO_Card_Init(LPC_SDMMC_T *pSDMMC, uint32_t freq);
133
144 int SDIO_Write_Direct(LPC_SDMMC_T *pSDMMC, uint32_t func, uint32_t addr, uint32_t data);
145
155 int SDIO_WriteRead_Direct(LPC_SDMMC_T *pSDMMC, uint32_t func, uint32_t addr, uint32_t *data);
156
165 int SDIO_Read_Direct(LPC_SDMMC_T *pSDMMC, uint32_t func, uint32_t addr, uint32_t *data);
166
176 void SDIO_Setup_Callback(LPC_SDMMC_T *pSDMMC,
177 void (*wake_evt)(LPC_SDMMC_T *pSDMMC, uint32_t event, void *arg),
178 uint32_t (*wait_evt)(LPC_SDMMC_T *pSDMMC, uint32_t event, void *arg));
179
185 void SDIO_Handler(LPC_SDMMC_T *pSDMMC);
186
194 uint32_t SDIO_Send_Command(LPC_SDMMC_T *pSDMMC, uint32_t cmd, uint32_t arg);
195
206 uint32_t SDIO_Card_GetBlockSize(LPC_SDMMC_T *pSDMMC, uint32_t func);
207
219 int SDIO_Card_SetBlockSize(LPC_SDMMC_T *pSDMMC, uint32_t func, uint32_t blkSize);
220
234 int SDIO_Card_WriteData(LPC_SDMMC_T *pSDMMC, uint32_t func,
235 uint32_t dest_addr, const uint8_t *src_addr,
236 uint32_t size, uint32_t flags);
237
251 int SDIO_Card_ReadData(LPC_SDMMC_T *pSDMMC, uint32_t func,
252 uint8_t *dest_addr, uint32_t src_addr,
253 uint32_t size, uint32_t flags);
254
261 int SDIO_Card_DisableInt(LPC_SDMMC_T *pSDMMC, uint32_t func);
262
269 int SDIO_Card_EnableInt(LPC_SDMMC_T *pSDMMC, uint32_t func);
270
274 #ifdef __cplusplus
275 }
276 #endif
277
278 #endif /* __SDIO_18XX_43XX_H_ */