updating things

stable
penguin 4 years ago
parent 8b6ad41411
commit 6a874d4c2d

@ -1,96 +1,121 @@
s
s
n
p resp
p/x resp
s
s
s
s
ss
s
q
q
tar ext /dev/ttyACM0
q
mon s
q
tar ext /dev/ttyS0
detach 1
detach
q
tar ext /dev/ttyS0
tar ext /dev/ttyS1
tar ext /dev/ttyS2
mon s
q
tar ext /dev/ttyS3
q
mon s
mon s
mon s
mon s
mon s
mon s
tar ext /dev/ttyS3
tar ext /dev/ttyS2
tar ext /dev/ttyS1
tar ext /dev/ttyS0
q
tar ext /dev/ttyACM0
mon s
tar ext /dev/ttyS0
q
mon s
tar ext /dev/ttyS0
q
tar ext /dev/ttyACM0
mon s
q
q
q
tar ext /dev/blackmagic_0
mon s
q
tar ext /dev/blackmagic_0
mon s
attach 1
detach
q
n
n
n
s
n
c
r
n
c
r
n
n
n
s
s
s
break sd_mmc.c:1616
n
break
c
q
n
n
n
s
c
r
n
n
n
s
n
n
n
s
s
finish
finish
s
s
break sd_mmc.c:50
r
c
s
s
s
s
s
n
n
s
s
s
s
s
s
s
s
s
s
s
s
finish
q
n
n
n
c
s
break sd_mmc.c:50
c
break sd_mmc.c:56
c
r
c
s
n
n
n
n
n
n
n
n
n
s
n
n
n
n
q
break sd_mmc.c:50
c
s
s
n
n
n
n
r
c
s
s
@ -115,32 +140,31 @@ s
s
s
s
finish
n
n
s
s
s
finish
finish
s
s
s
s
n
n
n
n
n
f
finish
n
n
n
n
n
n
n
s
s
q
break sd_mmc.c:50
r
c
s
s
n
n
r
c
s
s
s
s
@ -152,9 +176,6 @@ s
s
s
s
n
n
n
s
s
s
@ -162,10 +183,7 @@ s
s
s
finish
n
n
n
c
finish
s
s
s
@ -173,84 +191,66 @@ s
s
s
s
finish
finish
s
p res7[1]
s
break sd_mmc.c:220
r
c
c
q
break sd_mmc.c:210
r
c
s
s
s
s
s
n
n
n
n
s
s
s
s
n
n
n
n
finish
finish
s
s
n
p resp
p/x resp
s
s
s
finish
s
s
p ret
p ret
s
s
s
s
p ret
s
sq
q
q
tar ext /dev/ttyACM0
q
mon s
q
tar ext /dev/ttyS0
detach 1
detach
q
tar ext /dev/ttyS0
tar ext /dev/ttyS1
tar ext /dev/ttyS2
mon s
q
tar ext /dev/ttyS3
q
tar ext /dev/ttyS3
tar ext /dev/ttyS2
tar ext /dev/ttyS1
tar ext /dev/ttyS0
q
tar ext /dev/ttyS0
q
tar ext /dev/ttyS0
q
q
q
q
tar ext /dev/blackmagic_0
mon s
q
tar ext /dev/blackmagic_0
mon s
attach 1
detach
q
n
break sd_mmc.c:38
c
n
n
s
n
q
break sd_mmc.c:30
c
r
n
c
r
n
n
n
s
s
n
break
n
n
q
break sd_mmc.c:306
c
q

File diff suppressed because it is too large Load Diff

