main/task_ds18b20.c

changeset 12
7dc9003f86a8
parent 10
d08c7466bb40
child 23
58a328e91881
equal deleted inserted replaced
11:e33f2d325d15 12:7dc9003f86a8
1 /** 1 /**
2 * @file task_ds18b20.c 2 * @file task_ds18b20.c
3 * @brief The FreeRTOS task to query the DS18B20 sensors on one or two 3 * @brief The FreeRTOS task to query the DS18B20 sensors on the
4 * one-wire busses. Each bus must have only one sensor. That way 4 * one-wire bus.
5 * we don't need to care about the DS18B20 internal ROM address.
6 * The task will update the DS18B20_State structure. 5 * The task will update the DS18B20_State structure.
7 */ 6 */
8 7
9 8
10 #include "owb.h" 9 #include "owb.h"
156 ds18b20_state->sensor[i].temperature, dsErrors[ds18b20_state->sensor[i].error]); 155 ds18b20_state->sensor[i].temperature, dsErrors[ds18b20_state->sensor[i].error]);
157 #endif 156 #endif
158 } 157 }
159 ds18b20_state->num_sensors = num_devices; 158 ds18b20_state->num_sensors = num_devices;
160 xSemaphoreGive(xSemaphoreDS18B20); 159 xSemaphoreGive(xSemaphoreDS18B20);
160 } else {
161 ESP_LOGE(TAG, "Missed lock 1");
161 } 162 }
162 } else { 163 } else {
163 164
164 ESP_LOGW(TAG, "No temperature sensors found."); 165 ESP_LOGW(TAG, "No temperature sensors found.");
165 } 166 }
173 ds18b20_state->sensor[i].temperature = 0.0; 174 ds18b20_state->sensor[i].temperature = 0.0;
174 ds18b20_state->sensor[i].rom_code[0] = '\0'; 175 ds18b20_state->sensor[i].rom_code[0] = '\0';
175 ds18b20_state->sensor[i].error = DS18B20_ERR_READ; 176 ds18b20_state->sensor[i].error = DS18B20_ERR_READ;
176 } 177 }
177 xSemaphoreGive(xSemaphoreDS18B20); 178 xSemaphoreGive(xSemaphoreDS18B20);
179 } else {
180 ESP_LOGE(TAG, "Missed lock 2");
178 } 181 }
179 182
180 xEventGroupClearBits(xEventGroupDS18B20, TASK_DS18B20_REQUEST_TEMPS); 183 xEventGroupClearBits(xEventGroupDS18B20, TASK_DS18B20_REQUEST_TEMPS);
181 xEventGroupSetBits(xEventGroupDS18B20, TASK_DS18B20_REQUEST_DONE); 184 xEventGroupSetBits(xEventGroupDS18B20, TASK_DS18B20_REQUEST_DONE);
182 } 185 }
183 vTaskDelay(10 / portTICK_PERIOD_MS);
184 } 186 }
185 } 187 }
186 188

mercurial