typedef uint16_t timer_t;
-#define set_timer_ms(msec) (set_timer_duration(((msec * TICKSPERSEC) / 1000U) == 0 ? 1 : ((msec * TICKSPERSEC) / 1000U)))
-#define set_timer_sec(sec) (set_timer_duration(sec * TICKSPERSEC))
+#define set_timer_ms(msec) (set_timer_duration(msec < 100U ? 1 : ((msec) / 100U))
+#define set_timer_sec(sec) (set_timer_duration((sec) * 10))
timer_t set_timer_duration(uint16_t duration); /* good for up to 32K ticks */
bool timer_expired(timer_t timer_val);
/* Enter Idle state */
if (sd_send_command(CMD0, 0) == 1) {
/* initialisation timeout 1 second */
- timer = set_timer_duration(TICKSPERSEC);
+ timer = set_timer_sec(1);
if (sd_send_command(CMD8, (uint32_t)0x1AA) == 1) { /* SDHC */
/* Get trailing return value of R7 resp */
for (n = 0; n < 4; n++) ocr[n] = sd_spi_receive_byte();
unsigned char res;
timer_t timer;
- timer = set_timer_duration(TICKSPERSEC/10); /* 100ms */
+ timer = set_timer_ms(100); /* 100ms */
sd_spi_receive_byte();
do{
res = sd_spi_receive_byte();
unsigned int timer;
unsigned char b;
- timer = set_timer_duration(TICKSPERSEC/5); /* 200ms */
+ timer = set_timer_ms(200); /* 200ms */
do{
b = sd_spi_receive_byte();
udata.u_utime++;
}
- ticks.full++;
-
/* Do once-per-decisecond things - this doesn't work out well on
boxes with 64 ticks/second.. need a better approach */
if (++ticks_this_dsecond == TICKSPERSEC / 10) {
/* Update global time counters */
ticks_this_dsecond = 0;
+ ticks.full++;
/* Update process alarm clocks and timeouts */
for (p = ptab; p < ptab + maxproc; ++p) {