#define DS_DMA DMA1
#define DS_DMA_CH 6
-#define DS_DEBUG
+#undef DS_DEBUG
#undef DS_DEBUG2
#ifdef DS_DEBUG
if (!maxn--)
return;
ds_current_id++;
- if (ds_current_id >= DS_NUM_SENSORS)
+ if (ds_current_id >= DS_NUM_SENSORS) {
ds_current_id = 0;
+ }
} while (!ds_sensors[ds_current_id].address[0]);
#endif
if (!ds_activate()) {
usart_enable(USART1);
}
+static void show_temperature(void)
+{
+ debug_putc('#');
+ for (uint i=0; ds_sensors[i].address[0]; i++) {
+ debug_putc(' ');
+ int t = ds_sensors[i].current_temp;
+ if (t == DS_TEMP_UNKNOWN)
+ debug_puts("---.---");
+ else
+ debug_printf("%3d.%03d", t / 1000, t % 1000);
+ }
+ debug_puts("\r\n");
+}
+
int main(void)
{
clock_setup();
usart_setup();
ds_init();
+
+ byte cycles = 0;
for (;;) {
gpio_toggle(GPIOC, GPIO13);
delay_ms(100);
ds_step();
+ if (cycles++ >= 50) {
+ cycles = 0;
+ show_temperature();
+ }
}
return 0;