Эх сурвалжийг харах

Merge pull request #30 from tangzz98/esp

Add missing definitions for esp-idf
tangzz98 3 жил өмнө
parent
commit
352e2c4cbc

+ 14 - 0
FreeRTOS/include/freertos/FreeRTOS.h

@@ -755,6 +755,20 @@
     #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength )
     #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength )
 #endif
 #endif
 
 
+#ifdef ESP_PLATFORM
+#ifndef traceISR_EXIT_TO_SCHEDULER
+    #define traceISR_EXIT_TO_SCHEDULER()
+#endif
+
+#ifndef traceISR_EXIT
+    #define traceISR_EXIT()
+#endif
+
+#ifndef traceISR_ENTER
+    #define traceISR_ENTER(_n_)
+#endif
+#endif // ESP_PLATFORM
+
 #ifndef configGENERATE_RUN_TIME_STATS
 #ifndef configGENERATE_RUN_TIME_STATS
     #define configGENERATE_RUN_TIME_STATS    0
     #define configGENERATE_RUN_TIME_STATS    0
 #endif
 #endif

+ 4 - 0
FreeRTOS/include/freertos/portable.h

@@ -33,7 +33,11 @@
 #ifndef PORTABLE_H
 #ifndef PORTABLE_H
 #define PORTABLE_H
 #define PORTABLE_H
 
 
+#ifdef ESP_PLATFORM
+#include "freertos/portmacro.h"
+#else
 #include "portmacro.h"
 #include "portmacro.h"
+#endif
 
 
 #if portBYTE_ALIGNMENT == 32
 #if portBYTE_ALIGNMENT == 32
     #define portBYTE_ALIGNMENT_MASK    ( 0x001f )
     #define portBYTE_ALIGNMENT_MASK    ( 0x001f )

+ 1 - 3
FreeRTOS/portable/esp-idf/port_common.c

@@ -69,9 +69,7 @@ void esp_startup_start_app_common(void)
     esp_gdbstub_init();
     esp_gdbstub_init();
 #endif // CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME
 #endif // CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME
 
 
-#ifdef CONFIG_IDF_RTOS_RTTHREAD
-    app_main();
-#else
+#if !defined CONFIG_IDF_RTOS_RTTHREAD
     portBASE_TYPE res = xTaskCreatePinnedToCore(&main_task, "main",
     portBASE_TYPE res = xTaskCreatePinnedToCore(&main_task, "main",
                                                 ESP_TASK_MAIN_STACK, NULL,
                                                 ESP_TASK_MAIN_STACK, NULL,
                                                 ESP_TASK_MAIN_PRIO, NULL, ESP_TASK_MAIN_CORE);
                                                 ESP_TASK_MAIN_PRIO, NULL, ESP_TASK_MAIN_CORE);

+ 7 - 0
FreeRTOS/portable/esp-idf/riscv/include/freertos/portmacro.h

@@ -340,6 +340,13 @@ FORCE_INLINE_ATTR bool xPortCanYield(void)
 
 
 BaseType_t rt_err_to_freertos(rt_err_t rt_err);
 BaseType_t rt_err_to_freertos(rt_err_t rt_err);
 
 
+#if CONFIG_APPTRACE_SV_ENABLE
+extern int xPortSwitchFlag;
+#define os_task_switch_is_pended(_cpu_) (xPortSwitchFlag)
+#else
+#define os_task_switch_is_pended(_cpu_) (false)
+#endif
+
 #ifdef __cplusplus
 #ifdef __cplusplus
 }
 }
 #endif
 #endif

+ 5 - 1
FreeRTOS/portable/esp-idf/riscv/port.c

@@ -56,7 +56,11 @@
 #include "portmacro.h"
 #include "portmacro.h"
 #include "esp_memory_utils.h"
 #include "esp_memory_utils.h"
 
 
+/* ---------------------------------------------------- Variables ------------------------------------------------------
+ *
+ * ------------------------------------------------------------------------------------------------------------------ */
 
 
+static const char *TAG = "cpu_start";
 
 
 /* ---------------------------------------------- Port Implementations -------------------------------------------------
 /* ---------------------------------------------- Port Implementations -------------------------------------------------
  *
  *
@@ -66,7 +70,7 @@
 
 
 BaseType_t xPortInIsrContext(void)
 BaseType_t xPortInIsrContext(void)
 {
 {
-    rreturn (BaseType_t)rt_interrupt_get_nest();
+    return (BaseType_t)rt_interrupt_get_nest();
 }
 }
 
 
 BaseType_t IRAM_ATTR xPortInterruptedFromISRContext(void)
 BaseType_t IRAM_ATTR xPortInterruptedFromISRContext(void)

+ 17 - 0
FreeRTOS/tasks.c

@@ -494,6 +494,10 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
 void vTaskStartScheduler( void )
 void vTaskStartScheduler( void )
 {
 {
     xSchedulerRunning = pdTRUE;
     xSchedulerRunning = pdTRUE;
+#ifdef ESP_PLATFORM
+    extern int rtthread_startup(void);
+    rtthread_startup();
+#endif
 }
 }
 /*-----------------------------------------------------------*/
 /*-----------------------------------------------------------*/
 
 
@@ -1220,6 +1224,19 @@ TaskHandle_t xTaskGetIdleTaskHandleForCPU( UBaseType_t cpuid )
     return xTaskGetIdleTaskHandle();
     return xTaskGetIdleTaskHandle();
 }
 }
 
 
+#if ( configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H == 1 )
+
+    #include "freertos_tasks_c_additions.h"
+
+    #ifdef FREERTOS_TASKS_C_ADDITIONS_INIT
+        static void freertos_tasks_c_additions_init( void )
+        {
+            FREERTOS_TASKS_C_ADDITIONS_INIT();
+        }
+    #endif
+
+#endif /* if ( configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H == 1 ) */
+
 /* Unimplemented */
 /* Unimplemented */
 #include "esp_log.h"
 #include "esp_log.h"
 static const char *TAG = "freertos";
 static const char *TAG = "freertos";