diff options
author | Uros Majstorovic <majstor@majstor.org> | 2022-05-13 12:26:19 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2022-05-13 12:26:19 +0200 |
commit | 9ccb4db8d59ec9dab33ee8617d462f21a8bb4fa8 (patch) | |
tree | a4f8ba9375a4ee82bae6ddc0cb3a35227f6f9469 /fw/fe310/eos/sdcard.c | |
parent | 45f0d9b890b086493f9bb06428c46cd802324223 (diff) |
touch controller/eve fixes
Diffstat (limited to 'fw/fe310/eos/sdcard.c')
-rw-r--r-- | fw/fe310/eos/sdcard.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/fw/fe310/eos/sdcard.c b/fw/fe310/eos/sdcard.c index 6f5488d..d081388 100644 --- a/fw/fe310/eos/sdcard.c +++ b/fw/fe310/eos/sdcard.c @@ -94,8 +94,8 @@ static uint16_t sdc_crc16(uint16_t crc, uint8_t b) { return crc; } -static uint32_t sdc_nto(uint64_t start, uint32_t timeout) { - uint32_t d = eos_time_since(start); +static uint32_t sdc_nto(uint32_t start, uint32_t timeout) { + uint32_t d = eos_time_delta_ms(start); return (d > timeout) ? 0 : timeout - d; } @@ -167,12 +167,12 @@ static int sdc_xchg_cmd(uint8_t cmd, uint32_t arg, uint8_t flags) { static int sdc_ready(uint32_t timeout) { uint8_t d = 0; - uint64_t start; + uint32_t start; if (timeout == 0) return EOS_ERR_BUSY; start = eos_time_get_tick(); do { - if (eos_time_since(start) > timeout) break; + if (eos_time_delta_ms(start) > timeout) break; d = sdc_xchg8(0xff); } while (d != 0xff); if (d != 0xff) return EOS_ERR_BUSY; @@ -182,12 +182,12 @@ static int sdc_ready(uint32_t timeout) { static int sdc_block_read(uint8_t *buffer, uint16_t len, uint32_t timeout) { uint8_t token = 0xff; - uint64_t start; + uint32_t start; if (timeout == 0) return EOS_ERR_BUSY; start = eos_time_get_tick(); do { - if (eos_time_since(start) > timeout) break; + if (eos_time_delta_ms(start) > timeout) break; token = sdc_xchg8(0xff); } while (token == 0xff); if (token == 0xff) return EOS_ERR_BUSY; @@ -236,7 +236,7 @@ static int sdc_cmd(uint8_t cmd, uint32_t arg, uint8_t flags, uint32_t timeout) { static int sdc_acmd(uint8_t cmd, uint32_t arg, uint8_t flags, uint32_t timeout) { int rv; - uint64_t start; + uint32_t start; start = eos_time_get_tick(); rv = sdc_cmd(APP_CMD, 0, flags, timeout); @@ -253,7 +253,7 @@ static int sdc_init(uint32_t timeout) { int rv, i; uint8_t _type; uint8_t ocr[4]; - uint64_t start; + uint32_t start; start = eos_time_get_tick(); eos_time_sleep(100); @@ -378,7 +378,7 @@ uint8_t eos_sdc_cap(void) { int eos_sdc_get_sect_count(uint32_t timeout, uint32_t *sectors) { int rv; uint8_t csd[16]; - uint64_t start = eos_time_get_tick(); + uint32_t start = eos_time_get_tick(); sdc_select(); rv = sdc_cmd(SEND_CSD, 0, SDC_CMD_FLAG_NOCS, timeout); @@ -404,7 +404,7 @@ int eos_sdc_get_sect_count(uint32_t timeout, uint32_t *sectors) { int eos_sdc_get_blk_size(uint32_t timeout, uint32_t *size) { int rv; uint8_t rbl[64]; /* SD Status or CSD register */ - uint64_t start = eos_time_get_tick(); + uint32_t start = eos_time_get_tick(); sdc_select(); if (sdc_type & EOS_SDC_TYPE_SDC2) { @@ -444,7 +444,7 @@ int eos_sdc_sync(uint32_t timeout) { int eos_sdc_erase(uint32_t blk_start, uint32_t blk_end, uint32_t timeout) { int rv; - uint64_t start; + uint32_t start; if (!(sdc_type & EOS_SDC_TYPE_SDC)) return EOS_ERR; if (!(sdc_type & EOS_SDC_CAP_ERASE_EN)) return EOS_ERR; @@ -468,11 +468,9 @@ int eos_sdc_erase(uint32_t blk_start, uint32_t blk_end, uint32_t timeout) { int eos_sdc_sect_read(uint32_t sect, unsigned int count, uint8_t *buffer) { int rv; - uint64_t start; uint8_t cmd = ((count == 1) ? READ_SINGLE_BLOCK : READ_MULTIPLE_BLOCK); if (!(sdc_type & EOS_SDC_CAP_BLK)) sect *= 512; - start = eos_time_get_tick(); sdc_select(); rv = sdc_cmd(cmd, sect, SDC_CMD_FLAG_NOCS, SDC_TIMEOUT_CMD); @@ -498,10 +496,8 @@ int eos_sdc_sect_read(uint32_t sect, unsigned int count, uint8_t *buffer) { int eos_sdc_sect_write(uint32_t sect, unsigned int count, uint8_t *buffer) { int rv; - uint64_t start; if (!(sdc_type & EOS_SDC_CAP_BLK)) sect *= 512; - start = eos_time_get_tick(); if (count == 1) { sdc_select(); |