From 236b06b3591f581fdaf8e396b4bf5499450e5c50 Mon Sep 17 00:00:00 2001 From: Ethan Havemann Date: Tue, 3 Dec 2024 20:30:09 -0600 Subject: [PATCH] Fix Formatting --- .clang-format-ignore | 2 ++ Makefile | 8 ++------ include/hal/i2c_controller.hpp | 7 +++---- include/hal/i2c_wrapper.hpp | 5 +++-- include/scheduler/mpu.hpp | 2 +- src/hal/i2c_controller.cpp | 6 +++--- src/hal/i2c_wrapper.cpp | 12 +++++------- src/user_programs/user_program_ipc_part_1.cpp | 4 ++-- 8 files changed, 21 insertions(+), 25 deletions(-) create mode 100644 .clang-format-ignore diff --git a/.clang-format-ignore b/.clang-format-ignore new file mode 100644 index 00000000..bac011f2 --- /dev/null +++ b/.clang-format-ignore @@ -0,0 +1,2 @@ +src/scheduler/scheduler.cpp +include/scheduler/scheduler.hpp diff --git a/Makefile b/Makefile index bdcafee5..7eecfa67 100644 --- a/Makefile +++ b/Makefile @@ -49,12 +49,8 @@ CPP_FILES := $(wildcard src/*.cpp include/*.hpp) .PHONY: format format: - clang-format -style=file -i $(CPP_FILES) - -.PHONY: tidy -tidy: - clang-tidy $(CPP_FILES) -- -std=c++20 + find src include -name '*.cpp' -o -name '*.hpp' | xargs clang-format --style=file -i .PHONY: lint -lint: format tidy +lint: format diff --git a/include/hal/i2c_controller.hpp b/include/hal/i2c_controller.hpp index e52c7a43..ff58db08 100644 --- a/include/hal/i2c_controller.hpp +++ b/include/hal/i2c_controller.hpp @@ -1,13 +1,12 @@ #pragma once -namespace edge::aidan -{ +namespace edge::aidan { -class I2CController -{ +class I2CController { public: ~I2CController() = default; static I2CController& get(); + private: I2CController(); }; diff --git a/include/hal/i2c_wrapper.hpp b/include/hal/i2c_wrapper.hpp index 0a512d99..d98cb389 100644 --- a/include/hal/i2c_wrapper.hpp +++ b/include/hal/i2c_wrapper.hpp @@ -1,8 +1,9 @@ #pragma once -#include -#include "nrf_twi_mngr.h" #include "nrf_delay.h" +#include "nrf_twi_mngr.h" + +#include namespace edge::aidan { diff --git a/include/scheduler/mpu.hpp b/include/scheduler/mpu.hpp index 53f357f2..41e7d796 100644 --- a/include/scheduler/mpu.hpp +++ b/include/scheduler/mpu.hpp @@ -4,7 +4,7 @@ namespace edge { class MpuController { - MpuController() { } + MpuController() {} ~MpuController() { disable_mpu(); }; diff --git a/src/hal/i2c_controller.cpp b/src/hal/i2c_controller.cpp index 7515bbe4..b6a2d599 100644 --- a/src/hal/i2c_controller.cpp +++ b/src/hal/i2c_controller.cpp @@ -1,12 +1,12 @@ #include "hal/i2c_controller.hpp" + #include "hal/i2c_wrapper.hpp" -#include "nrf_drv_twi.h" #include "microbit_v2.h" +#include "nrf_drv_twi.h" #include "nrf_twi.h" #include "nrf_twi_mngr.h" -namespace edge::aidan -{ +namespace edge::aidan { static constexpr int QUEUE_SIZE = 1; NRF_TWI_MNGR_DEF(twi_mngr, QUEUE_SIZE, 0); diff --git a/src/hal/i2c_wrapper.cpp b/src/hal/i2c_wrapper.cpp index 915c001f..3e7bc15d 100644 --- a/src/hal/i2c_wrapper.cpp +++ b/src/hal/i2c_wrapper.cpp @@ -1,11 +1,11 @@ #include "hal/i2c_wrapper.hpp" + #include "nrf_error.h" #include "nrf_twi_mngr.h" #include "sdk_errors.h" namespace edge::aidan { - NRF_TWI_MNGR_DEF(twi_mngr, 1, 0); static const nrf_twi_mngr_t* i2c_manager = &twi_mngr; @@ -17,8 +17,7 @@ uint8_t i2c_reg_read(uint8_t i2c_addr, uint8_t reg_addr) NRF_TWI_MNGR_READ(i2c_addr, &rx_buf, 1, NRF_TWI_MNGR_NO_STOP) }; ret_code_t result = nrf_twi_mngr_perform(i2c_manager, NULL, read_transfer, 2, NULL); - if (result != NRF_SUCCESS) - { + if (result != NRF_SUCCESS) { printf("I2C TRANSACTION FAILED!"); } return rx_buf; @@ -31,9 +30,9 @@ void i2c_reg_write(uint8_t i2c_addr, uint8_t reg_addr, uint8_t data) nrf_twi_mngr_transfer_t const write_transfer[] = { NRF_TWI_MNGR_WRITE(i2c_addr, &rx_buf, 2, NRF_TWI_MNGR_NO_STOP), }; - ret_code_t result = nrf_twi_mngr_perform(i2c_manager, NULL, write_transfer, 1, NULL); - if (result != NRF_SUCCESS) - { + ret_code_t result = + nrf_twi_mngr_perform(i2c_manager, NULL, write_transfer, 1, NULL); + if (result != NRF_SUCCESS) { printf("I2C transaction failed! Error: %lX\n", result); } } @@ -67,5 +66,4 @@ void lsm303agr_init() i2c_reg_write(LSM303AGR_ACC_ADDRESS, TEMP_CFG_REG_A, 0xC0); } - } // namespace edge::aidan diff --git a/src/user_programs/user_program_ipc_part_1.cpp b/src/user_programs/user_program_ipc_part_1.cpp index 985269a2..db6a77eb 100644 --- a/src/user_programs/user_program_ipc_part_1.cpp +++ b/src/user_programs/user_program_ipc_part_1.cpp @@ -1,6 +1,7 @@ -#include "userlib/syscalls.hpp" #include "nrf52833.h" #include "nrf_delay.h" +#include "userlib/syscalls.hpp" + #include void ipc_part1(void) @@ -25,4 +26,3 @@ void ipc_part1(void) } } } -