FatFs demo for the STM32F103ZG using the SDC driver.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3028 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2011-06-05 08:39:49 +00:00
parent 9b147c2551
commit 03b4c7ddcb
5 changed files with 40 additions and 15 deletions

View File

@ -286,7 +286,7 @@ static const ShellCommand commands[] = {
};
static const ShellConfig shell_cfg1 = {
(BaseChannel *)&SD2,
(BaseChannel *)&SD1,
commands
};
@ -302,11 +302,11 @@ static void InsertHandler(eventid_t id) {
(void)id;
/*
* On insertion MMC initialization and FS mount.
* On insertion SDC initialization and FS mount.
*/
if (sdcConnect(&SDCD1)) {
if (sdcConnect(&SDCD1))
return;
}
err = f_mount(0, &SDC_FS);
if (err != FR_OK) {
sdcDisconnect(&SDCD1);
@ -321,7 +321,8 @@ static void InsertHandler(eventid_t id) {
static void RemoveHandler(eventid_t id) {
(void)id;
sdcDisconnect(&SDCD1);
if (sdcGetDriverState(&SDCD1) == SDC_ACTIVE)
sdcDisconnect(&SDCD1);
fs_ready = FALSE;
}
@ -352,6 +353,12 @@ static msg_t Thread1(void *arg) {
* Application entry point.
*/
int main(void) {
static const evhandler_t evhndl[] = {
InsertHandler,
RemoveHandler
};
Thread *shelltp = NULL;
struct EventListener el0, el1;
/*
* System initializations.
@ -364,9 +371,16 @@ int main(void) {
chSysInit();
/*
* Activates the serial driver 1 using the driver default configuration.
* Activates the serial driver 1 and SDC driver 1 using default
* configuration.
*/
sdStart(&SD1, NULL);
sdcStart(&SDCD1, NULL);
/*
* Shell manager initialization.
*/
shellInit();
/*
* Activates the card insertion monitor.
@ -380,11 +394,17 @@ int main(void) {
/*
* Normal main() thread activity, in this demo it does nothing except
* sleeping in a loop and check the button state.
* sleeping in a loop and listen for events.
*/
chEvtRegister(&inserted_event, &el0, 0);
chEvtRegister(&removed_event, &el1, 1);
while (TRUE) {
if (!palReadPad(GPIOG, GPIOG_USER_BUTTON))
TestThread(&SD1);
chThdSleepMilliseconds(500);
if (!shelltp)
shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
else if (chThdTerminated(shelltp)) {
chThdRelease(shelltp); /* Recovers memory of the previous shell. */
shelltp = NULL; /* Triggers spawning of a new shell. */
}
chEvtDispatch(evhndl, chEvtWaitOne(ALL_EVENTS));
}
}

View File

@ -114,7 +114,7 @@
* SERIAL driver system settings.
*/
#define STM32_SERIAL_USE_USART1 TRUE
#define STM32_SERIAL_USE_USART2 TRUE
#define STM32_SERIAL_USE_USART2 FALSE
#define STM32_SERIAL_USE_USART3 FALSE
#define STM32_SERIAL_USE_UART4 FALSE
#define STM32_SERIAL_USE_UART5 FALSE

View File

@ -422,7 +422,8 @@ void sdc_lld_init(void) {
/**
* @brief Configures and activates the SDC peripheral.
*
* @param[in] sdcp pointer to the @p SDCDriver object
* @param[in] sdcp pointer to the @p SDCDriver object, must be @p NULL,
* this driver does not require any configuration
*
* @notapi
*/

View File

@ -113,13 +113,15 @@ void sdcObjectInit(SDCDriver *sdcp) {
* @brief Configures and activates the SDC peripheral.
*
* @param[in] sdcp pointer to the @p SDCDriver object
* @param[in] config pointer to the @p SDCConfig object
* @param[in] config pointer to the @p SDCConfig object, can be @p NULL if
* the driver supports a default configuration or
* requires no configuration
*
* @api
*/
void sdcStart(SDCDriver *sdcp, const SDCConfig *config) {
chDbgCheck((sdcp != NULL) && (config != NULL), "sdcStart");
chDbgCheck(sdcp != NULL, "sdcStart");
chSysLock();
chDbgAssert((sdcp->state == SDC_STOP) || (sdcp->state == SDC_READY),

View File

@ -73,8 +73,10 @@
*** 2.3.4 ***
- FIX: Fixed wrong macro definition in ARMv6-M architecture files (bug
3310084).
- NEW: FatFs demo for the STM32F103ZG using the SDC driver (untested).
- NEW: Now the STM32 SDC driver supports unaligned buffers transparently.
Optimized the driver for single block read and write operations.
Optimized the driver for single block read and write operations. Optimized
the driver state machine.
- NEW: Finished the reorganization of the Cortex-Mx ports, now also the
IAR and RVCT ports support the new Compact mode.
- NEW: Added to the ARMv6-M sub-port an option to use the PendSV exception