static inline uint32_t xferbit(uint32_t thebit) { setpin0(); BusyWait8(12); // 1.5us if(thebit) setpinhiz(); thebit = 0; BusyWait8(13<<3); if(getpin()) thebit = 0x01; BusyWait8(45<<3); setpinhiz(); BusyWait8(10<<3); return thebit; }
static inline uint32_t xferbit(uint32_t thebit) { setpin0(); BusyWait(TICKS_US(1.5)); if (thebit) setpinhiz(); thebit = 0; BusyWait(TICKS_US(13)); if (getpin()) thebit = 0x01; BusyWait(TICKS_US(45)); setpinhiz(); BusyWait(TICKS_US(10)); return thebit; }
static inline uint32_t xferbyte(uint32_t thebyte) { for(uint32_t bits=0; bits<8; bits++) { setpin0(); BusyWait8(12); // 1.5us if(thebyte&0x01) setpinhiz(); thebyte >>= 1; BusyWait8(13<<3); if(getpin()) thebyte |= 0x80; BusyWait8(45<<3); setpinhiz(); BusyWait8(10<<3); } return thebyte; }
static inline uint32_t xferbyte(uint32_t thebyte) { for (uint32_t bits = 0; bits < 8; bits++) { setpin0(); BusyWait(TICKS_US(1.5)); // 1.5us if (thebyte&0x01) setpinhiz(); thebyte >>= 1; BusyWait(TICKS_US(13)); if (getpin()) thebyte |= 0x80; BusyWait(TICKS_US(45)); setpinhiz(); BusyWait(TICKS_US(10)); } return thebyte; }
static inline uint32_t resetbus(void) { uint32_t devicepresent=0; setpin0(); BusyWait8(480<<3); setpinhiz(); BusyWait8(70<<3); if(getpin() == 0) devicepresent=1; BusyWait8(410<<3); return devicepresent; }
static inline uint32_t resetbus(void) { uint32_t devicepresent = 0; setpin0(); BusyWait(TICKS_US(480)); setpinhiz(); BusyWait(TICKS_US(70)); if (getpin() == 0) devicepresent = 1; BusyWait(TICKS_US(410)); return devicepresent; }