Skip to content

Commit

Permalink
debug system info
Browse files Browse the repository at this point in the history
  • Loading branch information
jia-xie committed Apr 6, 2024
1 parent 488af43 commit ccdc1c9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/typec-board-base
2 changes: 1 addition & 1 deletion src/app/inc/debug_task.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef DEBUG_TASK_H
#define DEBUG_TASK_H

#define DEBUG_PERIOD (1)
#define DEBUG_PERIOD (10)

void Debug_Task_Init(void);
void Debug_Task_Loop(void);
Expand Down
27 changes: 25 additions & 2 deletions src/app/src/debug_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,37 @@ extern Remote_t g_remote;
extern Launch_Target_t g_launch_target;
extern uint64_t t;
extern Daemon_Instance_t *g_daemon_instances[3];
extern Daemon_Instance_t *g_remote_daemon;
#define PRINT_RUNTIME_STATS
#ifdef PRINT_RUNTIME_STATS
char g_debug_buffer[1024*2] = {0};
#endif

const char* top_border = "\r\n\r\n\r\n/***** System Info *****/\r\n";
const char* bottom_border = "/***** End of Info *****/\r\n";

#define DEBUG_ENABLED

void Debug_Task_Loop(void)
{
#ifdef DEBUG_ENABLED
static uint32_t counter = 0;
DEBUG_PRINTF(&huart6, "time=%.1f,a=%d,b=%d,c=%f,d=%d\r\n", (float) counter / 1000.0f * DEBUG_PERIOD,
2, 12, g_imu.deg.roll, counter);
#ifdef PRINT_RUNTIME_STATS
if (counter % 100 == 0) // Print every 100 cycles
{
vTaskGetRunTimeStats(g_debug_buffer);
DEBUG_PRINTF(&huart6, "%s", top_border);
DEBUG_PRINTF(&huart6, "%s", g_debug_buffer);
DEBUG_PRINTF(&huart6, "%s", bottom_border);
}
#endif

DEBUG_PRINTF(&huart6, ">time:%.1f\n>yaw:%f\n>pitch:%f\n>roll:%f\n", (float) counter / 1000.0f * DEBUG_PERIOD,
g_imu.deg.yaw, g_imu.deg.pitch, g_imu.deg.roll);
DEBUG_PRINTF(&huart6, ">remote_daemon:%d\n", g_remote_daemon->counter);
counter++;
if (counter > 0xFFFFFFFF) {
counter = 0;
}
#endif
}

0 comments on commit ccdc1c9

Please sign in to comment.