48 MICRO_SD_PWR_PORT_DDR |= (1 << MICRO_SD_PWR_PIN);
53 MICRO_SD_PWR_PORT |= (1 << MICRO_SD_PWR_PIN);
65 for (i = 0; i < 16; i++) {
69 uint8_t cmd[6] = { 0x40, 0x00, 0x00, 0x00, 0x00, 0x95 };
98 uint8_t cmd[6] = { 0x51, 0x00, 0x00, 0x00, 0x00, 0xff };
102 cmd[1] = ((addr & 0xFF000000) >> 24);
103 cmd[2] = ((addr & 0x00FF0000) >> 16);
104 cmd[3] = ((addr & 0x0000FF00) >> 8);
110 printf(
"\nCMD17 failure!");
119 for (i = 0; i < 512; i++) {
132 uint8_t microSD_deinit(
void) {
133 MICRO_SD_PWR_PORT &= ~(1 << MICRO_SD_PWR_PIN);
140 uint8_t cmd[6] = { 0x58, 0x00, 0x00, 0x00, 0x00, 0xFF };
145 cmd[1] = ((addr & 0xFF000000) >> 24);
146 cmd[2] = ((addr & 0x00FF0000) >> 16);
147 cmd[3] = ((addr & 0x0000FF00) >> 8);
152 printf(
"\nCMD24 failure!");
157 for (i = 0; i < 10; i++) {
166 for (i = 0; i < 512; i++) {
177 printf(
"\nblock failure!");
200 for (i = 0; i < 6; i++) {
210 printf(
"\nwrite_cmd timeout!");
215 }
while (data == 0xFF);