Library to communicate with Maxim OneWire protocol devices Modified timings and IRQ overrides
Fork of Onewire by
Diff: Onewire.h
- Revision:
- 6:d2452e9b169b
- Parent:
- 4:b678c7c8203c
- Child:
- 7:0a87f8c2d9e6
--- a/Onewire.h Mon Sep 28 10:31:58 2015 +0000 +++ b/Onewire.h Mon Oct 05 14:03:29 2015 +0000 @@ -5,9 +5,15 @@ #define ONEWIRE_ADDR_BYTES 8 -class Onewire{ +const int ONEWIRE_OK = 0; +const int ONEWIRE_SEARCH_ALL_DONE = 1; +const int ONEWIRE_SEARCH_INIT_FAIL = 2; +const int ONEWIRE_SEARCH_NOT_FOUND = 3; -public: +class Onewire +{ + +public: Onewire(PinName oneBus); void writeBit(int bit); int readBit(); @@ -18,10 +24,13 @@ // 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 + // Look for the next device. + // Returns + // ONEWIRE_OK if a new address has been returned. + // ONEWIRE_SEARCH_ALL_DONE = all devices found + // ONEWIRE_SEARCH_INIT_FAIL = failed to init + // ONEWIRE_SEARCH_NOT_FOUND = no devices found + // 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);