Просмотр исходного кода

add clangd and fix some linted warnings

Thomas Buck 5 месяцев назад
Родитель
Сommit
eb3cf24075
6 измененных файлов: 13 добавлений и 8 удалений
  1. 2
    0
      .clangd
  2. 1
    0
      .gitignore
  3. 2
    1
      CMakeLists.txt
  4. 2
    1
      include/log.h
  5. 1
    1
      src/cache.c
  6. 5
    5
      src/crafty.c

+ 2
- 0
.clangd Просмотреть файл

@@ -0,0 +1,2 @@
1
+CompileFlags:
2
+  Add: [-I/usr/arm-none-eabi/include]

+ 1
- 0
.gitignore Просмотреть файл

@@ -8,3 +8,4 @@ build_debug
8 8
 *.wow
9 9
 .directory
10 10
 case/stl
11
+.cache

+ 2
- 1
CMakeLists.txt Просмотреть файл

@@ -14,7 +14,7 @@
14 14
 # See <http://www.gnu.org/licenses/>.
15 15
 # ----------------------------------------------------------------------------
16 16
 
17
-cmake_minimum_required(VERSION 3.13)
17
+cmake_minimum_required(VERSION 3.5)
18 18
 
19 19
 # build MCUFont encoder host tool and convert included example fonts
20 20
 execute_process(COMMAND make
@@ -42,6 +42,7 @@ include(pico-sdk/pico_sdk_init.cmake)
42 42
 project(gadget C CXX)
43 43
 set(CMAKE_C_STANDARD 11)
44 44
 set(CMAKE_CXX_STANDARD 17)
45
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
45 46
 
46 47
 # initialize the Raspberry Pi Pico SDK
47 48
 pico_sdk_init()

+ 2
- 1
include/log.h Просмотреть файл

@@ -21,13 +21,14 @@
21 21
 
22 22
 #include <stdarg.h>
23 23
 #include <stdbool.h>
24
+#include <inttypes.h>
24 25
 #include "pico/stdlib.h"
25 26
 
26 27
 // for output that is stored in the debug log.
27 28
 // will be re-played from buffer when terminal connects
28 29
 #ifndef PICOWOTA
29 30
 #define debug(fmt, ...) debug_log(true, \
30
-        "%08lu %s:%d: " fmt "\r\n", \
31
+        "%08" PRIu32 " %s:%d: " fmt "\r\n", \
31 32
         to_ms_since_boot(get_absolute_time()), \
32 33
         __func__, __LINE__, \
33 34
         ##__VA_ARGS__)

+ 1
- 1
src/cache.c Просмотреть файл

@@ -105,7 +105,7 @@ static void cache_flush(size_t i) {
105 105
 
106 106
     // now actually write contents back to flash
107 107
     uint32_t addr = CACHE_FLASH_OFFSET + (cache[i].page * PAGE_SIZE);
108
-    debug("flushing entry %d page %d at 0x%08lX", i, cache[i].page, addr);
108
+    debug("flushing entry %d page %d at 0x%08" PRIX32, i, cache[i].page, addr);
109 109
 
110 110
     struct cache_write_data tmp = { .addr = addr, .buff = cache[i].buff };
111 111
     int r = flash_safe_execute(cache_write_flash, &tmp, FLASH_LOCK_TIMEOUT_MS);

+ 5
- 5
src/crafty.c Просмотреть файл

@@ -52,7 +52,7 @@ int16_t crafty_get_current_temp(void) {
52 52
     uint8_t buff[2];
53 53
     int32_t r = ble_read(uuid_base, buff, sizeof(buff));
54 54
     if (r != sizeof(buff)) {
55
-        debug("ble_read unexpected value %ld", r);
55
+        debug("ble_read unexpected value %" PRId32, r);
56 56
         return -1;
57 57
     }
58 58
 
@@ -66,7 +66,7 @@ int16_t crafty_get_target_temp(void) {
66 66
     uint8_t buff[2];
67 67
     int32_t r = ble_read(uuid_base, buff, sizeof(buff));
68 68
     if (r != sizeof(buff)) {
69
-        debug("ble_read unexpected value %ld", r);
69
+        debug("ble_read unexpected value %" PRId32, r);
70 70
         return -1;
71 71
     }
72 72
 
@@ -84,7 +84,7 @@ int8_t crafty_set_target_temp(uint16_t value) {
84 84
 
85 85
     int8_t r = ble_write(uuid_base, uuid_base2, buff, sizeof(buff));
86 86
     if (r != 0) {
87
-        debug("ble_write unexpected value %d", r);
87
+        debug("ble_write unexpected value %" PRId8, r);
88 88
     }
89 89
     return r;
90 90
 }
@@ -101,7 +101,7 @@ int8_t crafty_set_heater_state(bool value) {
101 101
     uint16_t d = 0;
102 102
     int8_t r = ble_write(uuid_base, uuid_base2, (uint8_t *)&d, sizeof(d));
103 103
     if (r != 0) {
104
-        debug("ble_write unexpected value %d", r);
104
+        debug("ble_write unexpected value %" PRId8, r);
105 105
     }
106 106
     return r;
107 107
 }
@@ -112,7 +112,7 @@ int8_t crafty_get_battery_state(void) {
112 112
     uint8_t buff[2];
113 113
     int32_t r = ble_read(uuid_base, buff, sizeof(buff));
114 114
     if (r != sizeof(buff)) {
115
-        debug("ble_read unexpected value %ld", r);
115
+        debug("ble_read unexpected value %" PRId32, r);
116 116
         return -1;
117 117
     }
118 118
 

Загрузка…
Отмена
Сохранить