| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sdmmc_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 __SDMMC_18XX_43XX_H_
33 #define __SDMMC_18XX_43XX_H_
34
35 #include "lpc_sdmmc.h"
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
46 #define CMD_MASK_RESP (0x3UL << 28)
47 #define CMD_RESP(r) (((r) & 0x3) << 28)
48 #define CMD_RESP_R0 (0 << 28)
49 #define CMD_RESP_R1 (1 << 28)
50 #define CMD_RESP_R2 (2 << 28)
51 #define CMD_RESP_R3 (3 << 28)
52 #define CMD_BIT_AUTO_STOP (1 << 24)
53 #define CMD_BIT_APP (1 << 23)
54 #define CMD_BIT_INIT (1 << 22)
55 #define CMD_BIT_BUSY (1 << 21)
56 #define CMD_BIT_LS (1 << 20) /* Low speed, used during acquire */
57 #define CMD_BIT_DATA (1 << 19)
58 #define CMD_BIT_WRITE (1 << 18)
59 #define CMD_BIT_STREAM (1 << 17)
60 #define CMD_MASK_CMD (0xff)
61 #define CMD_SHIFT_CMD (0)
62
63 #define CMD(c, r) ( ((c) & CMD_MASK_CMD) | CMD_RESP((r)) )
64
65 #define CMD_IDLE CMD(MMC_GO_IDLE_STATE, 0) | CMD_BIT_LS | CMD_BIT_INIT
66 #define CMD_SD_OP_COND CMD(SD_APP_OP_COND, 1) | CMD_BIT_LS | CMD_BIT_APP
67 #define CMD_SD_SEND_IF_COND CMD(SD_CMD8, 1) | CMD_BIT_LS
68 #define CMD_MMC_OP_COND CMD(MMC_SEND_OP_COND, 3) | CMD_BIT_LS | CMD_BIT_INIT
69 #define CMD_ALL_SEND_CID CMD(MMC_ALL_SEND_CID, 2) | CMD_BIT_LS
70 #define CMD_MMC_SET_RCA CMD(MMC_SET_RELATIVE_ADDR, 1) | CMD_BIT_LS
71 #define CMD_SD_SEND_RCA CMD(SD_SEND_RELATIVE_ADDR, 1) | CMD_BIT_LS
72 #define CMD_SEND_CSD CMD(MMC_SEND_CSD, 2) | CMD_BIT_LS
73 #define CMD_SEND_EXT_CSD CMD(MMC_SEND_EXT_CSD, 1) | CMD_BIT_LS | CMD_BIT_DATA
74 #define CMD_DESELECT_CARD CMD(MMC_SELECT_CARD, 0)
75 #define CMD_SELECT_CARD CMD(MMC_SELECT_CARD, 1)
76 #define CMD_SET_BLOCKLEN CMD(MMC_SET_BLOCKLEN, 1)
77 #define CMD_SEND_STATUS CMD(MMC_SEND_STATUS, 1)
78 #define CMD_READ_SINGLE CMD(MMC_READ_SINGLE_BLOCK, 1) | CMD_BIT_DATA
79 #define CMD_READ_MULTIPLE CMD(MMC_READ_MULTIPLE_BLOCK, 1) | CMD_BIT_DATA | CMD_BIT_AUTO_STOP
80 #define CMD_SD_SET_WIDTH CMD(SD_APP_SET_BUS_WIDTH, 1) | CMD_BIT_APP
81 #define CMD_STOP CMD(MMC_STOP_TRANSMISSION, 1) | CMD_BIT_BUSY
82 #define CMD_WRITE_SINGLE CMD(MMC_WRITE_BLOCK, 1) | CMD_BIT_DATA | CMD_BIT_WRITE
83 #define CMD_WRITE_MULTIPLE CMD(MMC_WRITE_MULTIPLE_BLOCK, 1) | CMD_BIT_DATA | CMD_BIT_WRITE | CMD_BIT_AUTO_STOP
84
85 /* Card specific setup data */
86 typedef struct _mci_card_struct {
87 sdif_device sdif_dev;
88 SDMMC_CARD_T card_info;
89 } mci_card_struct;
90
96 int32_t Chip_SDMMC_GetState(LPC_SDMMC_T *pSDMMC);
97
104 uint32_t Chip_SDMMC_Acquire(LPC_SDMMC_T *pSDMMC, mci_card_struct *pcardinfo);
105
111 int32_t Chip_SDMMC_GetDeviceSize(LPC_SDMMC_T *pSDMMC);
112
121 int32_t Chip_SDMMC_GetDeviceBlocks(LPC_SDMMC_T *pSDMMC);
122
131 int32_t Chip_SDMMC_ReadBlocks(LPC_SDMMC_T *pSDMMC, void *buffer, int32_t start_block, int32_t num_blocks);
132
141 int32_t Chip_SDMMC_WriteBlocks(LPC_SDMMC_T *pSDMMC, void *buffer, int32_t start_block, int32_t num_blocks);
142
147 #ifdef __cplusplus
148 }
149 #endif
150
151 #endif /* __SDMMC_18XX_43XX_H_ */