SDC. Added RTC support. Improved testhal.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/sdc_dev2@4031 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
41895e5c36
commit
2b35b5a2a5
Binary file not shown.
|
@ -151,6 +151,7 @@ extern "C" {
|
|||
void rtcInit(void);
|
||||
void rtcSetTime(RTCDriver *rtcp, const RTCTime *timespec);
|
||||
void rtcGetTime(RTCDriver *rtcp, RTCTime *timespec);
|
||||
uint32_t rtcGetFatTime(RTCDriver *rtcp);
|
||||
#if RTC_ALARMS > 0
|
||||
void rtcSetAlarm(RTCDriver *rtcp,
|
||||
rtcalarm_t alarm,
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
|
@ -290,6 +292,28 @@ void rtc_lld_set_callback(RTCDriver *rtcp, rtccb_t callback) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get current time in format suitable for usage in FatFS.
|
||||
*
|
||||
* @param[in] timespec pointer to RTCTime structure
|
||||
* @return FAT time value.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
uint32_t rtc_lld_calc_fat_time(RTCTime *timespec){
|
||||
uint32_t fattime = 0;
|
||||
struct tm *timp;
|
||||
|
||||
timp = localtime((time_t *)(timespec->tv_sec));
|
||||
|
||||
fattime |= (timp->tm_sec / 2);
|
||||
fattime |= (timp->tm_min) << 5;
|
||||
fattime |= (timp->tm_hour) << 11;
|
||||
fattime |= (timp->tm_mday) << 16;
|
||||
fattime |= (timp->tm_mon + 1) << 21;
|
||||
fattime |= (timp->tm_year - 80) << 25;
|
||||
return fattime;
|
||||
}
|
||||
#endif /* HAL_USE_RTC */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -178,6 +178,7 @@ extern "C" {
|
|||
rtcalarm_t alarm,
|
||||
RTCAlarm *alarmspec);
|
||||
void rtc_lld_set_callback(RTCDriver *rtcp, rtccb_t callback);
|
||||
uint32_t rtc_lld_calc_fat_time(RTCTime *timespec);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -264,6 +264,29 @@ void rtcGetPeriodicWakeup_v2(RTCDriver *rtcp, RTCWakeup *wakeupspec){
|
|||
wakeupspec->wakeup |= (((uint32_t)rtcp->id_rtc->CR) & 0x7) << 16;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get current time in format suitable for usage in FatFS.
|
||||
*
|
||||
* @param[in] timespec pointer to RTCTime structure
|
||||
* @return FAT time value.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
uint32_t rtc_lld_calc_fat_time(RTCTime *timespec){
|
||||
uint32_t fattime = 0;
|
||||
struct tm timp;
|
||||
|
||||
stm32_rtc_bcd2tm(&timp, timespec);
|
||||
|
||||
fattime |= (timp.tm_sec / 2);
|
||||
fattime |= (timp.tm_min) << 5;
|
||||
fattime |= (timp.tm_hour) << 11;
|
||||
fattime |= (timp.tm_mday) << 16;
|
||||
fattime |= (timp.tm_mon + 1) << 21;
|
||||
fattime |= (timp.tm_year - 80) << 25;
|
||||
return fattime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Converts from STM32 BCD to canonicalized time format.
|
||||
*
|
||||
|
|
|
@ -200,6 +200,7 @@ extern "C" {
|
|||
RTCAlarm *alarmspec);
|
||||
void rtcSetPeriodicWakeup_v2(RTCDriver *rtcp, RTCWakeup *wakeupspec);
|
||||
void rtcGetPeriodicWakeup_v2(RTCDriver *rtcp, RTCWakeup *wakeupspec);
|
||||
uint32_t rtc_lld_calc_fat_time(RTCTime *timespec);
|
||||
void stm32_rtc_bcd2tm(struct tm *timp, RTCTime *timespec);
|
||||
void stm32_rtc_tm2bcd(struct tm *timp, RTCTime *timespec);
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -56,7 +56,7 @@ SDCDriver SDCD1;
|
|||
/* Driver local variables. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if STM32_SDC_UNALIGNED_SUPPORT
|
||||
#if STM32_SDC_SDIO_UNALIGNED_SUPPORT
|
||||
/**
|
||||
* @brief Buffer for temporary storage during unaligned transfers.
|
||||
*/
|
||||
|
@ -64,7 +64,7 @@ static union {
|
|||
uint32_t alignment;
|
||||
uint8_t buf[SDC_BLOCK_SIZE];
|
||||
} u;
|
||||
#endif
|
||||
#endif /* STM32_SDC_SDIO_UNALIGNED_SUPPORT */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local functions. */
|
||||
|
@ -706,7 +706,7 @@ error:
|
|||
bool_t sdc_lld_read(SDCDriver *sdcp, uint32_t startblk,
|
||||
uint8_t *buf, uint32_t n) {
|
||||
|
||||
#if STM32_SDC_UNALIGNED_SUPPORT
|
||||
#if STM32_SDC_SDIO_UNALIGNED_SUPPORT
|
||||
if (((unsigned)buf & 3) != 0) {
|
||||
uint32_t i;
|
||||
for (i = 0; i < n; i++) {
|
||||
|
@ -718,7 +718,7 @@ bool_t sdc_lld_read(SDCDriver *sdcp, uint32_t startblk,
|
|||
}
|
||||
return SDC_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
#endif /* STM32_SDC_SDIO_UNALIGNED_SUPPORT */
|
||||
return sdc_lld_read_aligned(sdcp, startblk, buf, n);
|
||||
}
|
||||
|
||||
|
@ -739,7 +739,7 @@ bool_t sdc_lld_read(SDCDriver *sdcp, uint32_t startblk,
|
|||
bool_t sdc_lld_write(SDCDriver *sdcp, uint32_t startblk,
|
||||
const uint8_t *buf, uint32_t n) {
|
||||
|
||||
#if STM32_SDC_UNALIGNED_SUPPORT
|
||||
#if STM32_SDC_SDIO_UNALIGNED_SUPPORT
|
||||
if (((unsigned)buf & 3) != 0) {
|
||||
uint32_t i;
|
||||
for (i = 0; i < n; i++) {
|
||||
|
@ -751,7 +751,7 @@ bool_t sdc_lld_write(SDCDriver *sdcp, uint32_t startblk,
|
|||
}
|
||||
return SDC_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
#endif /* STM32_SDC_SDIO_UNALIGNED_SUPPORT */
|
||||
return sdc_lld_write_aligned(sdcp, startblk, buf, n);
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,20 @@
|
|||
#define STM32_PLS_LEV7 (7 << 5) /**< PVD level 7. */
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Platform capabilities. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @name STM32F1xx capabilities
|
||||
* @{
|
||||
*/
|
||||
/* RTC attributes.*/
|
||||
#define STM32_HAS_RTC TRUE
|
||||
#define STM32_RTC_HAS_SUBSECONDS TRUE
|
||||
#define STM32_RTC_IS_CALENDAR TRUE
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -239,9 +239,6 @@
|
|||
#define STM32_SPI3_TX_DMA_MSK 0
|
||||
#define STM32_SPI3_TX_DMA_CHN 0x00000000
|
||||
|
||||
#define STM32_HAS_RTC TRUE
|
||||
#define STM32_RTCSEL_HAS_SUBSECONDS TRUE
|
||||
|
||||
/* SDIO attributes.*/
|
||||
#define STM32_HAS_SDIO FALSE
|
||||
|
||||
|
|
|
@ -249,10 +249,6 @@
|
|||
#define STM32_SPI3_TX_DMA_MSK 0
|
||||
#define STM32_SPI3_TX_DMA_CHN 0x00000000
|
||||
|
||||
/* RTC attributes.*/
|
||||
#define STM32_HAS_RTC TRUE
|
||||
#define STM32_RTCSEL_HAS_SUBSECONDS TRUE
|
||||
|
||||
/* SDIO attributes.*/
|
||||
#define STM32_HAS_SDIO FALSE
|
||||
|
||||
|
|
|
@ -266,10 +266,6 @@
|
|||
#define STM32_I2C3_TX_DMA_MSK 0
|
||||
#define STM32_I2C3_TX_DMA_CHN 0x00000000
|
||||
|
||||
/* RTC attributes.*/
|
||||
#define STM32_HAS_RTC TRUE
|
||||
#define STM32_RTCSEL_HAS_SUBSECONDS TRUE
|
||||
|
||||
/* SDIO attributes.*/
|
||||
#define STM32_HAS_SDIO FALSE
|
||||
|
||||
|
|
|
@ -337,6 +337,7 @@
|
|||
/* RTC attributes.*/
|
||||
#define STM32_HAS_RTC TRUE
|
||||
#define STM32_RTC_HAS_SUBSECONDS TRUE
|
||||
#define STM32_RTC_IS_CALENDAR TRUE
|
||||
|
||||
/* SDIO attributes.*/
|
||||
#define STM32_HAS_SDIO TRUE
|
||||
|
|
|
@ -336,6 +336,7 @@
|
|||
/* RTC attributes.*/
|
||||
#define STM32_HAS_RTC TRUE
|
||||
#define STM32_RTC_HAS_SUBSECONDS TRUE
|
||||
#define STM32_RTC_IS_CALENDAR TRUE
|
||||
|
||||
/* SDIO attributes.*/
|
||||
#define STM32_HAS_SDIO TRUE
|
||||
|
|
|
@ -233,6 +233,7 @@
|
|||
/* RTC attributes.*/
|
||||
#define STM32_HAS_RTC TRUE
|
||||
#define STM32_RTC_HAS_SUBSECONDS FALSE
|
||||
#define STM32_RTC_IS_CALENDAR TRUE
|
||||
|
||||
/* SDIO attributes.*/
|
||||
#define STM32_HAS_SDIO FALSE
|
||||
|
|
|
@ -101,6 +101,26 @@ void rtcGetTime(RTCDriver *rtcp, RTCTime *timespec) {
|
|||
chSysUnlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get current time in format suitable for usage in FatFS.
|
||||
*
|
||||
* @param[in] rtcp pointer to RTC driver structure
|
||||
* @return FAT time value.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
uint32_t rtcGetFatTime(RTCDriver *rtcp) {
|
||||
RTCTime timespec;
|
||||
|
||||
chDbgCheck((rtcp != NULL), "rtcGetTime");
|
||||
|
||||
chSysLock();
|
||||
rtcGetTimeI(rtcp, ×pec);
|
||||
chSysUnlock();
|
||||
|
||||
return rtc_lld_calc_fat_time(×pec);
|
||||
}
|
||||
|
||||
#if (RTC_ALARMS > 0) || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Set alarm time.
|
||||
|
|
|
@ -67,6 +67,7 @@ include $(CHIBIOS)/os/hal/platforms/STM32F4xx/platform.mk
|
|||
include $(CHIBIOS)/os/hal/hal.mk
|
||||
include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F4xx/port.mk
|
||||
include $(CHIBIOS)/os/kernel/kernel.mk
|
||||
include $(CHIBIOS)/ext/fatfs/fatfs.mk
|
||||
#include $(CHIBIOS)/test/test.mk
|
||||
|
||||
# Define linker script file here
|
||||
|
@ -80,8 +81,11 @@ CSRC = $(PORTSRC) \
|
|||
$(HALSRC) \
|
||||
$(PLATFORMSRC) \
|
||||
$(BOARDSRC) \
|
||||
$(FATFSSRC) \
|
||||
$(CHIBIOS)/os/various/evtimer.c \
|
||||
$(CHIBIOS)/os/various/syscalls.c \
|
||||
$(CHIBIOS)/os/various/shell.c \
|
||||
$(CHIBIOS)/os/various/chprintf.c \
|
||||
main.c
|
||||
|
||||
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
||||
|
@ -113,6 +117,7 @@ ASMSRC = $(PORTASM)
|
|||
|
||||
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
|
||||
$(HALINC) $(PLATFORMINC) $(BOARDINC) \
|
||||
$(CHIBIOS)/os/various $(FATFSINC) \
|
||||
$(CHIBIOS)/os/various
|
||||
|
||||
#
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
#ifndef _CHCONF_H_
|
||||
#define _CHCONF_H_
|
||||
|
||||
#define CORTEX_USE_FPU FALSE
|
||||
#define PORT_IDLE_THREAD_STACK_SIZE 32
|
||||
#define CORTEX_USE_FPU FALSE
|
||||
|
||||
/*===========================================================================*/
|
||||
/**
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
* @brief Enables the RTC subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_RTC FALSE
|
||||
#define HAL_USE_RTC TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -122,7 +122,7 @@
|
|||
* @brief Enables the SERIAL subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_SERIAL FALSE
|
||||
#define HAL_USE_SERIAL TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,13 +22,22 @@
|
|||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
#include "shell.h"
|
||||
#include "chprintf.h"
|
||||
|
||||
#define SDC_DATA_DESTRUCTIVE_TEST TRUE
|
||||
#include "ff.h"
|
||||
|
||||
#define SDC_DATA_DESTRUCTIVE_TEST FALSE
|
||||
|
||||
#define SDC_BURST_SIZE 8 /* how many sectors reads at once */
|
||||
static uint8_t outbuf[SDC_BLOCK_SIZE * SDC_BURST_SIZE + 1];
|
||||
static uint8_t inbuf[SDC_BLOCK_SIZE * SDC_BURST_SIZE + 1];
|
||||
|
||||
/* FS object.*/
|
||||
static FATFS SDC_FS;
|
||||
|
||||
/* FS mounted and ready.*/
|
||||
static bool_t fs_ready = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Parody of UNIX badblocks program.
|
||||
|
@ -93,42 +102,49 @@ void fillbuffers(uint8_t pattern){
|
|||
fillbuffer(pattern, outbuf);
|
||||
}
|
||||
|
||||
/*
|
||||
* SDIO configuration.
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static const SDCConfig sdccfg = {
|
||||
0
|
||||
};
|
||||
bool_t sdc_lld_is_write_protected(SDCDriver *sdcp) {
|
||||
(void)sdcp;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Application entry point.
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int main(void) {
|
||||
void cmd_sdiotest(BaseChannel *chp, int argc, char *argv[]){
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
uint32_t i = 0;
|
||||
|
||||
halInit();
|
||||
chSysInit();
|
||||
|
||||
/*
|
||||
* Initializes the SDIO drivers.
|
||||
*/
|
||||
sdcStart(&SDCD1, &sdccfg);
|
||||
chprintf(chp, "Trying to connect SDIO... ");
|
||||
chThdSleepMilliseconds(100);
|
||||
|
||||
if (!sdcConnect(&SDCD1)) {
|
||||
|
||||
/* Single aligned read.*/
|
||||
chprintf(chp, "OK\r\nSingle aligned read...");
|
||||
chThdSleepMilliseconds(100);
|
||||
if (sdcRead(&SDCD1, 0, inbuf, 1))
|
||||
chSysHalt();
|
||||
chprintf(chp, " OK\r\n");
|
||||
chThdSleepMilliseconds(100);
|
||||
|
||||
/* Single unaligned read.*/
|
||||
|
||||
chprintf(chp, "Single unaligned read...");
|
||||
chThdSleepMilliseconds(100);
|
||||
if (sdcRead(&SDCD1, 0, inbuf + 1, 1))
|
||||
chSysHalt();
|
||||
if (sdcRead(&SDCD1, 0, inbuf + 2, 1))
|
||||
chSysHalt();
|
||||
if (sdcRead(&SDCD1, 0, inbuf + 3, 1))
|
||||
chSysHalt();
|
||||
chprintf(chp, " OK\r\n");
|
||||
chThdSleepMilliseconds(100);
|
||||
|
||||
/* Multiple aligned reads from one place to ensure in bus stability */
|
||||
|
||||
chprintf(chp, "Multiple aligned reads...");
|
||||
chThdSleepMilliseconds(100);
|
||||
fillbuffers(0x55);
|
||||
/* fill reference buffer from SD card */
|
||||
if (sdcRead(&SDCD1, 0, inbuf, SDC_BURST_SIZE))
|
||||
|
@ -139,8 +155,12 @@ int main(void) {
|
|||
if (memcmp(inbuf, outbuf, SDC_BURST_SIZE * SDC_BLOCK_SIZE) != 0)
|
||||
chSysHalt();
|
||||
}
|
||||
chprintf(chp, " OK\r\n");
|
||||
chThdSleepMilliseconds(100);
|
||||
|
||||
/* Repeated multiple unaligned reads.*/
|
||||
|
||||
chprintf(chp, "Multiple unaligned reads...");
|
||||
chThdSleepMilliseconds(100);
|
||||
fillbuffers(0x55);
|
||||
/* fill reference buffer from SD card */
|
||||
if (sdcRead(&SDCD1, 0, inbuf + 1, SDC_BURST_SIZE))
|
||||
|
@ -151,16 +171,13 @@ int main(void) {
|
|||
if (memcmp(inbuf, outbuf, SDC_BURST_SIZE * SDC_BLOCK_SIZE) != 0)
|
||||
chSysHalt();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
chprintf(chp, " OK\r\n");
|
||||
chThdSleepMilliseconds(100);
|
||||
|
||||
#if SDC_DATA_DESTRUCTIVE_TEST
|
||||
|
||||
/* Single aligned write.*/
|
||||
chprintf(chp, "Single aligned write...");
|
||||
chThdSleepMilliseconds(100);
|
||||
fillbuffer(0xAA, inbuf);
|
||||
if (sdcWrite(&SDCD1, 0, inbuf, 1))
|
||||
chSysHalt();
|
||||
|
@ -169,8 +186,10 @@ int main(void) {
|
|||
chSysHalt();
|
||||
if (memcmp(inbuf, outbuf, SDC_BLOCK_SIZE) != 0)
|
||||
chSysHalt();
|
||||
chprintf(chp, " OK\r\n");
|
||||
|
||||
/* Single unaligned write.*/
|
||||
chprintf(chp, "Single unaligned write...");
|
||||
chThdSleepMilliseconds(100);
|
||||
fillbuffer(0xFF, inbuf);
|
||||
if (sdcWrite(&SDCD1, 0, inbuf+1, 1))
|
||||
chSysHalt();
|
||||
|
@ -179,24 +198,152 @@ int main(void) {
|
|||
chSysHalt();
|
||||
if (memcmp(inbuf+1, outbuf+1, SDC_BLOCK_SIZE) != 0)
|
||||
chSysHalt();
|
||||
chprintf(chp, " OK\r\n");
|
||||
|
||||
|
||||
chprintf(chp, "Running badblocks at 0x10000 offset...");
|
||||
chThdSleepMilliseconds(100);
|
||||
if(badblocks(0x10000, 0x11000, SDC_BURST_SIZE, 0xAA))
|
||||
chSysHalt();
|
||||
chprintf(chp, " OK\r\n");
|
||||
#endif /* !SDC_DATA_DESTRUCTIVE_TEST */
|
||||
|
||||
|
||||
/**
|
||||
* Now some perform FS tests.
|
||||
*/
|
||||
|
||||
FRESULT err;
|
||||
uint32_t clusters;
|
||||
FATFS *fsp;
|
||||
FIL FileObject;
|
||||
uint32_t bytes_written;
|
||||
|
||||
|
||||
chprintf(chp, "Register working area for filesystem... ");
|
||||
chThdSleepMilliseconds(100);
|
||||
err = f_mount(0, &SDC_FS);
|
||||
if (err != FR_OK){
|
||||
chSysHalt();
|
||||
}
|
||||
else{
|
||||
fs_ready = TRUE;
|
||||
chprintf(chp, "OK\r\n");
|
||||
}
|
||||
|
||||
|
||||
#if SDC_DATA_DESTRUCTIVE_TEST
|
||||
chprintf(chp, "Formatting... ");
|
||||
chThdSleepMilliseconds(100);
|
||||
err = f_mkfs (0,0,0);
|
||||
if (err != FR_OK){
|
||||
chSysHalt();
|
||||
}
|
||||
else{
|
||||
chprintf(chp, "OK\r\n");
|
||||
}
|
||||
#endif /* SDC_DATA_DESTRUCTIVE_TEST */
|
||||
|
||||
|
||||
chprintf(chp, "Mount filesystem... ");
|
||||
chThdSleepMilliseconds(100);
|
||||
err = f_getfree("/", &clusters, &fsp);
|
||||
if (err != FR_OK) {
|
||||
chSysHalt();
|
||||
}
|
||||
chprintf(chp, "OK\r\n");
|
||||
chprintf(chp,
|
||||
"FS: %lu free clusters, %lu sectors per cluster, %lu bytes free\r\n",
|
||||
clusters, (uint32_t)SDC_FS.csize,
|
||||
clusters * (uint32_t)SDC_FS.csize * (uint32_t)SDC_BLOCK_SIZE);
|
||||
|
||||
|
||||
chprintf(chp, "Create file \"chtest.txt\"... ");
|
||||
chThdSleepMilliseconds(100);
|
||||
err = f_open(&FileObject, "0:chtest.txt", FA_WRITE | FA_OPEN_ALWAYS);
|
||||
if (err != FR_OK) {
|
||||
chSysHalt();
|
||||
}
|
||||
chprintf(chp, "OK\r\n");
|
||||
chprintf(chp, "Write some data in it... ");
|
||||
chThdSleepMilliseconds(100);
|
||||
err = f_write(&FileObject, "This is test file", 17, (void *)&bytes_written);
|
||||
if (err != FR_OK) {
|
||||
chSysHalt();
|
||||
}
|
||||
else
|
||||
chprintf(chp, "OK\r\n");
|
||||
|
||||
|
||||
chprintf(chp, "Close file \"chtest.txt\"... ");
|
||||
err = f_close(&FileObject);
|
||||
if (err != FR_OK) {
|
||||
chSysHalt();
|
||||
}
|
||||
else
|
||||
chprintf(chp, "OK\r\n");
|
||||
|
||||
chprintf(chp, "Umount filesystem... ");
|
||||
f_mount(0, NULL);
|
||||
chprintf(chp, "OK\r\n");
|
||||
|
||||
|
||||
chprintf(chp, "Disconnecting from SDIO...");
|
||||
chThdSleepMilliseconds(100);
|
||||
if (sdcDisconnect(&SDCD1))
|
||||
chSysHalt();
|
||||
chprintf(chp, " OK\r\n");
|
||||
chprintf(chp, "------------------------------------------------------\r\n");
|
||||
chprintf(chp, "All tests passed successfully.\r\n");
|
||||
chThdSleepMilliseconds(100);
|
||||
}
|
||||
else{
|
||||
chSysHalt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* SDIO configuration.
|
||||
*/
|
||||
static const SDCConfig sdccfg = {
|
||||
0
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static SerialConfig ser_cfg = {
|
||||
115200,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
static const ShellCommand commands[] = {
|
||||
{"sdiotest", cmd_sdiotest},
|
||||
{NULL, NULL}
|
||||
};
|
||||
static const ShellConfig shell_cfg1 = {
|
||||
(BaseChannel *)&SD2,
|
||||
commands
|
||||
};
|
||||
|
||||
/*
|
||||
* Application entry point.
|
||||
*/
|
||||
int main(void) {
|
||||
halInit();
|
||||
chSysInit();
|
||||
|
||||
/* start debugging serial link */
|
||||
sdStart(&SD2, &ser_cfg);
|
||||
shellInit();
|
||||
static WORKING_AREA(waShell, 2048);
|
||||
shellCreateStatic(&shell_cfg1, waShell, sizeof(waShell), NORMALPRIO);
|
||||
|
||||
/*
|
||||
* Initializes the SDIO drivers.
|
||||
*/
|
||||
sdcStart(&SDCD1, &sdccfg);
|
||||
|
||||
/*
|
||||
* Normal main() thread activity.
|
||||
|
@ -204,6 +351,6 @@ int main(void) {
|
|||
*/
|
||||
while (TRUE) {
|
||||
palTogglePad(GPIOB, GPIOB_LED_R);
|
||||
chThdSleepMilliseconds(500);
|
||||
chThdSleepMilliseconds(100);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue