Przeglądaj źródła

add clangd and fix some linted warnings

Thomas Buck 11 miesięcy temu
rodzic
commit
eb3cf24075
6 zmienionych plików z 13 dodań i 8 usunięć
  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 Wyświetl plik

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

+ 1
- 0
.gitignore Wyświetl plik

8
 *.wow
8
 *.wow
9
 .directory
9
 .directory
10
 case/stl
10
 case/stl
11
+.cache

+ 2
- 1
CMakeLists.txt Wyświetl plik

14
 # See <http://www.gnu.org/licenses/>.
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
 # build MCUFont encoder host tool and convert included example fonts
19
 # build MCUFont encoder host tool and convert included example fonts
20
 execute_process(COMMAND make
20
 execute_process(COMMAND make
42
 project(gadget C CXX)
42
 project(gadget C CXX)
43
 set(CMAKE_C_STANDARD 11)
43
 set(CMAKE_C_STANDARD 11)
44
 set(CMAKE_CXX_STANDARD 17)
44
 set(CMAKE_CXX_STANDARD 17)
45
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
45
 
46
 
46
 # initialize the Raspberry Pi Pico SDK
47
 # initialize the Raspberry Pi Pico SDK
47
 pico_sdk_init()
48
 pico_sdk_init()

+ 2
- 1
include/log.h Wyświetl plik

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

+ 1
- 1
src/cache.c Wyświetl plik

105
 
105
 
106
     // now actually write contents back to flash
106
     // now actually write contents back to flash
107
     uint32_t addr = CACHE_FLASH_OFFSET + (cache[i].page * PAGE_SIZE);
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
     struct cache_write_data tmp = { .addr = addr, .buff = cache[i].buff };
110
     struct cache_write_data tmp = { .addr = addr, .buff = cache[i].buff };
111
     int r = flash_safe_execute(cache_write_flash, &tmp, FLASH_LOCK_TIMEOUT_MS);
111
     int r = flash_safe_execute(cache_write_flash, &tmp, FLASH_LOCK_TIMEOUT_MS);

+ 5
- 5
src/crafty.c Wyświetl plik

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

Ładowanie…
Anuluj
Zapisz