From 54dbe7e2aef8a8794e2adfbddbea5a3ee919a00f Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 4 Sep 2019 10:30:14 +0100 Subject: [PATCH] Clear all warnings generated by the example project files. --- main.cpp | 3 ++- stats_report.h | 29 +++++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/main.cpp b/main.cpp index e3448f2f..91e599a8 100644 --- a/main.cpp +++ b/main.cpp @@ -4,6 +4,7 @@ */ #include "mbed.h" +#include "ThisThread.h" #include "stats_report.h" DigitalOut led1(LED1); @@ -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 diff --git a/stats_report.h b/stats_report.h index 62e05726..50f6f2ef 100644 --- a/stats_report.h +++ b/stats_report.h @@ -4,8 +4,9 @@ */ #ifndef STATS_REPORT_H -#define STATS_REPORT +#define STATS_REPORT_H +#include #include "mbed.h" /** @@ -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]); } } } @@ -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); } /** @@ -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); } } };