Library to communicate with Maxim OneWire protocol devices Modified timings and IRQ overrides
Fork of Onewire by
Onewire.h
- Committer:
- Bobty
- Date:
- 2015-02-21
- Revision:
- 1:8e9464e05ddf
- Parent:
- 0:d961f715d82b
- Child:
- 4:b678c7c8203c
File content as of revision 1:8e9464e05ddf:
#ifndef Onewire_h #define Onewire_h #include "mbed.h" class Onewire{ public: 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_; // search state unsigned char _search_ROM_NO[8]; uint8_t _search_LastDiscrepancy; uint8_t _search_LastFamilyDiscrepancy; uint8_t _search_LastDeviceFlag; }; #endif