Library to communicate with Maxim OneWire protocol devices Modified timings and IRQ overrides
Fork of Onewire by
Diff: Onewire.h
- Revision:
- 1:8e9464e05ddf
- Parent:
- 0:d961f715d82b
- Child:
- 4:b678c7c8203c
--- a/Onewire.h Sun Jun 23 15:17:39 2013 +0000 +++ b/Onewire.h Sat Feb 21 17:16:16 2015 +0000 @@ -6,15 +6,31 @@ class Onewire{ public: - Onewire(PinName oneBus); - void writeBit(int bit); + Onewire(PinName oneBus); + void writeBit(int bit); int readBit(); int init(); int readByte(); void writeByte(char data); unsigned char CRC(unsigned char* addr, unsigned char len); + // Clear the search state so that if will start from the beginning again. + void reset_search(); + // Look for the next device. Returns 1 if a new address has been + // returned. A zero might mean that the bus is shorted, there are + // no devices, or you have already retrieved all of them. It + // might be a good idea to check the CRC to make sure you didn't + // get garbage. The order is deterministic. You will always get + // the same devices in the same order. + uint8_t search(uint8_t *newAddr); + private: - DigitalInOut oneBus_; + DigitalInOut oneBus_; + + // search state + unsigned char _search_ROM_NO[8]; + uint8_t _search_LastDiscrepancy; + uint8_t _search_LastFamilyDiscrepancy; + uint8_t _search_LastDeviceFlag; }; #endif \ No newline at end of file