Update readme.MD

Added example code (will obviously need to setup timers etc.
This commit is contained in:
smallsolar 2025-04-19 16:43:02 +00:00
parent d06b0b2621
commit 345d16b542
1 changed files with 11 additions and 0 deletions

View File

@ -8,6 +8,17 @@ A simple driver written for libopencm3 and stm32f0, it was written from first pr
* It uses `NOP` for some of its timing which is probably not ideal
* The timings are rough, it could need some optimisation (but works with the fake ds18b20s I have.)
## Example Usage
```
#include "ds18b20.h"
//Get Data from DS18b20 Sensor 1
ds18b20_start_conversion(GPIOB, GPIO1);
// Wait for conversion to complete
delay_ms(750);
int16_t ds_temp = ds18b20_read_raw_temperature(GPIOB, GPIO1);
```
## References
* https://teslabs.com/openplayer/docs/docs/other/ds18b20_pre1.pdf
* https://www.circuitbread.com/tutorials/embedded-c-programming-with-the-pic18f14k50-12-digital-thermometer