Add correct handling of sd card, add reset command, add ls command
This commit is contained in:
@@ -32,9 +32,9 @@ static struct sd_info card_info; // = {.type = CARD_NONE};
|
||||
* @brief checkNotInserted
|
||||
* @return return 0 if card is inserted, else 1
|
||||
*/
|
||||
static int sdio_check_inserted() {
|
||||
int sdio_check_inserted() {
|
||||
#if SDIO_ENABLE_INS
|
||||
return ((INS_PORT->IDR & INS_PIN) == (INS_ACTIVE_LEVEL<<INS_PIN) ? 0 : 1);
|
||||
return ((INS_PORT->IDR & (1<<INS_PIN)) == (INS_ACTIVE_LEVEL<<INS_PIN) ? 0 : 1);
|
||||
#else
|
||||
return 0; // Assume Card is inserted
|
||||
#endif
|
||||
@@ -46,7 +46,7 @@ static int sdio_check_inserted() {
|
||||
*/
|
||||
static int sdio_check_write_protection() {
|
||||
#if SDIO_ENABLE_WRITEPROT
|
||||
return ((WRITEPROT_PORT->IDR & WRITEPROT_PIN) == (WRITEPROT_ACTIVE_LEVEL<<WRITEPROT_PIN) ? 1 : 0);
|
||||
return ((WRITEPROT_PORT->IDR & (1<<WRITEPROT_PIN)) == (WRITEPROT_ACTIVE_LEVEL<<WRITEPROT_PIN) ? 1 : 0);
|
||||
#else
|
||||
return 0; // Assume Card is not write protected
|
||||
#endif
|
||||
|
@@ -20,6 +20,8 @@ DRESULT sdio_disk_write(const BYTE *buff, DWORD sector, UINT count);
|
||||
DRESULT sdio_disk_ioctl(BYTE cmd, void* buff);
|
||||
DWORD get_fattime();
|
||||
|
||||
int sdio_check_inserted();
|
||||
|
||||
|
||||
//Defines for Card Status in struct _CardStatus
|
||||
#define CURRENT_STATE_IDLE 0
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
/* Port Definitions */
|
||||
|
||||
#define PORTCLKMASK (RCC_AHB1ENR_GPIODEN | RCC_AHB1ENR_GPIOCEN)
|
||||
#define PORTCLKMASK (RCC_AHB1ENR_GPIODEN | RCC_AHB1ENR_GPIOCEN | RCC_AHB1ENR_GPIOAEN)
|
||||
|
||||
#define ALTFUNC 12
|
||||
|
||||
@@ -50,10 +50,10 @@
|
||||
#define WRITEPROT_ACTIVE_LEVEL 0
|
||||
|
||||
// Card inserted pin
|
||||
#define SDIO_ENABLE_INS 0
|
||||
#define INS_PORT GPIOD // Add this port to port clock mask!
|
||||
#define INS_PIN 0
|
||||
#define INS_PULLUP 0
|
||||
#define SDIO_ENABLE_INS 1
|
||||
#define INS_PORT GPIOA // Add this port to port clock mask!
|
||||
#define INS_PIN 8
|
||||
#define INS_PULLUP 1
|
||||
#define INS_ACTIVE_LEVEL 0
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user