From f0d941bef6a9b6e3af78cfc68e1f82d6b47ccb2f Mon Sep 17 00:00:00 2001 From: fishsoupisgood Date: Tue, 26 May 2020 14:33:34 +0100 Subject: happy --- stm32/app/temp.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 stm32/app/temp.c (limited to 'stm32/app/temp.c') diff --git a/stm32/app/temp.c b/stm32/app/temp.c new file mode 100644 index 0000000..25a5de3 --- /dev/null +++ b/stm32/app/temp.c @@ -0,0 +1,72 @@ +#include "project.h" + + +#define N_SENSORS 2 + +#define SENSOR_INDEX_CH_RETURN 0 +#define SENSOR_INDEX_DHW_FEED 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\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]; +} -- cgit v1.2.3