Skip to content

Commit 1a247d3

Browse files
authored
Merge pull request #186 from hugueskamba/hk-fix-warnings
Clear all warnings generated by the example project files.
2 parents 10a3702 + 54dbe7e commit 1a247d3

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#include "mbed.h"
7+
#include "ThisThread.h"
78
#include "stats_report.h"
89

910
DigitalOut led1(LED1);
@@ -20,7 +21,7 @@ int main()
2021
while (true) {
2122
// Blink LED and wait 0.5 seconds
2223
led1 = !led1;
23-
wait_ms(SLEEP_TIME);
24+
ThisThread::sleep_for(SLEEP_TIME);
2425

2526
if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) {
2627
// Following the main thread wait, report on the current system status

stats_report.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
*/
55

66
#ifndef STATS_REPORT_H
7-
#define STATS_REPORT
7+
#define STATS_REPORT_H
88

9+
#include <inttypes.h>
910
#include "mbed.h"
1011

1112
/**
@@ -37,19 +38,19 @@ class SystemReport {
3738
mbed_stats_sys_get(&sys_stats);
3839

3940
printf("=============================== SYSTEM INFO ================================\r\n");
40-
printf("Mbed OS Version: %ld \r\n", sys_stats.os_version);
41-
printf("CPU ID: 0x%lx \r\n", sys_stats.cpu_id);
41+
printf("Mbed OS Version: %" PRIu32 " \r\n", sys_stats.os_version);
42+
printf("CPU ID: 0x%" PRIx32 " \r\n", sys_stats.cpu_id);
4243
printf("Compiler ID: %d \r\n", sys_stats.compiler_id);
43-
printf("Compiler Version: %ld \r\n", sys_stats.compiler_version);
44+
printf("Compiler Version: %" PRIu32 " \r\n", sys_stats.compiler_version);
4445

4546
for (int i = 0; i < MBED_MAX_MEM_REGIONS; i++) {
4647
if (sys_stats.ram_size[i] != 0) {
47-
printf("RAM%d: Start 0x%lx Size: 0x%lx \r\n", i, sys_stats.ram_start[i], sys_stats.ram_size[i]);
48+
printf("RAM%d: Start 0x%" PRIx32 " Size: 0x%" PRIx32 " \r\n", i, sys_stats.ram_start[i], sys_stats.ram_size[i]);
4849
}
4950
}
5051
for (int i = 0; i < MBED_MAX_MEM_REGIONS; i++) {
5152
if (sys_stats.rom_size[i] != 0) {
52-
printf("ROM%d: Start 0x%lx Size: 0x%lx \r\n", i, sys_stats.rom_start[i], sys_stats.rom_size[i]);
53+
printf("ROM%d: Start 0x%" PRIx32 " Size: 0x%" PRIx32 " \r\n", i, sys_stats.rom_start[i], sys_stats.rom_size[i]);
5354
}
5455
}
5556
}
@@ -104,8 +105,8 @@ class SystemReport {
104105
// Collect and print heap stats
105106
mbed_stats_heap_get(&heap_stats);
106107

107-
printf("Current heap: %lu\r\n", heap_stats.current_size);
108-
printf("Max heap size: %lu\r\n", heap_stats.max_size);
108+
printf("Current heap: %" PRIu32 "\r\n", heap_stats.current_size);
109+
printf("Max heap size: %" PRIu32 "\r\n", heap_stats.max_size);
109110
}
110111

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

121122
for (int i = 0; i < count; i++) {
122-
printf("ID: 0x%lx \r\n", thread_stats[i].id);
123-
printf("Name: %s \r\n", thread_stats[i].name);
124-
printf("State: %ld \r\n", thread_stats[i].state);
125-
printf("Priority: %ld \r\n", thread_stats[i].priority);
126-
printf("Stack Size: %ld \r\n", thread_stats[i].stack_size);
127-
printf("Stack Space: %ld \r\n", thread_stats[i].stack_space);
123+
printf("ID: 0x%" PRIx32 " \r\n", thread_stats[i].id);
124+
printf("Name: %s \r\n", thread_stats[i].name);
125+
printf("State: %" PRIu32 " \r\n", thread_stats[i].state);
126+
printf("Priority: %" PRIu32 " \r\n", thread_stats[i].priority);
127+
printf("Stack Size: %" PRIu32 " \r\n", thread_stats[i].stack_size);
128+
printf("Stack Space: %" PRIu32 " \r\n", thread_stats[i].stack_space);
128129
}
129130
}
130131
};

0 commit comments

Comments
 (0)