Index: sys/dev/ow/owc_gpiobus.c =================================================================== --- sys/dev/ow/owc_gpiobus.c +++ sys/dev/ow/owc_gpiobus.c @@ -279,6 +279,8 @@ if (error != 0) return (error); + critical_enter(); + /* Force low for t_lowr microseconds */ then = sbinuptime(); OUTPIN(sc); @@ -291,14 +293,13 @@ * master's pushing the line low. */ INPIN(sc); - critical_enter(); do { now = sbinuptime(); GETPIN(sc, &sample); - } while (sbttous(now - then) < t->t_rdv + 2 && sample == 0); + } while (now - then < (t->t_rdv + 2) * SBT_1US && sample == 0); critical_exit(); - if (sbttons(now - then) < t->t_rdv * 1000) + if (now - then < t->t_rdv * SBT_1US) *bit = 1; else *bit = 0; @@ -306,7 +307,7 @@ /* Wait out the rest of t_slot */ do { now = sbinuptime(); - } while ((now - then) / SBT_1US < t->t_slot); + } while (now - then < (t->t_slot + 2 * t->t_rec) * SBT_1US); RELBUS(sc);