Libary for DS18B20 working in MBED-OS
Diff: ds18b20.h
- Revision:
- 0:1abc4873af36
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ds18b20.h Wed Nov 04 07:36:02 2020 +0000 @@ -0,0 +1,35 @@ +#ifndef ds18b20_h +#define ds18b20_h + +#include "mbed.h" + +#define OWI_SKIP_ROM 0xCC +#define DS18S20_START 0x44 +#define DS18S20_READ_SCRATCH_PAD 0xBE + +class OWI +{ + public: + OWI(PinName pin); + void sendByte(unsigned char data); + unsigned char receiveByte(); + unsigned char detectPresence(); + + private: + void write0(); + void write1(); + unsigned char readBit(); + DigitalInOut owi_io; +}; + +class DS18B20 +{ + public: + DS18B20(PinName pin); + float readTemp(); + + private: + OWI DS18B20_OWI; +}; + +#endif \ No newline at end of file