Resources https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/system/log.html Why use the log instead of printf? Writing to log What we do Including values Including strings Value format codes See here. Enabling/disabling logs from being output E.g. selectively including messages from certain files, production release code where you don’t want messages to appear at the serial port or take time away from […]
All posts by
Event group
Using an event group static EventGroupHandle_t tcpserver_event_group; //Create it tcpserver_event_group = xEventGroupCreate(); //Set the state when say a connection happens or is lost xEventGroupSetBits(tcpserver_event_group, CONNECTED_BIT); xEventGroupClearBits(tcpserver_event_group, CONNECTED_BIT); //Wait for connected xEventGroupWaitBits(tcpserver_event_group, CONNECTED_BIT, false, true, portMAX_DELAY); //Stalls (with timeout)
Event handler
You can subscribe to be notified of ESP events using this In your initialise ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) ); Event handler fucntion //*************************************** //*************************************** //********** ESP EVENT HANDLER ********** //*************************************** //*************************************** //Call this at startup: //ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) ); static esp_err_t event_handler(void *ctx, system_event_t *event) { switch(event->event_id) { case SYSTEM_EVENT_STA_START: //WiFi connected break; case SYSTEM_EVENT_STA_GOT_IP: //WiFi […]
.TCP/IP General
Resources https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/ethernet/esp_eth.html
FreeRTOS Tick Rate
Defaint is 100Hz / 10mS You can change it with make menuconfig: Component config > FreeRTOS > Tick Rate (Hz) Whacking it all the way up to 1000 will cause some things to be affected as the scheduler has less time to deal with calling different tasks.
Priority
Priority Each task is assigned a priority from 0 to (configMAX_PRIORITIES – 1 ), (configMAX_PRIORITIES is defined in FreeRTOSConfig.h). Low priority numbers denote low priority tasks. The idle task has priority zero (tskIDLE_PRIORITY). The task placed into the Running state by the scheduler is always the highest priority task that is able to run – higher priority tasks […]
Co-routines
Co-routines are rarely used these days and there are no plans to develop them further in FreeRTOS
.Tasks general
The basics ESP-IDF uses FreeRTOS and this is a “tasks” based Operating System. The FreeRTOS default tick rate is 100Hz (you can configure this, but 100 is a good tradeoff between ISR overhead and responsiveness). This means portTICK_PERIOD_MS is 10 (10ms per tick). If you use a vTaskDelay < 10mS, it is effectively a 0 […]
.FreeRTOS Resources
FreeRTOS.org https://www.freertos.org/FreeRTOS-quick-start-guide.html
Semaphores
Semaphores are typically used for both synchronization and mutual exclusion in access to resources. Semaphore example #include "semphr.h" //Create semphore SemaphoreHandle_t SemaphoreHandle1 = NULL; SemaphoreHandle1 = xSemaphoreCreateMutex(); //Use sempahore xSemaphoreTake(SemaphoreHandle1, portMAX_DELAY); //Do something… xSemaphoreGive(SemaphoreHandle1);