Libary for DS18B20 working in MBED-OS
ds18b20.h@0:1abc4873af36, 2020-11-04 (annotated)
- Committer:
- Scheinost_Alexander
- Date:
- Wed Nov 04 07:36:02 2020 +0000
- Revision:
- 0:1abc4873af36
Libary for DS18B20; working in MBED-OS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Scheinost_Alexander | 0:1abc4873af36 | 1 | #ifndef ds18b20_h |
Scheinost_Alexander | 0:1abc4873af36 | 2 | #define ds18b20_h |
Scheinost_Alexander | 0:1abc4873af36 | 3 | |
Scheinost_Alexander | 0:1abc4873af36 | 4 | #include "mbed.h" |
Scheinost_Alexander | 0:1abc4873af36 | 5 | |
Scheinost_Alexander | 0:1abc4873af36 | 6 | #define OWI_SKIP_ROM 0xCC |
Scheinost_Alexander | 0:1abc4873af36 | 7 | #define DS18S20_START 0x44 |
Scheinost_Alexander | 0:1abc4873af36 | 8 | #define DS18S20_READ_SCRATCH_PAD 0xBE |
Scheinost_Alexander | 0:1abc4873af36 | 9 | |
Scheinost_Alexander | 0:1abc4873af36 | 10 | class OWI |
Scheinost_Alexander | 0:1abc4873af36 | 11 | { |
Scheinost_Alexander | 0:1abc4873af36 | 12 | public: |
Scheinost_Alexander | 0:1abc4873af36 | 13 | OWI(PinName pin); |
Scheinost_Alexander | 0:1abc4873af36 | 14 | void sendByte(unsigned char data); |
Scheinost_Alexander | 0:1abc4873af36 | 15 | unsigned char receiveByte(); |
Scheinost_Alexander | 0:1abc4873af36 | 16 | unsigned char detectPresence(); |
Scheinost_Alexander | 0:1abc4873af36 | 17 | |
Scheinost_Alexander | 0:1abc4873af36 | 18 | private: |
Scheinost_Alexander | 0:1abc4873af36 | 19 | void write0(); |
Scheinost_Alexander | 0:1abc4873af36 | 20 | void write1(); |
Scheinost_Alexander | 0:1abc4873af36 | 21 | unsigned char readBit(); |
Scheinost_Alexander | 0:1abc4873af36 | 22 | DigitalInOut owi_io; |
Scheinost_Alexander | 0:1abc4873af36 | 23 | }; |
Scheinost_Alexander | 0:1abc4873af36 | 24 | |
Scheinost_Alexander | 0:1abc4873af36 | 25 | class DS18B20 |
Scheinost_Alexander | 0:1abc4873af36 | 26 | { |
Scheinost_Alexander | 0:1abc4873af36 | 27 | public: |
Scheinost_Alexander | 0:1abc4873af36 | 28 | DS18B20(PinName pin); |
Scheinost_Alexander | 0:1abc4873af36 | 29 | float readTemp(); |
Scheinost_Alexander | 0:1abc4873af36 | 30 | |
Scheinost_Alexander | 0:1abc4873af36 | 31 | private: |
Scheinost_Alexander | 0:1abc4873af36 | 32 | OWI DS18B20_OWI; |
Scheinost_Alexander | 0:1abc4873af36 | 33 | }; |
Scheinost_Alexander | 0:1abc4873af36 | 34 | |
Scheinost_Alexander | 0:1abc4873af36 | 35 | #endif |