Add the stack high water mark for custom tasks using the printTaskStackHighWaterMark() function.

This commit is contained in:
aixiao 2024-04-14 22:26:12 +08:00
parent c6fdf8d4e2
commit 436bd377f9
3 changed files with 30 additions and 7 deletions

View File

@ -33,29 +33,49 @@ void vApplicationTickHook(void)
{
/* The full demo includes a software timer demo/test that requires
prodding periodically from the tick interrupt. */
/*完整的演示包括软件定时器演示/测试,需要
*/
#if (mainENABLE_TIMER_DEMO == 1)
vTimerPeriodicISRTests();
#endif
/* Call the periodic queue overwrite from ISR demo. */
/*调用ISR演示中的周期性队列覆盖*/
#if (mainENABLE_QUEUE_OVERWRITE == 1)
vQueueOverwritePeriodicISRDemo();
#endif
/* Call the periodic event group from ISR demo. */
/*从ISR演示中调用定期事件组*/
#if (mainENABLE_EVENT_GROUP == 1)
vPeriodicEventGroupsProcessing();
#endif
/* Call the code that uses a mutex from an ISR. */
/*从ISR调用使用互斥的代码*/
#if (mainENABLE_INTERRUPT_SEMAPHORE == 1)
vInterruptSemaphorePeriodicTest();
#endif
/* Call the code that 'gives' a task notification from an ISR. */
/*调用从ISR“发出”任务通知的代码*/
#if (mainENABLE_TASK_NOTIFY == 1)
xNotifyTaskFromISR();
#endif
}
#endif
}
void _printTaskStackHighWaterMark(void)
{
TaskHandle_t currentTask = xTaskGetCurrentTaskHandle();
if (currentTask != NULL)
{
printf("TASK STACK HIGH WATER MARK: %ld\n", uxTaskGetStackHighWaterMark(currentTask));
}
else
{
printf("FAILED TO GET CURRENT TASK HANDLE.\n");
}
}

View File

@ -6,11 +6,17 @@
#include "task.h"
#include "semphr.h"
#include <stdio.h>
#include "hardware/pio.h"
#define BUILD(fmt...) do { fprintf(stderr,"%s %s ",__DATE__,__TIME__); fprintf(stderr, ##fmt); } while(0)
static inline bool uart_rx_program_available(PIO pio, uint sm)
{
return !pio_sm_is_rx_fifo_empty(pio, sm);
}
void _printTaskStackHighWaterMark(void);
#endif

View File

@ -42,9 +42,7 @@ void Read_Onboard_Temperature(void *pvParameters)
adc_set_temp_sensor_enabled(true);
adc_select_input(4); // Input 4 is the onboard temperature sensor.
UBaseType_t uxHighWaterMark;
uxHighWaterMark = uxTaskGetStackHighWaterMark( NULL );
printf("%ld\n", uxHighWaterMark);
_printTaskStackHighWaterMark();
while (1) {
const float conversionFactor = 3.3f / (1 << 12);
@ -54,8 +52,7 @@ void Read_Onboard_Temperature(void *pvParameters)
printf("Onboard temperature %.02f°C %.02f°F\n", tempC, (tempC * 9 / 5 + 32));
uxHighWaterMark = uxTaskGetStackHighWaterMark( NULL );
printf("%ld\n", uxHighWaterMark);
_printTaskStackHighWaterMark();
vTaskDelay(pdMS_TO_TICKS(3000)); // 非阻塞延时
}
@ -88,7 +85,7 @@ int main(void)
{
printf("Temperature Task Error!");
}
/*
// IM1253B 电压、功率模块
xReturned = xTaskCreate(IM1253B, "IM1253B task", 1024, NULL, tskIDLE_PRIORITY, &IM1253B_xHandle);
if (xReturned == errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY)
@ -116,7 +113,7 @@ int main(void)
{
printf("HC-04 Task Error!");
}
*/
vTaskStartScheduler();
return 0;