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-d51de3d6d3f4master
parent
9b147c2551
commit
03b4c7ddcb
|
@ -286,7 +286,7 @@ static const ShellCommand commands[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const ShellConfig shell_cfg1 = {
|
static const ShellConfig shell_cfg1 = {
|
||||||
(BaseChannel *)&SD2,
|
(BaseChannel *)&SD1,
|
||||||
commands
|
commands
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -302,11 +302,11 @@ static void InsertHandler(eventid_t id) {
|
||||||
|
|
||||||
(void)id;
|
(void)id;
|
||||||
/*
|
/*
|
||||||
* On insertion MMC initialization and FS mount.
|
* On insertion SDC initialization and FS mount.
|
||||||
*/
|
*/
|
||||||
if (sdcConnect(&SDCD1)) {
|
if (sdcConnect(&SDCD1))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
err = f_mount(0, &SDC_FS);
|
err = f_mount(0, &SDC_FS);
|
||||||
if (err != FR_OK) {
|
if (err != FR_OK) {
|
||||||
sdcDisconnect(&SDCD1);
|
sdcDisconnect(&SDCD1);
|
||||||
|
@ -321,6 +321,7 @@ static void InsertHandler(eventid_t id) {
|
||||||
static void RemoveHandler(eventid_t id) {
|
static void RemoveHandler(eventid_t id) {
|
||||||
|
|
||||||
(void)id;
|
(void)id;
|
||||||
|
if (sdcGetDriverState(&SDCD1) == SDC_ACTIVE)
|
||||||
sdcDisconnect(&SDCD1);
|
sdcDisconnect(&SDCD1);
|
||||||
fs_ready = FALSE;
|
fs_ready = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -352,6 +353,12 @@ static msg_t Thread1(void *arg) {
|
||||||
* Application entry point.
|
* Application entry point.
|
||||||
*/
|
*/
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
static const evhandler_t evhndl[] = {
|
||||||
|
InsertHandler,
|
||||||
|
RemoveHandler
|
||||||
|
};
|
||||||
|
Thread *shelltp = NULL;
|
||||||
|
struct EventListener el0, el1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* System initializations.
|
* System initializations.
|
||||||
|
@ -364,9 +371,16 @@ int main(void) {
|
||||||
chSysInit();
|
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);
|
sdStart(&SD1, NULL);
|
||||||
|
sdcStart(&SDCD1, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Shell manager initialization.
|
||||||
|
*/
|
||||||
|
shellInit();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Activates the card insertion monitor.
|
* Activates the card insertion monitor.
|
||||||
|
@ -380,11 +394,17 @@ int main(void) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Normal main() thread activity, in this demo it does nothing except
|
* 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) {
|
while (TRUE) {
|
||||||
if (!palReadPad(GPIOG, GPIOG_USER_BUTTON))
|
if (!shelltp)
|
||||||
TestThread(&SD1);
|
shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
|
||||||
chThdSleepMilliseconds(500);
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
* SERIAL driver system settings.
|
* SERIAL driver system settings.
|
||||||
*/
|
*/
|
||||||
#define STM32_SERIAL_USE_USART1 TRUE
|
#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_USART3 FALSE
|
||||||
#define STM32_SERIAL_USE_UART4 FALSE
|
#define STM32_SERIAL_USE_UART4 FALSE
|
||||||
#define STM32_SERIAL_USE_UART5 FALSE
|
#define STM32_SERIAL_USE_UART5 FALSE
|
||||||
|
|
|
@ -422,7 +422,8 @@ void sdc_lld_init(void) {
|
||||||
/**
|
/**
|
||||||
* @brief Configures and activates the SDC peripheral.
|
* @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
|
* @notapi
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -113,13 +113,15 @@ void sdcObjectInit(SDCDriver *sdcp) {
|
||||||
* @brief Configures and activates the SDC peripheral.
|
* @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
|
||||||
* @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
|
* @api
|
||||||
*/
|
*/
|
||||||
void sdcStart(SDCDriver *sdcp, const SDCConfig *config) {
|
void sdcStart(SDCDriver *sdcp, const SDCConfig *config) {
|
||||||
|
|
||||||
chDbgCheck((sdcp != NULL) && (config != NULL), "sdcStart");
|
chDbgCheck(sdcp != NULL, "sdcStart");
|
||||||
|
|
||||||
chSysLock();
|
chSysLock();
|
||||||
chDbgAssert((sdcp->state == SDC_STOP) || (sdcp->state == SDC_READY),
|
chDbgAssert((sdcp->state == SDC_STOP) || (sdcp->state == SDC_READY),
|
||||||
|
|
|
@ -73,8 +73,10 @@
|
||||||
*** 2.3.4 ***
|
*** 2.3.4 ***
|
||||||
- FIX: Fixed wrong macro definition in ARMv6-M architecture files (bug
|
- FIX: Fixed wrong macro definition in ARMv6-M architecture files (bug
|
||||||
3310084).
|
3310084).
|
||||||
|
- NEW: FatFs demo for the STM32F103ZG using the SDC driver (untested).
|
||||||
- NEW: Now the STM32 SDC driver supports unaligned buffers transparently.
|
- 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
|
- NEW: Finished the reorganization of the Cortex-Mx ports, now also the
|
||||||
IAR and RVCT ports support the new Compact mode.
|
IAR and RVCT ports support the new Compact mode.
|
||||||
- NEW: Added to the ARMv6-M sub-port an option to use the PendSV exception
|
- NEW: Added to the ARMv6-M sub-port an option to use the PendSV exception
|
||||||
|
|
Loading…
Reference in New Issue