From 9d87c925a9eaa4fc256be3173c14a20d1469472d Mon Sep 17 00:00:00 2001 From: fishsoupisgood Date: Wed, 9 Sep 2020 11:53:37 +0100 Subject: everything, mostly, working --- boiler-monster/stm32/app/temp.c | 76 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 boiler-monster/stm32/app/temp.c (limited to 'boiler-monster/stm32/app/temp.c') diff --git a/boiler-monster/stm32/app/temp.c b/boiler-monster/stm32/app/temp.c new file mode 100644 index 0000000..4548d01 --- /dev/null +++ b/boiler-monster/stm32/app/temp.c @@ -0,0 +1,76 @@ +#include "project.h" + + +#define N_SENSORS 2 + +#define SENSOR_INDEX_CH_RETURN 0 +#define SENSOR_INDEX_SUPPLY_INLET 1 + +static const Onewire_addr s_addr[N_SENSORS] = { + [0] = {{0x28, 0x60, 0x06, 0x53, 0x03, 0x00, 0x00, 0xf5}}, + [1] = {{0x28, 0xa4, 0x08, 0x53, 0x03, 0x00, 0x00, 0x14}}, +}; + + +static int s_temp[N_SENSORS]; + +static unsigned poke; + + +void temp_tick (void) +{ + static unsigned ticker; + + ticker++; + + if (ticker < 3000) + return; + + ticker = 0; + poke = 1; + +} + + + + + +void temp_dispatch (void) +{ + static unsigned sensor; + + if (!poke) return; + + poke = 0; + + if (sensor < N_SENSORS) { + if (ds1820_read (&s_addr[sensor], &s_temp[sensor])) + s_temp[sensor] = 0; + + + printf ("Q1W: sensor %d temp %d\r\n", sensor, (s_temp[sensor] * 100) / 256); + + + sensor++; + } else { +#if 0 + onewire_search(); +#endif + } + + if (sensor == N_SENSORS) + sensor = 0; + + +} + + + +uint16_t temp_ch_return (void) +{ + return s_temp[SENSOR_INDEX_CH_RETURN]; +} +uint16_t temp_supply_inlet (void) +{ + return s_temp[SENSOR_INDEX_SUPPLY_INLET]; +} -- cgit v1.2.3