From eb3cf2407514100d3973f25b9f74d6772df70697 Mon Sep 17 00:00:00 2001 From: Thomas Buck Date: Mon, 20 May 2024 20:18:53 +0200 Subject: [PATCH] add clangd and fix some linted warnings --- .clangd | 2 ++ .gitignore | 1 + CMakeLists.txt | 3 ++- include/log.h | 3 ++- src/cache.c | 2 +- src/crafty.c | 10 +++++----- 6 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 .clangd diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..d1fb880 --- /dev/null +++ b/.clangd @@ -0,0 +1,2 @@ +CompileFlags: + Add: [-I/usr/arm-none-eabi/include] diff --git a/.gitignore b/.gitignore index 0d83041..3b5f79d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ build_debug *.wow .directory case/stl +.cache diff --git a/CMakeLists.txt b/CMakeLists.txt index ca07912..75bd4d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ # See . # ---------------------------------------------------------------------------- -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.5) # build MCUFont encoder host tool and convert included example fonts execute_process(COMMAND make @@ -42,6 +42,7 @@ include(pico-sdk/pico_sdk_init.cmake) project(gadget C CXX) set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 17) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # initialize the Raspberry Pi Pico SDK pico_sdk_init() diff --git a/include/log.h b/include/log.h index 15bac38..7241c86 100644 --- a/include/log.h +++ b/include/log.h @@ -21,13 +21,14 @@ #include #include +#include #include "pico/stdlib.h" // for output that is stored in the debug log. // will be re-played from buffer when terminal connects #ifndef PICOWOTA #define debug(fmt, ...) debug_log(true, \ - "%08lu %s:%d: " fmt "\r\n", \ + "%08" PRIu32 " %s:%d: " fmt "\r\n", \ to_ms_since_boot(get_absolute_time()), \ __func__, __LINE__, \ ##__VA_ARGS__) diff --git a/src/cache.c b/src/cache.c index 0a82b25..20ebcc3 100644 --- a/src/cache.c +++ b/src/cache.c @@ -105,7 +105,7 @@ static void cache_flush(size_t i) { // now actually write contents back to flash uint32_t addr = CACHE_FLASH_OFFSET + (cache[i].page * PAGE_SIZE); - debug("flushing entry %d page %d at 0x%08lX", i, cache[i].page, addr); + debug("flushing entry %d page %d at 0x%08" PRIX32, i, cache[i].page, addr); struct cache_write_data tmp = { .addr = addr, .buff = cache[i].buff }; int r = flash_safe_execute(cache_write_flash, &tmp, FLASH_LOCK_TIMEOUT_MS); diff --git a/src/crafty.c b/src/crafty.c index 99b6dd9..9bcbeae 100644 --- a/src/crafty.c +++ b/src/crafty.c @@ -52,7 +52,7 @@ int16_t crafty_get_current_temp(void) { uint8_t buff[2]; int32_t r = ble_read(uuid_base, buff, sizeof(buff)); if (r != sizeof(buff)) { - debug("ble_read unexpected value %ld", r); + debug("ble_read unexpected value %" PRId32, r); return -1; } @@ -66,7 +66,7 @@ int16_t crafty_get_target_temp(void) { uint8_t buff[2]; int32_t r = ble_read(uuid_base, buff, sizeof(buff)); if (r != sizeof(buff)) { - debug("ble_read unexpected value %ld", r); + debug("ble_read unexpected value %" PRId32, r); return -1; } @@ -84,7 +84,7 @@ int8_t crafty_set_target_temp(uint16_t value) { int8_t r = ble_write(uuid_base, uuid_base2, buff, sizeof(buff)); if (r != 0) { - debug("ble_write unexpected value %d", r); + debug("ble_write unexpected value %" PRId8, r); } return r; } @@ -101,7 +101,7 @@ int8_t crafty_set_heater_state(bool value) { uint16_t d = 0; int8_t r = ble_write(uuid_base, uuid_base2, (uint8_t *)&d, sizeof(d)); if (r != 0) { - debug("ble_write unexpected value %d", r); + debug("ble_write unexpected value %" PRId8, r); } return r; } @@ -112,7 +112,7 @@ int8_t crafty_get_battery_state(void) { uint8_t buff[2]; int32_t r = ble_read(uuid_base, buff, sizeof(buff)); if (r != sizeof(buff)) { - debug("ble_read unexpected value %ld", r); + debug("ble_read unexpected value %" PRId32, r); return -1; }