zzz
iButton.h@14:2d0b5e0f0aed, 2020-08-26 (annotated)
- Committer:
- mauuuuul
- Date:
- Wed Aug 26 19:44:50 2020 +0000
- Revision:
- 14:2d0b5e0f0aed
- Parent:
- OneWire.h@13:016b84669050
zzzz
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mauuuuul | 14:2d0b5e0f0aed | 1 | #ifndef I_BUTTON_H |
mauuuuul | 14:2d0b5e0f0aed | 2 | #define I_BUTTON_H |
hudakz | 10:c89b9ad6097c | 3 | |
mauuuuul | 14:2d0b5e0f0aed | 4 | #include "mbed.h" |
mauuuuul | 14:2d0b5e0f0aed | 5 | #include <string> |
mauuuuul | 14:2d0b5e0f0aed | 6 | #include <vector> |
hudakz | 0:acf75feb0947 | 7 | |
mauuuuul | 14:2d0b5e0f0aed | 8 | //typedef struct |
mauuuuul | 14:2d0b5e0f0aed | 9 | //{ |
mauuuuul | 14:2d0b5e0f0aed | 10 | // unsigned char family; |
mauuuuul | 14:2d0b5e0f0aed | 11 | // unsigned char serial[6]; |
mauuuuul | 14:2d0b5e0f0aed | 12 | // unsigned char crc; |
mauuuuul | 14:2d0b5e0f0aed | 13 | // unsigned char valid; |
mauuuuul | 14:2d0b5e0f0aed | 14 | //} ibuttonvalue; |
mauuuuul | 14:2d0b5e0f0aed | 15 | class ibuttonvalue |
mauuuuul | 14:2d0b5e0f0aed | 16 | { |
mauuuuul | 14:2d0b5e0f0aed | 17 | public: |
mauuuuul | 14:2d0b5e0f0aed | 18 | unsigned char family; |
mauuuuul | 14:2d0b5e0f0aed | 19 | std::vector<unsigned char> serial; |
mauuuuul | 14:2d0b5e0f0aed | 20 | unsigned char crc; |
mauuuuul | 14:2d0b5e0f0aed | 21 | bool valid; |
hudakz | 0:acf75feb0947 | 22 | }; |
hudakz | 0:acf75feb0947 | 23 | |
mauuuuul | 14:2d0b5e0f0aed | 24 | class iButton |
mauuuuul | 14:2d0b5e0f0aed | 25 | { |
mauuuuul | 14:2d0b5e0f0aed | 26 | public: |
mauuuuul | 14:2d0b5e0f0aed | 27 | |
mauuuuul | 14:2d0b5e0f0aed | 28 | iButton(PinName IO); |
mauuuuul | 14:2d0b5e0f0aed | 29 | ~iButton(); |
mauuuuul | 14:2d0b5e0f0aed | 30 | |
mauuuuul | 14:2d0b5e0f0aed | 31 | void OneWireReset(void); |
mauuuuul | 14:2d0b5e0f0aed | 32 | void OneWireOutByte(unsigned char data); |
mauuuuul | 14:2d0b5e0f0aed | 33 | unsigned char OneWireReadByte(void); |
mauuuuul | 14:2d0b5e0f0aed | 34 | void DetectiButton(void); |
mauuuuul | 14:2d0b5e0f0aed | 35 | std::string GetData(void); |
mauuuuul | 14:2d0b5e0f0aed | 36 | bool IsTaping(void); |
mauuuuul | 14:2d0b5e0f0aed | 37 | |
mauuuuul | 14:2d0b5e0f0aed | 38 | private: |
mauuuuul | 14:2d0b5e0f0aed | 39 | DigitalInOut io; |
mauuuuul | 14:2d0b5e0f0aed | 40 | ibuttonvalue detect; |
mauuuuul | 14:2d0b5e0f0aed | 41 | unsigned char CrcTemp; |
mauuuuul | 14:2d0b5e0f0aed | 42 | |
mauuuuul | 14:2d0b5e0f0aed | 43 | unsigned char crc8(unsigned char crc, unsigned char data); |
mauuuuul | 14:2d0b5e0f0aed | 44 | void ResetData(); |
mauuuuul | 14:2d0b5e0f0aed | 45 | |
mauuuuul | 14:2d0b5e0f0aed | 46 | }; |
hudakz | 12:27a1b359b95c | 47 | |
mauuuuul | 14:2d0b5e0f0aed | 48 | #endif // I_BUTTON_H |