/*---------------------------------------------------------------------------*/ PROCESS_THREAD(ds18b20_poll_process, ev, data) { static struct etimer et; static uint8_t scratchpad[DS18B20_SCRATCHPAD_SIZE]; static ow_rom_code_t id; PROCESS_BEGIN(); printf("\nDS18B20 test\n"); printf("VSEC ON\n"); power_control_vsec_set(1); /* initialize the DS18B20 hardware */ printf("Initialize 1-wire\n"); ow_init(); printf("1-wire READ ROM\n"); id = ow_read_rom(); printf("Initialize DS18B20\n"); ds18b20_init(); printf("DS18B20 init done\n"); /* Poll at 1Hz */ etimer_set(&et, CLOCK_SECOND); while(1) { PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); /* Reset the etimer to trig again */ etimer_reset(&et); ds18b20_read_scratchpad(id, scratchpad); ds18b20_convert_temperature(id); } PROCESS_END(); }
void ds18b20_convert_temperature_all(void) { uint8_t i = 0; for (i = 0; i < one_wire_devices_list_size; ++i) { ds18b20_convert_temperature(one_wire_list_of_devices[i]); } }