diff options
| Commit | 1d7becedc3b0c87c8b38e7c59c6b482843bd83e1 (patch) | |
|---|---|---|
| Author | 2024-05-29 08:58:20 +0300 | |
| Committer | 2024-05-29 08:58:20 +0300 | |
| Files | 569d4b239e7165d8c38b05332f5f7e5dc0ed4e36 | |
| uni-projects-1d7becedc3b0c87c8b38e7c59c6b482843bd83e1.tar uni-projects-1d7becedc3b0c87c8b38e7c59c6b482843bd83e1.tar.gz uni-projects-1d7becedc3b0c87c8b38e7c59c6b482843bd83e1.zip | ||
| Parent | 1f2c57338684cb7fb50e322fbe35f63e34130fd7 (diff) | |
[iot/goam] Replaced division by portTICK_PERIOD_MS with pdMS_TO_TICKS
5 files changed, 19 insertions, 20 deletions
| -rw-r--r-- | Year 3/Internet of things/goam/main/buttons.c | 6 | ||||
| -rw-r--r-- | Year 3/Internet of things/goam/main/main.c | 4 | ||||
| -rw-r--r-- | Year 3/Internet of things/goam/main/ptc06.c | 17 | ||||
| -rw-r--r-- | Year 3/Internet of things/goam/main/spiffs.c | 4 | ||||
| -rw-r--r-- | Year 3/Internet of things/goam/main/wifi.c | 8 |
diff --git a/Year 3/Internet of things/goam/main/buttons.c b/Year 3/Internet of things/goam/main/buttons.c index d9799d7..dfda13c 100644 --- a/Year 3/Internet of things/goam/main/buttons.c +++ b/Year 3/Internet of things/goam/main/buttons.c @@ -54,7 +54,7 @@ static void on_button_event_task(void* arg) // this logic is good enough. Under normal circumstances there should just be a // check to not create another task for the same button action do { - xTaskNotifyWait(ULONG_MAX, 0, ¬ification, 100 / portTICK_PERIOD_MS); + xTaskNotifyWait(ULONG_MAX, 0, ¬ification, pdMS_TO_TICKS(100)); } while (!(notification & BUTTON_ACTION_COMPLETED_BIT)); // If any button was pressed, this effectively blocks all other button presses @@ -63,7 +63,7 @@ static void on_button_event_task(void* arg) // when physically pressed once, and there is only one so its alright. // Better logic would be to remove all repeated occurences of the same current // event, but again, here we don't need to. - vTaskDelay(100 / portTICK_PERIOD_MS); + vTaskDelay(pdMS_TO_TICKS(100)); xQueueReset(gpio_button_queue); } } @@ -110,5 +110,5 @@ void add_push_button(unsigned pin, void (*on_press)()) { } void press_push_button(int gpio_num) { - xQueueSend(gpio_button_queue, &gpio_num, 100 / portTICK_PERIOD_MS); + xQueueSend(gpio_button_queue, &gpio_num, pdMS_TO_TICKS(100)); } diff --git a/Year 3/Internet of things/goam/main/main.c b/Year 3/Internet of things/goam/main/main.c index 58c1767..82e142f 100644 --- a/Year 3/Internet of things/goam/main/main.c +++ b/Year 3/Internet of things/goam/main/main.c @@ -265,11 +265,11 @@ void app_main(void) long unsigned int notification = 0; while (!(notification & INIT_CAMERA_BIT)) { - xTaskNotifyWait(0, 0, ¬ification, 50 / portTICK_PERIOD_MS); + xTaskNotifyWait(0, 0, ¬ification, pdMS_TO_TICKS(50)); } while (true) { - xTaskNotifyWait(ULONG_MAX, 0, ¬ification, 5000 / portTICK_PERIOD_MS); + xTaskNotifyWait(ULONG_MAX, 0, ¬ification, pdMS_TO_TICKS(5000)); } printf("Restarting now.\n"); diff --git a/Year 3/Internet of things/goam/main/ptc06.c b/Year 3/Internet of things/goam/main/ptc06.c index 5f29656..00efa76 100644 --- a/Year 3/Internet of things/goam/main/ptc06.c +++ b/Year 3/Internet of things/goam/main/ptc06.c @@ -27,7 +27,6 @@ static size_t arr4ToNum(const char arr[4]) { } #define min(a, b) (a < b) ? (a) : (b) -#define wait(milliseconds) vTaskDelay(milliseconds / portTICK_PERIOD_MS); /* * Logging @@ -86,12 +85,12 @@ static void init_uart_interface() { // // It also seems that these wait periods are the perfect values, anything less and it has failed. static void dynamic_flush_uart() { - wait(500); + vTaskDelay(pdMS_TO_TICKS(500)); size_t length; ESP_ERROR_CHECK(uart_get_buffered_data_len(UART_NUM, &length)); while (length > 0) { uart_flush(UART_NUM); - wait(1000); + vTaskDelay(pdMS_TO_TICKS(1000)); ESP_ERROR_CHECK(uart_get_buffered_data_len(UART_NUM, &length)); } } @@ -186,7 +185,7 @@ static void vc0706_system_reset() { dynamic_flush_uart(); send(SYSTEM_RESET, 0, NULL); recv(SYSTEM_RESET, 0, temp_ack); - wait(20); + vTaskDelay(pdMS_TO_TICKS(20)); dynamic_flush_uart(); // ignore "basic configuration information" } @@ -235,7 +234,7 @@ static size_t vc0706_read_fbuf(enum FBufType fbt_byte, enum ControlMode cm_byte, send(READ_FBUF, 0x0C, temp_data); recv(READ_FBUF, 0, temp_ack); - wait(delayby * 0.01 * 2); + vTaskDelay(pdMS_TO_TICKS(delayby * 0.01 * 2)); size_t current = 0; size_t available = 1; @@ -244,10 +243,10 @@ static size_t vc0706_read_fbuf(enum FBufType fbt_byte, enum ControlMode cm_byte, /* size_t old = current; */ current += uart_read_bytes(UART_NUM, *image + current, min(available, length - current), 500); ESP_ERROR_CHECK(uart_wait_tx_done(UART_NUM, 500)); - wait(20); + vTaskDelay(pdMS_TO_TICKS(20)); } - wait(delayby * 0.01 * 2); + vTaskDelay(pdMS_TO_TICKS(delayby * 0.01 * 2)); recv(READ_FBUF, 0, temp_ack); return length; @@ -284,7 +283,7 @@ static void vc0706_write_data(enum DeviceType dt_byte, char write_data_len, cons */ static void init_camera() { - wait(2500); + vTaskDelay(pdMS_TO_TICKS(2500)); } /* @@ -308,7 +307,7 @@ void ptc06_reset() { size_t ptc06_get_image(char** image) { vc0706_fbuf_ctrl(STOP_CURRENT_FRAME); - wait(500); + vTaskDelay(pdMS_TO_TICKS(500)); vc0706_get_fbuf_len(CURRENT_FRAME); char start[4] = { 0x00 }; diff --git a/Year 3/Internet of things/goam/main/spiffs.c b/Year 3/Internet of things/goam/main/spiffs.c index 1e37525..c92166f 100644 --- a/Year 3/Internet of things/goam/main/spiffs.c +++ b/Year 3/Internet of things/goam/main/spiffs.c @@ -78,7 +78,7 @@ void spiffs_write(const char* filename, const char* data, int data_len) { int length = write(outf, data, data_len); for (int tries = 0; length < data_len && tries < 3; tries++) { ESP_LOGW(TAG, "Wrote only %d bytes to \"%s\", trying again...", length, filename); - vTaskDelay(50 / portTICK_PERIOD_MS); + vTaskDelay(pdMS_TO_TICKS(50)); length = write(outf, data, data_len); } @@ -97,7 +97,7 @@ static int readers = 0; int spiffs_read(const char* filename, char** data) { if (readers == 0) { if (xSemaphoreTake(rw_mutex, 100) == pdTRUE) { - vTaskDelay(150 / portTICK_PERIOD_MS); + vTaskDelay(pdMS_TO_TICKS(150)); } else { *data = NULL; diff --git a/Year 3/Internet of things/goam/main/wifi.c b/Year 3/Internet of things/goam/main/wifi.c index 99bb03a..e1e97b8 100644 --- a/Year 3/Internet of things/goam/main/wifi.c +++ b/Year 3/Internet of things/goam/main/wifi.c @@ -118,7 +118,7 @@ static void scan_and_connect_task() { xTaskNotify(launcher_handle, CONNECTED_BIT, eSetBits); if (open_ind == -1) { ESP_LOGW(TAG, "Couldn't find a good open network or the configured net, will retry in 2 seconds"); - vTaskDelay(2000 / portTICK_PERIOD_MS); + vTaskDelay(pdMS_TO_TICKS(2000)); xTaskNotify(launcher_handle, TO_CONNECT_BIT, eSetBits); } @@ -129,13 +129,13 @@ static void launcher_scan_and_connect_task(void*) { long unsigned int notification = 0; while (true) { do { - xTaskNotifyWait(ULONG_MAX, 0, ¬ification, 100 / portTICK_PERIOD_MS); + xTaskNotifyWait(ULONG_MAX, 0, ¬ification, pdMS_TO_TICKS(100)); } while (!(notification & TO_CONNECT_BIT)); xTaskCreate(scan_and_connect_task, "scan_and_connect_task", 4096, NULL, 18, NULL); do { - xTaskNotifyWait(ULONG_MAX, 0, ¬ification, 100 / portTICK_PERIOD_MS); + xTaskNotifyWait(ULONG_MAX, 0, ¬ification, pdMS_TO_TICKS(100)); } while (!(notification & CONNECTED_BIT)); } } @@ -160,7 +160,7 @@ static void sta_disconnect_handler(void* arg, esp_event_base_t event_base, int32 CONFIG_WIFI_COLUMN); connect_tries++; ESP_LOGW(TAG, "Retrying to connect... Try %d/%d", connect_tries, ESP_MAXIMUM_RETRY); - vTaskDelay(200 / portTICK_PERIOD_MS); + vTaskDelay(pdMS_TO_TICKS(200)); } else { wifi_config_t config; |
