diff --git a/ADIS_ESP32_Eclipse/main/CMakeLists.txt b/ADIS_ESP32_Eclipse/main/CMakeLists.txt index fb42854..b4fcedb 100644 --- a/ADIS_ESP32_Eclipse/main/CMakeLists.txt +++ b/ADIS_ESP32_Eclipse/main/CMakeLists.txt @@ -1,6 +1,7 @@ idf_component_register( SRCS "main.c" + "myTask.c" "platform.c" "led.c" "wifi.c" @@ -18,4 +19,4 @@ idf_component_register( INCLUDE_DIRS "." -) +) \ No newline at end of file diff --git a/ADIS_ESP32_Eclipse/main/main.c b/ADIS_ESP32_Eclipse/main/main.c index 32892ed..0690882 100644 --- a/ADIS_ESP32_Eclipse/main/main.c +++ b/ADIS_ESP32_Eclipse/main/main.c @@ -12,12 +12,14 @@ #include "freertos/task.h" #include "esp_system.h" #include "esp_spi_flash.h" +#include "myTask.h" #include "platform.h" void app_main(void) { printf("Hello world!\n"); PL_Init(); + /* Print chip information */ esp_chip_info_t chip_info; esp_chip_info(&chip_info); @@ -34,6 +36,14 @@ void app_main(void) printf("Minimum free heap size: %d bytes\n", esp_get_minimum_free_heap_size()); +/* Start task */ +#if 1 + printf("Starting task..."); + MyTask_Start(); +#endif +/* Test and restart */ +#if 0 + for (int i = 5; i <= 100; i++) { printf("Hello Test nr. %d\n", i); //printf("Restarting in %d seconds...\n", i); @@ -42,4 +52,5 @@ void app_main(void) printf("Restarting now.\n"); fflush(stdout); esp_restart(); +#endif } diff --git a/ADIS_ESP32_Eclipse/main/myTask.c b/ADIS_ESP32_Eclipse/main/myTask.c new file mode 100644 index 0000000..9e20ec2 --- /dev/null +++ b/ADIS_ESP32_Eclipse/main/myTask.c @@ -0,0 +1,34 @@ +/* + * task.c + * + * Created on: 03.11.2022 + * Author: jonas + */ + + +#include "myTask.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +static TaskHandle_t myTaskHandle; + +static void myTask(void *pv){ + uint32_t counter = 0; + if(pv != NULL){ + printf("task argument: %s\n", (char*)pv); + } + for(;;){ + printf("task was called. counter=%i\n", ++counter); + fflush(stdout); + vTaskDelay(pdMS_TO_TICKS(1000)); + } +} + +BaseType_t res; + +void MyTask_Start(void){ + res = xTaskCreate(myTask, "task1", 4096/sizeof(StackType_t), (void*)"hello!", tskIDLE_PRIORITY, &myTaskHandle); + if(res != pdPASS){ + printf("creating myTask failed!\r\n"); + } +} diff --git a/ADIS_ESP32_Eclipse/main/myTask.h b/ADIS_ESP32_Eclipse/main/myTask.h new file mode 100644 index 0000000..cd0fd34 --- /dev/null +++ b/ADIS_ESP32_Eclipse/main/myTask.h @@ -0,0 +1,14 @@ +/* + * task.h + * + * Created on: 03.11.2022 + * Author: jonas + */ + +#ifndef MAIN_MYTASK_H_ +#define MAIN_MYTASK_H_ + +void MyTask_Start(void); + + +#endif /* MAIN_MYTASK_H_ */