Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

#include "mbed.h"
#include "ThisThread.h"
#include "stats_report.h"

DigitalOut led1(LED1);
Expand All @@ -20,7 +21,7 @@ int main()
while (true) {
// Blink LED and wait 0.5 seconds
led1 = !led1;
wait_ms(SLEEP_TIME);
ThisThread::sleep_for(SLEEP_TIME);

if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) {
// Following the main thread wait, report on the current system status
Expand Down
29 changes: 15 additions & 14 deletions stats_report.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
*/

#ifndef STATS_REPORT_H
#define STATS_REPORT
#define STATS_REPORT_H

#include <inttypes.h>
#include "mbed.h"

/**
Expand Down Expand Up @@ -37,19 +38,19 @@ class SystemReport {
mbed_stats_sys_get(&sys_stats);

printf("=============================== SYSTEM INFO ================================\r\n");
printf("Mbed OS Version: %ld \r\n", sys_stats.os_version);
printf("CPU ID: 0x%lx \r\n", sys_stats.cpu_id);
printf("Mbed OS Version: %" PRIu32 " \r\n", sys_stats.os_version);
printf("CPU ID: 0x%" PRIx32 " \r\n", sys_stats.cpu_id);
printf("Compiler ID: %d \r\n", sys_stats.compiler_id);
printf("Compiler Version: %ld \r\n", sys_stats.compiler_version);
printf("Compiler Version: %" PRIu32 " \r\n", sys_stats.compiler_version);

for (int i = 0; i < MBED_MAX_MEM_REGIONS; i++) {
if (sys_stats.ram_size[i] != 0) {
printf("RAM%d: Start 0x%lx Size: 0x%lx \r\n", i, sys_stats.ram_start[i], sys_stats.ram_size[i]);
printf("RAM%d: Start 0x%" PRIx32 " Size: 0x%" PRIx32 " \r\n", i, sys_stats.ram_start[i], sys_stats.ram_size[i]);
}
}
for (int i = 0; i < MBED_MAX_MEM_REGIONS; i++) {
if (sys_stats.rom_size[i] != 0) {
printf("ROM%d: Start 0x%lx Size: 0x%lx \r\n", i, sys_stats.rom_start[i], sys_stats.rom_size[i]);
printf("ROM%d: Start 0x%" PRIx32 " Size: 0x%" PRIx32 " \r\n", i, sys_stats.rom_start[i], sys_stats.rom_size[i]);
}
}
}
Expand Down Expand Up @@ -104,8 +105,8 @@ class SystemReport {
// Collect and print heap stats
mbed_stats_heap_get(&heap_stats);

printf("Current heap: %lu\r\n", heap_stats.current_size);
printf("Max heap size: %lu\r\n", heap_stats.max_size);
printf("Current heap: %" PRIu32 "\r\n", heap_stats.current_size);
printf("Max heap size: %" PRIu32 "\r\n", heap_stats.max_size);
}

/**
Expand All @@ -119,12 +120,12 @@ class SystemReport {
int count = mbed_stats_thread_get_each(thread_stats, max_thread_count);

for (int i = 0; i < count; i++) {
printf("ID: 0x%lx \r\n", thread_stats[i].id);
printf("Name: %s \r\n", thread_stats[i].name);
printf("State: %ld \r\n", thread_stats[i].state);
printf("Priority: %ld \r\n", thread_stats[i].priority);
printf("Stack Size: %ld \r\n", thread_stats[i].stack_size);
printf("Stack Space: %ld \r\n", thread_stats[i].stack_space);
printf("ID: 0x%" PRIx32 " \r\n", thread_stats[i].id);
printf("Name: %s \r\n", thread_stats[i].name);
printf("State: %" PRIu32 " \r\n", thread_stats[i].state);
printf("Priority: %" PRIu32 " \r\n", thread_stats[i].priority);
printf("Stack Size: %" PRIu32 " \r\n", thread_stats[i].stack_size);
printf("Stack Space: %" PRIu32 " \r\n", thread_stats[i].stack_space);
}
}
};
Expand Down