66 static const ds18b20_cmd_t cmd = DS18B20_CONVERT_TEMPERATURE;
87 static const ds18b20_cmd_t cmd = DS18B20_READ_SCRATCHPAD;
94 printf(
"Scratchpad: ");
95 for(i = 0; i < DS18B20_SCRATCHPAD_SIZE / 2; ++i) {
96 buf = (dest[2 * i] << 8) | (dest[2 * i + 1]);
100 printf(
"CRC: %x (should be %x)\n", dest[8],
ow_compute_crc(dest, 8));
101 buf = (dest[1] << 8) | dest[0];
102 printf(
"Temp (celsius): %d.%d\n", (buf >> 4), (buf & 0x0f) * 625);
void ds18b20_convert_temperature(const ow_rom_code_t id)
Tell a DS18B20 sensor to initiate a temperature conversion.
Driver for the DS18B20 temperature sensor.
void ow_skip_or_match_rom(const ow_rom_code_t id)
Shorthand function for MATCH ROM or SKIP ROM if id is zero.
void ds18b20_init(void)
Initialize the DS18B20 driver.
One wire driver using hardware UART as a bus master.
void ow_read_bytes(uint8_t *dest, const uint8_t count)
Read a sequence of bytes from the 1-wire bus.
uint8_t ds18b20_read_scratchpad(const ow_rom_code_t id, uint8_t *dest)
Read the scratchpad of a DS18B20 sensor.
void ow_write_bytes(const uint8_t *src, const uint8_t count)
Write a sequence of bytes to the 1-wire bus.
uint8_t ow_compute_crc(const uint8_t *data, const uint8_t count)
Compute a 1-wire 8-bit CRC.