#include "hal_define.h"
#include "sys_define.h"
#include "fs_define.h"
Go to the source code of this file.
|
| #define | INIT_PORT() HAL_SPI_Init() /* Initialize MMC control port */ |
| |
| #define | FAST_MODE() SYS_MMC_FastMode() /* Maximize SD Card transfer speed */ |
| |
| #define | DLY_US(n) __delay_cycles(n * 12) |
| |
| #define | CS_H() SYS_MMC_DeselectCard() /* Set MMC CS "high" */ |
| |
| #define | CS_L() SYS_MMC_SelectCard() /* Set MMC CS "low" */ |
| |
| #define | WP (0) /* Card is write protected (yes:true, no:false, default:false) */ |
| |
| #define | CMD0 (0) /* GO_IDLE_STATE */ |
| |
| #define | CMD1 (1) /* SEND_OP_COND */ |
| |
| #define | ACMD41 (0x80 + 41) /* SEND_OP_COND (SDC) */ |
| |
| #define | CMD8 (8) /* SEND_IF_COND */ |
| |
| #define | CMD9 (9) /* SEND_CSD */ |
| |
| #define | CMD10 (10) /* SEND_CID */ |
| |
| #define | CMD12 (12) /* STOP_TRANSMISSION */ |
| |
| #define | ACMD13 (0x80 + 13) /* SD_STATUS (SDC) */ |
| |
| #define | CMD16 (16) /* SET_BLOCKLEN */ |
| |
| #define | CMD17 (17) /* READ_SINGLE_BLOCK */ |
| |
| #define | CMD18 (18) /* READ_MULTIPLE_BLOCK */ |
| |
| #define | CMD23 (23) /* SET_BLOCK_COUNT */ |
| |
| #define | ACMD23 (0x80 + 23) /* SET_WR_BLK_ERASE_COUNT (SDC) */ |
| |
| #define | CMD24 (24) /* WRITE_BLOCK */ |
| |
| #define | CMD25 (25) /* WRITE_MULTIPLE_BLOCK */ |
| |
| #define | CMD41 (41) /* SEND_OP_COND (ACMD) */ |
| |
| #define | CMD55 (55) /* APP_CMD */ |
| |
| #define | CMD58 (58) /* READ_OCR */ |
| |
| #define ACMD13 (0x80 + 13) /* SD_STATUS (SDC) */ |
| #define ACMD23 (0x80 + 23) /* SET_WR_BLK_ERASE_COUNT (SDC) */ |
| #define ACMD41 (0x80 + 41) /* SEND_OP_COND (SDC) */ |
| #define CMD0 (0) /* GO_IDLE_STATE */ |
| #define CMD1 (1) /* SEND_OP_COND */ |
| #define CMD10 (10) /* SEND_CID */ |
| #define CMD12 (12) /* STOP_TRANSMISSION */ |
| #define CMD16 (16) /* SET_BLOCKLEN */ |
| #define CMD17 (17) /* READ_SINGLE_BLOCK */ |
| #define CMD18 (18) /* READ_MULTIPLE_BLOCK */ |
| #define CMD23 (23) /* SET_BLOCK_COUNT */ |
| #define CMD24 (24) /* WRITE_BLOCK */ |
| #define CMD25 (25) /* WRITE_MULTIPLE_BLOCK */ |
| #define CMD41 (41) /* SEND_OP_COND (ACMD) */ |
| #define CMD55 (55) /* APP_CMD */ |
| #define CMD58 (58) /* READ_OCR */ |
| #define CMD8 (8) /* SEND_IF_COND */ |
| #define CMD9 (9) /* SEND_CSD */ |
| #define DLY_US |
( |
|
n | ) |
__delay_cycles(n * 12) |
| #define INIT_PORT |
( |
| ) |
HAL_SPI_Init() /* Initialize MMC control port */ |
| #define WP (0) /* Card is write protected (yes:true, no:false, default:false) */ |
| unsigned char detectCard |
( |
void |
| ) |
|
Definition at line 386 of file diskio.c.
{
#pragma diag_suppress=Pe550
return ( s) ;
}
for (n = 10; n; n--){rcvr_mmc(buf, 1);
}
ty = 0;
if (send_cmd(
CMD0, 0) == 1){
if (send_cmd(
CMD8, 0x1AA) == 1){
rcvr_mmc(buf, 4);
if (buf[2] == 0x01 && buf[3] == 0xAA){
for (tmr = 1000; tmr; tmr--)
{
if (send_cmd(
ACMD41, 1UL << 30) == 0){
break;
}
}
if (tmr && send_cmd(
CMD58, 0) == 0){
rcvr_mmc(buf, 4);
}
}
} else {
if (send_cmd(
ACMD41, 0) <= 1){
} else {
}
for (tmr = 1000; tmr; tmr--)
{
if (send_cmd(
ACMD41, 0) == 0){
break;
}
}
if (!tmr || send_cmd(
CMD16, 512) != 0){
ty = 0;
}
}
}
CardType = ty;
deselect();
if (ty){
} else {
}
Stat = s;
return (s);
}
Definition at line 461 of file diskio.c.
{
}
if (!count){
}
sector *= 512;
}
if (count == 1){
if ((send_cmd(
CMD17, sector) == 0)
&& rcvr_datablock(buff, 512)){
count = 0;
}
} else {
if (send_cmd(
CMD18, sector) == 0){
do {
if (!rcvr_datablock(buff, 512)){
break;
}
buff += 512;
} while (--count);
}
}
deselect();
}
Definition at line 301 of file diskio.c.
{
} else {
} else {
}
}
Stat = s;
return (s);
}
| DWORD get_fattime |
( |
void |
| ) |
|
| uint8_t validateCSD |
( |
void |
| ) |
|
Definition at line 323 of file diskio.c.
{
BYTE csd0[16], csd1[16], i;
if ((send_cmd(
CMD9, 0) == 0) && rcvr_datablock(csd0, 16)){
if ((send_cmd(
CMD9, 0) == 0) && rcvr_datablock(csd1, 16)){
for (i = 0; i <= 15; i++){
sum += csd0[i];
}
if (!((sum == 0) || (sum == 4096))){
i = 0;
while (i <= 15)
{
if (csd0[i] != csd1[i]){
break;
}
i++;
}
if (i > 15){
return ( 1) ;
}
}
}
}
return ( 0) ;
}