Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ow/owc_gpiobus.c
Show First 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | owc_gpiobus_read_data(device_t dev, struct ow_timing *t, int *bit) | ||||
int error, sample; | int error, sample; | ||||
sbintime_t then, now; | sbintime_t then, now; | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
error = GETBUS(sc); | error = GETBUS(sc); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
critical_enter(); | |||||
/* Force low for t_lowr microseconds */ | /* Force low for t_lowr microseconds */ | ||||
then = sbinuptime(); | then = sbinuptime(); | ||||
OUTPIN(sc); | OUTPIN(sc); | ||||
LOW(sc); | LOW(sc); | ||||
DELAY(t->t_lowr); | DELAY(t->t_lowr); | ||||
/* | /* | ||||
* Slave is supposed to hold the line low for t_rdv microseconds for 0 | * Slave is supposed to hold the line low for t_rdv microseconds for 0 | ||||
* and immediately float it high for a 1. This is measured from the | * and immediately float it high for a 1. This is measured from the | ||||
* master's pushing the line low. | * master's pushing the line low. | ||||
*/ | */ | ||||
INPIN(sc); | INPIN(sc); | ||||
critical_enter(); | |||||
do { | do { | ||||
now = sbinuptime(); | now = sbinuptime(); | ||||
GETPIN(sc, &sample); | 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(); | critical_exit(); | ||||
if (sbttons(now - then) < t->t_rdv * 1000) | if (now - then < t->t_rdv * SBT_1US) | ||||
*bit = 1; | *bit = 1; | ||||
else | else | ||||
*bit = 0; | *bit = 0; | ||||
/* Wait out the rest of t_slot */ | /* Wait out the rest of t_slot */ | ||||
do { | do { | ||||
now = sbinuptime(); | now = sbinuptime(); | ||||
} while ((now - then) / SBT_1US < t->t_slot); | } while (now - then < (t->t_slot + 2 * t->t_rec) * SBT_1US); | ||||
RELBUS(sc); | RELBUS(sc); | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
* RESET AND PRESENCE PULSE (see owll_if.m for timings) From Figure 4-4 AN-937 | * RESET AND PRESENCE PULSE (see owll_if.m for timings) From Figure 4-4 AN-937 | ||||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |