This example describes how to use the SD/MMC interface with a SD card and a FATFS filesystem.
To use the example, plug a SD card (Hitex A4 board) or microSD card (NGX or Keil boards) and connect a serial cable to the board's RS232/UART port start a terminal program to monitor the port. The terminal program on the host PC should be setup for 115K8N1.
Build procedure: LPCOpen 18xx/43xx build instructions
Supported boards and board setup:
- Hitex LPC1850EVA-A4-2 and LPC4350EVA-A4-2 boards
- Close pin 1-2 of JP9
- Open all SV3, SV6
- Close all SV12
- Uart1 terminal port: SV11-p2(U1_RXD) connect to SV1-p7, SV11-p4 (U1_TXD) connect to SV1-p5
- Keil MCB1857 and MCB4357 boards (debug output terminal on Uart0)
- NGX LPC1830 LPC4330 (no debug output terminal)
Submit bug reports for LPCOpen code here.
#define TIME_INTERVAL 1/* 1ms */ |
#define xmemset |
( |
|
x, |
|
|
|
y, |
|
|
|
z |
|
) |
| memset(x, y, z) |
#define xstrchr |
( |
|
x, |
|
|
|
y |
|
) |
| strchr(x, y) |
#define xstrcpy |
( |
|
x, |
|
|
|
y |
|
) |
| strcpy(x, y) |
#define xstrlen |
( |
|
x | ) |
strlen(x) |
static void App_SDMMC_Init |
( |
void |
| ) |
|
|
static |
static void App_Timer_Init |
( |
void |
| ) |
|
|
static |
Error processing function: stop with dying message.
- Parameters
-
- Returns
- Nothing
Definition at line 220 of file sdmmc.c.
Initialize Disk Drive.
- Parameters
-
drv | : Physical drive number |
- Returns
- Drive status
Definition at line 113 of file fs_mci.c.
Disk Drive miscellaneous Functions.
- Parameters
-
drv | : Physical drive number |
ctrl | : Control code |
buff | : Buffer to send/receive control data |
- Returns
- Drive status
Definition at line 146 of file fs_mci.c.
Read Sector(s)
- Parameters
-
drv | : Physical drive number |
buff | : Pointer to the data buffer to store read data |
sector | : Start sector number (LBA) |
count | : Sector count (1..255 |
- Returns
- Drive status
Definition at line 227 of file fs_mci.c.
Get Disk Status.
- Parameters
-
drv | : Physical drive number |
- Returns
- Drive status
Definition at line 244 of file fs_mci.c.
void disk_timerproc |
( |
void |
| ) |
|
Device timer function.
- Returns
- Nothing This function must be called from timer interrupt routine in period of 10 ms to generate card control timing
Definition at line 272 of file fs_mci.c.
Write Sector(s)
- Parameters
-
drv | : Physical drive number |
buff | : Pointer to the data to be written |
sector | : Start sector number (LBA) |
count | : Sector count (1..255 |
- Returns
- Drive status
Definition at line 254 of file fs_mci.c.
DWORD get_fattime |
( |
void |
| ) |
|
User Provided Timer Function for FatFs module.
- Returns
- Nothing This is a real time clock service to be called from FatFs module. Any valid time must be returned even if the system does not support a real time clock. This is not required in read-only configuration.
Definition at line 275 of file sdmmc.c.
Main routine for SDMMC example.
- Returns
- Nothing
Definition at line 295 of file sdmmc.c.
void RIT_IRQHandler |
( |
void |
| ) |
|
RIT interrupt handler sub-routine.
- Returns
- Nothing
Definition at line 256 of file sdmmc.c.
void SDIO_IRQHandler |
( |
void |
| ) |
|
SDIO controller interrupt handler.
- Returns
- Nothing
Definition at line 239 of file sdmmc.c.
static uint32_t sdmmc_irq_driven_wait |
( |
void |
| ) |
|
|
static |
A better wait callback for SDMMC driven by the IRQ flag.
- Parameters
-
bits | : Status bits to poll for command completion |
- Returns
- 0 on success, or failure condition (-1)
Definition at line 142 of file sdmmc.c.
static void sdmmc_setup_wakeup |
( |
uint32_t |
bits | ) |
|
|
static |
Sets up the SD event driven wakeup.
- Parameters
-
bits | : Status bits to poll for command completion |
- Returns
- Nothing
Definition at line 128 of file sdmmc.c.
static void sdmmc_waitms |
( |
uint32_t |
time | ) |
|
|
static |
void SysTick_Handler |
( |
void |
| ) |
|
System tick interrupt handler.
- Returns
- Nothing
Definition at line 230 of file sdmmc.c.
volatile int32_t sdio_wait_exit = 0 |
|
static |