summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/sd-as3525v2.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/as3525/sd-as3525v2.c')
-rw-r--r--firmware/target/arm/as3525/sd-as3525v2.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c
index 061be8d1c2..2d796c63cb 100644
--- a/firmware/target/arm/as3525/sd-as3525v2.c
+++ b/firmware/target/arm/as3525/sd-as3525v2.c
@@ -759,26 +759,22 @@ int sd_init(void)
759static int sd_wait_for_tran_state(const int drive) 759static int sd_wait_for_tran_state(const int drive)
760{ 760{
761 unsigned long response; 761 unsigned long response;
762 unsigned int timeout = 100; /* ticks */ 762 unsigned int timeout = current_tick + 5*HZ;
763 long t = current_tick;
764 763
765 while (1) 764 while (1)
766 { 765 {
767 long tick;
768
769 while(!(send_cmd(drive, SD_SEND_STATUS, card_info[drive].rca, MCI_RESP, &response))); 766 while(!(send_cmd(drive, SD_SEND_STATUS, card_info[drive].rca, MCI_RESP, &response)));
770 767
771 if (((response >> 9) & 0xf) == SD_TRAN) 768 if (((response >> 9) & 0xf) == SD_TRAN)
772 return 0; 769 return 0;
773 770
774 if(TIME_AFTER(current_tick, t + timeout)) 771 if(TIME_AFTER(current_tick, timeout))
775 return -10 * ((response >> 9) & 0xf); 772 return -10 * ((response >> 9) & 0xf);
776 773
777 if (TIME_AFTER((tick = current_tick), next_yield)) 774 if (TIME_AFTER(current_tick, next_yield))
778 { 775 {
779 yield(); 776 yield();
780 timeout += current_tick - tick; 777 next_yield = current_tick + MIN_YIELD_PERIOD;
781 next_yield = tick + MIN_YIELD_PERIOD;
782 } 778 }
783 } 779 }
784} 780}