Skip to content

Commit

Permalink
add clangd and fix some linted warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
xythobuz committed May 20, 2024
1 parent 689a318 commit eb3cf24
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CompileFlags:
Add: [-I/usr/arm-none-eabi/include]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ build_debug
*.wow
.directory
case/stl
.cache
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------------

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
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion include/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@

#include <stdarg.h>
#include <stdbool.h>
#include <inttypes.h>
#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__)
Expand Down
2 changes: 1 addition & 1 deletion src/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/crafty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}

Expand Down

0 comments on commit eb3cf24

Please sign in to comment.