@ -18,10 +18,12 @@ static void sd_mmc_send_clock(void);
static void sd_mmc_print_err(sd_mmc_err_t err);
static void sd_mmc_print_res1(uint8_t res);
static void sd_mmc_print_res7(const uint8_t* const res);
static void sd_mmc_print_res3(const uint8_t* const res);
sd_mmc_err_t sd_mmc_init(void)
{
sd_mmc_err_t ret = SD_MMC_SUCCESS;
uint8_t ocr[5];
do
{
@ -33,19 +35,25 @@ sd_mmc_err_t sd_mmc_init(void)
}
// Power up sd card sequence
if((ret != sd_mmc_power_up_sequence()) != SD_MMC_SUCCESS)
if((ret = sd_mmc_power_up_sequence()) != SD_MMC_SUCCESS)
{
break;
}
// go idle
if((ret != sd_mmc_idle_sequence()) != SD_MMC_SUCCESS)
if((ret = sd_mmc_idle_sequence()) != SD_MMC_SUCCESS)
{
break;
}
// interface sequence
if((ret != sd_mmc_if_sequence()) != SD_MMC_SUCCESS)
if((ret = sd_mmc_if_sequence()) != SD_MMC_SUCCESS)
{
break;
}
// read operation conditions register
if((ret = sd_mmc_read_ocr(ocr)) != SD_MMC_SUCCESS)
{
break;
}
@ -126,12 +134,12 @@ sd_mmc_err_t sd_mmc_read_res7(uint8_t* res7)
break;
}
if(res7[0] > 1)
{
// handle this error better later
ret = SD_MMC_ERR_COMM;
break;
}
/* if(res7[0] > 1) */
/* { */
/* // handle this error better later */
/* ret = SD_MMC_ERR_COMM; */
/* break; */
/* } */
}while(0);
return ret;
}
@ -141,18 +149,19 @@ sd_mmc_err_t sd_mmc_read_res3(uint8_t* res3)
sd_mmc_err_t ret = SD_MMC_SUCCESS;
do
{
SD_MMC_INTF_READ(res3, 1);
if(5 != SD_MMC_INTF_READ(res3, 5))
{
ret = SD_MMC_ERR_COMM;
break;
}
if(res3[0] > 1)
{
// handle this error better later
ret = SD_MMC_ERR_COMM;
break;
}
/* if(res3[0] > 1) */
/* { */
/* // handle this error better later */
/* ret = SD_MMC_ERR_COMM; */
/* break; */
/* } */
}while(0);
return ret;
@ -175,12 +184,12 @@ sd_mmc_err_t sd_mmc_idle_sequence()
do
{
sd_mmc_select(0, 0, 0, true);
if((ret != sd_mmc_send_command(CMD0, CMD0_ARG, CMD0_CRC)) != SD_MMC_SUCCESS)
if((ret = sd_mmc_send_command(CMD0, CMD0_ARG, CMD0_CRC)) != SD_MMC_SUCCESS)
{
break;
}
if((ret != sd_mmc_read_res1(&res1)) != SD_MMC_SUCCESS)
if((ret = sd_mmc_read_res1(&res1)) != SD_MMC_SUCCESS)
{
break;
}
@ -272,6 +281,7 @@ void sd_mmc_print_err(sd_mmc_err_t err)
void sd_mmc_print_res1(uint8_t res)
{
printf("RES1: 0x%02x\n", res);
if(res & 0b10000000)
{ printf("\tError: MSB = 1\r\n"); return; }
if(res == 0)
@ -295,7 +305,7 @@ void sd_mmc_print_res1(uint8_t res)
void sd_mmc_print_res7(const uint8_t* const res)
{
sd_mmc_print_res1(res[0]);
if(res[0] > 1) return;
/* if(res[0] > 1) return; */
printf("\tCommand Version: 0x%02x\n", CMD_VER(res[1]));
@ -307,6 +317,35 @@ void sd_mmc_print_res7(const uint8_t* const res)
printf("\tEcho: 0x%02x\n", res[4]);
}
void sd_mmc_print_res3(const uint8_t* const res)
{
sd_mmc_print_res1(res[0]);
/* if(res[0] > 1) return; */
printf("\tCard Power Up Status: 0x%02x\n", res[1]);
if(POWER_UP_STATUS(res[1]))
{
printf("READY\n");
printf("\tCCS Status: %d\n", CCS_VAL(res[1]) ? 1 : 0);
}
else
{
printf("BUSY\n");
}
printf("\tVDD Window: ");
if(VDD_2728(res[3])) printf("2.7-2.8, ");
if(VDD_2829(res[2])) printf("2.8-2.9, ");
if(VDD_2930(res[2])) printf("2.9-3.0, ");
if(VDD_3031(res[2])) printf("3.0-3.1, ");
if(VDD_3132(res[2])) printf("3.1-3.2, ");
if(VDD_3233(res[2])) printf("3.2-3.3, ");
if(VDD_3334(res[2])) printf("3.3-3.4, ");
if(VDD_3435(res[2])) printf("3.4-3.5, ");
if(VDD_3536(res[2])) printf("3.5-3.6");
printf("\n");
}
bool sd_mmc_check_cd(void)
{
@ -347,8 +386,6 @@ void sd_mmc_send_clock()
sd_mmc_err_t sd_mmc_read_ocr(uint8_t* res)
{
sd_mmc_err_t ret = SD_MMC_SUCCESS;
uint8_t res3[5];
sd_mmc_select(0, 0, 0, false);
do
{
@ -357,10 +394,11 @@ sd_mmc_err_t sd_mmc_read_ocr(uint8_t* res)
break;
}
if((ret = sd_mmc_read_res3(res3)) != SD_MMC_SUCCESS)
if((ret = sd_mmc_read_res3(res)) != SD_MMC_SUCCESS)
{
break;
}
sd_mmc_print_res3(res);
}while(0);
sd_mmc_deselect(0);
return ret;

@ -78,5 +78,16 @@ sd_mmc_err_t sd_mmc_send_command(uint8_t cmd, uint32_t arg, uint8_t crc);
#define VOLTAGE_ACC_RES1 0b00000100
#define VOLTAGE_ACC_RES2 0b00001000
#define POWER_UP_STATUS(X) X & 0x40
#define CCS_VAL(X) X & 0x40
#define VDD_2728(X) X & 0b10000000
#define VDD_2829(X) X & 0b00000001
#define VDD_2930(X) X & 0b00000010
#define VDD_3031(X) X & 0b00000100
#define VDD_3132(X) X & 0b00001000
#define VDD_3233(X) X & 0b00010000
#define VDD_3334(X) X & 0b00100000
#define VDD_3435(X) X & 0b01000000
#define VDD_3536(X) X & 0b10000000
#endif

Loading…
Cancel
Save