diff --git a/source/rtc.c b/source/rtc.c index 3463ea1..5f02594 100644 --- a/source/rtc.c +++ b/source/rtc.c @@ -143,10 +143,12 @@ static void rtc_cmd_arg(const unsigned int cmd, unsigned int data, unsigned int assume(len > 0 && len <= 32); rtc_write(data, len); + int wait = (TIMEOUT_CYCLES_WAIT_AFTER_WRITE_PER_BYTE * 7 + 11 + 6) / 12; __asm__ volatile ( - "L1%=: subs %[wait], #1" "\n\t" - "bne L1%=" - :: [wait]"l"(((TIMEOUT_CYCLES_WAIT_AFTER_WRITE_PER_BYTE * len + 7) / 8 + 11 + 6) / 12) + "L1%=:" "\n\t" + "subs %[wait], %[wait], #1" "\n\t" + "bne L1%=" + :: [wait]"r"(wait) ); } @@ -159,10 +161,12 @@ static void rtc_cmd_arg_datetime(unsigned int cmd, __agbabi_datetime_t datetime, rtc_write(date, 32); rtc_write(time, 24); + int wait = (TIMEOUT_CYCLES_WAIT_AFTER_WRITE_PER_BYTE * 7 + 11 + 6) / 12; __asm__ volatile ( - "L1%=: subs %[wait], #1" "\n\t" - "bne L1%=" - :: [wait]"l"((TIMEOUT_CYCLES_WAIT_AFTER_WRITE_PER_BYTE * 7 + 11 + 6) / 12) + "L1%=:" "\n\t" + "subs %[wait], %[wait], #1" "\n\t" + "bne L1%=" + :: [wait]"r"(wait) ); }