From b981183466ddfcfe322f76f68b3fd8deebbcd3ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Betto?= <niccolo.betto@skywarder.eu> Date: Thu, 5 Dec 2024 14:42:07 +0100 Subject: [PATCH] [Format] Reformat all files with clang-format 18 --- .../stm32f205rc_ciuti/core/stage_1_boot.cpp | 10 +- .../stm32f429zi_con_rig/core/stage_1_boot.cpp | 10 +- .../core/stage_1_boot.cpp | 10 +- .../core/stage_1_boot.cpp | 10 +- .../core/stage_1_boot.cpp | 10 +- .../stm32f429zi_nokia/core/stage_1_boot.cpp | 10 +- .../core/stage_1_boot.cpp | 10 +- .../core/stage_1_boot.cpp | 10 +- .../interfaces-impl/arch_registers_impl.h | 2 +- .../stm32f429zi_rig/core/stage_1_boot.cpp | 10 +- .../stm32f756zg_nucleo/core/stage_1_boot.cpp | 10 +- .../core/stage_1_boot.cpp | 13 +- .../interfaces-impl/hwmapping.h | 2 +- .../core/stage_1_boot.cpp | 13 +- .../core/stage_1_boot.cpp | 13 +- .../interfaces-impl/bsp.cpp | 6 +- .../core/stage_1_boot.cpp | 13 +- .../interfaces-impl/hwmapping.h | 2 +- .../core/stage_1_boot.cpp | 13 +- .../core/stage_1_boot.cpp | 13 +- .../core/stage_1_boot.cpp | 13 +- .../interfaces-impl/bsp.cpp | 6 +- .../interfaces-impl/hwmapping.h | 2 +- .../stm32f767zi_lyra_gs/core/stage_1_boot.cpp | 13 +- .../interfaces-impl/bsp_impl.h | 2 +- .../core/stage_1_boot.cpp | 13 +- .../interfaces-impl/bsp.cpp | 6 +- .../interfaces-impl/hwmapping.h | 2 +- .../stm32f767zi_rig_v2/core/stage_1_boot.cpp | 13 +- .../interfaces-impl/bsp.cpp | 6 +- .../interfaces-impl/hwmapping.h | 2 +- src/entrypoints/compute-unit-v2-testsuite.cpp | 58 +- src/entrypoints/config-dsgamma.cpp | 6 - src/entrypoints/kernel-testsuite.cpp | 557 ++++++++-------- src/entrypoints/runcam-settings.cpp | 8 - src/entrypoints/sdcard-benchmark.cpp | 4 + src/entrypoints/sx1278-serial.cpp | 22 +- src/shared/ActiveObject.h | 5 +- src/shared/actuators/Buzzer.h | 4 +- src/shared/actuators/stepper/Stepper.cpp | 18 +- src/shared/actuators/stepper/Stepper.h | 2 +- src/shared/actuators/stepper/StepperPWM.cpp | 4 +- src/shared/actuators/stepper/StepperPWM.h | 10 +- .../algorithms/AirBrakes/AirBrakesInterp.cpp | 12 +- .../algorithms/AirBrakes/AirBrakesInterp.h | 14 +- .../algorithms/AirBrakes/AirBrakesPI.cpp | 6 +- src/shared/algorithms/AirBrakes/AirBrakesPI.h | 12 +- src/shared/algorithms/AirBrakes/Trajectory.h | 2 +- src/shared/algorithms/Algorithm.h | 2 - src/shared/algorithms/Follower/Follower.cpp | 14 +- src/shared/algorithms/Follower/FollowerData.h | 10 +- src/shared/algorithms/MEA/MEA.cpp | 25 +- src/shared/algorithms/MEA/MEA.h | 16 +- src/shared/algorithms/MEA/MEAData.h | 4 +- src/shared/algorithms/NAS/NAS.cpp | 8 - src/shared/algorithms/PIController.h | 1 - src/shared/algorithms/ReferenceValues.h | 2 +- src/shared/diagnostic/PrintLogger.cpp | 8 - src/shared/diagnostic/StackLogger.h | 2 - src/shared/drivers/WIZ5500/WIZ5500.cpp | 85 +-- src/shared/drivers/WIZ5500/WIZ5500.h | 2 +- src/shared/drivers/WIZ5500/WIZ5500Defs.h | 2 +- src/shared/drivers/adc/InternalADC.cpp | 18 +- src/shared/drivers/adc/InternalADC.h | 4 +- src/shared/drivers/adc/InternalADCData.h | 2 - .../canbus/CanDriver/BusLoadEstimation.h | 4 - .../drivers/canbus/CanDriver/CanDriver.cpp | 8 - src/shared/drivers/canbus/CanDriver/Filters.h | 4 - .../canbus/CanProtocol/CanProtocol.cpp | 2 + .../drivers/canbus/CanProtocol/CanProtocol.h | 2 + src/shared/drivers/dma/DMAStream.h | 55 +- src/shared/drivers/i2c/I2C.cpp | 82 +-- src/shared/drivers/i2c/I2C.h | 102 +-- src/shared/drivers/i2c/I2CDriver-f4.cpp | 62 +- src/shared/drivers/i2c/I2CDriver-f7.cpp | 74 +-- src/shared/drivers/i2c/I2CDriver.h | 34 +- src/shared/drivers/i2c/stm32f2_f4_i2c.cpp | 20 +- .../drivers/interrupt/external_interrupts.cpp | 6 +- .../drivers/interrupt/external_interrupts.h | 2 +- src/shared/drivers/runcam/Runcam.cpp | 2 +- src/shared/drivers/runcam/Runcam.h | 4 +- src/shared/drivers/spi/SPIBus.h | 4 - src/shared/drivers/spi/SPITransaction.h | 30 +- src/shared/drivers/timer/BasicTimer.h | 14 +- src/shared/drivers/timer/CountedPWM.cpp | 2 +- src/shared/drivers/timer/CountedPWM.h | 2 +- .../drivers/timer/GeneralPurposeTimer.h | 8 +- src/shared/drivers/timer/TimerUtils.h | 52 +- src/shared/drivers/usart/USART.cpp | 72 +-- src/shared/drivers/usart/USART.h | 56 +- src/shared/events/EventBroker.cpp | 12 - src/shared/events/EventHandler.h | 4 +- src/shared/events/HSM.h | 4 +- src/shared/events/utils/EventCounter.h | 4 +- src/shared/events/utils/EventSniffer.h | 6 - src/shared/hil/HIL.h | 24 +- src/shared/hil/HILPhasesManager.h | 10 +- src/shared/hil/HILTransceiver.h | 20 +- src/shared/logger/Logger.cpp | 2 + src/shared/logger/Logger.h | 24 +- src/shared/radio/SX1278/SX1278Common.cpp | 26 +- src/shared/radio/SX1278/SX1278Common.h | 24 +- src/shared/radio/SX1278/SX1278Defs.h | 4 +- src/shared/radio/SX1278/SX1278Frontends.h | 2 +- src/shared/radio/SX1278/SX1278Fsk.cpp | 24 +- src/shared/radio/SX1278/SX1278Fsk.h | 10 +- src/shared/radio/SX1278/SX1278Lora.cpp | 26 +- src/shared/radio/SX1278/SX1278Lora.h | 14 +- src/shared/radio/Xbee/APIFrameParser.cpp | 6 - src/shared/radio/Xbee/APIFrames.h | 4 - src/shared/radio/Xbee/APIFramesLog.h | 28 - src/shared/radio/Xbee/ATCommands.h | 2 - src/shared/radio/Xbee/Xbee.cpp | 4 + src/shared/scheduler/TaskScheduler.cpp | 12 - src/shared/sensors/ADS1118/ADS1118.cpp | 18 +- src/shared/sensors/ADS1118/ADS1118.h | 18 +- src/shared/sensors/ADS131M04/ADS131M04.cpp | 24 +- src/shared/sensors/ADS131M08/ADS131M08.cpp | 24 +- src/shared/sensors/BME280/BME280.cpp | 8 +- src/shared/sensors/BME280/BME280I2C.cpp | 15 +- src/shared/sensors/BMP280/BMP280.cpp | 6 +- src/shared/sensors/BMP280/BMP280Data.h | 7 +- src/shared/sensors/BMP280/BMP280I2C.cpp | 12 +- src/shared/sensors/BMX160/BMX160.cpp | 15 +- src/shared/sensors/H3LIS331DL/H3LIS331DL.cpp | 2 - src/shared/sensors/H3LIS331DL/H3LIS331DL.h | 1 - .../sensors/H3LIS331DL/H3LIS331DLData.h | 7 +- src/shared/sensors/HILSensor.h | 6 +- src/shared/sensors/HX711/HX711.cpp | 2 +- src/shared/sensors/LIS2MDL/LIS2MDL.cpp | 2 +- src/shared/sensors/LIS2MDL/LIS2MDLData.h | 2 +- src/shared/sensors/LIS331HH/LIS331HH.h | 2 +- src/shared/sensors/LIS3DSH/LIS3DSH.h | 6 - src/shared/sensors/LIS3MDL/LIS3MDL.cpp | 3 - src/shared/sensors/LPS22DF/LPS22DF.h | 2 +- src/shared/sensors/LPS22DF/LPS22DFData.h | 4 +- src/shared/sensors/LPS22DF/LPS22DFDefs.h | 2 +- src/shared/sensors/LPS28DFW/LPS28DFW.h | 2 +- src/shared/sensors/LPS28DFW/LPS28DFWData.h | 1 - src/shared/sensors/LPS28DFW/LPS28DFWDefs.h | 2 +- src/shared/sensors/LPS331AP/LPS331AP.cpp | 3 - src/shared/sensors/LPS331AP/LPS331APData.h | 6 +- src/shared/sensors/LSM6DSRX/LSM6DSRX.cpp | 8 - src/shared/sensors/LSM6DSRX/LSM6DSRXConfig.h | 1 - src/shared/sensors/MAX31855/MAX31855.h | 2 +- src/shared/sensors/MAX31856/MAX31856.cpp | 1 - src/shared/sensors/MAX31856/MAX31856.h | 2 +- src/shared/sensors/MAX31856/MAX31856Data.h | 2 +- src/shared/sensors/MAX6675/MAX6675.cpp | 2 +- src/shared/sensors/MAX6675/MAX6675.h | 2 +- src/shared/sensors/MBLoadCell/MBLoadCell.cpp | 8 +- src/shared/sensors/MBLoadCell/MBLoadCell.h | 10 +- .../sensors/MBLoadCell/MBLoadCellData.h | 2 - src/shared/sensors/MPU9250/MPU9250.cpp | 2 - src/shared/sensors/MS5803/MS5803Data.h | 6 +- src/shared/sensors/SensorInfo.h | 2 +- src/shared/sensors/SensorManager.cpp | 2 + src/shared/sensors/SensorSampler.cpp | 8 - src/shared/sensors/UBXGPS/UBXGPSData.h | 4 +- src/shared/sensors/UBXGPS/UBXGPSSerial.cpp | 11 +- src/shared/sensors/UBXGPS/UBXGPSSpi.cpp | 6 + .../sensors/Vectornav/VN100/VN100Serial.cpp | 62 +- .../sensors/Vectornav/VN100/VN100Serial.h | 18 +- .../sensors/Vectornav/VN100/VN100SerialData.h | 5 +- .../sensors/Vectornav/VN100/VN100Spi.cpp | 2 - .../sensors/Vectornav/VN100/VN100SpiData.h | 5 +- src/shared/sensors/Vectornav/VN300/VN300.cpp | 27 - .../sensors/Vectornav/VN300/VN300Data.h | 5 +- .../sensors/Vectornav/VNCommonSerial.cpp | 62 +- src/shared/sensors/Vectornav/VNCommonSerial.h | 24 +- src/shared/sensors/analog/CurrentSensor.h | 2 - .../sensors/analog/TrafagPressureSensor.h | 6 +- .../sensors/analog/TwoPointAnalogLoadCell.h | 6 +- .../SoftAndHardIronCalibration.cpp | 2 + src/shared/units/Acceleration.h | 4 +- src/shared/units/Angle.h | 4 +- src/shared/units/Length.h | 4 +- src/shared/units/Pressure.h | 4 +- src/shared/units/Speed.h | 4 +- src/shared/units/Time.h | 6 +- src/shared/units/Units.h | 54 +- .../utils/ButtonHandler/ButtonHandler.cpp | 6 +- src/shared/utils/CRC.h | 4 +- src/shared/utils/CSVReader/CSVReader.h | 5 +- src/shared/utils/ClockUtils.h | 8 - .../DependencyManager/DependencyManager.cpp | 12 - .../DependencyManager/DependencyManager.h | 54 +- src/shared/utils/KernelTime.h | 2 +- src/shared/utils/Numeric.h | 6 - src/shared/utils/PinObserver/PinObserver.cpp | 8 +- src/shared/utils/PinObserver/PinObserver.h | 4 +- .../utils/Registry/Backend/FileBackend.h | 2 +- src/shared/utils/Registry/RegistryBackend.h | 2 +- .../utils/Registry/RegistryFrontend.cpp | 4 +- src/shared/utils/Registry/RegistryFrontend.h | 4 +- .../utils/Registry/RegistrySerializer.cpp | 6 +- .../utils/Registry/RegistrySerializer.h | 2 +- src/shared/utils/Registry/RegistryTypes.h | 3 +- .../utils/SkyQuaternion/SkyQuaternion.cpp | 59 +- src/shared/utils/TestUtils/MockSPIBus.h | 21 - .../utils/TestUtils/ThroughputCalculator.h | 6 - src/shared/utils/collections/CircularBuffer.h | 8 +- .../utils/collections/IRQCircularBuffer.h | 2 + .../utils/collections/SyncCircularBuffer.h | 2 - .../utils/collections/SyncPacketQueue.h | 5 +- src/shared/utils/gui/GridLayout.h | 6 - src/shared/utils/gui/NavController.h | 18 +- src/shared/utils/gui/OptionView.h | 12 - src/shared/utils/gui/ScreenManager.h | 4 - src/shared/utils/gui/TextView.h | 4 - src/shared/utils/gui/VerticalLayout.h | 4 - src/shared/utils/gui/View.h | 8 - src/tests/actuators/test-hbridge.cpp | 4 - src/tests/actuators/test-stepper-pwm.cpp | 2 +- src/tests/algorithms/ADA/ValueFollower.h | 8 +- src/tests/algorithms/ADA/test-ada.cpp | 2 +- .../Airbrakes/test-airbrakesInterp-data.h | 2 +- .../test-airbrakesInterp-references.h | 2 +- .../algorithms/NAS/test-nas-parafoil.cpp | 2 + .../algorithms/NAS/test-triad-parafoil.cpp | 2 + src/tests/algorithms/NAS/test-triad.cpp | 2 + src/tests/boards/test-compute-unit.cpp | 2 +- src/tests/catch/catch-tests-entry.cpp | 6 - .../catch/propagator/test-propagator-data.h | 602 +++++++++--------- .../catch/propagator/test-propagator.cpp | 2 +- .../skyQuaternion/test-skyquaternion.cpp | 4 +- src/tests/catch/test-MEA.cpp | 2 +- src/tests/catch/test-aero.cpp | 8 +- src/tests/catch/test-airbrakesInterp.cpp | 4 +- src/tests/catch/test-buttonhandler.cpp | 3 - src/tests/catch/test-dependencymanager.cpp | 32 +- src/tests/catch/test-kalman.cpp | 2 - src/tests/catch/test-modulemanager.cpp | 4 +- src/tests/catch/test-packetqueue.cpp | 2 - src/tests/catch/test-pitot.cpp | 2 +- src/tests/catch/test-registry-frontend.cpp | 10 +- src/tests/catch/test-sensormanager-catch.cpp | 50 +- src/tests/catch/test-units.cpp | 4 +- src/tests/catch/xbee/MockXbeeSPIBus.h | 2 - src/tests/catch/xbee/test-xbee-parser.cpp | 8 - .../canbus/CanDriver/SimpleCanManager.h | 2 - .../canbus/CanDriver/test-can-2way.cpp | 8 - .../canbus/CanDriver/test-can-loopback.cpp | 3 - src/tests/drivers/i2c/test-i2c-driver.cpp | 2 +- src/tests/drivers/i2c/test-i2c.cpp | 2 +- src/tests/drivers/test-MBLoadCell.cpp | 4 +- src/tests/drivers/test-wiz5500.cpp | 16 +- src/tests/drivers/timer/test-timer-utils.cpp | 8 +- .../drivers/timer/test-timestamptimer.cpp | 8 +- src/tests/drivers/usart/test-usart.cpp | 16 +- src/tests/drivers/xbee/EnergyScanData.h | 6 - src/tests/drivers/xbee/XbeeTestData.h | 6 - src/tests/drivers/xbee/XbeeTransceiver.h | 22 - src/tests/drivers/xbee/gui/EnergyScanScreen.h | 10 - src/tests/drivers/xbee/gui/StatusScreen.h | 4 - src/tests/drivers/xbee/test-xbee-bidir.cpp | 10 - src/tests/drivers/xbee/test-xbee-gui.cpp | 15 - src/tests/events/fsm/test-fsm.cpp | 2 - src/tests/hil/BoardScheduler.cpp | 2 +- src/tests/hil/BoardScheduler.h | 2 +- src/tests/hil/Buses.h | 2 +- src/tests/hil/HILSimulationConfig.h | 2 +- src/tests/hil/Sensors/HILSensors.h | 2 +- src/tests/hil/Sensors/Sensors.cpp | 14 +- src/tests/hil/Sensors/Sensors.h | 2 +- src/tests/hil/Sensors/SensorsConfig.h | 2 +- src/tests/hil/Sensors/SensorsData.h | 8 +- src/tests/hil/test-hil.cpp | 4 +- src/tests/logger/test-logger.cpp | 2 - src/tests/radio/sx1278/fsk/common.h | 6 +- .../radio/sx1278/fsk/test-sx1278-bidir.cpp | 10 +- src/tests/radio/sx1278/gui/GUI.h | 2 +- .../radio/sx1278/lora/test-sx1278-bidir.cpp | 16 +- .../radio/sx1278/lora/test-sx1278-simple.cpp | 3 +- src/tests/radio/sx1278/sx1278-init.h | 4 +- .../radio/sx1278/test-sx1278-bench-gui.cpp | 4 +- .../radio/sx1278/test-sx1278-bench-serial.cpp | 2 - src/tests/radio/sx1278/test-sx1278-bench.cpp | 4 +- src/tests/scheduler/test-taskscheduler.cpp | 10 - .../analog/test-analog-pressure-sensors.cpp | 4 - .../calibration/test-calibration-stats.cpp | 2 - src/tests/sensors/test-ads1118.cpp | 4 - src/tests/sensors/test-ads131m04.cpp | 4 - src/tests/sensors/test-ads131m08.cpp | 4 - src/tests/sensors/test-bmp280-i2c.cpp | 4 - src/tests/sensors/test-bmx160.cpp | 4 +- src/tests/sensors/test-h3lis331dl.cpp | 2 - src/tests/sensors/test-l3gd20-fifo.cpp | 6 - src/tests/sensors/test-l3gd20.cpp | 4 - src/tests/sensors/test-lis2mdl.cpp | 2 - src/tests/sensors/test-lis3dsh.cpp | 6 - src/tests/sensors/test-lis3mdl.cpp | 2 - src/tests/sensors/test-lps28dfw.cpp | 23 +- src/tests/sensors/test-lps331ap.cpp | 4 - src/tests/sensors/test-lsm6dsrx.cpp | 9 - src/tests/sensors/test-max31855.cpp | 2 - src/tests/sensors/test-max31856.cpp | 4 - src/tests/sensors/test-max6675.cpp | 2 - src/tests/sensors/test-ms5803-i2c.cpp | 4 - src/tests/sensors/test-ms5803-spi.cpp | 2 - src/tests/sensors/test-ubxgps-serial.cpp | 8 - src/tests/test-hsm.cpp | 9 - src/tests/test-max485.cpp | 8 +- src/tests/test-sensormanager.cpp | 4 - src/tests/test-trace-logger.cpp | 2 - src/tests/utils/test-buttonhandler.cpp | 2 +- 306 files changed, 1690 insertions(+), 2559 deletions(-) mode change 100755 => 100644 src/shared/sensors/Vectornav/VN300/VN300.cpp diff --git a/src/bsps/stm32f205rc_ciuti/core/stage_1_boot.cpp b/src/bsps/stm32f205rc_ciuti/core/stage_1_boot.cpp index c3f27e6bb..1fda9b23f 100644 --- a/src/bsps/stm32f205rc_ciuti/core/stage_1_boot.cpp +++ b/src/bsps/stm32f205rc_ciuti/core/stage_1_boot.cpp @@ -54,11 +54,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; // The memcpy is usually enclosed in an #ifndef __ENABLE_XRAM, in other // boards but in this case it is not, since the *_code_in_xram.ld linker // script puts code in XRAM, but data in the internal one, so there's still diff --git a/src/bsps/stm32f429zi_con_rig/core/stage_1_boot.cpp b/src/bsps/stm32f429zi_con_rig/core/stage_1_boot.cpp index d62f81003..a638e76cb 100644 --- a/src/bsps/stm32f429zi_con_rig/core/stage_1_boot.cpp +++ b/src/bsps/stm32f429zi_con_rig/core/stage_1_boot.cpp @@ -55,11 +55,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f429zi_death_stack_v1/core/stage_1_boot.cpp b/src/bsps/stm32f429zi_death_stack_v1/core/stage_1_boot.cpp index 0abb640f9..32d4e7ee8 100644 --- a/src/bsps/stm32f429zi_death_stack_v1/core/stage_1_boot.cpp +++ b/src/bsps/stm32f429zi_death_stack_v1/core/stage_1_boot.cpp @@ -55,11 +55,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f429zi_death_stack_v2/core/stage_1_boot.cpp b/src/bsps/stm32f429zi_death_stack_v2/core/stage_1_boot.cpp index e40004e97..77df418e4 100644 --- a/src/bsps/stm32f429zi_death_stack_v2/core/stage_1_boot.cpp +++ b/src/bsps/stm32f429zi_death_stack_v2/core/stage_1_boot.cpp @@ -55,11 +55,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f429zi_death_stack_v3/core/stage_1_boot.cpp b/src/bsps/stm32f429zi_death_stack_v3/core/stage_1_boot.cpp index 47b5354ae..614503f38 100644 --- a/src/bsps/stm32f429zi_death_stack_v3/core/stage_1_boot.cpp +++ b/src/bsps/stm32f429zi_death_stack_v3/core/stage_1_boot.cpp @@ -55,11 +55,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f429zi_nokia/core/stage_1_boot.cpp b/src/bsps/stm32f429zi_nokia/core/stage_1_boot.cpp index 6e86bb25f..46a36d1d6 100644 --- a/src/bsps/stm32f429zi_nokia/core/stage_1_boot.cpp +++ b/src/bsps/stm32f429zi_nokia/core/stage_1_boot.cpp @@ -55,11 +55,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f429zi_parafoil/core/stage_1_boot.cpp b/src/bsps/stm32f429zi_parafoil/core/stage_1_boot.cpp index 10804a0b7..0d0a46d5a 100644 --- a/src/bsps/stm32f429zi_parafoil/core/stage_1_boot.cpp +++ b/src/bsps/stm32f429zi_parafoil/core/stage_1_boot.cpp @@ -55,11 +55,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f429zi_pyxis_auxiliary/core/stage_1_boot.cpp b/src/bsps/stm32f429zi_pyxis_auxiliary/core/stage_1_boot.cpp index c5b8d22f2..bac4febca 100644 --- a/src/bsps/stm32f429zi_pyxis_auxiliary/core/stage_1_boot.cpp +++ b/src/bsps/stm32f429zi_pyxis_auxiliary/core/stage_1_boot.cpp @@ -55,11 +55,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f429zi_pyxis_auxiliary/interfaces-impl/arch_registers_impl.h b/src/bsps/stm32f429zi_pyxis_auxiliary/interfaces-impl/arch_registers_impl.h index 787b322d1..aa9f5579f 100644 --- a/src/bsps/stm32f429zi_pyxis_auxiliary/interfaces-impl/arch_registers_impl.h +++ b/src/bsps/stm32f429zi_pyxis_auxiliary/interfaces-impl/arch_registers_impl.h @@ -31,4 +31,4 @@ #define RCC_SYNC() __DSB() // Workaround for a bug in stm32f42x -#endif // ARCH_REGISTERS_IMPL_H \ No newline at end of file +#endif // ARCH_REGISTERS_IMPL_H diff --git a/src/bsps/stm32f429zi_rig/core/stage_1_boot.cpp b/src/bsps/stm32f429zi_rig/core/stage_1_boot.cpp index d62f81003..a638e76cb 100644 --- a/src/bsps/stm32f429zi_rig/core/stage_1_boot.cpp +++ b/src/bsps/stm32f429zi_rig/core/stage_1_boot.cpp @@ -55,11 +55,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f756zg_nucleo/core/stage_1_boot.cpp b/src/bsps/stm32f756zg_nucleo/core/stage_1_boot.cpp index f0bb48965..bd29b9007 100644 --- a/src/bsps/stm32f756zg_nucleo/core/stage_1_boot.cpp +++ b/src/bsps/stm32f756zg_nucleo/core/stage_1_boot.cpp @@ -71,11 +71,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f767zi_automated_antennas/core/stage_1_boot.cpp b/src/bsps/stm32f767zi_automated_antennas/core/stage_1_boot.cpp index d696c2eae..020a4ea64 100644 --- a/src/bsps/stm32f767zi_automated_antennas/core/stage_1_boot.cpp +++ b/src/bsps/stm32f767zi_automated_antennas/core/stage_1_boot.cpp @@ -49,8 +49,7 @@ void program_startup() // enabled __disable_irq(); - miosix::IRQconfigureCache((const unsigned int *)0xd0000000, - 8 * 1024 * 1024); + miosix::IRQconfigureCache((const unsigned int*)0xd0000000, 8 * 1024 * 1024); // These are defined in the linker script extern unsigned char _etext asm("_etext"); @@ -60,11 +59,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f767zi_automated_antennas/interfaces-impl/hwmapping.h b/src/bsps/stm32f767zi_automated_antennas/interfaces-impl/hwmapping.h index dcb443fcf..122f150d5 100644 --- a/src/bsps/stm32f767zi_automated_antennas/interfaces-impl/hwmapping.h +++ b/src/bsps/stm32f767zi_automated_antennas/interfaces-impl/hwmapping.h @@ -130,4 +130,4 @@ using intr = Gpio<GPIOC_BASE, 1>; using nrst = Gpio<GPIOB_BASE, 1>; } // namespace ethernet -} // namespace miosix \ No newline at end of file +} // namespace miosix diff --git a/src/bsps/stm32f767zi_compute_unit/core/stage_1_boot.cpp b/src/bsps/stm32f767zi_compute_unit/core/stage_1_boot.cpp index 83eac53b4..9b79851c2 100644 --- a/src/bsps/stm32f767zi_compute_unit/core/stage_1_boot.cpp +++ b/src/bsps/stm32f767zi_compute_unit/core/stage_1_boot.cpp @@ -49,8 +49,7 @@ void program_startup() // enabled __disable_irq(); - miosix::IRQconfigureCache((const unsigned int *)0xd0000000, - 8 * 1024 * 1024); + miosix::IRQconfigureCache((const unsigned int*)0xd0000000, 8 * 1024 * 1024); // These are defined in the linker script extern unsigned char _etext asm("_etext"); @@ -60,11 +59,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f767zi_compute_unit_v2/core/stage_1_boot.cpp b/src/bsps/stm32f767zi_compute_unit_v2/core/stage_1_boot.cpp index 95d830c5c..e9897cdbb 100644 --- a/src/bsps/stm32f767zi_compute_unit_v2/core/stage_1_boot.cpp +++ b/src/bsps/stm32f767zi_compute_unit_v2/core/stage_1_boot.cpp @@ -49,8 +49,7 @@ void program_startup() // enabled __disable_irq(); - miosix::IRQconfigureCache((const unsigned int *)0xd0000000, - 8 * 1024 * 1024); + miosix::IRQconfigureCache((const unsigned int*)0xd0000000, 8 * 1024 * 1024); // These are defined in the linker script extern unsigned char _etext asm("_etext"); @@ -60,11 +59,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f767zi_compute_unit_v2/interfaces-impl/bsp.cpp b/src/bsps/stm32f767zi_compute_unit_v2/interfaces-impl/bsp.cpp index e7bf2e4cf..91166cd57 100644 --- a/src/bsps/stm32f767zi_compute_unit_v2/interfaces-impl/bsp.cpp +++ b/src/bsps/stm32f767zi_compute_unit_v2/interfaces-impl/bsp.cpp @@ -232,9 +232,9 @@ void configureBackupSram() extern unsigned char _preserve_end asm("_preserve_end"); extern unsigned char _preserve_load asm("_preserve_load"); - unsigned char *preserve_start = &_preserve_start; - unsigned char *preserve_end = &_preserve_end; - unsigned char *preserve_load = &_preserve_load; + unsigned char* preserve_start = &_preserve_start; + unsigned char* preserve_end = &_preserve_end; + unsigned char* preserve_load = &_preserve_load; // Load the .preserve section from flash if not a software reset if (miosix::lastResetReason() != miosix::ResetReason::SOFTWARE) diff --git a/src/bsps/stm32f767zi_death_stack_v4/core/stage_1_boot.cpp b/src/bsps/stm32f767zi_death_stack_v4/core/stage_1_boot.cpp index 8374c9de6..2a3558d7b 100644 --- a/src/bsps/stm32f767zi_death_stack_v4/core/stage_1_boot.cpp +++ b/src/bsps/stm32f767zi_death_stack_v4/core/stage_1_boot.cpp @@ -49,8 +49,7 @@ void program_startup() // enabled __disable_irq(); - miosix::IRQconfigureCache((const unsigned int *)0xd0000000, - 8 * 1024 * 1024); + miosix::IRQconfigureCache((const unsigned int*)0xd0000000, 8 * 1024 * 1024); // These are defined in the linker script extern unsigned char _etext asm("_etext"); @@ -60,11 +59,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f767zi_death_stack_v4/interfaces-impl/hwmapping.h b/src/bsps/stm32f767zi_death_stack_v4/interfaces-impl/hwmapping.h index 8b6166f3b..1d3662a8d 100644 --- a/src/bsps/stm32f767zi_death_stack_v4/interfaces-impl/hwmapping.h +++ b/src/bsps/stm32f767zi_death_stack_v4/interfaces-impl/hwmapping.h @@ -218,4 +218,4 @@ using exp_sense = Gpio<GPIOG_BASE, 6>; } // namespace gpios -} // namespace miosix \ No newline at end of file +} // namespace miosix diff --git a/src/bsps/stm32f767zi_gemini_gs/core/stage_1_boot.cpp b/src/bsps/stm32f767zi_gemini_gs/core/stage_1_boot.cpp index cc96d3b51..01a2010d5 100644 --- a/src/bsps/stm32f767zi_gemini_gs/core/stage_1_boot.cpp +++ b/src/bsps/stm32f767zi_gemini_gs/core/stage_1_boot.cpp @@ -49,8 +49,7 @@ void program_startup() // enabled __disable_irq(); - miosix::IRQconfigureCache((const unsigned int *)0xd0000000, - 8 * 1024 * 1024); + miosix::IRQconfigureCache((const unsigned int*)0xd0000000, 8 * 1024 * 1024); // These are defined in the linker script extern unsigned char _etext asm("_etext"); @@ -60,11 +59,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f767zi_gemini_motor/core/stage_1_boot.cpp b/src/bsps/stm32f767zi_gemini_motor/core/stage_1_boot.cpp index 83eac53b4..9b79851c2 100644 --- a/src/bsps/stm32f767zi_gemini_motor/core/stage_1_boot.cpp +++ b/src/bsps/stm32f767zi_gemini_motor/core/stage_1_boot.cpp @@ -49,8 +49,7 @@ void program_startup() // enabled __disable_irq(); - miosix::IRQconfigureCache((const unsigned int *)0xd0000000, - 8 * 1024 * 1024); + miosix::IRQconfigureCache((const unsigned int*)0xd0000000, 8 * 1024 * 1024); // These are defined in the linker script extern unsigned char _etext asm("_etext"); @@ -60,11 +59,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f767zi_lyra_biscotto/core/stage_1_boot.cpp b/src/bsps/stm32f767zi_lyra_biscotto/core/stage_1_boot.cpp index 95d830c5c..e9897cdbb 100644 --- a/src/bsps/stm32f767zi_lyra_biscotto/core/stage_1_boot.cpp +++ b/src/bsps/stm32f767zi_lyra_biscotto/core/stage_1_boot.cpp @@ -49,8 +49,7 @@ void program_startup() // enabled __disable_irq(); - miosix::IRQconfigureCache((const unsigned int *)0xd0000000, - 8 * 1024 * 1024); + miosix::IRQconfigureCache((const unsigned int*)0xd0000000, 8 * 1024 * 1024); // These are defined in the linker script extern unsigned char _etext asm("_etext"); @@ -60,11 +59,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f767zi_lyra_biscotto/interfaces-impl/bsp.cpp b/src/bsps/stm32f767zi_lyra_biscotto/interfaces-impl/bsp.cpp index 2ffa98323..98eca468c 100644 --- a/src/bsps/stm32f767zi_lyra_biscotto/interfaces-impl/bsp.cpp +++ b/src/bsps/stm32f767zi_lyra_biscotto/interfaces-impl/bsp.cpp @@ -233,9 +233,9 @@ void configureBackupSram() extern unsigned char _preserve_end asm("_preserve_end"); extern unsigned char _preserve_load asm("_preserve_load"); - unsigned char *preserve_start = &_preserve_start; - unsigned char *preserve_end = &_preserve_end; - unsigned char *preserve_load = &_preserve_load; + unsigned char* preserve_start = &_preserve_start; + unsigned char* preserve_end = &_preserve_end; + unsigned char* preserve_load = &_preserve_load; // Load the .preserve section from flash if not a software reset if (miosix::lastResetReason() != miosix::ResetReason::SOFTWARE) diff --git a/src/bsps/stm32f767zi_lyra_biscotto/interfaces-impl/hwmapping.h b/src/bsps/stm32f767zi_lyra_biscotto/interfaces-impl/hwmapping.h index 499caf94b..25e88a3ce 100644 --- a/src/bsps/stm32f767zi_lyra_biscotto/interfaces-impl/hwmapping.h +++ b/src/bsps/stm32f767zi_lyra_biscotto/interfaces-impl/hwmapping.h @@ -231,4 +231,4 @@ using statusLed = Gpio<GPIOB_BASE, 13>; using camEnable = Gpio<GPIOB_BASE, 14>; } // namespace gpios -} // namespace miosix \ No newline at end of file +} // namespace miosix diff --git a/src/bsps/stm32f767zi_lyra_gs/core/stage_1_boot.cpp b/src/bsps/stm32f767zi_lyra_gs/core/stage_1_boot.cpp index 83eac53b4..9b79851c2 100644 --- a/src/bsps/stm32f767zi_lyra_gs/core/stage_1_boot.cpp +++ b/src/bsps/stm32f767zi_lyra_gs/core/stage_1_boot.cpp @@ -49,8 +49,7 @@ void program_startup() // enabled __disable_irq(); - miosix::IRQconfigureCache((const unsigned int *)0xd0000000, - 8 * 1024 * 1024); + miosix::IRQconfigureCache((const unsigned int*)0xd0000000, 8 * 1024 * 1024); // These are defined in the linker script extern unsigned char _etext asm("_etext"); @@ -60,11 +59,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f767zi_lyra_gs/interfaces-impl/bsp_impl.h b/src/bsps/stm32f767zi_lyra_gs/interfaces-impl/bsp_impl.h index 35a052111..e274e630d 100644 --- a/src/bsps/stm32f767zi_lyra_gs/interfaces-impl/bsp_impl.h +++ b/src/bsps/stm32f767zi_lyra_gs/interfaces-impl/bsp_impl.h @@ -96,4 +96,4 @@ void configureSdram(); */ inline bool sdCardSense() { return true; } -} // namespace miosix \ No newline at end of file +} // namespace miosix diff --git a/src/bsps/stm32f767zi_lyra_motor/core/stage_1_boot.cpp b/src/bsps/stm32f767zi_lyra_motor/core/stage_1_boot.cpp index 95d830c5c..e9897cdbb 100644 --- a/src/bsps/stm32f767zi_lyra_motor/core/stage_1_boot.cpp +++ b/src/bsps/stm32f767zi_lyra_motor/core/stage_1_boot.cpp @@ -49,8 +49,7 @@ void program_startup() // enabled __disable_irq(); - miosix::IRQconfigureCache((const unsigned int *)0xd0000000, - 8 * 1024 * 1024); + miosix::IRQconfigureCache((const unsigned int*)0xd0000000, 8 * 1024 * 1024); // These are defined in the linker script extern unsigned char _etext asm("_etext"); @@ -60,11 +59,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f767zi_lyra_motor/interfaces-impl/bsp.cpp b/src/bsps/stm32f767zi_lyra_motor/interfaces-impl/bsp.cpp index d7daea5cd..2f8f98c30 100644 --- a/src/bsps/stm32f767zi_lyra_motor/interfaces-impl/bsp.cpp +++ b/src/bsps/stm32f767zi_lyra_motor/interfaces-impl/bsp.cpp @@ -233,9 +233,9 @@ void configureBackupSram() extern unsigned char _preserve_end asm("_preserve_end"); extern unsigned char _preserve_load asm("_preserve_load"); - unsigned char *preserve_start = &_preserve_start; - unsigned char *preserve_end = &_preserve_end; - unsigned char *preserve_load = &_preserve_load; + unsigned char* preserve_start = &_preserve_start; + unsigned char* preserve_end = &_preserve_end; + unsigned char* preserve_load = &_preserve_load; // Load the .preserve section from flash if not a software reset if (miosix::lastResetReason() != miosix::ResetReason::SOFTWARE) diff --git a/src/bsps/stm32f767zi_lyra_motor/interfaces-impl/hwmapping.h b/src/bsps/stm32f767zi_lyra_motor/interfaces-impl/hwmapping.h index e7443d6e2..387fe9bd3 100644 --- a/src/bsps/stm32f767zi_lyra_motor/interfaces-impl/hwmapping.h +++ b/src/bsps/stm32f767zi_lyra_motor/interfaces-impl/hwmapping.h @@ -140,4 +140,4 @@ namespace gpios using boardLed = Gpio<GPIOC_BASE, 5>; } // namespace gpios -} // namespace miosix \ No newline at end of file +} // namespace miosix diff --git a/src/bsps/stm32f767zi_rig_v2/core/stage_1_boot.cpp b/src/bsps/stm32f767zi_rig_v2/core/stage_1_boot.cpp index 95d830c5c..e9897cdbb 100644 --- a/src/bsps/stm32f767zi_rig_v2/core/stage_1_boot.cpp +++ b/src/bsps/stm32f767zi_rig_v2/core/stage_1_boot.cpp @@ -49,8 +49,7 @@ void program_startup() // enabled __disable_irq(); - miosix::IRQconfigureCache((const unsigned int *)0xd0000000, - 8 * 1024 * 1024); + miosix::IRQconfigureCache((const unsigned int*)0xd0000000, 8 * 1024 * 1024); // These are defined in the linker script extern unsigned char _etext asm("_etext"); @@ -60,11 +59,11 @@ void program_startup() extern unsigned char _bss_end asm("_bss_end"); // Initialize .data section, clear .bss section - unsigned char *etext = &_etext; - unsigned char *data = &_data; - unsigned char *edata = &_edata; - unsigned char *bss_start = &_bss_start; - unsigned char *bss_end = &_bss_end; + unsigned char* etext = &_etext; + unsigned char* data = &_data; + unsigned char* edata = &_edata; + unsigned char* bss_start = &_bss_start; + unsigned char* bss_end = &_bss_end; memcpy(data, etext, edata - data); memset(bss_start, 0, bss_end - bss_start); diff --git a/src/bsps/stm32f767zi_rig_v2/interfaces-impl/bsp.cpp b/src/bsps/stm32f767zi_rig_v2/interfaces-impl/bsp.cpp index f6ddb1f55..cbf61373e 100644 --- a/src/bsps/stm32f767zi_rig_v2/interfaces-impl/bsp.cpp +++ b/src/bsps/stm32f767zi_rig_v2/interfaces-impl/bsp.cpp @@ -233,9 +233,9 @@ void configureBackupSram() extern unsigned char _preserve_end asm("_preserve_end"); extern unsigned char _preserve_load asm("_preserve_load"); - unsigned char *preserve_start = &_preserve_start; - unsigned char *preserve_end = &_preserve_end; - unsigned char *preserve_load = &_preserve_load; + unsigned char* preserve_start = &_preserve_start; + unsigned char* preserve_end = &_preserve_end; + unsigned char* preserve_load = &_preserve_load; // Load the .preserve section from flash if not a software reset if (miosix::lastResetReason() != miosix::ResetReason::SOFTWARE) diff --git a/src/bsps/stm32f767zi_rig_v2/interfaces-impl/hwmapping.h b/src/bsps/stm32f767zi_rig_v2/interfaces-impl/hwmapping.h index eec700e5e..0560321ff 100644 --- a/src/bsps/stm32f767zi_rig_v2/interfaces-impl/hwmapping.h +++ b/src/bsps/stm32f767zi_rig_v2/interfaces-impl/hwmapping.h @@ -242,4 +242,4 @@ using nitrogen = miosix::interfaces::relays::relay2; using armLight = miosix::interfaces::relays::relay3; } // namespace relays -} // namespace miosix \ No newline at end of file +} // namespace miosix diff --git a/src/entrypoints/compute-unit-v2-testsuite.cpp b/src/entrypoints/compute-unit-v2-testsuite.cpp index 86dd9292d..e9617a6ae 100644 --- a/src/entrypoints/compute-unit-v2-testsuite.cpp +++ b/src/entrypoints/compute-unit-v2-testsuite.cpp @@ -33,10 +33,10 @@ using namespace miosix; struct PinDef { GpioPin pin; - const char *gpio_name; - const char *conan_name; + const char* gpio_name; + const char* conan_name; // ADRIANOOOOOOOOOOOOOOOO - const char *breakout_v1_name; + const char* breakout_v1_name; }; std::array<PinDef, 53> PIN_DEFS{{ @@ -271,7 +271,7 @@ void sd_test() puts("*** Starting SD test..."); bool ok = true; - FILE *f = fopen("/sd/test.bin", "wb"); + FILE* f = fopen("/sd/test.bin", "wb"); if (f == NULL) { puts("Failed to open test.bin"); @@ -299,9 +299,7 @@ void sd_test() } if (f != NULL) - { fclose(f); - } if (ok) { @@ -344,37 +342,29 @@ void sd_test() } if (f != NULL) - { fclose(f); - } if (ok) - { puts("*** SD test succesfull!"); - } else - { puts("*** SD test failed!"); - } } void xram_test() { - volatile uint16_t *const START = (volatile uint16_t *)0xd0000000; - volatile uint16_t *const END = START + (16 * 1024 * 1024); + volatile uint16_t* const START = (volatile uint16_t*)0xd0000000; + volatile uint16_t* const END = START + (16 * 1024 * 1024); // First clear the whole RAM - for (volatile uint16_t *iter = START; iter != END; iter++) - { + for (volatile uint16_t* iter = START; iter != END; iter++) *iter = 0; - } __DMB(); // Flush cache puts("*** Starting basic XRAM test..."); bool ok = true; - for (volatile uint16_t *iter = START; iter != END; iter++) + for (volatile uint16_t* iter = START; iter != END; iter++) { // Set a marker value at this address *iter = 0xffff; @@ -392,13 +382,9 @@ void xram_test() } if (ok) - { puts("*** XRAM basic test succesfull!"); - } else - { puts("*** XRAM basic test failed!"); - } puts("*** Starting XRAM mirroring test..."); ok = true; @@ -406,20 +392,18 @@ void xram_test() // Generate addresses to test every line for (int i = 1; i < 25; i++) { - volatile uint16_t *other = - (volatile uint16_t *)((size_t)START | (1 << i)); + volatile uint16_t* other = + (volatile uint16_t*)((size_t)START | (1 << i)); // Write something *other = 0xdead; __DMB(); // Flush cache - for (volatile uint16_t *iter = START; iter != END; iter++) + for (volatile uint16_t* iter = START; iter != END; iter++) { // Skip the written address if (iter == other) - { continue; - } // Check for mirroring if (*iter == 0xdead) @@ -435,31 +419,25 @@ void xram_test() } if (ok) - { puts("*** XRAM mirror test succesfull!"); - } else - { puts("*** XRAM mirror test failed!"); - } } void pin_continuity_test() { - for (auto &a : PIN_DEFS) - { + for (auto& a : PIN_DEFS) a.pin.mode(Mode::INPUT_PULL_DOWN); - } puts("*** Starting pin continuity test..."); bool ok = true; // Ok now start testing - for (auto &a : PIN_DEFS) + for (auto& a : PIN_DEFS) { a.pin.mode(Mode::OUTPUT); a.pin.high(); - for (auto &b : PIN_DEFS) + for (auto& b : PIN_DEFS) { if (a.pin.getNumber() == b.pin.getNumber() && a.pin.getPort() == b.pin.getPort()) @@ -479,18 +457,14 @@ void pin_continuity_test() } if (ok) - { puts("*** Pin continuity test succesfull!"); - } else - { puts("*** Pin continuity test failed!"); - } } void pin_semi_test() { - for (auto &a : PIN_DEFS) + for (auto& a : PIN_DEFS) { a.pin.mode(Mode::OUTPUT); a.pin.low(); @@ -523,7 +497,7 @@ void pin_semi_test() for (size_t i = 0; i < PIN_DEFS.size(); i++) { - PinDef &a = PIN_DEFS[i]; + PinDef& a = PIN_DEFS[i]; // Pause waiting for keys while (getchar() != '\n') diff --git a/src/entrypoints/config-dsgamma.cpp b/src/entrypoints/config-dsgamma.cpp index 37147cc22..a3a7e891c 100644 --- a/src/entrypoints/config-dsgamma.cpp +++ b/src/entrypoints/config-dsgamma.cpp @@ -85,13 +85,9 @@ int main() bool configStatus = gamma.configure(newConf); if (configStatus == true) - { printf("New configuration set!\n"); - } else - { printf("Failed to set new configuration!\n"); - } Thread::sleep(500); } @@ -104,8 +100,6 @@ int main() void waitForButton() { while (1) - { if (button::value() == 1) break; // Wait for button - } } diff --git a/src/entrypoints/kernel-testsuite.cpp b/src/entrypoints/kernel-testsuite.cpp index d78e82416..485e7bbe1 100644 --- a/src/entrypoints/kernel-testsuite.cpp +++ b/src/entrypoints/kernel-testsuite.cpp @@ -83,9 +83,9 @@ using namespace Boardcore; const unsigned int STACK_SMALL = 512; // Functions common to all tests -static void test_name(const char *name); +static void test_name(const char* name); static void pass(); -static void fail(const char *cause); +static void fail(const char* cause); // Kernel test functions static void test_1(); static void test_2(); @@ -145,12 +145,12 @@ void syscall_test_mpu_read(); void syscall_test_mpu_write(); #endif // WITH_FILESYSTEM -unsigned int *memAllocation(unsigned int size); -bool memCheck(unsigned int *base, unsigned int size); -void runElfTest(const char *name, const unsigned char *filename, +unsigned int* memAllocation(unsigned int size); +bool memCheck(unsigned int* base, unsigned int size); +void runElfTest(const char* name, const unsigned char* filename, unsigned int file_length); -int runProgram(const unsigned char *filename, unsigned int file_length); +int runProgram(const unsigned char* filename, unsigned int file_length); bool isSignaled(int exit_code); void mpuTest1(); void mpuTest2(); @@ -190,7 +190,7 @@ int main() break; } // For testing mpu - unsigned int *m __attribute__((unused)); + unsigned int* m __attribute__((unused)); switch (c) { case 't': @@ -360,7 +360,7 @@ int main() * Called @ the beginning of a test * \param name test name */ -static void test_name(const char *name) { iprintf("Testing %s...\n", name); } +static void test_name(const char* name) { iprintf("Testing %s...\n", name); } /** * Called @ the end of a successful test @@ -371,7 +371,7 @@ static void pass() { iprintf("Ok.\n"); } * Called if a test fails * \param cause cause of the failure */ -static void fail(const char *cause) +static void fail(const char* cause) { // Can't use iprintf here because fail() may be used in threads // with 256 bytes of stack, and iprintf may cause stack overflow @@ -390,12 +390,10 @@ void process_test_file_concurrency() remove("/file1.bin"); remove("/file2.bin"); - ElfProgram prog1( - reinterpret_cast<const unsigned int *>(testsuite_file1_elf), - testsuite_file1_elf_len); - ElfProgram prog2( - reinterpret_cast<const unsigned int *>(testsuite_file2_elf), - testsuite_file2_elf_len); + ElfProgram prog1(reinterpret_cast<const unsigned int*>(testsuite_file1_elf), + testsuite_file1_elf_len); + ElfProgram prog2(reinterpret_cast<const unsigned int*>(testsuite_file2_elf), + testsuite_file2_elf_len); pid_t p1 = Process::create(prog1); pid_t p2 = Process::create(prog2); @@ -405,8 +403,8 @@ void process_test_file_concurrency() Process::waitpid(p1, &res1, 0); Process::waitpid(p2, &res2, 0); - FILE *f1 = fopen("/file1.bin", "rb"); - FILE *f2 = fopen("/file2.bin", "rb"); + FILE* f1 = fopen("/file1.bin", "rb"); + FILE* f2 = fopen("/file2.bin", "rb"); if (!f1) fail("Unable to open first file"); @@ -438,9 +436,8 @@ void process_test_file_concurrency() void process_test_process_ret() { test_name("Process return value"); - ElfProgram prog( - reinterpret_cast<const unsigned int *>(testsuite_simple_elf), - testsuite_simple_elf_len); + ElfProgram prog(reinterpret_cast<const unsigned int*>(testsuite_simple_elf), + testsuite_simple_elf_len); int ret = 0; pid_t p = Process::create(prog); Process::waitpid(p, &ret, 0); @@ -454,7 +451,7 @@ void syscall_test_mpu_open() { test_name("open and MPU"); ElfProgram prog( - reinterpret_cast<const unsigned int *>(testsuite_syscall_mpu_open_elf), + reinterpret_cast<const unsigned int*>(testsuite_syscall_mpu_open_elf), testsuite_syscall_mpu_open_elf_len); int ret = 0; pid_t p = Process::create(prog); @@ -469,7 +466,7 @@ void syscall_test_mpu_read() { test_name("read calls and MPU"); ElfProgram prog( - reinterpret_cast<const unsigned int *>(testsuite_syscall_mpu_read_elf), + reinterpret_cast<const unsigned int*>(testsuite_syscall_mpu_read_elf), testsuite_syscall_mpu_read_elf_len); int ret = 0; pid_t p = Process::create(prog); @@ -484,7 +481,7 @@ void syscall_test_mpu_write() { test_name("write and MPU"); ElfProgram prog( - reinterpret_cast<const unsigned int *>(testsuite_syscall_mpu_write_elf), + reinterpret_cast<const unsigned int*>(testsuite_syscall_mpu_write_elf), testsuite_syscall_mpu_write_elf_len); int ret = 0; pid_t p = Process::create(prog); @@ -504,7 +501,7 @@ void syscall_test_system() iprintf("The system lookup table is empty. Correct.\n"); SystemMap::instance().addElfProgram( - "test", reinterpret_cast<const unsigned int *>(testsuite_simple_elf), + "test", reinterpret_cast<const unsigned int*>(testsuite_simple_elf), testsuite_simple_elf_len); if (SystemMap::instance().getElfCount() != 1) @@ -512,17 +509,18 @@ void syscall_test_system() else iprintf("The system lookup table contain one program. Correct.\n"); - std::pair<const unsigned int *, unsigned int> sysret = + std::pair<const unsigned int*, unsigned int> sysret = SystemMap::instance().getElfProgram("test"); if (sysret.first == 0 || sysret.second == 0) + { fail( "The system lookup table has returned an invalid process size or " "an invalid elf pointer for the process"); + } - ElfProgram prog( - reinterpret_cast<const unsigned int *>(testsuite_system_elf), - testsuite_system_elf_len); + ElfProgram prog(reinterpret_cast<const unsigned int*>(testsuite_system_elf), + testsuite_system_elf_len); int ret = 0; pid_t p = Process::create(prog); @@ -545,7 +543,7 @@ void syscall_test_system() void syscall_test_sleep() { test_name("System Call: sleep"); - ElfProgram prog(reinterpret_cast<const unsigned int *>(testsuite_sleep_elf), + ElfProgram prog(reinterpret_cast<const unsigned int*>(testsuite_sleep_elf), testsuite_sleep_elf_len); int ret = 0; @@ -566,7 +564,7 @@ void syscall_test_files() test_name("System Call: open, read, write, seek, close, system"); ElfProgram prog( - reinterpret_cast<const unsigned int *>(testsuite_syscall_elf), + reinterpret_cast<const unsigned int*>(testsuite_syscall_elf), testsuite_syscall_elf_len); int ret = 0; @@ -636,7 +634,7 @@ and test argv pointer passing static volatile bool t1_v1; -static void t1_p1(void *argv __attribute__((unused))) +static void t1_p1(void* argv __attribute__((unused))) { for (;;) { @@ -649,13 +647,13 @@ static void t1_p1(void *argv __attribute__((unused))) } } -static void t1_p3(void *argv) +static void t1_p3(void* argv) { if (reinterpret_cast<unsigned int>(argv) != 0xdeadbeef) fail("argv passing"); } -static void t1_f1(Thread *p) +static void t1_f1(Thread* p) { // This test is very strict and sometimes might fail. To see why consider // this: yield() moves control flow to the second thread, but a preemption @@ -708,18 +706,18 @@ static void test_1() { test_name("thread creation/deletion"); // Testing getStackBottom() - const unsigned int *y = Thread::getStackBottom(); + const unsigned int* y = Thread::getStackBottom(); if (*y != STACK_FILL) fail("getStackBottom() (1)"); y--; // Now should point to last word of watermark if (*y != WATERMARK_FILL) fail("getStackBottom() (2)"); // Testing thread termination - Thread *p = Thread::create(t1_p1, STACK_SMALL, 0, NULL); + Thread* p = Thread::create(t1_p1, STACK_SMALL, 0, NULL); t1_f1(p); // Testing argv passing p = Thread::create(t1_p3, STACK_SMALL, 0, - reinterpret_cast<void *>(0xdeadbeef)); + reinterpret_cast<void*>(0xdeadbeef)); Thread::sleep(5); if (Thread::exists(p)) fail("thread not deleted (2)"); @@ -737,9 +735,9 @@ Thread::getCurrentThread */ static volatile bool t2_v1; -static Thread *t2_p_v1; +static Thread* t2_p_v1; -static void t2_p1(void *argv __attribute__((unused))) +static void t2_p1(void* argv __attribute__((unused))) { // This is to fix a race condition: the immediately after the thread // creation a yield occurs, t2_p_v1 is not yet assigned so the check fails @@ -757,7 +755,7 @@ static void t2_p1(void *argv __attribute__((unused))) } } -static void t2_p2(void *argv __attribute__((unused))) +static void t2_p2(void* argv __attribute__((unused))) { while (Thread::testTerminate() == false) t2_v1 = true; @@ -830,7 +828,7 @@ getTime() also tests creation of multiple instances of the same thread */ -static void t3_p1(void *argv __attribute__((unused))) +static void t3_p1(void* argv __attribute__((unused))) { const int SLEEP_TIME = 100; // ms for (;;) @@ -849,7 +847,7 @@ static void t3_p1(void *argv __attribute__((unused))) static volatile bool t3_v2; // Set to true by t3_p2 static volatile bool t3_deleted; // Set when an instance of t3_p2 is deleted -static void t3_p2(void *argv __attribute__((unused))) +static void t3_p2(void* argv __attribute__((unused))) { const int SLEEP_TIME = 15; for (;;) @@ -867,7 +865,7 @@ static void t3_p2(void *argv __attribute__((unused))) static void test_3() { test_name("time and sleep"); - Thread *p = Thread::create(t3_p1, STACK_SMALL, 0, NULL); + Thread* p = Thread::create(t3_p1, STACK_SMALL, 0, NULL); for (int i = 0; i < 4; i++) { // The other thread is running getTime() test @@ -896,7 +894,7 @@ static void test_3() t3_v2 = false; // Creating another instance of t3_p2 to check what happens when 3 threads // are sleeping - Thread *p2 = Thread::create(t3_p2, STACK_SMALL, 0, NULL); + Thread* p2 = Thread::create(t3_p2, STACK_SMALL, 0, NULL); // p will wake @ t=45, main will wake @ t=47 and p2 @ t=50ms // this will test proper sorting of sleeping_list in the kernel Thread::sleep(12); @@ -952,7 +950,7 @@ Thread::IRQgetPriority static volatile bool t4_v1; -static void t4_p1(void *argv __attribute__((unused))) +static void t4_p1(void* argv __attribute__((unused))) { for (;;) { @@ -967,7 +965,7 @@ static void t4_p1(void *argv __attribute__((unused))) #ifdef SCHED_TYPE_EDF // This takes .014/.03=47% of CPU time -static void t4_p2(void *argv) +static void t4_p2(void* argv) { const long long period = msInNs(30); // 30ms long long time = getTime(); @@ -987,13 +985,13 @@ static void t4_p2(void *argv) static void test_4() { test_name("disableInterrupts and priority"); - Thread *p = Thread::create(t4_p1, STACK_SMALL, 0, NULL); + Thread* p = Thread::create(t4_p1, STACK_SMALL, 0, NULL); // Check getPriority() if (p->getPriority() != 0) fail("getPriority (0)"); // Check that getCurrentThread() and IRQgetCurrentThread() return the // same value - Thread *q = Thread::getCurrentThread(); + Thread* q = Thread::getCurrentThread(); disableInterrupts(); // if (q != Thread::IRQgetCurrentThread()) fail("IRQgetCurrentThread"); @@ -1102,7 +1100,7 @@ static volatile bool t5_v1; static volatile bool t5_v2; // False=testing Thread::wait() else Thread::IRQwait() -static void t5_p1(void *argv __attribute__((unused))) +static void t5_p1(void* argv __attribute__((unused))) { for (;;) { @@ -1110,7 +1108,9 @@ static void t5_p1(void *argv __attribute__((unused))) break; t5_v1 = true; if (t5_v2) + { Thread::wait(); + } else { disableInterrupts(); @@ -1126,7 +1126,7 @@ static void test_5() test_name("wait, wakeup, IRQwait, IRQwakeup"); t5_v2 = false; // Testing wait t5_v1 = false; - Thread *p = Thread::create(t5_p1, STACK_SMALL, 0, NULL); + Thread* p = Thread::create(t5_p1, STACK_SMALL, 0, NULL); // Should not happen, since already tested Thread::sleep(5); if (t5_v1 == false) @@ -1208,7 +1208,7 @@ public: strcat(s, t); } - char *read() { return s; } + char* read() { return s; } void clear() { s[0] = '\0'; } @@ -1220,7 +1220,7 @@ static Sequence seq; static Mutex t6_m1; static FastMutex t6_m1a; -static void t6_p1(void *argv __attribute__((unused))) +static void t6_p1(void* argv __attribute__((unused))) { t6_m1.lock(); seq.add('1'); @@ -1232,7 +1232,7 @@ static void t6_p1(void *argv __attribute__((unused))) t6_m1.unlock(); } -static void t6_p2(void *argv __attribute__((unused))) +static void t6_p2(void* argv __attribute__((unused))) { t6_m1.lock(); seq.add('2'); @@ -1243,7 +1243,7 @@ static void t6_p2(void *argv __attribute__((unused))) t6_m1.unlock(); } -static void t6_p3(void *argv __attribute__((unused))) +static void t6_p3(void* argv __attribute__((unused))) { t6_m1.lock(); seq.add('3'); @@ -1254,7 +1254,7 @@ static void t6_p3(void *argv __attribute__((unused))) t6_m1.unlock(); } -static void t6_p4(void *argv __attribute__((unused))) +static void t6_p4(void* argv __attribute__((unused))) { t6_m1.lock(); for (;;) @@ -1272,7 +1272,7 @@ static void t6_p4(void *argv __attribute__((unused))) } } -static void t6_p1a(void *argv __attribute__((unused))) +static void t6_p1a(void* argv __attribute__((unused))) { t6_m1a.lock(); seq.add('1'); @@ -1280,7 +1280,7 @@ static void t6_p1a(void *argv __attribute__((unused))) t6_m1a.unlock(); } -static void t6_p2a(void *argv __attribute__((unused))) +static void t6_p2a(void* argv __attribute__((unused))) { t6_m1a.lock(); seq.add('2'); @@ -1288,7 +1288,7 @@ static void t6_p2a(void *argv __attribute__((unused))) t6_m1a.unlock(); } -static void t6_p3a(void *argv __attribute__((unused))) +static void t6_p3a(void* argv __attribute__((unused))) { t6_m1a.lock(); seq.add('3'); @@ -1296,7 +1296,7 @@ static void t6_p3a(void *argv __attribute__((unused))) t6_m1a.unlock(); } -static void t6_p4a(void *argv __attribute__((unused))) +static void t6_p4a(void* argv __attribute__((unused))) { t6_m1a.lock(); for (;;) @@ -1318,7 +1318,7 @@ static volatile bool t6_v1; static Mutex t6_m2; static FastMutex t6_m2a; -static void t6_p5(void *argv __attribute__((unused))) +static void t6_p5(void* argv __attribute__((unused))) { for (;;) { @@ -1334,7 +1334,7 @@ static void t6_p5(void *argv __attribute__((unused))) } } -static void t6_p5a(void *argv __attribute__((unused))) +static void t6_p5a(void* argv __attribute__((unused))) { for (;;) { @@ -1353,18 +1353,18 @@ static void t6_p5a(void *argv __attribute__((unused))) static Mutex t6_m3; static Mutex t6_m4; -static void t6_p6(void *argv) +static void t6_p6(void* argv) { - Mutex *m = reinterpret_cast<Mutex *>(argv); + Mutex* m = reinterpret_cast<Mutex*>(argv); { Lock<Mutex> l(*m); Thread::sleep(1); } } -static void t6_p6a(void *argv) +static void t6_p6a(void* argv) { - FastMutex *m = reinterpret_cast<FastMutex *>(argv); + FastMutex* m = reinterpret_cast<FastMutex*>(argv); { Lock<FastMutex> l(*m); Thread::sleep(1); @@ -1374,34 +1374,34 @@ static void t6_p6a(void *argv) static Mutex t6_m5(Mutex::RECURSIVE); static FastMutex t6_m5a(FastMutex::RECURSIVE); -static void *t6_p7(void *argv __attribute__((unused))) +static void* t6_p7(void* argv __attribute__((unused))) { if (t6_m5.tryLock() == false) - return reinterpret_cast<void *>(1); // 1 = locked + return reinterpret_cast<void*>(1); // 1 = locked t6_m5.unlock(); - return reinterpret_cast<void *>(0); // 0 = unlocked + return reinterpret_cast<void*>(0); // 0 = unlocked } bool checkIft6_m5IsLocked() { - Thread *t = Thread::create(t6_p7, STACK_SMALL, 0, 0, Thread::JOINABLE); - void *result; + Thread* t = Thread::create(t6_p7, STACK_SMALL, 0, 0, Thread::JOINABLE); + void* result; t->join(&result); return reinterpret_cast<int>(result) == 0 ? false : true; } -static void *t6_p7a(void *argv __attribute__((unused))) +static void* t6_p7a(void* argv __attribute__((unused))) { if (t6_m5a.tryLock() == false) - return reinterpret_cast<void *>(1); // 1 = locked + return reinterpret_cast<void*>(1); // 1 = locked t6_m5a.unlock(); - return reinterpret_cast<void *>(0); // 0 = unlocked + return reinterpret_cast<void*>(0); // 0 = unlocked } bool checkIft6_m5aIsLocked() { - Thread *t = Thread::create(t6_p7a, STACK_SMALL, 0, 0, Thread::JOINABLE); - void *result; + Thread* t = Thread::create(t6_p7a, STACK_SMALL, 0, 0, Thread::JOINABLE); + void* result; t->join(&result); return reinterpret_cast<int>(result) == 0 ? false : true; } @@ -1448,7 +1448,7 @@ static void test_6() // // This thread will hold the lock until we terminate it - Thread *t = Thread::create(t6_p4, STACK_SMALL, 0); + Thread* t = Thread::create(t6_p4, STACK_SMALL, 0); Thread::yield(); if (t6_m1.tryLock() == true) fail("Mutex::tryLock() (1)"); @@ -1466,7 +1466,7 @@ static void test_6() fail("Mutex::tryLock() (3)"); t6_m1.unlock(); t6_v1 = false; - Thread *t2 = Thread::create(t6_p5, STACK_SMALL, 1); + Thread* t2 = Thread::create(t6_p5, STACK_SMALL, 1); Thread::sleep(30); if (t6_v1 == false) fail("Thread not created"); @@ -1485,8 +1485,8 @@ static void test_6() // // Testing full priority inheritance algorithm // - Thread *t3; - Thread *t4; + Thread* t3; + Thread* t4; { Lock<Mutex> l1(t6_m3); { @@ -1496,21 +1496,21 @@ static void test_6() fail("priority inheritance (5)"); // This thread will increase priority to 1 t = Thread::create(t6_p6, STACK_SMALL, priorityAdapter(1), - reinterpret_cast<void *>(&t6_m4), + reinterpret_cast<void*>(&t6_m4), Thread::JOINABLE); Thread::sleep(10); if (Thread::getCurrentThread()->getPriority() != priorityAdapter(1)) fail("priority inheritance (6)"); // This thread will do nothing t2 = Thread::create(t6_p6, STACK_SMALL, priorityAdapter(1), - reinterpret_cast<void *>(&t6_m3), + reinterpret_cast<void*>(&t6_m3), Thread::JOINABLE); Thread::sleep(10); if (Thread::getCurrentThread()->getPriority() != priorityAdapter(1)) fail("priority inheritance (7)"); // This thread will increase priority to 2 t3 = Thread::create(t6_p6, STACK_SMALL, priorityAdapter(2), - reinterpret_cast<void *>(&t6_m4), + reinterpret_cast<void*>(&t6_m4), Thread::JOINABLE); Thread::sleep(10); if (Thread::getCurrentThread()->getPriority() != priorityAdapter(2)) @@ -1536,7 +1536,7 @@ static void test_6() Thread::setPriority(priorityAdapter(1)); // This thread will increase priority to 2 t4 = Thread::create(t6_p6, STACK_SMALL, priorityAdapter(2), - reinterpret_cast<void *>(&t6_m3), Thread::JOINABLE); + reinterpret_cast<void*>(&t6_m3), Thread::JOINABLE); Thread::sleep(10); if (Thread::getCurrentThread()->getPriority() != priorityAdapter(2)) fail("priority inheritance (13)"); @@ -1563,7 +1563,7 @@ static void test_6() { Lock<Mutex> l3(t6_m5); t = Thread::create(t6_p6, STACK_SMALL, 0, - reinterpret_cast<void *>(&t6_m5)); + reinterpret_cast<void*>(&t6_m5)); Thread::sleep(10); // If thread does not exist it means it has locked the mutex // even if we locked it first @@ -1694,7 +1694,7 @@ static void test_6() { Lock<FastMutex> l3(t6_m5a); t = Thread::create(t6_p6a, STACK_SMALL, 0, - reinterpret_cast<void *>(&t6_m5a)); + reinterpret_cast<void*>(&t6_m5a)); Thread::sleep(10); // If thread does not exist it means it has locked the mutex // even if we locked it first @@ -1758,7 +1758,7 @@ std::chrono::system_clock std::chrono::steady_clock */ -static void fail_time(const char *msg, long long time) // time in ms +static void fail_time(const char* msg, long long time) // time in ms { fail((std::string(msg) + std::to_string(time)).c_str()); } @@ -1779,7 +1779,9 @@ static void test_7() if (llabs(duration_cast<milliseconds>(steadyEnd - steadyStart).count() - i) > 4) + { fail_time("steady_clock not precise ", i); + } auto sysStart = system_clock::now(); Thread::sleep(i); @@ -1787,7 +1789,9 @@ static void test_7() if (llabs(duration_cast<milliseconds>(sysEnd - sysStart).count() - i) > 4) + { fail_time("system_clock not precise ", i); + } } pass(); @@ -1813,7 +1817,7 @@ FIXME: The overloaded versions of IRQput and IRQget are not tested static Queue<char, 4> t8_q1; static Queue<char, 4> t8_q2; -static void t8_p1(void *argv __attribute__((unused))) +static void t8_p1(void* argv __attribute__((unused))) { for (;;) { @@ -1895,7 +1899,7 @@ static void test_8() // Test queue between threads t8_q1.reset(); t8_q2.reset(); - Thread *p = Thread::create(t8_p1, STACK_SMALL, 0, NULL); + Thread* p = Thread::create(t8_p1, STACK_SMALL, 0, NULL); char write = 'A', read = 'A'; for (int i = 1; i <= 8; i++) { @@ -2037,13 +2041,13 @@ void t10_f2() t10_f1(); fail("Exception not thrown (1)"); } - catch (std::logic_error &e) + catch (std::logic_error& e) { throw; } } -void t10_p1(void *argv __attribute__((unused))) +void t10_p1(void* argv __attribute__((unused))) { t10_f2(); fail("Exception not thrown"); @@ -2053,7 +2057,7 @@ void test_10() { test_name("Exception handling"); Thread::sleep(10); - Thread *t = Thread::create(t10_p1, 1024 + 512, 0, NULL); + Thread* t = Thread::create(t10_p1, 1024 + 512, 0, NULL); Thread::sleep(80); if (Thread::exists(t)) fail("Thread not deleted"); @@ -2070,7 +2074,7 @@ tests class MemoryProfiling static volatile unsigned int t11_v1; // Free heap after spawning thread -void t11_p1(void *argv __attribute__((unused))) +void t11_p1(void* argv __attribute__((unused))) { if (MemoryProfiling::getStackSize() != STACK_SMALL) fail("getStackSize (2)"); @@ -2103,7 +2107,7 @@ void test_11() if (MemoryProfiling::getAbsoluteFreeHeap() > heapSize) fail("getAbsoluteFreeHeap"); // Multithread test - Thread *t = Thread::create(t11_p1, STACK_SMALL, 0, 0, Thread::JOINABLE); + Thread* t = Thread::create(t11_p1, STACK_SMALL, 0, 0, Thread::JOINABLE); t11_v1 = MemoryProfiling::getCurrentFreeHeap(); t->join(0); Thread::sleep( @@ -2121,20 +2125,20 @@ Additional test for priority inheritance Mutex t12_m1; Mutex t12_m2; -void t12_p1(void *argv __attribute__((unused))) +void t12_p1(void* argv __attribute__((unused))) { Lock<Mutex> l1(t12_m1); Lock<Mutex> l2(t12_m2); } -void t12_p2(void *argv __attribute__((unused))) { Lock<Mutex> l(t12_m1); } +void t12_p2(void* argv __attribute__((unused))) { Lock<Mutex> l(t12_m1); } void test_12() { test_name("Priority inheritance 2"); Thread::setPriority(priorityAdapter(0)); // For EDF - Thread *t1; - Thread *t2; + Thread* t1; + Thread* t2; { // First, we lock the second Mutex Lock<Mutex> l(t12_m2); @@ -2191,7 +2195,7 @@ Tests: - Thread::detach */ -void *t14_p1(void *argv) +void* t14_p1(void* argv) { for (;;) { @@ -2206,16 +2210,16 @@ void *t14_p1(void *argv) return argv; } -void *t14_p2(void *argv) +void* t14_p2(void* argv) { Thread::sleep(50); return argv; } -void t14_p3(void *argv) +void t14_p3(void* argv) { Thread::sleep(20); - Thread *t = reinterpret_cast<Thread *>(argv); + Thread* t = reinterpret_cast<Thread*>(argv); t->detach(); } @@ -2230,7 +2234,7 @@ void test_14() // // Test 1: detached thread that returns void* - Thread *t = Thread::create(t14_p1, STACK_SMALL, 0, 0); + Thread* t = Thread::create(t14_p1, STACK_SMALL, 0, 0); t->terminate(); Thread::sleep(10); if (Thread::exists(t)) @@ -2252,7 +2256,7 @@ void test_14() Thread::sleep(10); // Test 5: detaching a thread on which some other thread called join t = Thread::create(t14_p2, STACK_SMALL, 0, 0, Thread::JOINABLE); - Thread::create(t14_p3, STACK_SMALL, 0, reinterpret_cast<void *>(t)); + Thread::create(t14_p3, STACK_SMALL, 0, reinterpret_cast<void*>(t)); if (t->join() == true) fail("thread not detached (1)"); @@ -2262,8 +2266,8 @@ void test_14() // // Test 1: join on joinable, not already deleted - void *result = 0; - t = Thread::create(t14_p2, STACK_SMALL, 0, (void *)0xdeadbeef, + void* result = 0; + t = Thread::create(t14_p2, STACK_SMALL, 0, (void*)0xdeadbeef, Thread::JOINABLE); Thread::yield(); if (t->join(&result) == false) @@ -2284,7 +2288,7 @@ void test_14() // Test 3: join on joinable, but detach called after t = Thread::create(t14_p1, STACK_SMALL, 0, 0, Thread::JOINABLE); - Thread::create(t14_p3, STACK_SMALL, 0, reinterpret_cast<void *>(t)); + Thread::create(t14_p3, STACK_SMALL, 0, reinterpret_cast<void*>(t)); if (t->join() == true) fail("Thread::join (3)"); t->terminate(); @@ -2303,7 +2307,7 @@ void test_14() // Test 6: join on already deleted result = 0; - t = Thread::create(t14_p1, STACK_SMALL, 0, (void *)0xdeadbeef, + t = Thread::create(t14_p1, STACK_SMALL, 0, (void*)0xdeadbeef, Thread::JOINABLE); t->terminate(); Thread::sleep(10); @@ -2345,7 +2349,7 @@ static int t15_v3; static ConditionVariable t15_c1; static Mutex t15_m1; -void t15_p1(void *argv __attribute__((unused))) +void t15_p1(void* argv __attribute__((unused))) { for (int i = 0; i < 10; i++) { @@ -2356,7 +2360,7 @@ void t15_p1(void *argv __attribute__((unused))) } } -void t15_p2(void *argv __attribute__((unused))) +void t15_p2(void* argv __attribute__((unused))) { for (int i = 0; i < 10; i++) { @@ -2374,8 +2378,8 @@ static void test_15() t15_v1 = false; t15_v2 = false; t15_v3 = 0; - Thread *p1 = Thread::create(t15_p1, STACK_SMALL, 0); - Thread *p2 = Thread::create(t15_p2, STACK_SMALL, 0); + Thread* p1 = Thread::create(t15_p1, STACK_SMALL, 0); + Thread* p2 = Thread::create(t15_p2, STACK_SMALL, 0); for (int i = 0; i < 20; i++) { Thread::sleep(10); @@ -2455,9 +2459,9 @@ posix threads API pthread_once */ -inline Thread *toThread(pthread_t t) { return reinterpret_cast<Thread *>(t); } +inline Thread* toThread(pthread_t t) { return reinterpret_cast<Thread*>(t); } -void *t16_p1(void *argv) +void* t16_p1(void* argv) { toThread(pthread_self())->wait(); return argv; @@ -2466,9 +2470,9 @@ void *t16_p1(void *argv) volatile bool t16_v1; pthread_mutex_t t16_m1 = PTHREAD_MUTEX_INITIALIZER; -void *t16_p2(void *argv) +void* t16_p2(void* argv) { - pthread_mutex_t *mutex = (pthread_mutex_t *)argv; + pthread_mutex_t* mutex = (pthread_mutex_t*)argv; if (pthread_mutex_lock(mutex) != 0) fail("mutex_lock (2)"); t16_v1 = true; @@ -2480,7 +2484,7 @@ void *t16_p2(void *argv) pthread_cond_t t16_c1 = PTHREAD_COND_INITIALIZER; -void *t16_p3(void *argv __attribute__((unused))) +void* t16_p3(void* argv __attribute__((unused))) { Thread::sleep(30); if (pthread_mutex_trylock(&t16_m1) != 0) @@ -2495,7 +2499,7 @@ void *t16_p3(void *argv __attribute__((unused))) pthread_cond_t t16_c2; -void *t16_p4(void *argv __attribute__((unused))) +void* t16_p4(void* argv __attribute__((unused))) { Thread::sleep(30); if (pthread_mutex_trylock(&t16_m1) != 0) @@ -2567,7 +2571,7 @@ static void test_16() pthread_t thread; if (pthread_create(&thread, &attr, t16_p1, NULL) != 0) fail("pthread_create (1)"); - Thread *t = toThread(thread); + Thread* t = toThread(thread); if (Thread::exists(t) == false) fail("thread not created"); if (t->isDetached() == false) @@ -2591,7 +2595,7 @@ static void test_16() // pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, STACK_SMALL); - if (pthread_create(&thread, &attr, t16_p1, (void *)0xdeadbeef) != 0) + if (pthread_create(&thread, &attr, t16_p1, (void*)0xdeadbeef) != 0) fail("pthread_create (2)"); t = toThread(thread); if (Thread::exists(t) == false) @@ -2600,7 +2604,7 @@ static void test_16() fail("detached by mistake (1)"); Thread::sleep(10); // Give the other thread time to call wait() t->wakeup(); - void *res; + void* res; if (pthread_join(thread, &res) != 0) fail("join return value"); if (((unsigned)res) != 0xdeadbeef) @@ -2631,7 +2635,7 @@ static void test_16() if (pthread_mutex_lock(&t16_m1) != 0) fail("mutex lock"); t16_v1 = false; - if (pthread_create(&thread, NULL, t16_p2, (void *)&t16_m1) != 0) + if (pthread_create(&thread, NULL, t16_p2, (void*)&t16_m1) != 0) fail("pthread_create (4)"); t = toThread(thread); if (Thread::exists(t) == false) @@ -2650,7 +2654,7 @@ static void test_16() Thread::sleep(10); // testing trylock, after the thread is created it will lock the mutex // for 50ms - if (pthread_create(&thread, NULL, t16_p2, (void *)&t16_m1) != 0) + if (pthread_create(&thread, NULL, t16_p2, (void*)&t16_m1) != 0) fail("pthread_create (5)"); Thread::sleep(10); if (pthread_mutex_trylock(&t16_m1) == 0) @@ -2668,7 +2672,7 @@ static void test_16() if (pthread_mutex_lock(&mutex) != 0) fail("mutex lock (4)"); t16_v1 = false; - if (pthread_create(&thread, NULL, t16_p2, (void *)&mutex) != 0) + if (pthread_create(&thread, NULL, t16_p2, (void*)&mutex) != 0) fail("pthread_create (6)"); t = toThread(thread); if (Thread::exists(t) == false) @@ -2686,7 +2690,7 @@ static void test_16() pthread_join(thread, NULL); Thread::sleep(10); // testing pthread_mutex_destroy - if (pthread_create(&thread, NULL, t16_p2, (void *)&mutex) != 0) + if (pthread_create(&thread, NULL, t16_p2, (void*)&mutex) != 0) fail("pthread_create (7)"); t = toThread(thread); if (Thread::exists(t) == false) @@ -2785,7 +2789,7 @@ public: unsigned int a, b; }; -static TestStaticConstructor &instance() +static TestStaticConstructor& instance() { static TestStaticConstructor singleton; return singleton; @@ -2833,8 +2837,8 @@ void __attribute__((noinline)) check32(unsigned int a, unsigned int b) fail("swapBytes32"); } -void __attribute__((noinline)) -check64(unsigned long long a, unsigned long long b) +void __attribute__((noinline)) check64(unsigned long long a, + unsigned long long b) { if (swapBytes64(a) != b) fail("swapBytes64"); @@ -2847,10 +2851,14 @@ static void test_18() fail("swapBytes16"); if (swapBytes32(0x12345678) != 0x78563412 || swapBytes32(0x55aa00ff) != 0xff00aa55) + { fail("swapBytes32"); + } if (swapBytes64(0x0123456789abcdefull) != 0xefcdab8967452301ull || swapBytes64(0x55aa00ffcc33ab56ull) != 0x56ab33ccff00aa55ull) + { fail("swapBytes64"); + } check16(0x1234, 0x3412); check16(0x55aa, 0xaa55); check32(0x12345678, 0x78563412); @@ -2869,19 +2877,27 @@ static void test_18() if (toBigEndian16(0x0123) != 0x0123 || toBigEndian32(0x01234567) != 0x01234567 || toBigEndian64(0x0123456789abcdef) != 0x0123456789abcdef) + { fail("toBigEndian"); + } if (fromBigEndian16(0x0123) != 0x0123 || fromBigEndian32(0x01234567) != 0x01234567 || fromBigEndian64(0x0123456789abcdef) != 0x0123456789abcdef) + { fail("fromBigEndian"); + } if (toLittleEndian16(0x0123) != 0x2301 || toLittleEndian32(0x01234567) != 0x67452301 || toLittleEndian64(0x0123456789abcdef) != 0xefcdab8967452301) + { fail("toLittleEndian"); + } if (fromLittleEndian16(0x0123) != 0x2301 || fromLittleEndian32(0x01234567) != 0x67452301 || fromLittleEndian64(0x0123456789abcdef) != 0xefcdab8967452301) + { fail("fromLittleEndian"); + } } else { @@ -2889,19 +2905,27 @@ static void test_18() if (toLittleEndian16(0x0123) != 0x0123 || toLittleEndian32(0x01234567) != 0x01234567 || toLittleEndian64(0x0123456789abcdef) != 0x0123456789abcdef) + { fail("toLittleEndian"); + } if (fromLittleEndian16(0x0123) != 0x0123 || fromLittleEndian32(0x01234567) != 0x01234567 || fromLittleEndian64(0x0123456789abcdef) != 0x0123456789abcdef) + { fail("fromLittleEndian"); + } if (toBigEndian16(0x0123) != 0x2301 || toBigEndian32(0x01234567) != 0x67452301 || toBigEndian64(0x0123456789abcdef) != 0xefcdab8967452301) + { fail("toBigEndian"); + } if (fromBigEndian16(0x0123) != 0x2301 || fromBigEndian32(0x01234567) != 0x67452301 || fromBigEndian64(0x0123456789abcdef) != 0xefcdab8967452301) + { fail("fromBigEndian"); + } } pass(); } @@ -2915,16 +2939,16 @@ class BufferQueue */ BufferQueue<char, 10, 3> bq; -Thread *t19_v1; +Thread* t19_v1; static const char b1c[] = "b1c----"; static const char b2c[] = "b2c----x"; static const char b3c[] = "b3c----xx"; static const char b4c[] = ""; -static char *IRQgbw(FastInterruptDisableLock &dLock) +static char* IRQgbw(FastInterruptDisableLock& dLock) { - char *buffer = 0; + char* buffer = 0; if (bq.tryGetWritableBuffer(buffer) == false) { FastInterruptEnableLock eLock(dLock); @@ -2933,7 +2957,7 @@ static char *IRQgbw(FastInterruptDisableLock &dLock) return buffer; } -static void gbr(const char *&buffer, unsigned int &size) +static void gbr(const char*& buffer, unsigned int& size) { FastInterruptDisableLock dLock; while (bq.tryGetReadableBuffer(buffer, size) == false) @@ -2952,12 +2976,12 @@ static void be() bq.bufferEmptied(); } -static void t19_p1(void *argv __attribute__((unused))) +static void t19_p1(void* argv __attribute__((unused))) { Thread::sleep(50); { FastInterruptDisableLock dLock; - char *buffer = IRQgbw(dLock); + char* buffer = IRQgbw(dLock); strcpy(buffer, b1c); bq.bufferFilled(strlen(b1c)); t19_v1->IRQwakeup(); @@ -3003,8 +3027,8 @@ static void test_19() fail("IRQisFull"); // Test filling only one slot - char *buf = 0; - const char *buffer = 0; + char* buf = 0; + const char* buffer = 0; unsigned int size; if (bq.tryGetReadableBuffer(buffer, size) == true) fail("IRQgetReadableBuffer"); @@ -3105,7 +3129,7 @@ static void test_19() // Now real multithreaded test t19_v1 = Thread::getCurrentThread(); - Thread *t = Thread::create(t19_p1, STACK_MIN, 0, 0, Thread::JOINABLE); + Thread* t = Thread::create(t19_p1, STACK_MIN, 0, 0, Thread::JOINABLE); gbr(buffer, size); if (size != strlen(b1c)) fail("returned size"); @@ -3184,9 +3208,9 @@ private: void thrower() { throw 5; } -void t20_t1(void *arg) +void t20_t1(void* arg) { - EventQueue *eq = reinterpret_cast<EventQueue *>(arg); + EventQueue* eq = reinterpret_cast<EventQueue*>(arg); t20_v1 = 0; eq->post(t20_f1); Thread::sleep(10); @@ -3203,9 +3227,9 @@ void t20_t1(void *arg) eq->post(thrower); } -void t20_t2(void *arg) +void t20_t2(void* arg) { - FixedEventQueue<2> *eq = reinterpret_cast<FixedEventQueue<2> *>(arg); + FixedEventQueue<2>* eq = reinterpret_cast<FixedEventQueue<2>*>(arg); t20_v1 = 0; eq->post(t20_f1); eq->post(t20_f1); @@ -3309,7 +3333,7 @@ static void test_20() fail("Empty EventQueue"); #ifndef __NO_EXCEPTIONS - Thread *t = Thread::create(t20_t1, STACK_SMALL, 0, &eq, Thread::JOINABLE); + Thread* t = Thread::create(t20_t1, STACK_SMALL, 0, &eq, Thread::JOINABLE); try { eq.run(); @@ -3436,7 +3460,7 @@ static float t21_f2() return result; } -static void *t21_t1(void *) +static void* t21_t1(void*) { for (int i = 0; i < 5; i++) { @@ -3486,7 +3510,7 @@ struct t22_s1 int b; }; -static void t22_t2(void *argv __attribute__((unused))) +static void t22_t2(void* argv __attribute__((unused))) { while (Thread::testTerminate() == false) { @@ -3495,7 +3519,7 @@ static void t22_t2(void *argv __attribute__((unused))) } } -static void *t22_t1(void *) +static void* t22_t1(void*) { for (int i = 0; i < 100000; i++) { @@ -3556,9 +3580,9 @@ static void test_22() fail("atomicCompareAndSwap 4"); t22_s1 data1; - t22_s1 *dataPtr1 = &data1; - void *const volatile *ptr1 = - reinterpret_cast<void *const volatile *>(&dataPtr1); + t22_s1* dataPtr1 = &data1; + void* const volatile* ptr1 = + reinterpret_cast<void* const volatile*>(&dataPtr1); data1.a = 0; data1.b = 10; @@ -3573,7 +3597,7 @@ static void test_22() // Check that the implementation works with interrupts disabled too bool error = false; - Thread *t2 = Thread::create(t22_t2, STACK_MIN, 0, 0, Thread::JOINABLE); + Thread* t2 = Thread::create(t22_t2, STACK_MIN, 0, 0, Thread::JOINABLE); { FastInterruptDisableLock dLock; t22_v5 = false; @@ -3614,9 +3638,9 @@ static void test_22() delayMs(5); // Wait to check that interrupts are disabled t22_s1 data2; - t22_s1 *dataPtr2 = &data2; - void *const volatile *ptr2 = - reinterpret_cast<void *const volatile *>(&dataPtr2); + t22_s1* dataPtr2 = &data2; + void* const volatile* ptr2 = + reinterpret_cast<void* const volatile*>(&dataPtr2); data2.a = 0; data2.b = 10; if (atomicFetchAndIncrement(ptr2, 0, 2) != dataPtr2) @@ -3658,19 +3682,19 @@ static ConditionVariable t23_c2; static pthread_mutex_t t23_m3 = PTHREAD_MUTEX_RECURSIVE_INITIALIZER_NP; static pthread_cond_t t23_c3 = PTHREAD_COND_INITIALIZER; -static void t23_f1(void *) +static void t23_f1(void*) { Lock<Mutex> l(t23_m1); t23_c1.signal(); } -static void t23_f2(void *) +static void t23_f2(void*) { Lock<FastMutex> l(t23_m2); t23_c2.signal(); } -static void t23_f3(void *) +static void t23_f3(void*) { pthread_mutex_lock(&t23_m3); pthread_cond_signal(&t23_c3); @@ -3684,7 +3708,7 @@ static void test_23() { Lock<Mutex> l(t23_m1); Lock<Mutex> l2(t23_m1); - Thread *t = + Thread* t = Thread::create(t23_f1, 2 * STACK_MIN, 1, 0, Thread::JOINABLE); t23_c1.wait(l2); t->join(); @@ -3692,14 +3716,14 @@ static void test_23() { Lock<FastMutex> l(t23_m2); Lock<FastMutex> l2(t23_m2); - Thread *t = + Thread* t = Thread::create(t23_f2, 2 * STACK_MIN, 1, 0, Thread::JOINABLE); t23_c2.wait(l2); t->join(); } pthread_mutex_lock(&t23_m3); pthread_mutex_lock(&t23_m3); - Thread *t = Thread::create(t23_f3, 2 * STACK_MIN, 1, 0, Thread::JOINABLE); + Thread* t = Thread::create(t23_f3, 2 * STACK_MIN, 1, 0, Thread::JOINABLE); pthread_cond_wait(&t23_c3, &t23_m3); t->join(); pthread_mutex_unlock(&t23_m3); @@ -3899,10 +3923,10 @@ static void test_24() intrusive_ref_ptr<Base0> ptr1(new Base0); ptr1->check(); - Base0 *p = ptr1.get(); + Base0* p = ptr1.get(); p->check(); - Base0 &r = *ptr1; + Base0& r = *ptr1; r.check(); } assert(dtorCalled); @@ -3922,9 +3946,9 @@ static void test_24() // Copy construction, interleaved dtorCalled = false; { - intrusive_ref_ptr<Base0> *ptr1 = + intrusive_ref_ptr<Base0>* ptr1 = new intrusive_ref_ptr<Base0>(new Base0); - intrusive_ref_ptr<Base0> *ptr2 = new intrusive_ref_ptr<Base0>(*ptr1); + intrusive_ref_ptr<Base0>* ptr2 = new intrusive_ref_ptr<Base0>(*ptr1); (*ptr2)->check(); delete ptr1; assert(dtorCalled == false); @@ -4085,7 +4109,7 @@ static void test_24() } #if defined(_ARCH_CORTEXM7_STM32F7) || defined(_ARCH_CORTEXM7_STM32H7) -static Thread *waiting = nullptr; /// Thread waiting on DMA completion IRQ +static Thread* waiting = nullptr; /// Thread waiting on DMA completion IRQ /** * DMA completion IRQ @@ -4107,16 +4131,18 @@ void dma2s0irq() waiting->IRQwakeup(); if (waiting->IRQgetPriority() > Thread::IRQgetCurrentThread()->IRQgetPriority()) + { Scheduler::IRQfindNextThread(); + } waiting = nullptr; } /** * Copy memory to memory using DMA, used to test cache and DMA consistency */ -void dmaMemcpy(void *dest, const void *source, int size, void *slackBeforeDest, - void *slackBeforeSource, int slackBeforeSize, - void *slackAfterDest, void *slackAfterSource, int slackAfterSize) +void dmaMemcpy(void* dest, const void* source, int size, void* slackBeforeDest, + void* slackBeforeSource, int slackBeforeSize, + void* slackAfterDest, void* slackAfterSource, int slackAfterSize) { FastInterruptDisableLock dLock; DMA2_Stream1->NDTR = size; @@ -4152,21 +4178,21 @@ void testOneDmaTransaction(unsigned int size, unsigned int offset) { // Pointer to buffer where the DMA will write, with the desired offset from // perfect cache line alignment - char *source = src + offset; - char *dest = dst + offset; + char* source = src + offset; + char* dest = dst + offset; // If the DMA memory buffer beginning is misaligned, get pointer and size to // the cache line that includes the buffer beginning - char *slackBeforeSource = reinterpret_cast<char *>( + char* slackBeforeSource = reinterpret_cast<char*>( reinterpret_cast<unsigned int>(source) & (~(cacheLine - 1))); - char *slackBeforeDest = reinterpret_cast<char *>( + char* slackBeforeDest = reinterpret_cast<char*>( reinterpret_cast<unsigned int>(dest) & (~(cacheLine - 1))); unsigned int slackBeforeSize = source - slackBeforeSource; // If the DMA memory buffer end is misaligned, get pointer and size to // the cache line that includes the buffer end - char *slackAfterSource = source + size; - char *slackAfterDest = dest + size; + char* slackAfterSource = source + size; + char* slackAfterDest = dest + size; unsigned int slackAfterSize = cacheLine - (reinterpret_cast<unsigned int>(slackAfterSource) & (cacheLine - 1)); @@ -4285,16 +4311,16 @@ Also tests concurrent write by opening and writing 3 files from 3 threads */ static volatile bool fs_1_error; -static void fs_t1_p1(void *argv __attribute__((unused))) +static void fs_t1_p1(void* argv __attribute__((unused))) { - FILE *f; + FILE* f; if ((f = fopen("/sd/testdir/file_1.txt", "w")) == NULL) { fs_1_error = true; return; } setbuf(f, NULL); - char *buf = new char[512]; + char* buf = new char[512]; memset(buf, '1', 512); for (int i = 0; i < 512; i++) { @@ -4316,16 +4342,16 @@ static void fs_t1_p1(void *argv __attribute__((unused))) } } -static void fs_t1_p2(void *argv __attribute__((unused))) +static void fs_t1_p2(void* argv __attribute__((unused))) { - FILE *f; + FILE* f; if ((f = fopen("/sd/testdir/file_2.txt", "w")) == NULL) { fs_1_error = true; return; } setbuf(f, NULL); - char *buf = new char[512]; + char* buf = new char[512]; memset(buf, '2', 512); for (int i = 0; i < 512; i++) { @@ -4347,16 +4373,16 @@ static void fs_t1_p2(void *argv __attribute__((unused))) } } -static void fs_t1_p3(void *argv __attribute__((unused))) +static void fs_t1_p3(void* argv __attribute__((unused))) { - FILE *f; + FILE* f; if ((f = fopen("/sd/testdir/file_3.txt", "w")) == NULL) { fs_1_error = true; return; } setbuf(f, NULL); - char *buf = new char[512]; + char* buf = new char[512]; memset(buf, '3', 512); for (int i = 0; i < 512; i++) { @@ -4402,11 +4428,11 @@ static void fs_test_1() } // Test concurrent file write access fs_1_error = false; - Thread *t1 = + Thread* t1 = Thread::create(fs_t1_p1, 2048 + 512, 1, NULL, Thread::JOINABLE); - Thread *t2 = + Thread* t2 = Thread::create(fs_t1_p2, 2048 + 512, 1, NULL, Thread::JOINABLE); - Thread *t3 = + Thread* t3 = Thread::create(fs_t1_p3, 2048 + 512, 1, NULL, Thread::JOINABLE); t1->join(); t2->join(); @@ -4414,9 +4440,9 @@ static void fs_test_1() if (fs_1_error) fail("Concurrent write"); // Testing file read - char *buf = new char[1024]; + char* buf = new char[1024]; int i, j, k; - FILE *f; + FILE* f; // file_1.txt if ((f = fopen("/sd/testdir/file_1.txt", "r")) == NULL) fail("can't open file_1.txt"); @@ -4528,7 +4554,9 @@ static void fs_test_1() fseek(f, 21 + 17, SEEK_SET); // Seek to 002\n if ((fgetc(f) != '0') | (fgetc(f) != '0') | (fgetc(f) != '2') | (fgetc(f) != '\n')) + { fail("fgetc SEEK_SET"); + } if (ftell(f) != (21 * 2)) { iprintf("ftell=%ld\n", ftell(f)); @@ -4537,7 +4565,9 @@ static void fs_test_1() fseek(f, 21 * 50 + 17, SEEK_CUR); // Seek to 053\n if ((fgetc(f) != '0') | (fgetc(f) != '5') | (fgetc(f) != '3') | (fgetc(f) != '\n')) + { fail("fgetc SEEK_CUR"); + } if (ftell(f) != (21 * 53)) { iprintf("ftell=%ld\n", ftell(f)); @@ -4570,13 +4600,13 @@ mkdir/unlink/rename * \param b if not null, this file most not be in the directory * \return true on success, false on failure */ -static bool checkDirContent(const std::string &d, const char *a, const char *b) +static bool checkDirContent(const std::string& d, const char* a, const char* b) { - DIR *dir = opendir(d.c_str()); + DIR* dir = opendir(d.c_str()); bool found = false; for (;;) { - struct dirent *de = readdir(dir); + struct dirent* de = readdir(dir); if (de == NULL) break; if (a && !strcasecmp(de->d_name, a)) @@ -4594,7 +4624,7 @@ static bool checkDirContent(const std::string &d, const char *a, const char *b) return true; } -static void checkInDir(const std::string &d, bool createFile) +static void checkInDir(const std::string& d, bool createFile) { using namespace std; const char dirname1[] = "test1"; @@ -4615,7 +4645,7 @@ static void checkInDir(const std::string &d, bool createFile) if (createFile == false) return; const char filename1[] = "test.txt"; - FILE *f; + FILE* f; if ((f = fopen((d + filename1).c_str(), "w")) == NULL) fail("fopen"); const char teststr[] = "Testing\n"; @@ -4647,7 +4677,7 @@ static void fs_test_2() { test_name("mkdir/rename/unlink"); checkInDir("/", false); - DIR *d = opendir("/sd"); + DIR* d = opendir("/sd"); if (d != NULL) { // the /sd mountpoint exists, check mkdir/rename/unlink also here @@ -4674,11 +4704,11 @@ static void fs_test_3() const unsigned int size = 1024; const unsigned int numBlocks = 2048; - FILE *f; + FILE* f; if ((f = fopen(name, "w")) == NULL) fail("open 1"); setbuf(f, NULL); // cppcheck-suppress nullPointerRedundantCheck - char *buf = new char[size]; + char* buf = new char[size]; unsigned short checksum = 0; for (unsigned int i = 0; i < numBlocks; i++) { @@ -4721,14 +4751,14 @@ tests: opendir()/readdir() */ -unsigned int checkInodes(const char *dir, unsigned int curInode, +unsigned int checkInodes(const char* dir, unsigned int curInode, unsigned int parentInode, short curDev, short parentDev) { if (chdir(dir)) fail("chdir"); - DIR *d = opendir("."); + DIR* d = opendir("."); if (d == NULL) fail("opendir"); puts(dir); @@ -4736,7 +4766,7 @@ unsigned int checkInodes(const char *dir, unsigned int curInode, unsigned int result = 0; for (;;) { - struct dirent *de = readdir(d); + struct dirent* de = readdir(d); if (de == NULL) break; @@ -4772,7 +4802,9 @@ unsigned int checkInodes(const char *dir, unsigned int curInode, fail("parent dev"); } else if (st.st_dev != curDev) + { fail("cur dev"); + } if (mustBeDir) { @@ -4781,20 +4813,17 @@ unsigned int checkInodes(const char *dir, unsigned int curInode, if (!S_ISDIR(st.st_mode)) fail("st_mode"); } - else + else if (!S_ISDIR(st.st_mode)) { - if (!S_ISDIR(st.st_mode)) - { - int fd = open(de->d_name, O_RDONLY); - if (fd < 0) - fail("open"); - struct stat st2; - if (fstat(fd, &st2)) - fail("fstat"); - close(fd); - if (memcmp(&st, &st2, sizeof(struct stat))) - fail("stat/fstat mismatch"); - } + int fd = open(de->d_name, O_RDONLY); + if (fd < 0) + fail("open"); + struct stat st2; + if (fstat(fd, &st2)) + fail("fstat"); + close(fd); + if (memcmp(&st, &st2, sizeof(struct stat))) + fail("stat/fstat mismatch"); } if ((de->d_type == DT_DIR) ^ (S_ISDIR(st.st_mode))) @@ -4822,13 +4851,13 @@ static void fs_test_4() unsigned int curInode = 0, parentInode = 0, devFsInode = 0, sdInode = 0; // cppcheck-suppress unreadVariable short curDevice = 0, devDevice = 0, sdDevice = 0; - DIR *d = opendir("/"); + DIR* d = opendir("/"); if (d == NULL) fail("opendir"); puts("/"); for (;;) { - struct dirent *de = readdir(d); + struct dirent* de = readdir(d); if (de == NULL) break; // de->d_ino may differ from st.st_ino across mountpoints, such as /dev @@ -4905,11 +4934,11 @@ static void fs_test_4() const int nThreads = 8; bool flags[nThreads]; -static int throwable(std::vector<int> &v) __attribute__((noinline)); +static int throwable(std::vector<int>& v) __attribute__((noinline)); // cppcheck-suppress containerOutOfBounds -static int throwable(std::vector<int> &v) { return v.at(10); } +static int throwable(std::vector<int>& v) { return v.at(10); } -static void test(void *argv) +static void test(void* argv) { const int n = reinterpret_cast<int>(argv); for (;;) @@ -4921,7 +4950,7 @@ static void test(void *argv) throwable(v); fail("Exception not thrown"); } - catch (std::out_of_range &e) + catch (std::out_of_range& e) { flags[n] = true; } @@ -4933,7 +4962,7 @@ static void exception_test() test_name("C++ exception thread safety"); iprintf("Note: test never ends. Reset the board when you are satisfied\n"); for (int i = 0; i < nThreads; i++) - Thread::create(test, 1024 + 512, 0, reinterpret_cast<void *>(i)); + Thread::create(test, 1024 + 512, 0, reinterpret_cast<void*>(i)); bool toggle = false; for (int j = 0;; j++) { @@ -4973,7 +5002,7 @@ serial write speed static void benchmark_1() { extern unsigned long _data asm("_data"); - char *data = reinterpret_cast<char *>(&_data); + char* data = reinterpret_cast<char*>(&_data); using namespace std::chrono; auto start = system_clock::now(); @@ -5007,7 +5036,7 @@ tests: context switch speed */ -static void b2_p1(void *argv __attribute__((unused))) +static void b2_p1(void* argv __attribute__((unused))) { for (;;) { @@ -5037,7 +5066,7 @@ static void benchmark_2() #ifndef SCHED_TYPE_EDF // Test context switch time at maximum priority Thread::setPriority(3); // Using max priority - Thread *p = Thread::create(b2_p1, STACK_SMALL, 3, NULL); + Thread* p = Thread::create(b2_p1, STACK_SMALL, 3, NULL); int i = b2_f1(); p->terminate(); iprintf("%d context switch per second (max priority)\n", i); @@ -5069,9 +5098,9 @@ static void benchmark_3() // Write benchmark const char FILENAME[] = "/sd/speed.txt"; const unsigned int BUFSIZE = 1024; - char *buf = new char[BUFSIZE]; - memset((void *)buf, '0', BUFSIZE); - FILE *f; + char* buf = new char[BUFSIZE]; + memset((void*)buf, '0', BUFSIZE); + FILE* f; if ((f = fopen(FILENAME, "w")) == NULL) { iprintf("Filesystem write benchmark not made. Can't open file\n"); @@ -5131,11 +5160,13 @@ static void benchmark_3() if (diff > max) max = diff; for (unsigned j = 0; j < BUFSIZE; j++) + { if (buf[j] != '0') { iprintf("Read error 2\n"); goto quit; } + } } quit: endTotal = system_clock::now(); @@ -5161,7 +5192,7 @@ Mutex lock/unlock time volatile bool b4_end = false; -void b4_t1(void *argv __attribute__((unused))) +void b4_t1(void* argv __attribute__((unused))) { Thread::sleep(1000); b4_end = true; @@ -5254,9 +5285,9 @@ static void benchmark_4() #ifdef WITH_PROCESSES -unsigned int *memAllocation(unsigned int size) +unsigned int* memAllocation(unsigned int size) { - unsigned int *p = ProcessPool::instance().allocate(size); + unsigned int* p = ProcessPool::instance().allocate(size); memset(p, WATERMARK_FILL, size); iprintf("Allocated %d bytes. Base: %p. Size: 0x%x.\n\n", size, p, size); return p; @@ -5264,37 +5295,35 @@ unsigned int *memAllocation(unsigned int size) // Returns true if a watermark filled memory zone is not corrupted. // 'base' must be 4-byte aligned -bool memCheck(unsigned int *base, unsigned int size) +bool memCheck(unsigned int* base, unsigned int size) { for (unsigned int i = 0; i < size / 4; i++) - { if (*(base + i) != WATERMARK_FILL) return false; - } return true; } -void runElfTest(const char *name, const unsigned char *filename, +void runElfTest(const char* name, const unsigned char* filename, unsigned int file_length) { iprintf("Executing %s...", name); try { - ElfProgram prog(reinterpret_cast<const unsigned int *>(filename), + ElfProgram prog(reinterpret_cast<const unsigned int*>(filename), file_length); iprintf("not passed.\n"); } - catch (std::runtime_error &err) + catch (std::runtime_error& err) { iprintf("passed.\n"); } } // It runs the program, waits for its exit, and returns the exit code -int runProgram(const unsigned char *filename, unsigned int file_length) +int runProgram(const unsigned char* filename, unsigned int file_length) { int ec; - ElfProgram prog(reinterpret_cast<const unsigned int *>(filename), + ElfProgram prog(reinterpret_cast<const unsigned int*>(filename), file_length); pid_t child = Process::create(prog); Process::waitpid(child, &ec, 0); @@ -5305,28 +5334,32 @@ int runProgram(const unsigned char *filename, unsigned int file_length) bool isSignaled(int exit_code) { if (WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGSEGV) - { return true; - } return false; } void mpuTest1() { int ec; - unsigned int *addr = (unsigned int *)0x64100000; + unsigned int* addr = (unsigned int*)0x64100000; iprintf("Executing MPU Test 1...\n"); ec = runProgram(test1_elf, test1_elf_len); if (isSignaled(ec)) { if (*addr == 0xbbbbbbbb) + { iprintf( "...not passed! The process has written a forbidden memory " "location.\n\n"); + } else if (*addr == WATERMARK_FILL) + { iprintf("...passed!\n\n"); + } else + { iprintf("...not passed! Memory has been somehow corrupted.\n\n"); + } } else { @@ -5337,36 +5370,36 @@ void mpuTest1() void mpuTest2() { int ec; - unsigned int *addr = (unsigned int *)0x64100200; + unsigned int* addr = (unsigned int*)0x64100200; iprintf("Executing MPU Test 2...\n"); ec = runProgram(test2_elf, test2_elf_len); if (isSignaled(ec)) - { if (*addr == WATERMARK_FILL) iprintf("...passed!\n\n"); else iprintf("...not passed! Memory has been somehow corrupted.\n\n"); - } else - { iprintf("...not passed! Process exited normally.\n\n"); - } } void mpuTest3() { int ec; - unsigned int *addr = (unsigned int *)0x64100200; + unsigned int* addr = (unsigned int*)0x64100200; iprintf("Executing MPU Test 3...\n"); ec = runProgram(test3_elf, test3_elf_len); if (isSignaled(ec)) { if (*addr == 0xbbbbbbbb) + { iprintf( "...not passed! The process has written a forbidden memory " "location.\n\n"); + } else + { iprintf("...passed!\n\n"); + } } else { @@ -5380,29 +5413,29 @@ void mpuTest4() iprintf("Executing MPU Test 4...\n"); ec = runProgram(test4_elf, test4_elf_len); if (isSignaled(ec)) - { iprintf("...passed!.\n\n"); - } else - { iprintf("...not passed! Process exited normally.\n\n"); - } } void mpuTest5() { int ec; - unsigned int *addr = (unsigned int *)0x64101000; + unsigned int* addr = (unsigned int*)0x64101000; iprintf("Executing MPU Test 5...\n"); ec = runProgram(test5_elf, test5_elf_len); if (isSignaled(ec)) { if (*addr == 0xbbbbbbbb) + { iprintf( "...not passed! The process has written a forbidden memory " "location.\n\n"); + } else + { iprintf("...passed!.\n\n"); + } } else { @@ -5413,17 +5446,21 @@ void mpuTest5() void mpuTest6() { int ec; - unsigned int *addr = (unsigned int *)0x64101404; + unsigned int* addr = (unsigned int*)0x64101404; iprintf("Executing MPU Test 6...\n"); ec = runProgram(test6_elf, test6_elf_len); if (isSignaled(ec)) { if (*addr == 0xbbbbbbbb) + { iprintf( "...not passed! The process has written a forbidden memory " "location.\n\n"); + } else + { iprintf("...passed!.\n\n"); + } } else { @@ -5437,9 +5474,9 @@ void mpuTest7() unsigned int memSize = 8192; iprintf("Executing MPU Test 7...\n"); - unsigned int *p = ProcessPool::instance().allocate(memSize); + unsigned int* p = ProcessPool::instance().allocate(memSize); memset(p, WATERMARK_FILL, memSize); - ElfProgram prog(reinterpret_cast<const unsigned int *>(test7_elf), + ElfProgram prog(reinterpret_cast<const unsigned int*>(test7_elf), test7_elf_len); pid_t child = Process::create(prog); delayMs(1000); @@ -5464,11 +5501,11 @@ void mpuTest8() // We create two processes. The first goes to sleep for 2 seconds, // while the second process tries to access the data region of the // first. - unsigned int *addr = (unsigned int *)0x64104004; + unsigned int* addr = (unsigned int*)0x64104004; iprintf("Executing MPU Test 8...\n"); - ElfProgram prog1(reinterpret_cast<const unsigned int *>(test8_1_elf), + ElfProgram prog1(reinterpret_cast<const unsigned int*>(test8_1_elf), test8_1_elf_len); - ElfProgram prog2(reinterpret_cast<const unsigned int *>(test8_2_elf), + ElfProgram prog2(reinterpret_cast<const unsigned int*>(test8_2_elf), test8_2_elf_len); pid_t child1 = Process::create(prog1); pid_t child2 = Process::create(prog2); @@ -5478,11 +5515,15 @@ void mpuTest8() if (WIFSIGNALED(ec2) && (WTERMSIG(ec2) == SIGSEGV) && WIFEXITED(ec1)) { if (*addr == 0xbbbbbbbb) + { iprintf( "...not passed! The process has written a forbidden memory " "location.\n\n"); + } else + { iprintf("...passed!.\n\n"); + } } else { @@ -5493,7 +5534,7 @@ void mpuTest8() void mpuTest9() { iprintf("Executing MPU Test 9...\n"); - ElfProgram prog(reinterpret_cast<const unsigned int *>(test9_elf), + ElfProgram prog(reinterpret_cast<const unsigned int*>(test9_elf), test9_elf_len); std::vector<pid_t> pids; int ec; @@ -5505,7 +5546,7 @@ void mpuTest9() pid = Process::create(prog); pids.push_back(pid); } - catch (std::bad_alloc &ex) + catch (std::bad_alloc& ex) { iprintf("Bad alloc raised: %s\nIteration is: %d\n", ex.what(), i); break; @@ -5530,9 +5571,9 @@ void mpuTest10() // should end properly, the second process should fault. int ec1, ec2; iprintf("Executing MPU Test 10...\n"); - ElfProgram prog1(reinterpret_cast<const unsigned int *>(test10_1_elf), + ElfProgram prog1(reinterpret_cast<const unsigned int*>(test10_1_elf), test10_1_elf_len); - ElfProgram prog2(reinterpret_cast<const unsigned int *>(test10_2_elf), + ElfProgram prog2(reinterpret_cast<const unsigned int*>(test10_2_elf), test10_2_elf_len); pid_t child1 = Process::create(prog1); pid_t child2 = Process::create(prog2); @@ -5540,12 +5581,8 @@ void mpuTest10() Process::waitpid(child2, &ec2, 0); if (!isSignaled(ec1) && isSignaled(ec2)) - { iprintf("...passed!.\n\n"); - } else - { iprintf("...not passed!\n\n"); - } } #endif // WITH_PROCESSES diff --git a/src/entrypoints/runcam-settings.cpp b/src/entrypoints/runcam-settings.cpp index 17ca888b3..824623c2b 100644 --- a/src/entrypoints/runcam-settings.cpp +++ b/src/entrypoints/runcam-settings.cpp @@ -57,9 +57,7 @@ int main() Runcam test(usart1); if (!test.init()) - { return -1; - } char c; while (true) @@ -72,17 +70,11 @@ int main() test.selectSetting(); test.openMenu(); if (c == 'd') - { test.moveDown(); - } else if (c == 'c') - { test.selectSetting(); - } else if (c == 'o') - { test.openMenu(); - } } test.close(); diff --git a/src/entrypoints/sdcard-benchmark.cpp b/src/entrypoints/sdcard-benchmark.cpp index 9a54a3a63..f5219b2f6 100644 --- a/src/entrypoints/sdcard-benchmark.cpp +++ b/src/entrypoints/sdcard-benchmark.cpp @@ -76,10 +76,14 @@ int main() for (size_t bufferSize : BUFFER_SIZES) { if (benchmark(bufferSize, data)) + { printResults(bufferSize, data); + } else + { printf("Error while performing the benchmark (buffer size: %lu)\n", (unsigned long)bufferSize); + } } printf("Test completed\n"); diff --git a/src/entrypoints/sx1278-serial.cpp b/src/entrypoints/sx1278-serial.cpp index ede273cb2..196bc3d48 100644 --- a/src/entrypoints/sx1278-serial.cpp +++ b/src/entrypoints/sx1278-serial.cpp @@ -78,8 +78,8 @@ using sck = radio::sck; using miso = radio::miso; using mosi = radio::mosi; -using txen = radio::txEn; -using rxen = radio::rxEn; +using txen = radio::txEn; +using rxen = radio::rxEn; #define SX1278_SPI SPI4 @@ -146,10 +146,10 @@ using rst = miosix::radio2::nrst; #ifdef SX1278_IS_LORA static constexpr size_t SX1278_MTU = Boardcore::SX1278Lora::MTU; -Boardcore::SX1278Lora *sx1278 = nullptr; +Boardcore::SX1278Lora* sx1278 = nullptr; #else static constexpr size_t SX1278_MTU = Boardcore::SX1278Fsk::MTU; -Boardcore::SX1278Fsk *sx1278 = nullptr; +Boardcore::SX1278Fsk* sx1278 = nullptr; #endif volatile int dio0_cnt = 0; @@ -220,9 +220,7 @@ void sendLoop() auto serial = miosix::DefaultConsole::instance().get(); int len = serial->readBlock(msg, sizeof(msg), 0); if (len > 0) - { sx1278->send(msg, len); - } } } @@ -239,11 +237,11 @@ int main() #elif defined SX1278_IS_SKYWARD433 printf("[sx1278] Confuring Skyward 433 frontend...\n"); std::unique_ptr<Boardcore::SX1278::ISX1278Frontend> frontend( - new Boardcore::Skyward433Frontend()); + new Boardcore::Skyward433Frontend()); #else printf("[sx1278] Confuring RA01 frontend...\n"); std::unique_ptr<Boardcore::SX1278::ISX1278Frontend> frontend( - new Boardcore::RA01Frontend()); + new Boardcore::RA01Frontend()); #endif #ifdef SX1278_IS_LORA @@ -273,14 +271,14 @@ int main() config.enable_crc = false; sx1278 = new Boardcore::SX1278Fsk(sx1278_bus, cs::getPin(), dio0::getPin(), - dio1::getPin(), dio3::getPin(), - Boardcore::SPI::ClockDivider::DIV_256, - std::move(frontend)); + dio1::getPin(), dio3::getPin(), + Boardcore::SPI::ClockDivider::DIV_256, + std::move(frontend)); printf("\n[sx1278] Configuring sx1278 fsk...\n"); if ((err = sx1278->init(config)) != Boardcore::SX1278Fsk::Error::NONE) { - // FIXME: Why does clang-format put this line up here? + // FIXME: Why does clang-format put this line up here? printf("[sx1278] sx1278->init error\n"); return false; } diff --git a/src/shared/ActiveObject.h b/src/shared/ActiveObject.h index abecefa32..2d952b453 100644 --- a/src/shared/ActiveObject.h +++ b/src/shared/ActiveObject.h @@ -37,7 +37,6 @@ namespace Boardcore */ class ActiveObject { - public: /** * Constructor. This will create the AO, but will NOT start the thread @@ -48,7 +47,7 @@ public: ActiveObject(unsigned int stacksize = miosix::STACK_DEFAULT_FOR_PTHREAD, miosix::Priority priority = miosix::MAIN_PRIORITY); - virtual ~ActiveObject(){}; + virtual ~ActiveObject() {}; /** * @brief Start the thread associated with this active object. @@ -125,9 +124,7 @@ inline bool ActiveObject::start() miosix::Thread::JOINABLE); if (thread == nullptr) - { running = false; - } return running; } diff --git a/src/shared/actuators/Buzzer.h b/src/shared/actuators/Buzzer.h index 207c49d8a..b359b40c5 100644 --- a/src/shared/actuators/Buzzer.h +++ b/src/shared/actuators/Buzzer.h @@ -42,7 +42,7 @@ public: * @param timer Timer used to provide the alternating on and off signal. * @param channel Timer channel to output the signal. */ - Buzzer(TIM_TypeDef *timer, TimerUtils::Channel channel); + Buzzer(TIM_TypeDef* timer, TimerUtils::Channel channel); /** * @brief Turns on the buzzer. @@ -80,7 +80,7 @@ private: TimerUtils::Channel channel; }; -inline Buzzer::Buzzer(TIM_TypeDef *timer, TimerUtils::Channel channel) +inline Buzzer::Buzzer(TIM_TypeDef* timer, TimerUtils::Channel channel) : timer(timer), channel(channel) { } diff --git a/src/shared/actuators/stepper/Stepper.cpp b/src/shared/actuators/stepper/Stepper.cpp index 52804e9fa..6eb23fb02 100644 --- a/src/shared/actuators/stepper/Stepper.cpp +++ b/src/shared/actuators/stepper/Stepper.cpp @@ -45,26 +45,18 @@ Stepper::Stepper(miosix::GpioPin stepPin, miosix::GpioPin directionPin, void Stepper::enable() { if (pinConfig == PinConfiguration::COMMON_CATHODE) - { enablePin.low(); - } else - { enablePin.high(); - } enabled = true; } void Stepper::disable() { if (pinConfig == PinConfiguration::COMMON_CATHODE) - { enablePin.high(); - } else - { enablePin.low(); - } enabled = false; } @@ -138,24 +130,16 @@ void Stepper::move(int16_t steps) for (int i = 0; i < stepsAbs; i++) { if (pinConfig == PinConfiguration::COMMON_CATHODE) - { stepPin.high(); - } else - { stepPin.low(); - } miosix::delayUs(halfStepDelay); if (pinConfig == PinConfiguration::COMMON_CATHODE) - { stepPin.low(); - } else - { stepPin.high(); - } miosix::delayUs(halfStepDelay); } @@ -170,4 +154,4 @@ StepperData Stepper::getState(float moveDeg) speed, moveDeg}; } -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/actuators/stepper/Stepper.h b/src/shared/actuators/stepper/Stepper.h index 6e9d25dca..a1a3ca890 100644 --- a/src/shared/actuators/stepper/Stepper.h +++ b/src/shared/actuators/stepper/Stepper.h @@ -195,4 +195,4 @@ inline int16_t Stepper::getCurrentPosition() inline float Stepper::getCurrentDegPosition() { return currentPositionDeg; } -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/actuators/stepper/StepperPWM.cpp b/src/shared/actuators/stepper/StepperPWM.cpp index 4f04532df..9071485ca 100644 --- a/src/shared/actuators/stepper/StepperPWM.cpp +++ b/src/shared/actuators/stepper/StepperPWM.cpp @@ -24,7 +24,7 @@ namespace Boardcore { -StepperPWM::StepperPWM(CountedPWM &pwm, miosix::GpioPin stepPin, +StepperPWM::StepperPWM(CountedPWM& pwm, miosix::GpioPin stepPin, miosix::GpioPin directionPin, float speed, float stepAngle, bool revertDirection, uint16_t microStep, PinConfiguration pinConfiguration, @@ -96,4 +96,4 @@ float StepperPWM::getCurrentDegPosition() currentDirection * pwm.getCurrentCount() * stepAngle / microStep; } -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/actuators/stepper/StepperPWM.h b/src/shared/actuators/stepper/StepperPWM.h index 6c91c24b7..c7de4c427 100644 --- a/src/shared/actuators/stepper/StepperPWM.h +++ b/src/shared/actuators/stepper/StepperPWM.h @@ -49,7 +49,7 @@ public: * @param revertDirection Whether or not revert the direction signal. */ StepperPWM( - CountedPWM &pwm, miosix::GpioPin stepPin, miosix::GpioPin directionPin, + CountedPWM& pwm, miosix::GpioPin stepPin, miosix::GpioPin directionPin, float speed = 1, float stepAngle = 1.8, bool revertDirection = false, uint16_t microStep = 1, PinConfiguration pinConfiguration = PinConfiguration::COMMON_CATHODE, @@ -93,12 +93,12 @@ public: private: // This class is not copyable! - StepperPWM &operator=(const StepperPWM &) = delete; - StepperPWM(const StepperPWM &p) = delete; + StepperPWM& operator=(const StepperPWM&) = delete; + StepperPWM(const StepperPWM& p) = delete; void setDirection(); - CountedPWM &pwm; + CountedPWM& pwm; }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/algorithms/AirBrakes/AirBrakesInterp.cpp b/src/shared/algorithms/AirBrakes/AirBrakesInterp.cpp index 4fa04719f..b758acc0b 100644 --- a/src/shared/algorithms/AirBrakes/AirBrakesInterp.cpp +++ b/src/shared/algorithms/AirBrakes/AirBrakesInterp.cpp @@ -35,9 +35,9 @@ namespace Boardcore AirBrakesInterp::AirBrakesInterp( std::function<TimedTrajectoryPoint()> getCurrentPosition, - const TrajectorySet &trajectoryOpenSet, - const TrajectorySet &trajectoryCloseSet, - const AirBrakesInterpConfig &configInterp, + const TrajectorySet& trajectoryOpenSet, + const TrajectorySet& trajectoryCloseSet, + const AirBrakesInterpConfig& configInterp, std::function<void(float)> setActuator) : getCurrentPosition(getCurrentPosition), setActuator(setActuator), trajectoryOpenSet(trajectoryOpenSet), @@ -149,12 +149,18 @@ float AirBrakesInterp::controlInterp(TrajectoryPoint currentPosition) // trjPointOpen.vz); if (currentPosition.vz <= trjPointClosed.vz) + { return 0; + } else if (currentPosition.vz >= trjPointOpen.vz) + { return 1; + } else + { return (currentPosition.vz - trjPointClosed.vz) / (trjPointOpen.vz - trjPointClosed.vz); + } } } // namespace Boardcore diff --git a/src/shared/algorithms/AirBrakes/AirBrakesInterp.h b/src/shared/algorithms/AirBrakes/AirBrakesInterp.h index f2e9ee6f3..4d52c2ba2 100644 --- a/src/shared/algorithms/AirBrakes/AirBrakesInterp.h +++ b/src/shared/algorithms/AirBrakes/AirBrakesInterp.h @@ -37,9 +37,9 @@ class AirBrakesInterp : public Algorithm { public: AirBrakesInterp(std::function<TimedTrajectoryPoint()> getCurrentPosition, - const TrajectorySet &trajectoryOpenSet, - const TrajectorySet &trajectoryCloseSet, - const AirBrakesInterpConfig &configInterp, + const TrajectorySet& trajectoryOpenSet, + const TrajectorySet& trajectoryCloseSet, + const AirBrakesInterpConfig& configInterp, std::function<void(float)> setActuator); bool init() override; @@ -74,12 +74,12 @@ private: // Trajectory sets (open and closed) from which the algorithm will choose at // the beginning the tuple with which interpolate the data. The selection // depends on the rocket mass. - const TrajectorySet &trajectoryOpenSet; - const TrajectorySet &trajectoryCloseSet; + const TrajectorySet& trajectoryOpenSet; + const TrajectorySet& trajectoryCloseSet; // Choosen trajectories from the begin function - Trajectory *choosenCloseTrajectory = nullptr; - Trajectory *choosenOpenTrajectory = nullptr; + Trajectory* choosenCloseTrajectory = nullptr; + Trajectory* choosenOpenTrajectory = nullptr; AirBrakesInterpConfig configInterp; ///< specialized config float lastPercentage = 0; ///< last opening of the airbrakes diff --git a/src/shared/algorithms/AirBrakes/AirBrakesPI.cpp b/src/shared/algorithms/AirBrakes/AirBrakesPI.cpp index bd1866637..4455d2230 100644 --- a/src/shared/algorithms/AirBrakes/AirBrakesPI.cpp +++ b/src/shared/algorithms/AirBrakes/AirBrakesPI.cpp @@ -38,7 +38,7 @@ namespace Boardcore AirBrakesPI::AirBrakesPI( std::function<TimedTrajectoryPoint()> getCurrentPosition, - const TrajectorySet &trajectorySet, const AirBrakesPIConfig &config, + const TrajectorySet& trajectorySet, const AirBrakesPIConfig& config, std::function<void(float)> setActuator) : getCurrentPosition(getCurrentPosition), config(config), setActuator(setActuator), pi(config.KP, config.KI, config.TS), @@ -81,7 +81,7 @@ float AirBrakesPI::getRho(float z) return Constants::RHO_0 * expf(-z / Constants::Hn); } -float AirBrakesPI::getSurface(const TimedTrajectoryPoint ¤tPosition, +float AirBrakesPI::getSurface(const TimedTrajectoryPoint& currentPosition, float rho, float targetDrag) { float bestDDrag = numeric_limits<float>::infinity(); @@ -168,7 +168,7 @@ void AirBrakesPI::chooseTrajectory(TrajectoryPoint currentPosition) for (uint8_t trjIndex = 0; trjIndex < trajectorySet.length(); trjIndex++) { - Trajectory &trajectory = trajectorySet.trajectories[trjIndex]; + Trajectory& trajectory = trajectorySet.trajectories[trjIndex]; for (uint32_t ptIndex = 0; ptIndex < trajectory.size(); ptIndex++) { diff --git a/src/shared/algorithms/AirBrakes/AirBrakesPI.h b/src/shared/algorithms/AirBrakes/AirBrakesPI.h index ce72b5a42..be8db3d18 100644 --- a/src/shared/algorithms/AirBrakes/AirBrakesPI.h +++ b/src/shared/algorithms/AirBrakes/AirBrakesPI.h @@ -39,8 +39,8 @@ class AirBrakesPI : public Algorithm { public: AirBrakesPI(std::function<TimedTrajectoryPoint()> getCurrentPosition, - const TrajectorySet &trajectorySet, - const AirBrakesPIConfig &config, + const TrajectorySet& trajectorySet, + const AirBrakesPIConfig& config, std::function<void(float)> setActuator); bool init() override; @@ -76,7 +76,7 @@ private: * @param drag Target drag force. * @return AirBrakes surface [m]; */ - float getSurface(const TimedTrajectoryPoint ¤tPosition, float rho, + float getSurface(const TimedTrajectoryPoint& currentPosition, float rho, float drag); /** @@ -131,7 +131,7 @@ private: private: std::function<TimedTrajectoryPoint()> getCurrentPosition; - const AirBrakesPIConfig &config; + const AirBrakesPIConfig& config; std::function<void(float)> setActuator; TimedTrajectoryPoint lastPosition; @@ -140,9 +140,9 @@ private: PIController pi; // Trajectory set from which the used trajectory can be choosen - const TrajectorySet &trajectorySet; + const TrajectorySet& trajectorySet; - Trajectory *chosenTrajectory = nullptr; + Trajectory* chosenTrajectory = nullptr; }; } // namespace Boardcore diff --git a/src/shared/algorithms/AirBrakes/Trajectory.h b/src/shared/algorithms/AirBrakes/Trajectory.h index 3c139cd22..a585d50ba 100644 --- a/src/shared/algorithms/AirBrakes/Trajectory.h +++ b/src/shared/algorithms/AirBrakes/Trajectory.h @@ -31,7 +31,7 @@ class Trajectory { public: float extension; ///< AirBrakes target extension for this trajectory [m]. - TrajectoryPoint *points; + TrajectoryPoint* points; uint16_t trjSize; Trajectory(float extension, TrajectoryPoint points[], uint16_t trjSize) diff --git a/src/shared/algorithms/Algorithm.h b/src/shared/algorithms/Algorithm.h index 0dfbc0275..4f4dcf4d7 100644 --- a/src/shared/algorithms/Algorithm.h +++ b/src/shared/algorithms/Algorithm.h @@ -54,9 +54,7 @@ public: void update() { if (running) - { step(); - } } bool isRunning() { return running; } diff --git a/src/shared/algorithms/Follower/Follower.cpp b/src/shared/algorithms/Follower/Follower.cpp index 07fd53198..46beec180 100644 --- a/src/shared/algorithms/Follower/Follower.cpp +++ b/src/shared/algorithms/Follower/Follower.cpp @@ -43,13 +43,9 @@ namespace Boardcore float minimizeRotation(float angle) { if (angle > 180) - { angle -= 360; - } else if (angle < -180) - { angle += 360; - } return angle; } @@ -180,11 +176,11 @@ void Follower::step() setState(newState); #ifndef NDEBUG - std::cout << "[FOLLOWER] STEPPER " - << "Angles: [" << newState.yaw << ", " << newState.pitch << "] " - << "Speed: [" << newState.horizontalSpeed << ", " - << newState.verticalSpeed << "] VN300 measure: [" << vn300.yaw - << ", " << vn300.pitch << "]\n"; + std::cout << "[FOLLOWER] STEPPER " << "Angles: [" << newState.yaw << ", " + << newState.pitch << "] " << "Speed: [" + << newState.horizontalSpeed << ", " << newState.verticalSpeed + << "] VN300 measure: [" << vn300.yaw << ", " << vn300.pitch + << "]\n"; #endif } diff --git a/src/shared/algorithms/Follower/FollowerData.h b/src/shared/algorithms/Follower/FollowerData.h index e30123af7..d8e2c9df0 100644 --- a/src/shared/algorithms/Follower/FollowerData.h +++ b/src/shared/algorithms/Follower/FollowerData.h @@ -48,10 +48,10 @@ struct AntennaAngles AntennaAngles() : timestamp{0}, yaw{0}, pitch{0} {}; AntennaAngles(uint64_t timestamp, float yaw, float pitch) - : timestamp{timestamp}, yaw(yaw), pitch(pitch){}; + : timestamp{timestamp}, yaw(yaw), pitch(pitch) {}; AntennaAngles(uint64_t timestamp, float yaw, float pitch, uint32_t nrPropagations) - : timestamp{timestamp}, yaw(yaw), pitch(pitch){}; + : timestamp{timestamp}, yaw(yaw), pitch(pitch) {}; }; /** @@ -62,13 +62,13 @@ struct AntennaAnglesLog : public AntennaAngles uint32_t nrPropagations = 0; //!< Nr of propagations by the propagator (0 if no propagation) - AntennaAnglesLog() : AntennaAngles(), nrPropagations(0){}; + AntennaAnglesLog() : AntennaAngles(), nrPropagations(0) {}; AntennaAnglesLog(uint64_t timestamp, float yaw, float pitch) : AntennaAngles(timestamp, yaw, pitch), nrPropagations{0} {}; AntennaAnglesLog(uint64_t timestamp, float yaw, float pitch, uint32_t nrPropagations) - : AntennaAngles(timestamp, yaw, pitch), nrPropagations{ - nrPropagations} {}; + : AntennaAngles(timestamp, yaw, pitch), + nrPropagations{nrPropagations} {}; AntennaAnglesLog(AntennaAngles angle, uint32_t nrPropagations) : AntennaAngles(angle), nrPropagations{nrPropagations} {}; diff --git a/src/shared/algorithms/MEA/MEA.cpp b/src/shared/algorithms/MEA/MEA.cpp index 0b4108a07..0856368cb 100644 --- a/src/shared/algorithms/MEA/MEA.cpp +++ b/src/shared/algorithms/MEA/MEA.cpp @@ -58,20 +58,19 @@ void MEA::Step::withSpeedAndAlt(float verticalSpeed, float mslAltitude) hasSpeedAndAlt = true; } -MEA::MEA(const Config &config) +MEA::MEA(const Config& config) : F{config.F}, Q{config.Q}, G{config.G}, baroH{config.baroH}, baroR{config.baroR}, P{config.P}, x{0, 0, config.initialMass}, mass{config.initialMass}, accelThresh{config.accelThresh}, speedThresh{config.speedThresh}, Kt{config.Kt}, alpha{config.alpha}, - c{config.c}, coeffs{config.coeffs}, - crossSection{config.crossSection}, ae{config.ae}, p0{config.p0}, - minMass{config.minMass}, maxMass{config.maxMass}, - cdCorrectionFactor(config.cdCorrectionFactor) + c{config.c}, coeffs{config.coeffs}, crossSection{config.crossSection}, + ae{config.ae}, p0{config.p0}, minMass{config.minMass}, + maxMass{config.maxMass}, cdCorrectionFactor(config.cdCorrectionFactor) { updateState(); } -void MEA::update(const Step &step) +void MEA::update(const Step& step) { // First run the prediction step predict(step); @@ -97,13 +96,13 @@ void MEA::update(const Step &step) MEAState MEA::getState() { return state; } -void MEA::predict(const Step &step) +void MEA::predict(const Step& step) { x = F * x + G * step.mainValveOpen; P = F * P * F.transpose() + Q; } -void MEA::computeForce(const Step &step) +void MEA::computeForce(const Step& step) { if (!step.hasSpeedAndAlt) return; @@ -133,7 +132,7 @@ void MEA::computeForce(const Step &step) } } -void MEA::correctBaro(const Step &step) +void MEA::correctBaro(const Step& step) { if (!step.hasCCPressure) return; @@ -150,7 +149,7 @@ void MEA::correctBaro(const Step &step) x = x + K * (step.ccPressure - baroH * x); } -void MEA::correctAccel(const Step &step) +void MEA::correctAccel(const Step& step) { if (!step.hasAcceleration || !step.hasSpeedAndAlt) return; @@ -158,7 +157,9 @@ void MEA::correctAccel(const Step &step) // Do not correct at low speed/acceleration if (step.acceleration.norm() < accelThresh || step.verticalSpeed < speedThresh) + { return; + } float y = (Kt * (float)(baroH * x) - force) / x(2); @@ -188,7 +189,7 @@ void MEA::computeMass() mass = std::max(std::min(x(2), maxMass), minMass); } -void MEA::computeApogee(const Step &step) +void MEA::computeApogee(const Step& step) { if (!step.hasSpeedAndAlt) return; @@ -214,4 +215,4 @@ void MEA::updateState() state.estimatedPressure = baroH * x; state.estimatedApogee = apogee; state.estimatedForce = force; -} \ No newline at end of file +} diff --git a/src/shared/algorithms/MEA/MEA.h b/src/shared/algorithms/MEA/MEA.h index fbe18c7e6..feaf1a83a 100644 --- a/src/shared/algorithms/MEA/MEA.h +++ b/src/shared/algorithms/MEA/MEA.h @@ -99,19 +99,19 @@ public: void withSpeedAndAlt(float verticalSpeed, float mslAltitude); }; - explicit MEA(const Config &config); + explicit MEA(const Config& config); - void update(const Step &step); + void update(const Step& step); MEAState getState(); private: - void predict(const Step &step); - void computeForce(const Step &step); - void correctBaro(const Step &step); - void correctAccel(const Step &step); + void predict(const Step& step); + void computeForce(const Step& step); + void correctBaro(const Step& step); + void correctAccel(const Step& step); void computeMass(); - void computeApogee(const Step &step); + void computeApogee(const Step& step); void updateState(); Eigen::Matrix<float, 3, 3> F; //< State propagation matrix @@ -155,4 +155,4 @@ private: MEAState state; }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/algorithms/MEA/MEAData.h b/src/shared/algorithms/MEA/MEAData.h index 8e26d62a4..bb515b8ff 100644 --- a/src/shared/algorithms/MEA/MEAData.h +++ b/src/shared/algorithms/MEA/MEAData.h @@ -47,7 +47,7 @@ struct MEAState "estimatedForce,x0,x1,x2\n"; } - void print(std::ostream &os) const + void print(std::ostream& os) const { os << timestamp << "," << estimatedPressure << "," << estimatedMass << "," << estimatedApogee << "," << estimatedForce << "," << x0 @@ -55,4 +55,4 @@ struct MEAState } }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/algorithms/NAS/NAS.cpp b/src/shared/algorithms/NAS/NAS.cpp index 1b162b6a1..e200f046f 100644 --- a/src/shared/algorithms/NAS/NAS.cpp +++ b/src/shared/algorithms/NAS/NAS.cpp @@ -173,9 +173,7 @@ void NAS::correctBaro(const float pressure) // If not invertible, don't do the correction and return if (S < 1e-3) - { return; - } float y_hat = Aeroutils::relPressure(reference.refAltitude - x(2), @@ -236,9 +234,7 @@ void NAS::correctGPS(const Vector4f& gps) // If not invertible, don't do the correction and return if (S.determinant() < 1e-3) - { return; - } Matrix<float, 6, 4> K = Pl * H_gps_tr * S.inverse(); @@ -357,9 +353,7 @@ void NAS::correctPitot(const float staticPressure, const float dynamicPressure) // If a nan is generated, don't do the correction if (isnan(H(0, 5))) - { return; - } float R = config.SIGMA_PITOT * config.SIGMA_PITOT; @@ -368,9 +362,7 @@ void NAS::correctPitot(const float staticPressure, const float dynamicPressure) // If not invertible, don't do the correction and return if (S < 1e-3) - { return; - } float y_hat = std::pow(temp, (GAMMA_AIR / (GAMMA_AIR - 1))) - 1; // pRatio_model diff --git a/src/shared/algorithms/PIController.h b/src/shared/algorithms/PIController.h index c30e3e409..a39db5f21 100644 --- a/src/shared/algorithms/PIController.h +++ b/src/shared/algorithms/PIController.h @@ -32,7 +32,6 @@ namespace Boardcore * */ class PIController { - public: PIController(float Kp, float Ki, float Ts = 1, float uMin = -std::numeric_limits<float>::infinity(), diff --git a/src/shared/algorithms/ReferenceValues.h b/src/shared/algorithms/ReferenceValues.h index 62dcddd50..d4141ab6d 100644 --- a/src/shared/algorithms/ReferenceValues.h +++ b/src/shared/algorithms/ReferenceValues.h @@ -46,7 +46,7 @@ struct ReferenceValues float mslPressure = Constants::MSL_PRESSURE; float mslTemperature = Constants::MSL_TEMPERATURE; - ReferenceValues(){}; + ReferenceValues() {}; ReferenceValues(float altitude, float pressure, float temperature, float refLatitude = Constants::B21_LATITUDE, diff --git a/src/shared/diagnostic/PrintLogger.cpp b/src/shared/diagnostic/PrintLogger.cpp index 2b74b1df0..1b1d83107 100644 --- a/src/shared/diagnostic/PrintLogger.cpp +++ b/src/shared/diagnostic/PrintLogger.cpp @@ -55,9 +55,7 @@ static string truncateFileName(const string& name, int depth = 0) // Now traverse the path until we reach the end or the required depth for (int i = 0; i < depth && start != string::npos; i++) - { start = name.find_last_of("\\/", start - 1); - } // Truncate the path if needed return start == string::npos @@ -143,12 +141,8 @@ void PrintLogger::vlogAsync(uint8_t level, const string& function, void Logging::log(const LogRecord& record) { for (auto& s : sinks) - { if (s->isEnabled()) - { s->log(record); - } - } } void Logging::logAsync(const LogRecord& record) { asyncLog.log(record); } @@ -173,9 +167,7 @@ void Logging::AsyncLogger::run() { Lock<FastMutex> l(mutex); while (records.isEmpty()) - { cv.wait(mutex); - } rec = records.pop(); } diff --git a/src/shared/diagnostic/StackLogger.h b/src/shared/diagnostic/StackLogger.h index 7be7d81de..d615f10df 100644 --- a/src/shared/diagnostic/StackLogger.h +++ b/src/shared/diagnostic/StackLogger.h @@ -74,9 +74,7 @@ public: { Lock<FastMutex> l(mutex); for (auto it = stacks.begin(); it != stacks.end(); it++) - { Logger::getInstance().log(it->second); - } } } diff --git a/src/shared/drivers/WIZ5500/WIZ5500.cpp b/src/shared/drivers/WIZ5500/WIZ5500.cpp index 89577709c..43dc983de 100644 --- a/src/shared/drivers/WIZ5500/WIZ5500.cpp +++ b/src/shared/drivers/WIZ5500/WIZ5500.cpp @@ -46,7 +46,7 @@ SPIBusConfig getSpiBusConfig(SPI::ClockDivider clock_divider) return bus_config; } -Wiz5500::Wiz5500(SPIBus &bus, miosix::GpioPin cs, miosix::GpioPin intn, +Wiz5500::Wiz5500(SPIBus& bus, miosix::GpioPin cs, miosix::GpioPin intn, SPI::ClockDivider clock_divider) : intn(intn), slave(bus, cs, getSpiBusConfig(clock_divider)) { @@ -114,9 +114,7 @@ void Wiz5500::reset() // Reset all socketsOSI for (int i = 0; i < NUM_SOCKETS; i++) - { spiWrite8(Wiz::getSocketRegBlock(i), Wiz::Socket::REG_MR, 0); - } } void Wiz5500::handleINTn() @@ -163,9 +161,7 @@ bool Wiz5500::connectTcp(int sock_n, uint16_t src_port, WizIp dst_ip, // Check that we are closed if (socket_infos[sock_n].mode != Wiz5500::SocketMode::CLOSED) - { return false; - } // Setup the socket spiWrite8(Wiz::getSocketRegBlock(sock_n), Wiz::Socket::REG_MR, @@ -182,9 +178,7 @@ bool Wiz5500::connectTcp(int sock_n, uint16_t src_port, WizIp dst_ip, // Ok now check that we actually went into that mode int status = spiRead8(Wiz::getSocketRegBlock(sock_n), Wiz::Socket::REG_SR); if (status != Wiz::Socket::STAT_INIT) - { return false; - } // Connect the socket spiWrite8(Wiz::getSocketRegBlock(sock_n), Wiz::Socket::REG_CR, @@ -196,24 +190,20 @@ bool Wiz5500::connectTcp(int sock_n, uint16_t src_port, WizIp dst_ip, // Connection failed if ((irq & Wiz::Socket::Irq::CON) == 0) - { return false; - } socket_infos[sock_n].mode = Wiz5500::SocketMode::TCP; return true; } -bool Wiz5500::listenTcp(int sock_n, uint16_t src_port, WizIp &dst_ip, - uint16_t &dst_port, int timeout) +bool Wiz5500::listenTcp(int sock_n, uint16_t src_port, WizIp& dst_ip, + uint16_t& dst_port, int timeout) { Lock<FastMutex> l(mutex); // Check that we are closed if (socket_infos[sock_n].mode != Wiz5500::SocketMode::CLOSED) - { return false; - } // Setup the socket spiWrite8(Wiz::getSocketRegBlock(sock_n), Wiz::Socket::REG_MR, @@ -227,9 +217,7 @@ bool Wiz5500::listenTcp(int sock_n, uint16_t src_port, WizIp &dst_ip, // Ok now check that we actually went into that mode int status = spiRead8(Wiz::getSocketRegBlock(sock_n), Wiz::Socket::REG_SR); if (status != Wiz::Socket::STAT_INIT) - { return false; - } // Connect the socket spiWrite8(Wiz::getSocketRegBlock(sock_n), Wiz::Socket::REG_CR, @@ -244,9 +232,7 @@ bool Wiz5500::listenTcp(int sock_n, uint16_t src_port, WizIp &dst_ip, // Connection failed if ((irq & Wiz::Socket::Irq::CON) == 0) - { return false; - } // Read remote side infos dst_ip = spiReadIp(Wiz::getSocketRegBlock(sock_n), Wiz::Socket::REG_DIPR); @@ -264,9 +250,7 @@ bool Wiz5500::openUdp(int sock_n, uint16_t src_port, WizIp dst_ip, // Check that we are closed if (socket_infos[sock_n].mode != Wiz5500::SocketMode::CLOSED) - { return false; - } // Setup the socket spiWrite8(Wiz::getSocketRegBlock(sock_n), Wiz::Socket::REG_MR, @@ -283,23 +267,19 @@ bool Wiz5500::openUdp(int sock_n, uint16_t src_port, WizIp dst_ip, // Ok now check that we actually went into that mode int status = spiRead8(Wiz::getSocketRegBlock(sock_n), Wiz::Socket::REG_SR); if (status != Wiz::Socket::STAT_UDP) - { return false; - } socket_infos[sock_n].mode = Wiz5500::SocketMode::UDP; return true; } -bool Wiz5500::send(int sock_n, const uint8_t *data, size_t len, int timeout) +bool Wiz5500::send(int sock_n, const uint8_t* data, size_t len, int timeout) { Lock<FastMutex> l(mutex); // We cannot send through a closed socket if (socket_infos[sock_n].mode == Wiz5500::SocketMode::CLOSED) - { return false; - } // First get the start write address uint16_t start_addr = @@ -319,31 +299,25 @@ bool Wiz5500::send(int sock_n, const uint8_t *data, size_t len, int timeout) // It didn't signal it as an error if ((irq & Wiz::Socket::Irq::SEND_OK) == 0) - { return false; - } return true; } -ssize_t Wiz5500::recv(int sock_n, uint8_t *data, size_t len, int timeout) +ssize_t Wiz5500::recv(int sock_n, uint8_t* data, size_t len, int timeout) { Lock<FastMutex> l(mutex); // This is only valid for TCP if (socket_infos[sock_n].mode != Wiz5500::SocketMode::TCP) - { return -1; - } // Wait for the device to signal that we received something, or a // disconnection int irq = waitForSocketIrq( l, sock_n, Wiz::Socket::Irq::RECV | Wiz::Socket::Irq::DISCON, timeout); if ((irq & Wiz::Socket::Irq::RECV) == 0) - { return -1; - } // Ok we received something, get the received length uint16_t recv_len = @@ -353,9 +327,7 @@ ssize_t Wiz5500::recv(int sock_n, uint8_t *data, size_t len, int timeout) // Check if we actually have space if (recv_len < len) - { spiRead(Wiz::getSocketRxBlock(sock_n), addr, data, recv_len); - } addr += recv_len; spiWrite16(Wiz::getSocketRegBlock(sock_n), Wiz::Socket::REG_RX_RD, addr); @@ -367,25 +339,21 @@ ssize_t Wiz5500::recv(int sock_n, uint8_t *data, size_t len, int timeout) return recv_len < len ? recv_len : -1; } -ssize_t Wiz5500::recvfrom(int sock_n, uint8_t *data, size_t len, WizIp &dst_ip, - uint16_t &dst_port, int timeout) +ssize_t Wiz5500::recvfrom(int sock_n, uint8_t* data, size_t len, WizIp& dst_ip, + uint16_t& dst_port, int timeout) { Lock<FastMutex> l(mutex); // This is only valid for UDP if (socket_infos[sock_n].mode != Wiz5500::SocketMode::UDP) - { return -1; - } // Wait for the device to signal that we received something, or a // disconnection int irq = waitForSocketIrq( l, sock_n, Wiz::Socket::Irq::RECV | Wiz::Socket::Irq::DISCON, timeout); if ((irq & Wiz::Socket::Irq::RECV) == 0) - { return -1; - } // Ok we received something, get the received length uint16_t recv_len = @@ -395,16 +363,16 @@ ssize_t Wiz5500::recvfrom(int sock_n, uint8_t *data, size_t len, WizIp &dst_ip, // First read the internal header spiRead(Wiz::getSocketRxBlock(sock_n), addr, - reinterpret_cast<uint8_t *>(&dst_ip), sizeof(WizIp)); + reinterpret_cast<uint8_t*>(&dst_ip), sizeof(WizIp)); addr += sizeof(WizIp); spiRead(Wiz::getSocketRxBlock(sock_n), addr, - reinterpret_cast<uint8_t *>(&dst_port), sizeof(uint16_t)); + reinterpret_cast<uint8_t*>(&dst_port), sizeof(uint16_t)); addr += sizeof(uint16_t); // Now, what's this? uint16_t what = 0; spiRead(Wiz::getSocketRxBlock(sock_n), addr, - reinterpret_cast<uint8_t *>(&what), sizeof(uint16_t)); + reinterpret_cast<uint8_t*>(&what), sizeof(uint16_t)); addr += sizeof(uint16_t); // Remove what we have already read. @@ -412,9 +380,7 @@ ssize_t Wiz5500::recvfrom(int sock_n, uint8_t *data, size_t len, WizIp &dst_ip, // Check if we actually have space if (recv_len < len) - { spiRead(Wiz::getSocketRxBlock(sock_n), addr, data, recv_len); - } addr += recv_len; spiWrite16(Wiz::getSocketRegBlock(sock_n), Wiz::Socket::REG_RX_RD, addr); @@ -432,9 +398,7 @@ void Wiz5500::close(int sock_n, int timeout) // We cannot receive close a closed socket if (socket_infos[sock_n].mode == Wiz5500::SocketMode::CLOSED) - { return; - } spiWrite8(Wiz::getSocketRegBlock(sock_n), Wiz::Socket::REG_CR, Wiz::Socket::CMD_DISCON); @@ -443,7 +407,7 @@ void Wiz5500::close(int sock_n, int timeout) socket_infos[sock_n].mode = Wiz5500::SocketMode::CLOSED; } -void Wiz5500::waitForINTn(Lock<FastMutex> &l) +void Wiz5500::waitForINTn(Lock<FastMutex>& l) { long long start = Kernel::getOldTick(); TimedWaitResult result = TimedWaitResult::NoTimeout; @@ -457,21 +421,19 @@ void Wiz5500::waitForINTn(Lock<FastMutex> &l) } } -int Wiz5500::waitForSocketIrq(miosix::Lock<miosix::FastMutex> &l, int sock_n, +int Wiz5500::waitForSocketIrq(miosix::Lock<miosix::FastMutex>& l, int sock_n, uint8_t irq_mask, int timeout) { // Check that someone else isn't already waiting for one of ours interrupts if ((socket_infos[sock_n].irq_mask & irq_mask) != 0) - { return 0; - } // Enable the interrupts requested, updating the IRQ mask socket_infos[sock_n].irq_mask |= irq_mask; spiWrite8(Wiz::getSocketRegBlock(sock_n), Wiz::Socket::REG_IMR, socket_infos[sock_n].irq_mask); - Thread *this_thread = Thread::getCurrentThread(); + Thread* this_thread = Thread::getCurrentThread(); // Find a free slot in the data structure int i = 0; @@ -491,9 +453,7 @@ int Wiz5500::waitForSocketIrq(miosix::Lock<miosix::FastMutex> &l, int sock_n, // We didn't find any, return with failure if (i == NUM_THREAD_WAIT_INFOS) - { return 0; - } long long start = Kernel::getOldTick(); TimedWaitResult result = TimedWaitResult::NoTimeout; @@ -561,7 +521,7 @@ int Wiz5500::waitForSocketIrq(miosix::Lock<miosix::FastMutex> &l, int sock_n, return wait_infos[i].irq; } -void Wiz5500::runInterruptServiceRoutine(Lock<FastMutex> &l) +void Wiz5500::runInterruptServiceRoutine(Lock<FastMutex>& l) { // Other threads might wake us up in order to waitForINTn(l); @@ -626,7 +586,7 @@ void Wiz5500::runInterruptServiceRoutine(Lock<FastMutex> &l) } } -void Wiz5500::spiRead(uint8_t block, uint16_t address, uint8_t *data, +void Wiz5500::spiRead(uint8_t block, uint16_t address, uint8_t* data, size_t len) { // Do a manual SPI transaction @@ -639,7 +599,7 @@ void Wiz5500::spiRead(uint8_t block, uint16_t address, uint8_t *data, slave.bus.deselect(slave.cs); } -void Wiz5500::spiWrite(uint8_t block, uint16_t address, const uint8_t *data, +void Wiz5500::spiWrite(uint8_t block, uint16_t address, const uint8_t* data, size_t len) { // Do a manual SPI transaction @@ -662,7 +622,7 @@ uint8_t Wiz5500::spiRead8(uint8_t block, uint16_t address) uint16_t Wiz5500::spiRead16(uint8_t block, uint16_t address) { uint16_t data; - spiRead(block, address, reinterpret_cast<uint8_t *>(&data), + spiRead(block, address, reinterpret_cast<uint8_t*>(&data), sizeof(uint16_t)); return fromBigEndian16(data); } @@ -670,7 +630,7 @@ uint16_t Wiz5500::spiRead16(uint8_t block, uint16_t address) WizIp Wiz5500::spiReadIp(uint8_t block, uint16_t address) { WizIp data; - spiRead(block, address, reinterpret_cast<uint8_t *>(&data), sizeof(WizIp)); + spiRead(block, address, reinterpret_cast<uint8_t*>(&data), sizeof(WizIp)); return data; } @@ -689,17 +649,16 @@ void Wiz5500::spiWrite8(uint8_t block, uint16_t address, uint8_t data) void Wiz5500::spiWrite16(uint8_t block, uint16_t address, uint16_t data) { data = toBigEndian16(data); - spiWrite(block, address, reinterpret_cast<uint8_t *>(&data), + spiWrite(block, address, reinterpret_cast<uint8_t*>(&data), sizeof(uint16_t)); } void Wiz5500::spiWriteIp(uint8_t block, uint16_t address, WizIp data) { - spiWrite(block, address, reinterpret_cast<uint8_t *>(&data), sizeof(WizIp)); + spiWrite(block, address, reinterpret_cast<uint8_t*>(&data), sizeof(WizIp)); } void Wiz5500::spiWriteMac(uint8_t block, uint16_t address, WizMac data) { - spiWrite(block, address, reinterpret_cast<uint8_t *>(&data), - sizeof(WizMac)); -} \ No newline at end of file + spiWrite(block, address, reinterpret_cast<uint8_t*>(&data), sizeof(WizMac)); +} diff --git a/src/shared/drivers/WIZ5500/WIZ5500.h b/src/shared/drivers/WIZ5500/WIZ5500.h index 9d76cec26..728b50916 100644 --- a/src/shared/drivers/WIZ5500/WIZ5500.h +++ b/src/shared/drivers/WIZ5500/WIZ5500.h @@ -327,4 +327,4 @@ inline ostream& operator<<(ostream& os, const Boardcore::WizMac& mac) os.flags(old_flags); return os; } -} // namespace std \ No newline at end of file +} // namespace std diff --git a/src/shared/drivers/WIZ5500/WIZ5500Defs.h b/src/shared/drivers/WIZ5500/WIZ5500Defs.h index 096ab3ff0..e5ff7acb3 100644 --- a/src/shared/drivers/WIZ5500/WIZ5500Defs.h +++ b/src/shared/drivers/WIZ5500/WIZ5500Defs.h @@ -172,4 +172,4 @@ inline uint8_t buildModeMacraw(bool enable_mac_filter, bool block_broadcast, } // namespace Wiz -}; // namespace Boardcore \ No newline at end of file +}; // namespace Boardcore diff --git a/src/shared/drivers/adc/InternalADC.cpp b/src/shared/drivers/adc/InternalADC.cpp index f5dbbe0af..c0829a3c8 100644 --- a/src/shared/drivers/adc/InternalADC.cpp +++ b/src/shared/drivers/adc/InternalADC.cpp @@ -31,17 +31,17 @@ namespace Boardcore { #if defined(STM32F407xx) || defined(STM32F429xx) -#define CAL_PT1_VALUE ((uint16_t volatile *)((uint32_t)0x1FFF7A2C)) -#define CAL_PT2_VALUE ((uint16_t volatile *)((uint32_t)0x1FFF7A2E)) +#define CAL_PT1_VALUE ((uint16_t volatile*)((uint32_t)0x1FFF7A2C)) +#define CAL_PT2_VALUE ((uint16_t volatile*)((uint32_t)0x1FFF7A2E)) static const float CAL_PT1_TEMP = 30; static const float CAL_PT2_TEMP = 110; static const float CAL_V_DDA = 3.3f; #elif defined(STM32F767xx) || defined(STM32F769xx) || defined(STM32F756xx) -#define CAL_PT1_VALUE ((uint16_t volatile *)((uint32_t)0x1FF0F44C)) -#define CAL_PT2_VALUE ((uint16_t volatile *)((uint32_t)0x1FF0F44E)) -static const float CAL_PT1_TEMP = 30; -static const float CAL_PT2_TEMP = 110; -static const float CAL_V_DDA = 3.3f; +#define CAL_PT1_VALUE ((uint16_t volatile*)((uint32_t)0x1FF0F44C)) +#define CAL_PT2_VALUE ((uint16_t volatile*)((uint32_t)0x1FF0F44E)) +static const float CAL_PT1_TEMP = 30; +static const float CAL_PT2_TEMP = 110; +static const float CAL_V_DDA = 3.3f; #else #warning This micro controller does not have a calibrated temperature sensor or is not currently supported by this driver #endif @@ -65,7 +65,7 @@ static const float VBAT_DIV = 4.0f; #define V_DDA_VOLTAGE 3.0f #endif -InternalADC::InternalADC(ADC_TypeDef *adc) : adc(adc) +InternalADC::InternalADC(ADC_TypeDef* adc) : adc(adc) { #ifndef INTERNAL_ADC_WITHOUT_CALIBRATION loadCalibrationValues(); @@ -84,9 +84,7 @@ InternalADC::InternalADC(ADC_TypeDef *adc) : adc(adc) ADC->CCR |= ADC_CCR_ADCPRE_1 | ADC_CCR_ADCPRE_0; for (int i = 0; i < CH_NUM; i++) - { channelsEnabled[i] = false; - } } InternalADC::~InternalADC() diff --git a/src/shared/drivers/adc/InternalADC.h b/src/shared/drivers/adc/InternalADC.h index 46e5fdee4..6e642e3f4 100644 --- a/src/shared/drivers/adc/InternalADC.h +++ b/src/shared/drivers/adc/InternalADC.h @@ -98,7 +98,7 @@ public: * @brief Resets the ADC configuration and automatically enables the * peripheral clock. */ - explicit InternalADC(ADC_TypeDef *adc); + explicit InternalADC(ADC_TypeDef* adc); ~InternalADC(); @@ -140,7 +140,7 @@ private: uint16_t readChannel(Channel channel); - ADC_TypeDef *adc; + ADC_TypeDef* adc; bool channelsEnabled[CH_NUM]; bool tempEnabled = false; diff --git a/src/shared/drivers/adc/InternalADCData.h b/src/shared/drivers/adc/InternalADCData.h index 8a4bcfc71..76d0af67e 100644 --- a/src/shared/drivers/adc/InternalADCData.h +++ b/src/shared/drivers/adc/InternalADCData.h @@ -49,9 +49,7 @@ struct InternalADCData os << timestamp << ","; for (int i = 0; i < 16; i++) - { os << voltage[i] << ","; - } os << temperature << "," << vBat << "\n"; } diff --git a/src/shared/drivers/canbus/CanDriver/BusLoadEstimation.h b/src/shared/drivers/canbus/CanDriver/BusLoadEstimation.h index d635553ac..878ea88e7 100644 --- a/src/shared/drivers/canbus/CanDriver/BusLoadEstimation.h +++ b/src/shared/drivers/canbus/CanDriver/BusLoadEstimation.h @@ -62,9 +62,7 @@ public: { Lock<FastMutex> l(mutex); if (c.count() < 2) - { return {0, 0, 0}; - } float dt = (c.get(c.count() - 1).timestamp - c.get(0).timestamp) / 1000.0f; @@ -72,9 +70,7 @@ public: uint32_t sizeFrames = 0; for (size_t i = 0; i < c.count(); ++i) - { sizePayload += c.get(i).dataLength * 8; - } sizeFrames = sizePayload + (64 + 8) * c.count(); return BusLoadInfo{(sizePayload / dt), (sizeFrames / dt), diff --git a/src/shared/drivers/canbus/CanDriver/CanDriver.cpp b/src/shared/drivers/canbus/CanDriver/CanDriver.cpp index 61c57cb5d..2d4fa7213 100644 --- a/src/shared/drivers/canbus/CanDriver/CanDriver.cpp +++ b/src/shared/drivers/canbus/CanDriver/CanDriver.cpp @@ -136,9 +136,7 @@ CanbusDriver::~CanbusDriver() { ClockUtils::disablePeripheralClock(can); if (can == CAN2) - { ClockUtils::disablePeripheralClock(CAN1); - } } CanbusDriver::BitTiming CanbusDriver::calcBitTiming(AutoBitTiming autoBt) @@ -239,9 +237,7 @@ bool CanbusDriver::addFilter(FilterBank filter) // CAN2 filters start from the 15th position if (can == CAN2) - { index = index + 14; - } if (isInit) { @@ -341,12 +337,10 @@ uint32_t CanbusDriver::send(CanPacket packet) // Fill data registers for (uint8_t i = 0; i < packet.length; ++i) - { if (i < 4) mailbox->TDLR |= packet.data[i] << i * 8; else mailbox->TDHR |= packet.data[i] << (i - 4) * 8; - } // Finally send the packet can->sTxMailBox[mbxCode].TIR |= CAN_TI0R_TXRQ; @@ -395,12 +389,10 @@ void CanbusDriver::handleRXInterrupt(int fifo) p.length = mailbox->RDTR & CAN_RDT0R_DLC; for (uint8_t i = 0; i < p.length; i++) - { if (i < 4) // Low register p.data[i] = (mailbox->RDLR >> (i * 8)) & 0xFF; else // High register p.data[i] = (mailbox->RDHR >> ((i - 4) * 8)) & 0xFF; - } *RFR |= CAN_RF0R_RFOM0; diff --git a/src/shared/drivers/canbus/CanDriver/Filters.h b/src/shared/drivers/canbus/CanDriver/Filters.h index 54bf0decf..9adda08d5 100644 --- a/src/shared/drivers/canbus/CanDriver/Filters.h +++ b/src/shared/drivers/canbus/CanDriver/Filters.h @@ -65,13 +65,9 @@ protected: { uint32_t reg = 0; if (isExt) - { reg = ((id & 0x1FFFFFFF) << 3); - } else - { reg = ((id & 0x7FF) << 21); - } reg |= ((ide & 0x1) << 2) | ((rtr & 0x1) << 1); return reg; diff --git a/src/shared/drivers/canbus/CanProtocol/CanProtocol.cpp b/src/shared/drivers/canbus/CanProtocol/CanProtocol.cpp index c17b89b1e..25518b18a 100644 --- a/src/shared/drivers/canbus/CanProtocol/CanProtocol.cpp +++ b/src/shared/drivers/canbus/CanProtocol/CanProtocol.cpp @@ -174,7 +174,9 @@ bool CanProtocol::enqueueSimplePacket(uint8_t priority, uint8_t primaryType, { if (priority > 0xF || primaryType > 0x3F || source > 0xF || destination > 0xF || secondaryType > 0xF) + { return false; + } CanMessage msg{}; diff --git a/src/shared/drivers/canbus/CanProtocol/CanProtocol.h b/src/shared/drivers/canbus/CanProtocol/CanProtocol.h index 128d23a6e..daaf99270 100644 --- a/src/shared/drivers/canbus/CanProtocol/CanProtocol.h +++ b/src/shared/drivers/canbus/CanProtocol/CanProtocol.h @@ -195,7 +195,9 @@ bool CanProtocol::enqueueData(uint8_t priority, uint8_t primaryType, { if (priority > 0xF || primaryType > 0x3F || source > 0xF || destination > 0xF || secondaryType > 0xF) + { return false; + } CanMessage msg = toCanMessage(t); diff --git a/src/shared/drivers/dma/DMAStream.h b/src/shared/drivers/dma/DMAStream.h index f1785adb0..ad3fd03b8 100644 --- a/src/shared/drivers/dma/DMAStream.h +++ b/src/shared/drivers/dma/DMAStream.h @@ -131,11 +131,11 @@ public: MEM_TO_MEM = DMA_SxCR_DIR_1, }; - DMAStream(DMA_Stream_TypeDef *dmaStream); + DMAStream(DMA_Stream_TypeDef* dmaStream); - DMA_TypeDef *getController(); + DMA_TypeDef* getController(); - DMA_Stream_TypeDef *getStream(); + DMA_Stream_TypeDef* getStream(); void reset(); @@ -210,64 +210,47 @@ public: uint16_t readNumberOfDataItems(); - void setPeripheralAddress(uint32_t *address); + void setPeripheralAddress(uint32_t* address); - void setMemory0Address(uint32_t *address); + void setMemory0Address(uint32_t* address); /** * @brief Sets the memory address used only in double buffer mode. */ - void setMemory1Address(uint32_t *address); + void setMemory1Address(uint32_t* address); void clearStatusRegister(); private: - DMA_TypeDef *dmaController; - DMA_Stream_TypeDef *dmaStream; + DMA_TypeDef* dmaController; + DMA_Stream_TypeDef* dmaStream; // Interrupt status flags - volatile uint32_t *IFCR; ///< Interrupt flags clear register + volatile uint32_t* IFCR; ///< Interrupt flags clear register uint32_t IFCR_MASK; ///< Clear mask for all interrupt flags PrintLogger logger = Logging::getLogger("DMAStream"); }; -inline DMAStream::DMAStream(DMA_Stream_TypeDef *dmaStream) +inline DMAStream::DMAStream(DMA_Stream_TypeDef* dmaStream) : dmaStream(dmaStream) { // Find the correct DMA controller - if (reinterpret_cast<uint32_t *>(dmaStream) < &(DMA2->LISR)) - { + if (reinterpret_cast<uint32_t*>(dmaStream) < &(DMA2->LISR)) dmaController = DMA1; - } else - { dmaController = DMA2; - } // Find the corret interrupt flags clear register if (dmaController == DMA1) - { if (dmaStream <= DMA1_Stream3) - { IFCR = &(DMA1->LIFCR); - } else - { IFCR = &(DMA1->HIFCR); - } - } + else if (dmaStream <= DMA2_Stream3) + IFCR = &(DMA2->LIFCR); else - { - if (dmaStream <= DMA2_Stream3) - { - IFCR = &(DMA2->LIFCR); - } - else - { - IFCR = &(DMA2->HIFCR); - } - } + IFCR = &(DMA2->HIFCR); // Find the correct clear mask if (dmaStream == DMA1_Stream0 || dmaStream == DMA2_Stream0) @@ -317,9 +300,9 @@ inline DMAStream::DMAStream(DMA_Stream_TypeDef *dmaStream) } } -inline DMA_TypeDef *DMAStream::getController() { return dmaController; } +inline DMA_TypeDef* DMAStream::getController() { return dmaController; } -inline DMA_Stream_TypeDef *DMAStream::getStream() { return dmaStream; } +inline DMA_Stream_TypeDef* DMAStream::getStream() { return dmaStream; } inline void DMAStream::reset() { @@ -507,17 +490,17 @@ inline void DMAStream::setNumberOfDataItems(uint16_t numberOfDataItems) inline uint16_t DMAStream::readNumberOfDataItems() { return dmaStream->NDTR; } -inline void DMAStream::setPeripheralAddress(uint32_t *address) +inline void DMAStream::setPeripheralAddress(uint32_t* address) { dmaStream->PAR = reinterpret_cast<uint32_t>(address); } -inline void DMAStream::setMemory0Address(uint32_t *address) +inline void DMAStream::setMemory0Address(uint32_t* address) { dmaStream->M0AR = reinterpret_cast<uint32_t>(address); } -inline void DMAStream::setMemory1Address(uint32_t *address) +inline void DMAStream::setMemory1Address(uint32_t* address) { dmaStream->M1AR = reinterpret_cast<uint32_t>(address); } diff --git a/src/shared/drivers/i2c/I2C.cpp b/src/shared/drivers/i2c/I2C.cpp index 56b2a9f4d..398ff1756 100644 --- a/src/shared/drivers/i2c/I2C.cpp +++ b/src/shared/drivers/i2c/I2C.cpp @@ -25,37 +25,37 @@ namespace Boardcore { -I2C::I2C(I2C_TypeDef *i2c, const miosix::GpioPin &scl, - const miosix::GpioPin &sda) +I2C::I2C(I2C_TypeDef* i2c, const miosix::GpioPin& scl, + const miosix::GpioPin& sda) : i2c(i2c, scl, sda) { } -bool I2C::read(const I2CDriver::I2CSlaveConfig &slaveConfig, void *buffer, +bool I2C::read(const I2CDriver::I2CSlaveConfig& slaveConfig, void* buffer, const size_t nBytes) { i2c.flushBus(); return i2c.read(slaveConfig, buffer, nBytes); } -bool I2C::write(const I2CDriver::I2CSlaveConfig &slaveConfig, - const void *buffer, const size_t nBytes) +bool I2C::write(const I2CDriver::I2CSlaveConfig& slaveConfig, + const void* buffer, const size_t nBytes) { i2c.flushBus(); return i2c.write(slaveConfig, buffer, nBytes); } -bool I2C::readRegister(const I2CDriver::I2CSlaveConfig &slaveConfig, - const uint8_t registerAddress, uint8_t ®isterContent) +bool I2C::readRegister(const I2CDriver::I2CSlaveConfig& slaveConfig, + const uint8_t registerAddress, uint8_t& registerContent) { i2c.flushBus(); return i2c.write(slaveConfig, ®isterAddress, 1, false) && i2c.read(slaveConfig, ®isterContent, 1); } -bool I2C::readRegister16(const I2CDriver::I2CSlaveConfig &slaveConfig, +bool I2C::readRegister16(const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, - uint16_t ®isterContent) + uint16_t& registerContent) { i2c.flushBus(); uint8_t buf[2] = {0}; @@ -70,9 +70,9 @@ bool I2C::readRegister16(const I2CDriver::I2CSlaveConfig &slaveConfig, return false; } -bool I2C::readRegister24(const I2CDriver::I2CSlaveConfig &slaveConfig, +bool I2C::readRegister24(const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, - uint32_t ®isterContent) + uint32_t& registerContent) { i2c.flushBus(); uint8_t buf[3] = {0}; @@ -88,9 +88,9 @@ bool I2C::readRegister24(const I2CDriver::I2CSlaveConfig &slaveConfig, return false; } -bool I2C::readRegister32(const I2CDriver::I2CSlaveConfig &slaveConfig, +bool I2C::readRegister32(const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, - uint32_t ®isterContent) + uint32_t& registerContent) { i2c.flushBus(); uint8_t buf[4] = {0}; @@ -108,7 +108,7 @@ bool I2C::readRegister32(const I2CDriver::I2CSlaveConfig &slaveConfig, return false; } -bool I2C::writeRegister(const I2CDriver::I2CSlaveConfig &slaveConfig, +bool I2C::writeRegister(const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint8_t registerContent) { @@ -117,7 +117,7 @@ bool I2C::writeRegister(const I2CDriver::I2CSlaveConfig &slaveConfig, return i2c.write(slaveConfig, reg, 2); } -bool I2C::writeRegister16(const I2CDriver::I2CSlaveConfig &slaveConfig, +bool I2C::writeRegister16(const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint16_t registerContent) { @@ -138,7 +138,7 @@ bool I2C::writeRegister16(const I2CDriver::I2CSlaveConfig &slaveConfig, } } -bool I2C::writeRegister24(const I2CDriver::I2CSlaveConfig &slaveConfig, +bool I2C::writeRegister24(const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint32_t registerContent) { @@ -161,7 +161,7 @@ bool I2C::writeRegister24(const I2CDriver::I2CSlaveConfig &slaveConfig, } } -bool I2C::writeRegister32(const I2CDriver::I2CSlaveConfig &slaveConfig, +bool I2C::writeRegister32(const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint32_t registerContent) { @@ -186,8 +186,8 @@ bool I2C::writeRegister32(const I2CDriver::I2CSlaveConfig &slaveConfig, } } -bool I2C::readFromRegister(const I2CDriver::I2CSlaveConfig &slaveConfig, - const uint8_t registerAddress, void *buffer, +bool I2C::readFromRegister(const I2CDriver::I2CSlaveConfig& slaveConfig, + const uint8_t registerAddress, void* buffer, const size_t nBytes) { i2c.flushBus(); @@ -195,7 +195,7 @@ bool I2C::readFromRegister(const I2CDriver::I2CSlaveConfig &slaveConfig, i2c.read(slaveConfig, buffer, nBytes); } -bool I2C::probe(const I2CDriver::I2CSlaveConfig &slaveConfig) +bool I2C::probe(const I2CDriver::I2CSlaveConfig& slaveConfig) { i2c.flushBus(); return i2c.write(slaveConfig, nullptr, 0); @@ -203,59 +203,59 @@ bool I2C::probe(const I2CDriver::I2CSlaveConfig &slaveConfig) uint16_t I2C::getLastError() { return i2c.getLastError(); } -SyncedI2C::SyncedI2C(I2C_TypeDef *i2c, const miosix::GpioPin &scl, - const miosix::GpioPin &sda) +SyncedI2C::SyncedI2C(I2C_TypeDef* i2c, const miosix::GpioPin& scl, + const miosix::GpioPin& sda) : I2C(i2c, scl, sda) { } -bool SyncedI2C::read(const I2CDriver::I2CSlaveConfig &slaveConfig, void *buffer, +bool SyncedI2C::read(const I2CDriver::I2CSlaveConfig& slaveConfig, void* buffer, const size_t nBytes) { miosix::Lock<miosix::FastMutex> lock(mutex); return I2C::read(slaveConfig, buffer, nBytes); } -bool SyncedI2C::write(const I2CDriver::I2CSlaveConfig &slaveConfig, - const void *buffer, const size_t nBytes) +bool SyncedI2C::write(const I2CDriver::I2CSlaveConfig& slaveConfig, + const void* buffer, const size_t nBytes) { miosix::Lock<miosix::FastMutex> lock(mutex); return I2C::write(slaveConfig, buffer, nBytes); } -bool SyncedI2C::readRegister(const I2CDriver::I2CSlaveConfig &slaveConfig, +bool SyncedI2C::readRegister(const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, - uint8_t ®isterContent) + uint8_t& registerContent) { miosix::Lock<miosix::FastMutex> lock(mutex); return I2C::readRegister(slaveConfig, registerAddress, registerContent); } -bool SyncedI2C::readRegister16(const I2CDriver::I2CSlaveConfig &slaveConfig, +bool SyncedI2C::readRegister16(const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, - uint16_t ®isterContent) + uint16_t& registerContent) { miosix::Lock<miosix::FastMutex> lock(mutex); return I2C::readRegister16(slaveConfig, registerAddress, registerContent); } -bool SyncedI2C::readRegister24(const I2CDriver::I2CSlaveConfig &slaveConfig, +bool SyncedI2C::readRegister24(const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, - uint32_t ®isterContent) + uint32_t& registerContent) { miosix::Lock<miosix::FastMutex> lock(mutex); return I2C::readRegister24(slaveConfig, registerAddress, registerContent); } -bool SyncedI2C::readRegister32(const I2CDriver::I2CSlaveConfig &slaveConfig, +bool SyncedI2C::readRegister32(const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, - uint32_t ®isterContent) + uint32_t& registerContent) { miosix::Lock<miosix::FastMutex> lock(mutex); return I2C::readRegister32(slaveConfig, registerAddress, registerContent); } -bool SyncedI2C::writeRegister(const I2CDriver::I2CSlaveConfig &slaveConfig, +bool SyncedI2C::writeRegister(const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint8_t registerContent) { @@ -263,7 +263,7 @@ bool SyncedI2C::writeRegister(const I2CDriver::I2CSlaveConfig &slaveConfig, return I2C::writeRegister(slaveConfig, registerAddress, registerContent); } -bool SyncedI2C::writeRegister16(const I2CDriver::I2CSlaveConfig &slaveConfig, +bool SyncedI2C::writeRegister16(const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint16_t registerContent) { @@ -271,7 +271,7 @@ bool SyncedI2C::writeRegister16(const I2CDriver::I2CSlaveConfig &slaveConfig, return I2C::writeRegister16(slaveConfig, registerAddress, registerContent); } -bool SyncedI2C::writeRegister24(const I2CDriver::I2CSlaveConfig &slaveConfig, +bool SyncedI2C::writeRegister24(const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint32_t registerContent) { @@ -279,7 +279,7 @@ bool SyncedI2C::writeRegister24(const I2CDriver::I2CSlaveConfig &slaveConfig, return I2C::writeRegister24(slaveConfig, registerAddress, registerContent); } -bool SyncedI2C::writeRegister32(const I2CDriver::I2CSlaveConfig &slaveConfig, +bool SyncedI2C::writeRegister32(const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint32_t registerContent) { @@ -287,15 +287,15 @@ bool SyncedI2C::writeRegister32(const I2CDriver::I2CSlaveConfig &slaveConfig, return I2C::writeRegister32(slaveConfig, registerAddress, registerContent); } -bool SyncedI2C::readFromRegister(const I2CDriver::I2CSlaveConfig &slaveConfig, - const uint8_t registerAddress, void *buffer, +bool SyncedI2C::readFromRegister(const I2CDriver::I2CSlaveConfig& slaveConfig, + const uint8_t registerAddress, void* buffer, const size_t nBytes) { miosix::Lock<miosix::FastMutex> lock(mutex); return I2C::readFromRegister(slaveConfig, registerAddress, buffer, nBytes); } -bool SyncedI2C::probe(const I2CDriver::I2CSlaveConfig &slaveConfig) +bool SyncedI2C::probe(const I2CDriver::I2CSlaveConfig& slaveConfig) { miosix::Lock<miosix::FastMutex> lock(mutex); return I2C::probe(slaveConfig); @@ -307,4 +307,4 @@ uint16_t SyncedI2C::getLastError() return i2c.getLastError(); } -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/drivers/i2c/I2C.h b/src/shared/drivers/i2c/I2C.h index 507239b10..fb2f34edc 100644 --- a/src/shared/drivers/i2c/I2C.h +++ b/src/shared/drivers/i2c/I2C.h @@ -52,14 +52,14 @@ public: * @param scl Serial clock GpioPin of the relative I2C peripheral. * @param sda Serial data GpioPin of the relative I2C peripheral. */ - I2C(I2C_TypeDef *i2c, const miosix::GpioPin &scl, - const miosix::GpioPin &sda); + I2C(I2C_TypeDef* i2c, const miosix::GpioPin& scl, + const miosix::GpioPin& sda); ///< Delete copy/move constructors/operators. - I2C(const I2C &) = delete; - I2C &operator=(const I2C &) = delete; - I2C(I2C &&) = delete; - I2C &operator=(I2C &&) = delete; + I2C(const I2C&) = delete; + I2C& operator=(const I2C&) = delete; + I2C(I2C&&) = delete; + I2C& operator=(I2C&&) = delete; /** * @brief Non blocking read operation to read nBytes. @@ -73,8 +73,8 @@ public: * @param nBytes Number of bytes to read. * @returns True if the read is successful, false otherwise. */ - [[nodiscard]] bool read(const I2CDriver::I2CSlaveConfig &slaveConfig, - void *buffer, const size_t nBytes); + [[nodiscard]] bool read(const I2CDriver::I2CSlaveConfig& slaveConfig, + void* buffer, const size_t nBytes); /** * @brief Non blocking write operation to write nBytes. @@ -88,8 +88,8 @@ public: * @param nBytes Number of bytes to send. * @returns True if the write is successful, false otherwise. */ - [[nodiscard]] bool write(const I2CDriver::I2CSlaveConfig &slaveConfig, - const void *buffer, const size_t nBytes); + [[nodiscard]] bool write(const I2CDriver::I2CSlaveConfig& slaveConfig, + const void* buffer, const size_t nBytes); /** * @brief Non blocking operation to read an 8-bit register from a slave. @@ -104,8 +104,8 @@ public: * @returns True if the read is successful, false otherwise. */ [[nodiscard]] bool readRegister( - const I2CDriver::I2CSlaveConfig &slaveConfig, - const uint8_t registerAddress, uint8_t ®isterContent); + const I2CDriver::I2CSlaveConfig& slaveConfig, + const uint8_t registerAddress, uint8_t& registerContent); /** * @brief Non blocking operation to read a 16-bit register from a slave. @@ -120,8 +120,8 @@ public: * @returns True if the read is successful, false otherwise. */ [[nodiscard]] bool readRegister16( - const I2CDriver::I2CSlaveConfig &slaveConfig, - const uint8_t registerAddress, uint16_t ®isterContent); + const I2CDriver::I2CSlaveConfig& slaveConfig, + const uint8_t registerAddress, uint16_t& registerContent); /** * @brief Non blocking operation to read a 24-bit register from a slave. @@ -136,8 +136,8 @@ public: * @returns True if the read is successful, false otherwise. */ [[nodiscard]] bool readRegister24( - const I2CDriver::I2CSlaveConfig &slaveConfig, - const uint8_t registerAddress, uint32_t ®isterContent); + const I2CDriver::I2CSlaveConfig& slaveConfig, + const uint8_t registerAddress, uint32_t& registerContent); /** * @brief Non blocking operation to read a 32-bit register from a slave. @@ -152,8 +152,8 @@ public: * @returns True if the read is successful, false otherwise. */ [[nodiscard]] bool readRegister32( - const I2CDriver::I2CSlaveConfig &slaveConfig, - const uint8_t registerAddress, uint32_t ®isterContent); + const I2CDriver::I2CSlaveConfig& slaveConfig, + const uint8_t registerAddress, uint32_t& registerContent); /** * @brief Non blocking operation to write an 8-bit register from a slave. @@ -168,7 +168,7 @@ public: * @returns True if the write is successful, false otherwise. */ [[nodiscard]] bool writeRegister( - const I2CDriver::I2CSlaveConfig &slaveConfig, + const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint8_t registerContent); /** @@ -184,7 +184,7 @@ public: * @returns True if the write is successful, false otherwise. */ [[nodiscard]] bool writeRegister16( - const I2CDriver::I2CSlaveConfig &slaveConfig, + const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint16_t registerContent); /** @@ -200,7 +200,7 @@ public: * @returns True if the write is successful, false otherwise. */ [[nodiscard]] bool writeRegister24( - const I2CDriver::I2CSlaveConfig &slaveConfig, + const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint32_t registerContent); /** @@ -216,7 +216,7 @@ public: * @returns True if the write is successful, false otherwise. */ [[nodiscard]] bool writeRegister32( - const I2CDriver::I2CSlaveConfig &slaveConfig, + const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint32_t registerContent); /** @@ -233,8 +233,8 @@ public: * @returns True if the read is successful, false otherwise. */ [[nodiscard]] bool readFromRegister( - const I2CDriver::I2CSlaveConfig &slaveConfig, - const uint8_t registerAddress, void *buffer, const size_t nBytes); + const I2CDriver::I2CSlaveConfig& slaveConfig, + const uint8_t registerAddress, void* buffer, const size_t nBytes); /** * @brief Non blocking operation to check if a slave is available. @@ -243,7 +243,7 @@ public: * @param slaveConfig The configuration struct of the slave device. * @returns True if the device is available, false otherwise. */ - [[nodiscard]] bool probe(const I2CDriver::I2CSlaveConfig &slaveConfig); + [[nodiscard]] bool probe(const I2CDriver::I2CSlaveConfig& slaveConfig); /** * @brief Returns the last errors happened in the communication. @@ -277,14 +277,14 @@ public: * @param scl Serial clock GpioPin of the relative I2C peripheral. * @param sda Serial data GpioPin of the relative I2C peripheral. */ - SyncedI2C(I2C_TypeDef *i2c, const miosix::GpioPin &scl, - const miosix::GpioPin &sda); + SyncedI2C(I2C_TypeDef* i2c, const miosix::GpioPin& scl, + const miosix::GpioPin& sda); ///< Delete copy/move constructors/operators. - SyncedI2C(const SyncedI2C &) = delete; - SyncedI2C &operator=(const SyncedI2C &) = delete; - SyncedI2C(SyncedI2C &&) = delete; - SyncedI2C &operator=(SyncedI2C &&) = delete; + SyncedI2C(const SyncedI2C&) = delete; + SyncedI2C& operator=(const SyncedI2C&) = delete; + SyncedI2C(SyncedI2C&&) = delete; + SyncedI2C& operator=(SyncedI2C&&) = delete; /** * @brief Read operation to read nBytes. @@ -298,8 +298,8 @@ public: * @param nBytes Number of bytes to read. * @returns True if the read is successful, false otherwise. */ - [[nodiscard]] bool read(const I2CDriver::I2CSlaveConfig &slaveConfig, - void *buffer, const size_t nBytes); + [[nodiscard]] bool read(const I2CDriver::I2CSlaveConfig& slaveConfig, + void* buffer, const size_t nBytes); /** * @brief Write operation to write nBytes. @@ -313,8 +313,8 @@ public: * @param nBytes Number of bytes to send. * @returns True if the write is successful, false otherwise. */ - [[nodiscard]] bool write(const I2CDriver::I2CSlaveConfig &slaveConfig, - const void *buffer, const size_t nBytes); + [[nodiscard]] bool write(const I2CDriver::I2CSlaveConfig& slaveConfig, + const void* buffer, const size_t nBytes); /** * @brief Read an 8-bit register from the device. @@ -329,8 +329,8 @@ public: * @returns True if the read is successful, false otherwise. */ [[nodiscard]] bool readRegister( - const I2CDriver::I2CSlaveConfig &slaveConfig, - const uint8_t registerAddress, uint8_t ®isterContent); + const I2CDriver::I2CSlaveConfig& slaveConfig, + const uint8_t registerAddress, uint8_t& registerContent); /** * @brief Read a 16-bit register from the device. @@ -345,8 +345,8 @@ public: * @returns True if the read is successful, false otherwise. */ [[nodiscard]] bool readRegister16( - const I2CDriver::I2CSlaveConfig &slaveConfig, - const uint8_t registerAddress, uint16_t ®isterContent); + const I2CDriver::I2CSlaveConfig& slaveConfig, + const uint8_t registerAddress, uint16_t& registerContent); /** * @brief Read a 24-bit register from the device. @@ -361,8 +361,8 @@ public: * @returns True if the read is successful, false otherwise. */ [[nodiscard]] bool readRegister24( - const I2CDriver::I2CSlaveConfig &slaveConfig, - const uint8_t registerAddress, uint32_t ®isterContent); + const I2CDriver::I2CSlaveConfig& slaveConfig, + const uint8_t registerAddress, uint32_t& registerContent); /** * @brief Read a 32-bit register from the device. @@ -377,8 +377,8 @@ public: * @returns True if the read is successful, false otherwise. */ [[nodiscard]] bool readRegister32( - const I2CDriver::I2CSlaveConfig &slaveConfig, - const uint8_t registerAddress, uint32_t ®isterContent); + const I2CDriver::I2CSlaveConfig& slaveConfig, + const uint8_t registerAddress, uint32_t& registerContent); /** * @brief Write an 8-bit register from the device. @@ -393,7 +393,7 @@ public: * @returns True if the write is successful, false otherwise. */ [[nodiscard]] bool writeRegister( - const I2CDriver::I2CSlaveConfig &slaveConfig, + const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint8_t registerContent); /** @@ -409,7 +409,7 @@ public: * @returns True if the write is successful, false otherwise. */ [[nodiscard]] bool writeRegister16( - const I2CDriver::I2CSlaveConfig &slaveConfig, + const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint16_t registerContent); /** @@ -425,7 +425,7 @@ public: * @returns True if the write is successful, false otherwise. */ [[nodiscard]] bool writeRegister24( - const I2CDriver::I2CSlaveConfig &slaveConfig, + const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint32_t registerContent); /** @@ -441,7 +441,7 @@ public: * @returns True if the write is successful, false otherwise. */ [[nodiscard]] bool writeRegister32( - const I2CDriver::I2CSlaveConfig &slaveConfig, + const I2CDriver::I2CSlaveConfig& slaveConfig, const uint8_t registerAddress, const uint32_t registerContent); /** @@ -458,8 +458,8 @@ public: * @returns True if the read is successful, false otherwise. */ [[nodiscard]] bool readFromRegister( - const I2CDriver::I2CSlaveConfig &slaveConfig, - const uint8_t registerAddress, void *buffer, const size_t nBytes); + const I2CDriver::I2CSlaveConfig& slaveConfig, + const uint8_t registerAddress, void* buffer, const size_t nBytes); /** * @brief Check if a slave is available. @@ -470,7 +470,7 @@ public: * @param slaveConfig The configuration struct of the slave device. * @returns true if the device is available, false otherwise. */ - [[nodiscard]] bool probe(const I2CDriver::I2CSlaveConfig &slaveConfig); + [[nodiscard]] bool probe(const I2CDriver::I2CSlaveConfig& slaveConfig); /** * @brief Returns the last errors happened in the communication. @@ -491,4 +491,4 @@ private: miosix::FastMutex mutex; ///< Mutex for rx/tx }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/drivers/i2c/I2CDriver-f4.cpp b/src/shared/drivers/i2c/I2CDriver-f4.cpp index 79288dc17..b9a500530 100644 --- a/src/shared/drivers/i2c/I2CDriver-f4.cpp +++ b/src/shared/drivers/i2c/I2CDriver-f4.cpp @@ -31,7 +31,7 @@ namespace I2CConsts { -static Boardcore::I2CDriver *ports[N_I2C_PORTS] = +static Boardcore::I2CDriver* ports[N_I2C_PORTS] = {}; ///< Pointer to serial port classes to ///< let interrupts access the classes static const int MAX_N_POLLING = @@ -59,11 +59,9 @@ void __attribute__((naked)) I2C1_EV_IRQHandler() */ void __attribute__((used)) I2C1HandlerImpl() { - auto *port = I2CConsts::ports[0]; + auto* port = I2CConsts::ports[0]; if (port) - { port->IRQhandleInterrupt(); - } } /** @@ -81,11 +79,9 @@ void __attribute__((naked)) I2C1_ER_IRQHandler() */ void __attribute__((used)) I2C1errHandlerImpl() { - auto *port = I2CConsts::ports[0]; + auto* port = I2CConsts::ports[0]; if (port) - { port->IRQhandleErrInterrupt(); - } } #endif @@ -105,11 +101,9 @@ void __attribute__((naked)) I2C2_EV_IRQHandler() */ void __attribute__((used)) I2C2HandlerImpl() { - auto *port = I2CConsts::ports[1]; + auto* port = I2CConsts::ports[1]; if (port) - { port->IRQhandleInterrupt(); - } } /** @@ -127,11 +121,9 @@ void __attribute__((naked)) I2C2_ER_IRQHandler() */ void __attribute__((used)) I2C2errHandlerImpl() { - auto *port = I2CConsts::ports[1]; + auto* port = I2CConsts::ports[1]; if (port) - { port->IRQhandleErrInterrupt(); - } } #endif @@ -151,11 +143,9 @@ void __attribute__((naked)) I2C3_EV_IRQHandler() */ void __attribute__((used)) I2C3HandlerImpl() { - auto *port = I2CConsts::ports[2]; + auto* port = I2CConsts::ports[2]; if (port) - { port->IRQhandleInterrupt(); - } } /** @@ -173,11 +163,9 @@ void __attribute__((naked)) I2C3_ER_IRQHandler() */ void __attribute__((used)) I2C3errHandlerImpl() { - auto *port = I2CConsts::ports[2]; + auto* port = I2CConsts::ports[2]; if (port) - { port->IRQhandleErrInterrupt(); - } } #endif @@ -197,11 +185,9 @@ void __attribute__((naked)) I2C4_EV_IRQHandler() */ void __attribute__((used)) I2C4HandlerImpl() { - auto *port = I2CConsts::ports[3]; + auto* port = I2CConsts::ports[3]; if (port) - { port->IRQhandleInterrupt(); - } } /** @@ -219,18 +205,16 @@ void __attribute__((naked)) I2C4_ER_IRQHandler() */ void __attribute__((used)) I2C4errHandlerImpl() { - auto *port = I2CConsts::ports[3]; + auto* port = I2CConsts::ports[3]; if (port) - { port->IRQhandleErrInterrupt(); - } } #endif namespace Boardcore { -I2CDriver::I2CDriver(I2C_TypeDef *i2c, miosix::GpioPin scl, miosix::GpioPin sda) +I2CDriver::I2CDriver(I2C_TypeDef* i2c, miosix::GpioPin scl, miosix::GpioPin sda) : i2c(i2c), scl(scl), sda(sda), transaction() { // Setting the id and irqn of the right i2c peripheral @@ -341,7 +325,7 @@ void I2CDriver::init() I2C_CR2_ITBUFEN; // enabling interrupts for rx/tx byte } -void I2CDriver::setupPeripheral(const I2CSlaveConfig &slaveConfig) +void I2CDriver::setupPeripheral(const I2CSlaveConfig& slaveConfig) { // Frequency < 2MHz in standard mode or < 4MHz in fast mode not allowed by // the peripheral @@ -387,13 +371,13 @@ void I2CDriver::setupPeripheral(const I2CSlaveConfig &slaveConfig) i2c->CR1 |= I2C_CR1_PE; } -bool I2CDriver::read(const I2CSlaveConfig &slaveConfig, void *buffer, - const size_t &nBytes) +bool I2CDriver::read(const I2CSlaveConfig& slaveConfig, void* buffer, + const size_t& nBytes) { // Setting up the read transaction transaction.operation = Operation::READ; transaction.buffWrite = nullptr; - transaction.buffRead = static_cast<uint8_t *>(buffer); + transaction.buffRead = static_cast<uint8_t*>(buffer); transaction.nBytes = nBytes; transaction.nBytesDone = 0; transaction.generateStop = true; @@ -407,12 +391,12 @@ bool I2CDriver::read(const I2CSlaveConfig &slaveConfig, void *buffer, return doOperation(slaveConfig); }; -bool I2CDriver::write(const I2CSlaveConfig &slaveConfig, const void *buffer, - const size_t &nBytes, bool generateStop) +bool I2CDriver::write(const I2CSlaveConfig& slaveConfig, const void* buffer, + const size_t& nBytes, bool generateStop) { // Setting up the write transaction transaction.operation = Operation::WRITE; - transaction.buffWrite = static_cast<const uint8_t *>(buffer); + transaction.buffWrite = static_cast<const uint8_t*>(buffer); transaction.buffRead = nullptr; transaction.nBytes = nBytes; transaction.nBytesDone = 0; @@ -422,7 +406,7 @@ bool I2CDriver::write(const I2CSlaveConfig &slaveConfig, const void *buffer, return doOperation(slaveConfig); }; -bool I2CDriver::doOperation(const I2CSlaveConfig &slaveConfig) +bool I2CDriver::doOperation(const I2CSlaveConfig& slaveConfig) { // Not yet supported D(assert(slaveConfig.addressing == Addressing::BIT7 && @@ -512,9 +496,7 @@ void I2CDriver::flushBus() { // If there isn't any locked state return immediately if (!(lastError & Errors::BUS_LOCKED)) - { return; - } // Set the period of the bit-banged clock (Default to standard mode) uint8_t toggleDelay = 5; @@ -557,7 +539,7 @@ void I2CDriver::flushBus() uint16_t I2CDriver::getLastError() { return lastError; } inline bool I2CDriver::IRQwaitForOperationCompletion( - miosix::FastInterruptDisableLock &dLock) + miosix::FastInterruptDisableLock& dLock) { // Saving the current thread in order to be waken up by interrupts waiting = miosix::Thread::IRQgetCurrentThread(); @@ -644,9 +626,7 @@ void I2CDriver::IRQhandleInterrupt() // Clearing the ACK flag in order to send a NACK on the last byte // that will be read if (transaction.nBytesDone >= transaction.nBytes - 2) - { i2c->CR1 &= ~I2C_CR1_ACK; - } if (transaction.nBytesDone < transaction.nBytes) { @@ -700,9 +680,7 @@ void I2CDriver::IRQhandleErrInterrupt() // lines. Do not send STOP condition. In the other cases, the software must // issue the STOP condition. if (!(error & I2C_SR1_ARLO)) - { i2c->CR1 |= I2C_CR1_STOP; - } // Waking up the waiting thread IRQwakeUpWaitingThread(); @@ -710,4 +688,4 @@ void I2CDriver::IRQhandleErrInterrupt() } // namespace Boardcore -#endif // _ARCH_CORTEXM4_STM32F4 \ No newline at end of file +#endif // _ARCH_CORTEXM4_STM32F4 diff --git a/src/shared/drivers/i2c/I2CDriver-f7.cpp b/src/shared/drivers/i2c/I2CDriver-f7.cpp index 38b591ed3..0b039630b 100644 --- a/src/shared/drivers/i2c/I2CDriver-f7.cpp +++ b/src/shared/drivers/i2c/I2CDriver-f7.cpp @@ -31,7 +31,7 @@ namespace I2CConsts { -static Boardcore::I2CDriver *ports[N_I2C_PORTS] = +static Boardcore::I2CDriver* ports[N_I2C_PORTS] = {}; ///< Pointer to serial port classes to ///< let interrupts access the classes static const int MAX_N_POLLING = @@ -86,17 +86,11 @@ I2CTimings calculateTimings(uint32_t f, uint32_t fi2c) // presc is 4 bit long, so avoiding overflow if (temp_presc >= 16) - { i2cTimings.presc = 15; - } else if (temp_presc == 0) - { i2cTimings.presc = 0; - } else - { i2cTimings.presc = temp_presc - 1; - } // calculating SCLL and SCLH in order to have duty cycle of 50%. Also, // correcting for the 250ns delay of the peripheral (250ns = 12 I2C clocks) @@ -141,7 +135,7 @@ I2CTimings calculateTimings(uint32_t f, uint32_t fi2c) * @param speed Speed mode for which we want the timing parameters. * @return The struct with the timing parameters for the speed mode passed. */ -const I2CTimings &getTimings(Boardcore::I2CDriver::Speed speed) +const I2CTimings& getTimings(Boardcore::I2CDriver::Speed speed) { // Retrieving the frequency of the APB relative to the I2C peripheral // [kHz] (I2C peripherals are always connected to APB1, Low speed bus). In @@ -186,11 +180,9 @@ void __attribute__((naked)) I2C1_EV_IRQHandler() */ void __attribute__((used)) I2C1HandlerImpl() { - auto *port = I2CConsts::ports[0]; + auto* port = I2CConsts::ports[0]; if (port) - { port->IRQhandleInterrupt(); - } } /** @@ -208,11 +200,9 @@ void __attribute__((naked)) I2C1_ER_IRQHandler() */ void __attribute__((used)) I2C1errHandlerImpl() { - auto *port = I2CConsts::ports[0]; + auto* port = I2CConsts::ports[0]; if (port) - { port->IRQhandleErrInterrupt(); - } } #endif @@ -232,11 +222,9 @@ void __attribute__((naked)) I2C2_EV_IRQHandler() */ void __attribute__((used)) I2C2HandlerImpl() { - auto *port = I2CConsts::ports[1]; + auto* port = I2CConsts::ports[1]; if (port) - { port->IRQhandleInterrupt(); - } } /** @@ -254,11 +242,9 @@ void __attribute__((naked)) I2C2_ER_IRQHandler() */ void __attribute__((used)) I2C2errHandlerImpl() { - auto *port = I2CConsts::ports[1]; + auto* port = I2CConsts::ports[1]; if (port) - { port->IRQhandleErrInterrupt(); - } } #endif @@ -278,11 +264,9 @@ void __attribute__((naked)) I2C3_EV_IRQHandler() */ void __attribute__((used)) I2C3HandlerImpl() { - auto *port = I2CConsts::ports[2]; + auto* port = I2CConsts::ports[2]; if (port) - { port->IRQhandleInterrupt(); - } } /** @@ -300,11 +284,9 @@ void __attribute__((naked)) I2C3_ER_IRQHandler() */ void __attribute__((used)) I2C3errHandlerImpl() { - auto *port = I2CConsts::ports[2]; + auto* port = I2CConsts::ports[2]; if (port) - { port->IRQhandleErrInterrupt(); - } } #endif @@ -324,11 +306,9 @@ void __attribute__((naked)) I2C4_EV_IRQHandler() */ void __attribute__((used)) I2C4HandlerImpl() { - auto *port = I2CConsts::ports[3]; + auto* port = I2CConsts::ports[3]; if (port) - { port->IRQhandleInterrupt(); - } } /** @@ -346,18 +326,16 @@ void __attribute__((naked)) I2C4_ER_IRQHandler() */ void __attribute__((used)) I2C4errHandlerImpl() { - auto *port = I2CConsts::ports[3]; + auto* port = I2CConsts::ports[3]; if (port) - { port->IRQhandleErrInterrupt(); - } } #endif namespace Boardcore { -I2CDriver::I2CDriver(I2C_TypeDef *i2c, miosix::GpioPin scl, miosix::GpioPin sda) +I2CDriver::I2CDriver(I2C_TypeDef* i2c, miosix::GpioPin scl, miosix::GpioPin sda) : i2c(i2c), scl(scl), sda(sda), transaction() { // Setting the id and irqn of the right i2c peripheral @@ -461,13 +439,13 @@ void I2CDriver::init() i2c->CR1 |= I2C_CR1_PE; } -bool I2CDriver::read(const I2CSlaveConfig &slaveConfig, void *buffer, - const size_t &nBytes) +bool I2CDriver::read(const I2CSlaveConfig& slaveConfig, void* buffer, + const size_t& nBytes) { // Setting up the read transaction transaction.operation = Operation::READ; transaction.buffWrite = nullptr; - transaction.buffRead = static_cast<uint8_t *>(buffer); + transaction.buffRead = static_cast<uint8_t*>(buffer); transaction.nBytes = nBytes; transaction.nBytesDone = 0; transaction.generateStop = true; @@ -480,12 +458,12 @@ bool I2CDriver::read(const I2CSlaveConfig &slaveConfig, void *buffer, return doOperation(slaveConfig); }; -bool I2CDriver::write(const I2CSlaveConfig &slaveConfig, const void *buffer, - const size_t &nBytes, bool generateStop) +bool I2CDriver::write(const I2CSlaveConfig& slaveConfig, const void* buffer, + const size_t& nBytes, bool generateStop) { // Setting up the write transaction transaction.operation = Operation::WRITE; - transaction.buffWrite = static_cast<const uint8_t *>(buffer); + transaction.buffWrite = static_cast<const uint8_t*>(buffer); transaction.buffRead = nullptr; transaction.nBytes = nBytes; transaction.nBytesDone = 0; @@ -499,7 +477,7 @@ bool I2CDriver::write(const I2CSlaveConfig &slaveConfig, const void *buffer, return doOperation(slaveConfig); }; -bool I2CDriver::doOperation(const I2CSlaveConfig &slaveConfig) +bool I2CDriver::doOperation(const I2CSlaveConfig& slaveConfig) { // 10-bit addressing not supported D(assert(slaveConfig.addressing == Addressing::BIT7 && @@ -563,13 +541,9 @@ bool I2CDriver::doOperation(const I2CSlaveConfig &slaveConfig) // since, in case of a reStart, this would immediately end the previous // transaction before the start condition is generated. if (transaction.generateStop) - { i2c->CR2 |= I2C_CR2_AUTOEND; - } else - { i2c->CR2 &= ~I2C_CR2_AUTOEND; - } // Making the thread wait for the operation completion. The next steps // will be performed in the ISR while the thread stays in waiting state. @@ -579,7 +553,7 @@ bool I2CDriver::doOperation(const I2CSlaveConfig &slaveConfig) } } -void I2CDriver::setupPeripheral(const I2CSlaveConfig &slaveConfig) +void I2CDriver::setupPeripheral(const I2CSlaveConfig& slaveConfig) { // Disabling the I2C peripheral before setting the registers. // This will also perform a software reset, useful to restore the internal @@ -610,13 +584,9 @@ void I2CDriver::setupTransaction() { // Setting the direction of the transaction if (transaction.operation == Operation::READ) - { i2c->CR2 |= I2C_CR2_RD_WRN; - } else - { i2c->CR2 &= ~I2C_CR2_RD_WRN; - } // setting registers for the remaining bytes setupReload(); @@ -692,7 +662,7 @@ void I2CDriver::flushBus() uint16_t I2CDriver::getLastError() { return lastError; } inline bool I2CDriver::IRQwaitForOperationCompletion( - miosix::FastInterruptDisableLock &dLock) + miosix::FastInterruptDisableLock& dLock) { // Saving the current thread in order to be waken up by interrupts waiting = miosix::Thread::IRQgetCurrentThread(); @@ -773,9 +743,7 @@ void I2CDriver::IRQhandleInterrupt() // Transfer complete reload: setting registers for the remaining bytes if (i2c->ISR & I2C_ISR_TCR) - { setupReload(); - } if (transaction.nBytesDone < transaction.nBytes) { @@ -846,4 +814,4 @@ void I2CDriver::IRQhandleErrInterrupt() } // namespace Boardcore -#endif // _ARCH_CORTEXM7_STM32F7 \ No newline at end of file +#endif // _ARCH_CORTEXM7_STM32F7 diff --git a/src/shared/drivers/i2c/I2CDriver.h b/src/shared/drivers/i2c/I2CDriver.h index fee1e0531..532112c27 100644 --- a/src/shared/drivers/i2c/I2CDriver.h +++ b/src/shared/drivers/i2c/I2CDriver.h @@ -132,13 +132,13 @@ public: * @param scl Serial clock GpioPin of the relative I2C peripheral. * @param sda Serial data GpioPin of the relative I2C peripheral. */ - I2CDriver(I2C_TypeDef *i2c, miosix::GpioPin scl, miosix::GpioPin sda); + I2CDriver(I2C_TypeDef* i2c, miosix::GpioPin scl, miosix::GpioPin sda); ///< Delete copy/move constructors/operators. - I2CDriver(const I2CDriver &) = delete; - I2CDriver &operator=(const I2CDriver &) = delete; - I2CDriver(I2CDriver &&) = delete; - I2CDriver &operator=(I2CDriver &&) = delete; + I2CDriver(const I2CDriver&) = delete; + I2CDriver& operator=(const I2CDriver&) = delete; + I2CDriver(I2CDriver&&) = delete; + I2CDriver& operator=(I2CDriver&&) = delete; /** * @brief Disables the peripheral, the interrupts in the NVIC and the @@ -156,8 +156,8 @@ public: * @param nBytes Number of bytes to read. * @return True if the read is successful, false otherwise. */ - [[nodiscard]] bool read(const I2CSlaveConfig &slaveConfig, void *buffer, - const size_t &nBytes); + [[nodiscard]] bool read(const I2CSlaveConfig& slaveConfig, void* buffer, + const size_t& nBytes); /** * @brief Write operation to write nBytes. In case of an error during the @@ -170,8 +170,8 @@ public: * @param generateStop Flag for the stop condition generation. * @return True if the write is successful, false otherwise. */ - [[nodiscard]] bool write(const I2CSlaveConfig &slaveConfig, - const void *buffer, const size_t &nBytes, + [[nodiscard]] bool write(const I2CSlaveConfig& slaveConfig, + const void* buffer, const size_t& nBytes, bool generateStop = true); /** @@ -232,8 +232,8 @@ private: typedef struct { Operation operation; ///< Operation to be performed (R/W) - uint8_t *buffRead; ///< Buffer with the data to read - const uint8_t *buffWrite; ///< Buffer with the data to write + uint8_t* buffRead; ///< Buffer with the data to read + const uint8_t* buffWrite; ///< Buffer with the data to write size_t nBytes; ///< Number of bytes of the buffer size_t nBytesDone; ///< Number of bytes already processed bool generateStop; ///< Whether to generate stop condition @@ -250,7 +250,7 @@ private: * the speed and the addressing mode specified. * @param slaveConfig The configuration struct of the slave device. */ - void setupPeripheral(const I2CSlaveConfig &slaveConfig); + void setupPeripheral(const I2CSlaveConfig& slaveConfig); #ifdef _ARCH_CORTEXM7_STM32F7 /** @@ -277,7 +277,7 @@ private: * @param slaveConfig The configuration struct of the slave device. * @return True if the operation succeeded, False otherwise. */ - [[nodiscard]] bool doOperation(const I2CSlaveConfig &slaveConfig); + [[nodiscard]] bool doOperation(const I2CSlaveConfig& slaveConfig); /** * @brief This waits until the thread isn't waken up by an I2C interrupt (EV @@ -293,7 +293,7 @@ private: * @return True if waken up by an event, false if an error occurred. */ inline bool IRQwaitForOperationCompletion( - miosix::FastInterruptDisableLock &dLock); + miosix::FastInterruptDisableLock& dLock); /** * @brief This function has the logic to wake up and reschedule the thread @@ -302,7 +302,7 @@ private: */ inline void IRQwakeUpWaitingThread(); - I2C_TypeDef *i2c; + I2C_TypeDef* i2c; uint8_t id; IRQn_Type irqnEv; IRQn_Type irqnErr; @@ -312,10 +312,10 @@ private: uint16_t lastError = NO_ERROR; ///< Flag for the last error occurred uint32_t error = 0; ///< Flag that tells if an error occurred bool reStarting = false; ///< Flag true if not generated a STOP condition - miosix::Thread *waiting{}; ///< Pointer to the waiting for event thread + miosix::Thread* waiting{}; ///< Pointer to the waiting for event thread I2CTransaction transaction; ///< Struct storing the transaction info PrintLogger logger = Logging::getLogger("i2c"); }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/drivers/i2c/stm32f2_f4_i2c.cpp b/src/shared/drivers/i2c/stm32f2_f4_i2c.cpp index 3be83ddf4..8ac71a3ee 100644 --- a/src/shared/drivers/i2c/stm32f2_f4_i2c.cpp +++ b/src/shared/drivers/i2c/stm32f2_f4_i2c.cpp @@ -30,7 +30,7 @@ using namespace miosix; static volatile bool error; ///< Set to true by IRQ on error -static Thread *waiting = 0; ///< Thread waiting for an operation to complete +static Thread* waiting = 0; ///< Thread waiting for an operation to complete /* In non-DMA mode the variables below are used to * handle the reception of 2 or more bytes through @@ -39,7 +39,7 @@ static Thread *waiting = 0; ///< Thread waiting for an operation to complete */ #ifndef I2C_WITH_DMA -static uint8_t *rxBuf = 0; +static uint8_t* rxBuf = 0; static unsigned int rxBufCnt = 0; static unsigned int rxBufSize = 0; #endif @@ -68,7 +68,9 @@ void __attribute__((used)) I2C1rxDmaHandlerImpl() waiting->IRQwakeup(); if (waiting->IRQgetPriority() > Thread::IRQgetCurrentThread()->IRQgetPriority()) + { Scheduler::IRQfindNextThread(); + } waiting = 0; } @@ -149,7 +151,9 @@ void __attribute__((used)) I2C1HandlerImpl() waiting->IRQwakeup(); if (waiting->IRQgetPriority() > Thread::IRQgetCurrentThread()->IRQgetPriority()) + { Scheduler::IRQfindNextThread(); + } waiting = 0; } @@ -175,7 +179,9 @@ void __attribute__((used)) I2C1errHandlerImpl() waiting->IRQwakeup(); if (waiting->IRQgetPriority() > Thread::IRQgetCurrentThread()->IRQgetPriority()) + { Scheduler::IRQfindNextThread(); + } waiting = 0; } @@ -186,7 +192,7 @@ namespace miosix // class I2C // -I2C1Driver &I2C1Driver::instance() +I2C1Driver& I2C1Driver::instance() { static I2C1Driver singleton; return singleton; @@ -245,7 +251,7 @@ void I2C1Driver::init() I2C1->CR1 = I2C_CR1_PE; // Enable peripheral } -bool I2C1Driver::send(unsigned char address, const void *data, int len, +bool I2C1Driver::send(unsigned char address, const void* data, int len, bool sendStop) { /* if sendStop is true user is requesting to have the stop condition sent, @@ -299,7 +305,7 @@ bool I2C1Driver::send(unsigned char address, const void *data, int len, I2C1->CR2 |= I2C_CR2_ITERREN; - const uint8_t *txData = reinterpret_cast<const uint8_t *>(data); + const uint8_t* txData = reinterpret_cast<const uint8_t*>(data); for (int i = 0; i < len; i++) { I2C1->DR = txData[i]; @@ -350,7 +356,7 @@ bool I2C1Driver::send(unsigned char address, const void *data, int len, return true; } -bool I2C1Driver::recv(unsigned char address, void *data, int len) +bool I2C1Driver::recv(unsigned char address, void* data, int len) { address |= 0x01; if (start(address, len == 1) == false || I2C1->SR2 & I2C_SR2_TRA) @@ -402,7 +408,7 @@ bool I2C1Driver::recv(unsigned char address, void *data, int len) * greater than one. */ - rxBuf = reinterpret_cast<uint8_t *>(data); + rxBuf = reinterpret_cast<uint8_t*>(data); if (len > 1) { diff --git a/src/shared/drivers/interrupt/external_interrupts.cpp b/src/shared/drivers/interrupt/external_interrupts.cpp index 985a7b006..018814dcd 100644 --- a/src/shared/drivers/interrupt/external_interrupts.cpp +++ b/src/shared/drivers/interrupt/external_interrupts.cpp @@ -379,11 +379,15 @@ void enableExternalInterrupt(unsigned int gpioPort, unsigned int gpioNum, if (trigger == InterruptTrigger::RISING_EDGE || trigger == InterruptTrigger::RISING_FALLING_EDGE) + { EXTI->RTSR |= 1 << gpioNum; + } if (trigger == InterruptTrigger::FALLING_EDGE || trigger == InterruptTrigger::RISING_FALLING_EDGE) + { EXTI->FTSR |= 1 << gpioNum; + } NVIC_EnableIRQ(static_cast<IRQn_Type>(GetEXTI_IRQn(gpioNum))); NVIC_SetPriority(static_cast<IRQn_Type>(GetEXTI_IRQn(gpioNum)), priority); @@ -424,4 +428,4 @@ void changeInterruptTrigger(unsigned int gpioPort, unsigned int gpioNum, EXTI->FTSR |= 1 << gpioNum; break; } -} \ No newline at end of file +} diff --git a/src/shared/drivers/interrupt/external_interrupts.h b/src/shared/drivers/interrupt/external_interrupts.h index 33885f85f..82224e280 100644 --- a/src/shared/drivers/interrupt/external_interrupts.h +++ b/src/shared/drivers/interrupt/external_interrupts.h @@ -98,4 +98,4 @@ inline void changeInterruptTrigger(miosix::GpioPin gpio, InterruptTrigger trigger) { changeInterruptTrigger(gpio.getPort(), gpio.getNumber(), trigger); -} \ No newline at end of file +} diff --git a/src/shared/drivers/runcam/Runcam.cpp b/src/shared/drivers/runcam/Runcam.cpp index 95f51480e..d42f2757e 100644 --- a/src/shared/drivers/runcam/Runcam.cpp +++ b/src/shared/drivers/runcam/Runcam.cpp @@ -27,7 +27,7 @@ namespace Boardcore { -Runcam::Runcam(USARTInterface &usart) : usart(usart) {} +Runcam::Runcam(USARTInterface& usart) : usart(usart) {} bool Runcam::init() { diff --git a/src/shared/drivers/runcam/Runcam.h b/src/shared/drivers/runcam/Runcam.h index 3095ae500..f93c4780d 100644 --- a/src/shared/drivers/runcam/Runcam.h +++ b/src/shared/drivers/runcam/Runcam.h @@ -116,7 +116,7 @@ namespace Boardcore class Runcam { public: - explicit Runcam(USARTInterface &serial); + explicit Runcam(USARTInterface& serial); Runcam() = delete; @@ -149,7 +149,7 @@ private: */ uint32_t OPEN_MENU = 0xCC01024D; - USARTInterface &usart; + USARTInterface& usart; PrintLogger logger = Logging::getLogger("runcam"); }; diff --git a/src/shared/drivers/spi/SPIBus.h b/src/shared/drivers/spi/SPIBus.h index ef71a7d4c..8eb3081ed 100644 --- a/src/shared/drivers/spi/SPIBus.h +++ b/src/shared/drivers/spi/SPIBus.h @@ -451,17 +451,13 @@ inline void SPIBus::select(GpioType cs) cs.low(); if (config.csSetupTimeUs > 0) - { miosix::delayUs(config.csSetupTimeUs); - } } inline void SPIBus::deselect(GpioType cs) { if (config.csHoldTimeUs > 0) - { miosix::delayUs(config.csHoldTimeUs); - } cs.high(); } diff --git a/src/shared/drivers/spi/SPITransaction.h b/src/shared/drivers/spi/SPITransaction.h index 10606d840..5a2098f33 100644 --- a/src/shared/drivers/spi/SPITransaction.h +++ b/src/shared/drivers/spi/SPITransaction.h @@ -62,7 +62,7 @@ public: * * @param slave Slave to communicate with. */ - explicit SPITransaction(const SPISlave &slave); + explicit SPITransaction(const SPISlave& slave); // /** // * @brief Instantiates a new SPITransaction, configuring the bus with the @@ -75,17 +75,17 @@ public: // SPITransaction(SPIBusInterface &bus, GpioType cs, SPIBusConfig config); ///< Delete copy/move constructors/operators. - SPITransaction(const SPITransaction &) = delete; - SPITransaction &operator=(const SPITransaction &) = delete; - SPITransaction(SPITransaction &&) = delete; - SPITransaction &operator=(SPITransaction &&) = delete; + SPITransaction(const SPITransaction&) = delete; + SPITransaction& operator=(const SPITransaction&) = delete; + SPITransaction(SPITransaction&&) = delete; + SPITransaction& operator=(SPITransaction&&) = delete; /** * @brief Returns the underlying bus for low level access. * * @return SPIBusInterface associated with this transaction. */ - SPIBusInterface &getBus(); + SPIBusInterface& getBus(); // Read, write and transfer operations @@ -123,7 +123,7 @@ public: * @param data Buffer to be filled with received data. * @param size Size of the buffer in bytes. */ - void read(uint8_t *data, size_t size); + void read(uint8_t* data, size_t size); /** * @brief Reads multiple half words from the bus @@ -131,7 +131,7 @@ public: * @param data Buffer to be filled with received data. * @param size Size of the buffer in bytes. */ - void read16(uint16_t *data, size_t size); + void read16(uint16_t* data, size_t size); /** * @brief Writes a single byte to the bus. @@ -167,7 +167,7 @@ public: * @param data Buffer containing data to write. * @param size Size of the buffer in bytes. */ - void write(uint8_t *data, size_t size); + void write(uint8_t* data, size_t size); /** * @brief Writes multiple half words to the bus. @@ -175,7 +175,7 @@ public: * @param data Buffer containing data to write. * @param size Size of the buffer in bytes. */ - void write16(uint16_t *data, size_t size); + void write16(uint16_t* data, size_t size); /** * @brief Full duplex transmission of one byte on the bus. @@ -215,7 +215,7 @@ public: * @param data Buffer containing data to transfer. * @param size Size of the buffer in bytes. */ - void transfer(uint8_t *data, size_t size); + void transfer(uint8_t* data, size_t size); /** * @brief Full duplex transmission of multiple half words on the bus. @@ -223,7 +223,7 @@ public: * @param data Buffer containing data to transfer. * @param size Size of the buffer in bytes. */ - void transfer16(uint16_t *data, size_t size); + void transfer16(uint16_t* data, size_t size); // Read, write and transfer operations with registers @@ -261,7 +261,7 @@ public: * @param data Buffer to be filled with received data. * @param size Size of the buffer in bytes. */ - void readRegisters(uint8_t reg, uint8_t *data, size_t size); + void readRegisters(uint8_t reg, uint8_t* data, size_t size); /** * @brief Writes an 8 bit register. @@ -302,10 +302,10 @@ public: * @param data Buffer containing data to write. * @param size Size of the buffer in bytes. */ - void writeRegisters(uint8_t reg, uint8_t *data, size_t size); + void writeRegisters(uint8_t reg, uint8_t* data, size_t size); private: - const SPISlave &slave; + const SPISlave& slave; }; } // namespace Boardcore diff --git a/src/shared/drivers/timer/BasicTimer.h b/src/shared/drivers/timer/BasicTimer.h index 57c8476a4..5bfd9e543 100644 --- a/src/shared/drivers/timer/BasicTimer.h +++ b/src/shared/drivers/timer/BasicTimer.h @@ -82,14 +82,14 @@ public: * @brief Create a BasicTimer object. Note that this does not resets the * timer configuration but automatically enables the timer peripheral clock. */ - explicit BasicTimer(TIM_TypeDef *timer); + explicit BasicTimer(TIM_TypeDef* timer); /** * @brief Disables the peripheral clock. */ ~BasicTimer(); - TIM_TypeDef *getTimer(); + TIM_TypeDef* getTimer(); uint8_t getTimerNumber(); @@ -198,20 +198,20 @@ public: virtual void setMasterMode(TimerUtils::MasterMode masterMode); - static void clearUpdateInterruptFlag(TIM_TypeDef *timer); + static void clearUpdateInterruptFlag(TIM_TypeDef* timer); protected: - TIM_TypeDef *timer; + TIM_TypeDef* timer; }; -inline BasicTimer::BasicTimer(TIM_TypeDef *timer) : timer(timer) +inline BasicTimer::BasicTimer(TIM_TypeDef* timer) : timer(timer) { ClockUtils::enablePeripheralClock(timer); } inline BasicTimer::~BasicTimer() { ClockUtils::disablePeripheralClock(timer); } -inline TIM_TypeDef *BasicTimer::getTimer() { return timer; } +inline TIM_TypeDef* BasicTimer::getTimer() { return timer; } inline uint8_t BasicTimer::getTimerNumber() { @@ -360,7 +360,7 @@ inline void BasicTimer::setMasterMode(TimerUtils::MasterMode masterMode) timer->CR2 |= static_cast<uint32_t>(masterMode); } -inline void BasicTimer::clearUpdateInterruptFlag(TIM_TypeDef *timer) +inline void BasicTimer::clearUpdateInterruptFlag(TIM_TypeDef* timer) { timer->SR &= ~TIM_SR_UIF; } diff --git a/src/shared/drivers/timer/CountedPWM.cpp b/src/shared/drivers/timer/CountedPWM.cpp index f5cc4f8c6..f007f0054 100644 --- a/src/shared/drivers/timer/CountedPWM.cpp +++ b/src/shared/drivers/timer/CountedPWM.cpp @@ -148,4 +148,4 @@ void CountedPWM::configureTimers() } } -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/drivers/timer/CountedPWM.h b/src/shared/drivers/timer/CountedPWM.h index 30fe01640..80480ca1f 100644 --- a/src/shared/drivers/timer/CountedPWM.h +++ b/src/shared/drivers/timer/CountedPWM.h @@ -195,4 +195,4 @@ inline void CountedPWM::stop() counterTimer.setCaptureCompareRegister(counterChannel, getCurrentCount()); } -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/drivers/timer/GeneralPurposeTimer.h b/src/shared/drivers/timer/GeneralPurposeTimer.h index 3f30bb23e..2cba65fb5 100644 --- a/src/shared/drivers/timer/GeneralPurposeTimer.h +++ b/src/shared/drivers/timer/GeneralPurposeTimer.h @@ -107,7 +107,7 @@ public: * resets the timer configuration but automatically enables the timer * peripheral clock. */ - explicit GeneralPurposeTimer(TIM_TypeDef *timer); + explicit GeneralPurposeTimer(TIM_TypeDef* timer); /** * @brief Disables the peripheral clock. @@ -221,7 +221,7 @@ using GP16bitTimer = GeneralPurposeTimer<uint16_t>; using GP32bitTimer = GeneralPurposeTimer<uint32_t>; template <typename T> -inline GeneralPurposeTimer<T>::GeneralPurposeTimer(TIM_TypeDef *timer) +inline GeneralPurposeTimer<T>::GeneralPurposeTimer(TIM_TypeDef* timer) : BasicTimer(timer) { } @@ -263,9 +263,7 @@ inline void GeneralPurposeTimer<T>::enable() // On TIM1 and TIM8 the outputs are enabled only if the MOE bit in the BDTR // register is set if (timer == TIM1 || timer == TIM8) - { timer->BDTR |= TIM_BDTR_MOE; - } } template <typename T> @@ -276,9 +274,7 @@ inline void GeneralPurposeTimer<T>::disable() // On TIM1 and TIM8 the outputs are enabled only if the MOE bit in the BDTR // register is set if (timer == TIM1 || timer == TIM8) - { timer->BDTR |= TIM_BDTR_MOE; - } } template <typename T> diff --git a/src/shared/drivers/timer/TimerUtils.h b/src/shared/drivers/timer/TimerUtils.h index 106c7fbd4..ff80be7ca 100644 --- a/src/shared/drivers/timer/TimerUtils.h +++ b/src/shared/drivers/timer/TimerUtils.h @@ -256,7 +256,7 @@ enum class Channel : uint8_t * * @return Timer input clock, APB1 or ABP2. */ -ClockUtils::APB getTimerInputClock(const TIM_TypeDef *timer); +ClockUtils::APB getTimerInputClock(const TIM_TypeDef* timer); /** * @brief Returns the timer clock frequency before the prescaler. @@ -266,7 +266,7 @@ ClockUtils::APB getTimerInputClock(const TIM_TypeDef *timer); * @param timer Timer to use. * @return Prescaler input frequency. */ -uint32_t getPrescalerInputFrequency(const TIM_TypeDef *timer); +uint32_t getPrescalerInputFrequency(const TIM_TypeDef* timer); /** * @brief Return the timer clock frequency. @@ -274,7 +274,7 @@ uint32_t getPrescalerInputFrequency(const TIM_TypeDef *timer); * @param timer Timer to use. * @return Timer frequency. */ -uint32_t getFrequency(TIM_TypeDef *timer); +uint32_t getFrequency(TIM_TypeDef* timer); /** * @brief Returns the specified value converted in microseconds based on the @@ -282,7 +282,7 @@ uint32_t getFrequency(TIM_TypeDef *timer); * * @returns Timer counter in microseconds. */ -float toMicroSeconds(TIM_TypeDef *timer, uint32_t value); +float toMicroSeconds(TIM_TypeDef* timer, uint32_t value); /** * @brief Returns the timer counter converted in microseconds based on the @@ -290,7 +290,7 @@ float toMicroSeconds(TIM_TypeDef *timer, uint32_t value); * * @returns Timer counter in microseconds. */ -float toMicroSeconds(TIM_TypeDef *timer); +float toMicroSeconds(TIM_TypeDef* timer); /** * @brief Returns the specified value converted in microseconds based on the @@ -300,7 +300,7 @@ float toMicroSeconds(TIM_TypeDef *timer); * * @returns Timer counter in microseconds. */ -uint64_t toIntMicroSeconds(TIM_TypeDef *timer, uint32_t value); +uint64_t toIntMicroSeconds(TIM_TypeDef* timer, uint32_t value); /** * @brief Returns the timer counter converted in microseconds based on the @@ -310,7 +310,7 @@ uint64_t toIntMicroSeconds(TIM_TypeDef *timer, uint32_t value); * * @returns Timer counter in microseconds. */ -uint64_t toIntMicroSeconds(TIM_TypeDef *timer); +uint64_t toIntMicroSeconds(TIM_TypeDef* timer); /** * @brief Returns the specified value converted in milliseconds based on the @@ -318,7 +318,7 @@ uint64_t toIntMicroSeconds(TIM_TypeDef *timer); * * @returns Timer counter in milliseconds. */ -float toMilliSeconds(TIM_TypeDef *timer, uint32_t value); +float toMilliSeconds(TIM_TypeDef* timer, uint32_t value); /** * @brief Returns the timer counter converted in milliseconds based on the @@ -326,7 +326,7 @@ float toMilliSeconds(TIM_TypeDef *timer, uint32_t value); * * @returns Timer counter in milliseconds. */ -float toMilliSeconds(TIM_TypeDef *timer); +float toMilliSeconds(TIM_TypeDef* timer); /** * @brief Returns the timer counter converted in seconds based on the timer @@ -334,21 +334,21 @@ float toMilliSeconds(TIM_TypeDef *timer); * * @returns Timer counter in seconds. */ -float toSeconds(TIM_TypeDef *timer); +float toSeconds(TIM_TypeDef* timer); /** * @brief Computes the timer resolution in microseconds. * * @return Microseconds per timer tick. */ -float getResolution(TIM_TypeDef *timer); +float getResolution(TIM_TypeDef* timer); /** * @brief Computes the number of seconds for timer reset. * * @return Timer duration before counter reset in seconds. */ -float getMaxDuration(TIM_TypeDef *timer); +float getMaxDuration(TIM_TypeDef* timer); /** * @brief Compute the prescaler value for the specified target frequency. @@ -358,7 +358,7 @@ float getMaxDuration(TIM_TypeDef *timer); * * @return Prescaler value for the target frequency. */ -uint16_t computePrescalerValue(TIM_TypeDef *timer, int targetFrequency); +uint16_t computePrescalerValue(TIM_TypeDef* timer, int targetFrequency); /** * @brief Returns the corresponding master for for the given channel. @@ -367,7 +367,7 @@ MasterMode masterModeFromChannel(const Channel channel); } // namespace TimerUtils -inline ClockUtils::APB TimerUtils::getTimerInputClock(const TIM_TypeDef *timer) +inline ClockUtils::APB TimerUtils::getTimerInputClock(const TIM_TypeDef* timer) { // Timers can be connected to APB1 or APB2 clocks. // APB1: TIM2-7,12-15 @@ -384,68 +384,68 @@ inline ClockUtils::APB TimerUtils::getTimerInputClock(const TIM_TypeDef *timer) } } -inline uint32_t TimerUtils::getPrescalerInputFrequency(const TIM_TypeDef *timer) +inline uint32_t TimerUtils::getPrescalerInputFrequency(const TIM_TypeDef* timer) { return ClockUtils::getAPBTimersClock(getTimerInputClock(timer)); } -inline uint32_t TimerUtils::getFrequency(TIM_TypeDef *timer) +inline uint32_t TimerUtils::getFrequency(TIM_TypeDef* timer) { return getPrescalerInputFrequency(timer) / (1 + timer->PSC); } -inline float TimerUtils::toMicroSeconds(TIM_TypeDef *timer, uint32_t value) +inline float TimerUtils::toMicroSeconds(TIM_TypeDef* timer, uint32_t value) { return (1.0f * value * 1e6 * (1 + timer->PSC)) / getPrescalerInputFrequency(timer); } -inline float TimerUtils::toMicroSeconds(TIM_TypeDef *timer) +inline float TimerUtils::toMicroSeconds(TIM_TypeDef* timer) { return toMicroSeconds(timer, timer->CNT); } -inline uint64_t TimerUtils::toIntMicroSeconds(TIM_TypeDef *timer, +inline uint64_t TimerUtils::toIntMicroSeconds(TIM_TypeDef* timer, uint32_t value) { return ((uint64_t)value * 1e6 * (uint64_t)(1 + timer->PSC)) / getPrescalerInputFrequency(timer); } -inline uint64_t TimerUtils::toIntMicroSeconds(TIM_TypeDef *timer) +inline uint64_t TimerUtils::toIntMicroSeconds(TIM_TypeDef* timer) { return toIntMicroSeconds(timer, timer->CNT); } -inline float TimerUtils::toMilliSeconds(TIM_TypeDef *timer, uint32_t value) +inline float TimerUtils::toMilliSeconds(TIM_TypeDef* timer, uint32_t value) { return (1.0f * value * 1e3 * (1 + timer->PSC)) / getPrescalerInputFrequency(timer); } -inline float TimerUtils::toMilliSeconds(TIM_TypeDef *timer) +inline float TimerUtils::toMilliSeconds(TIM_TypeDef* timer) { return toMilliSeconds(timer, timer->CNT); } -inline float TimerUtils::toSeconds(TIM_TypeDef *timer) +inline float TimerUtils::toSeconds(TIM_TypeDef* timer) { return (1.0f * timer->CNT * (1 + timer->PSC)) / getPrescalerInputFrequency(timer); } -inline float TimerUtils::getResolution(TIM_TypeDef *timer) +inline float TimerUtils::getResolution(TIM_TypeDef* timer) { return (1.0e6f * (1 + timer->PSC)) / getPrescalerInputFrequency(timer); } -inline float TimerUtils::getMaxDuration(TIM_TypeDef *timer) +inline float TimerUtils::getMaxDuration(TIM_TypeDef* timer) { return (1.0f * timer->ARR * 1e6 * (1 + timer->PSC)) / getPrescalerInputFrequency(timer); } -inline uint16_t TimerUtils::computePrescalerValue(TIM_TypeDef *timer, +inline uint16_t TimerUtils::computePrescalerValue(TIM_TypeDef* timer, int targetFrequency) { int32_t targetPrescaler = diff --git a/src/shared/drivers/usart/USART.cpp b/src/shared/drivers/usart/USART.cpp index ea076f486..ad6203c70 100644 --- a/src/shared/drivers/usart/USART.cpp +++ b/src/shared/drivers/usart/USART.cpp @@ -35,7 +35,7 @@ #include "miosix.h" ///< Pointer to serial port classes to let interrupts access the classes -Boardcore::USART *ports[N_USART_PORTS]; +Boardcore::USART* ports[N_USART_PORTS]; #ifdef USART1 /** @@ -48,15 +48,11 @@ void usart1irqImpl(); */ void __attribute__((used)) usart1irqImplBoardcore() { - Boardcore::USART *port_boardcore = ports[0]; + Boardcore::USART* port_boardcore = ports[0]; if (port_boardcore) - { port_boardcore->IRQhandleInterrupt(); - } else - { usart1irqImpl(); - } } /** @@ -81,15 +77,11 @@ void usart2irqImpl(); */ void __attribute__((used)) usart2irqImplBoardcore() { - Boardcore::USART *port_boardcore = ports[1]; + Boardcore::USART* port_boardcore = ports[1]; if (port_boardcore) - { port_boardcore->IRQhandleInterrupt(); - } else - { usart2irqImpl(); - } } /** @@ -114,15 +106,11 @@ void usart3irqImpl(); */ void __attribute__((used)) usart3irqImplBoardcore() { - Boardcore::USART *port_boardcore = ports[2]; + Boardcore::USART* port_boardcore = ports[2]; if (port_boardcore) - { port_boardcore->IRQhandleInterrupt(); - } else - { usart3irqImpl(); - } } /** @@ -142,11 +130,9 @@ void __attribute__((naked, used)) USART3_IRQHandler() */ void __attribute__((used)) uart4irqImplBoardcore() { - Boardcore::USART *port_boardcore = ports[3]; + Boardcore::USART* port_boardcore = ports[3]; if (port_boardcore) - { port_boardcore->IRQhandleInterrupt(); - } } /** @@ -166,11 +152,9 @@ void __attribute__((naked, used)) UART4_IRQHandler() */ void __attribute__((used)) uart5irqImplBoardcore() { - Boardcore::USART *port_boardcore = ports[4]; + Boardcore::USART* port_boardcore = ports[4]; if (port_boardcore) - { port_boardcore->IRQhandleInterrupt(); - } } /** @@ -190,11 +174,9 @@ void __attribute__((naked, used)) UART5_IRQHandler() */ void __attribute__((used)) usart6irqImplBoardcore() { - Boardcore::USART *port_boardcore = ports[5]; + Boardcore::USART* port_boardcore = ports[5]; if (port_boardcore) - { port_boardcore->IRQhandleInterrupt(); - } } /** @@ -214,11 +196,9 @@ void __attribute__((naked, used)) USART6_IRQHandler() */ void __attribute__((used)) uart7irqImplBoardcore() { - Boardcore::USART *port_boardcore = ports[6]; + Boardcore::USART* port_boardcore = ports[6]; if (port_boardcore) - { port_boardcore->IRQhandleInterrupt(); - } } /** @@ -238,11 +218,9 @@ void __attribute__((naked, used)) UART7_IRQHandler() */ void __attribute__((used)) uart8irqImplBoardcore() { - Boardcore::USART *port_boardcore = ports[7]; + Boardcore::USART* port_boardcore = ports[7]; if (port_boardcore) - { port_boardcore->IRQhandleInterrupt(); - } } /** @@ -259,7 +237,7 @@ void __attribute__((naked, used)) UART8_IRQHandler() namespace Boardcore { -USARTInterface::USARTInterface(USARTType *usart, int baudrate) +USARTInterface::USARTInterface(USARTType* usart, int baudrate) : usart(usart), baudrate(baudrate) { // Setting the id of the serial port @@ -358,9 +336,7 @@ void USART::IRQhandleInterrupt() // If we received some data without framing error but the tryPut failed, // report a FIFO overflow if (framingError || (received && !rxQueue.tryPut(c))) - { error = true; - } // Wake up thread if communication finished (idle state), buffer reached // half of his capacity or error occurred @@ -380,7 +356,7 @@ void USART::IRQhandleInterrupt() } } -USART::USART(USARTType *usart, int baudrate, unsigned int queueLen) +USART::USART(USARTType* usart, int baudrate, unsigned int queueLen) : USARTInterface(usart, baudrate), rxQueue(queueLen) { // Enabling the peripheral on the right APB @@ -456,9 +432,7 @@ void USART::setStopBits(int stopBits) this->stopBits = stopBits; usart->CR2 &= ~USART_CR2_STOP; if (stopBits == 2) - { usart->CR2 |= USART_CR2_STOP_1; - } } void USART::setOversampling(bool oversampling) @@ -500,12 +474,12 @@ void USART::setBaudrate(int baudrate) this->baudrate = baudrate; } -bool USART::readImpl(void *buffer, size_t nBytes, size_t &nBytesRead, +bool USART::readImpl(void* buffer, size_t nBytes, size_t& nBytesRead, const bool blocking, std::chrono::nanoseconds timeout) { miosix::Lock<miosix::FastMutex> l(rxMutex); - char *buf = reinterpret_cast<char *>(buffer); + char* buf = reinterpret_cast<char*>(buffer); size_t result = 0; error = false; // Whether we timed out while waiting @@ -529,7 +503,9 @@ bool USART::readImpl(void *buffer, size_t nBytes, size_t &nBytesRead, // anyway if ((result == nBytes) || (idle && (!blocking || (result > 0))) || timedOut) + { break; + } // Wait for data in the queue do @@ -562,13 +538,13 @@ bool USART::readImpl(void *buffer, size_t nBytes, size_t &nBytesRead, return (result > 0) && !timedOut; } -void USART::write(const void *buffer, size_t nBytes) +void USART::write(const void* buffer, size_t nBytes) { miosix::Lock<miosix::FastMutex> l(txMutex); // TODO: Use the send complete interrupt in order not to have a busy while // loop waiting - const char *buf = reinterpret_cast<const char *>(buffer); + const char* buf = reinterpret_cast<const char*>(buffer); size_t i; for (i = 0; i < nBytes; i++) { @@ -584,7 +560,7 @@ void USART::write(const void *buffer, size_t nBytes) } } -void USART::writeString(const char *buffer) +void USART::writeString(const char* buffer) { int i = 0; miosix::Lock<miosix::FastMutex> l(txMutex); @@ -625,7 +601,7 @@ void USART::clearQueue() rxQueue.reset(); } -STM32SerialWrapper::STM32SerialWrapper(USARTType *usart, int baudrate) +STM32SerialWrapper::STM32SerialWrapper(USARTType* usart, int baudrate) : USARTInterface(usart, baudrate) { if (this->id < 1 || this->id > 4) @@ -648,7 +624,7 @@ STM32SerialWrapper::STM32SerialWrapper(USARTType *usart, int baudrate) } } -STM32SerialWrapper::STM32SerialWrapper(USARTType *usart, int baudrate, +STM32SerialWrapper::STM32SerialWrapper(USARTType* usart, int baudrate, miosix::GpioPin tx, miosix::GpioPin rx) : USARTInterface(usart, baudrate) { @@ -705,8 +681,8 @@ bool STM32SerialWrapper::serialCommSetup() return true; } -bool STM32SerialWrapper::readImpl(void *buffer, size_t nBytes, - size_t &nBytesRead, const bool blocking, +bool STM32SerialWrapper::readImpl(void* buffer, size_t nBytes, + size_t& nBytesRead, const bool blocking, std::chrono::nanoseconds timeout) { // non-blocking read not supported in STM32SerialWrapper @@ -734,12 +710,12 @@ bool STM32SerialWrapper::readImpl(void *buffer, size_t nBytes, return (n > 0); } -void STM32SerialWrapper::write(const void *buffer, size_t nBytes) +void STM32SerialWrapper::write(const void* buffer, size_t nBytes) { ::write(fd, buffer, nBytes); } -void STM32SerialWrapper::writeString(const char *buffer) +void STM32SerialWrapper::writeString(const char* buffer) { // strlen + 1 in order to send the '/0' terminated string ::write(fd, buffer, strlen(buffer) + 1); diff --git a/src/shared/drivers/usart/USART.h b/src/shared/drivers/usart/USART.h index d2d08f486..707e23d6b 100644 --- a/src/shared/drivers/usart/USART.h +++ b/src/shared/drivers/usart/USART.h @@ -75,7 +75,7 @@ public: * @param baudrate Baudrate in bit per second. Default values are [2400, * 9600, 19200, 38400, 57600, 115200, 230400, 256000, 460800, 921600] */ - explicit USARTInterface(USARTType *usart, int baudrate); + explicit USARTInterface(USARTType* usart, int baudrate); virtual ~USARTInterface() = 0; @@ -89,7 +89,7 @@ public: * @return Whether bytes were read and no timeout occurred. */ [[nodiscard]] virtual bool readBlocking( - void *buffer, size_t nBytes, + void* buffer, size_t nBytes, std::chrono::nanoseconds timeout = std::chrono::nanoseconds::zero()) { size_t temp; @@ -107,7 +107,7 @@ public: * @return Whether bytes were read and no timeout occurred. */ [[nodiscard]] virtual bool readBlocking( - void *buffer, size_t nBytes, size_t &nBytesRead, + void* buffer, size_t nBytes, size_t& nBytesRead, std::chrono::nanoseconds timeout = std::chrono::nanoseconds::zero()) { return readImpl(buffer, nBytes, nBytesRead, true, timeout); @@ -118,13 +118,13 @@ public: * @param buffer Buffer that contains the data to be sent. * @param nBytes Bytes to be sent. */ - virtual void write(const void *buf, size_t nBytes) = 0; + virtual void write(const void* buf, size_t nBytes) = 0; /** * @brief Write a string to the serial, comprising the '\0' character. * @param buffer Buffer that contains the string to be sent. */ - virtual void writeString(const char *buffer) = 0; + virtual void writeString(const char* buffer) = 0; /** * @brief Returns the id of the serial. @@ -144,11 +144,11 @@ protected: * mode, 0 to disable the timeout and wait forever. * @return Whether bytes were read and no timeout occurred. */ - virtual bool readImpl(void *buffer, size_t nBytes, size_t &nBytesRead, + virtual bool readImpl(void* buffer, size_t nBytes, size_t& nBytesRead, const bool blocking, std::chrono::nanoseconds timeout) = 0; - USARTType *usart; + USARTType* usart; int id = -1; ///< Can be from 1 to 8, -1 is invalid. IRQn_Type irqn; ///< IRQ number std::string serialPortName; ///< Port name of the port that has to be @@ -201,14 +201,14 @@ public: * @param baudrate Baudrate in bit per second. Default values are [2400, * 9600, 19200, 38400, 57600, 115200, 230400, 256000, 460800, 921600] */ - USART(USARTType *usart, int baudrate, + USART(USARTType* usart, int baudrate, unsigned int queueLen = usart_queue_default_capacity); ///< Delete copy/move constructors/operators. - USART(const USART &) = delete; - USART &operator=(const USART &) = delete; - USART(USART &&) = delete; - USART &operator=(USART &&) = delete; + USART(const USART&) = delete; + USART& operator=(const USART&) = delete; + USART(USART&&) = delete; + USART& operator=(USART&&) = delete; /** * @brief Disables the flags for the generation of the interrupts, the IRQ @@ -226,7 +226,7 @@ public: * @param nBytes Maximum size of the buffer. * @return If operation succeeded. */ - [[nodiscard]] bool read(void *buffer, size_t nBytes) + [[nodiscard]] bool read(void* buffer, size_t nBytes) { size_t temp; auto timeout = std::chrono::nanoseconds::zero(); @@ -243,7 +243,7 @@ public: * @param nBytesRead Number of bytes read. * @return If operation succeeded. */ - [[nodiscard]] bool read(void *buffer, size_t nBytes, size_t &nBytesRead) + [[nodiscard]] bool read(void* buffer, size_t nBytes, size_t& nBytesRead) { auto timeout = std::chrono::nanoseconds::zero(); return readImpl(buffer, nBytes, nBytesRead, false, timeout); @@ -254,13 +254,13 @@ public: * @param buffer Buffer that contains the data to be sent. * @param nBytes Bytes to be sent. */ - void write(const void *buf, size_t nBytes); + void write(const void* buf, size_t nBytes); /** * @brief Write a string to the serial, comprising the '\0' character. * @param buffer Buffer that contains the string to be sent. */ - void writeString(const char *buffer); + void writeString(const char* buffer); /** * @brief Set the length of the word to 8 or to 9. @@ -318,14 +318,14 @@ private: * mode, 0 to disable the timeout and wait forever. * @return Whether bytes were read and no timeout occurred. */ - [[nodiscard]] bool readImpl(void *buffer, size_t nBytes, size_t &nBytesRead, + [[nodiscard]] bool readImpl(void* buffer, size_t nBytes, size_t& nBytesRead, const bool blocking, std::chrono::nanoseconds timeout) override; miosix::FastMutex rxMutex; ///< mutex for receiving on serial miosix::FastMutex txMutex; ///< mutex for transmitting on serial - miosix::Thread *rxWaiter = + miosix::Thread* rxWaiter = nullptr; ///< The thread that is waiting to receive data miosix::DynUnsyncQueue<char> rxQueue; ///< Receiving queue @@ -357,7 +357,7 @@ public: * @param baudrate baudrate in bit per second. Default values are [2400, * 9600, 19200, 38400, 57600, 115200, 230400, 256000, 460800, 921600] */ - STM32SerialWrapper(USARTType *usart, int baudrate); + STM32SerialWrapper(USARTType* usart, int baudrate); /** * @brief Initializes the serialPortName and initializes the serial port @@ -369,14 +369,14 @@ public: * @param tx Tranmission pin * @param rx Reception pin */ - STM32SerialWrapper(USARTType *usart, int baudrate, miosix::GpioPin tx, + STM32SerialWrapper(USARTType* usart, int baudrate, miosix::GpioPin tx, miosix::GpioPin rx); ///< Delete copy/move constructors/operators. - STM32SerialWrapper(const STM32SerialWrapper &) = delete; - STM32SerialWrapper &operator=(const STM32SerialWrapper &) = delete; - STM32SerialWrapper(STM32SerialWrapper &&) = delete; - STM32SerialWrapper &operator=(STM32SerialWrapper &&) = delete; + STM32SerialWrapper(const STM32SerialWrapper&) = delete; + STM32SerialWrapper& operator=(const STM32SerialWrapper&) = delete; + STM32SerialWrapper(STM32SerialWrapper&&) = delete; + STM32SerialWrapper& operator=(STM32SerialWrapper&&) = delete; /** * @brief Removes the device from the list of the devices and closes the @@ -389,13 +389,13 @@ public: * @param buffer Buffer that contains the data to be sent. * @param nBytes Bytes to be sent. */ - void write(const void *buf, size_t nBytes); + void write(const void* buf, size_t nBytes); /** * @brief Write a string to the serial, comprising the '\0' character. * @param buffer Buffer that contains the string to be sent. */ - void writeString(const char *buffer); + void writeString(const char* buffer); private: /** @@ -410,7 +410,7 @@ private: * mode. * @return Whether bytes were read and no timeout occurred. */ - [[nodiscard]] bool readImpl(void *buffer, size_t nBytes, size_t &nBytesRead, + [[nodiscard]] bool readImpl(void* buffer, size_t nBytes, size_t& nBytesRead, const bool blocking, std::chrono::nanoseconds timeout) override; @@ -420,7 +420,7 @@ private: */ bool serialCommSetup(); - miosix::STM32Serial *serial; ///< Pointer to the serial object + miosix::STM32Serial* serial; ///< Pointer to the serial object ///< File descriptor of the serial port file opened for transmission int fd; diff --git a/src/shared/events/EventBroker.cpp b/src/shared/events/EventBroker.cpp index c4f1db75c..9b0557f2f 100644 --- a/src/shared/events/EventBroker.cpp +++ b/src/shared/events/EventBroker.cpp @@ -86,9 +86,7 @@ uint16_t EventBroker::postDelayed(const Event& ev, uint8_t topic, } if (!added) // In case this is the last/only event in the list - { delayedEvents.push_back(dev); - } return dev.schedId; } @@ -123,9 +121,7 @@ void EventBroker::unsubscribe(EventHandlerBase* subscriber) { Lock<FastMutex> lock(mtxSubscribers); for (auto it = subscribers.begin(); it != subscribers.end(); it++) - { deleteSubscriber(it->second, subscriber); - } } void EventBroker::clearDelayedEvents() @@ -162,9 +158,7 @@ void EventBroker::run() { // If a deadline expires earlier, sleep until the deadline instead if (delayedEvents.front().deadline < sleepUntil) - { sleepUntil = delayedEvents.front().deadline; - } } { @@ -183,16 +177,10 @@ void EventBroker::deleteSubscriber(vector<EventHandlerBase*>& subs, auto it = subs.begin(); while (it != subs.end()) - { if (*it == subscriber) - { it = subs.erase(it); - } else - { ++it; - } - } } } // namespace Boardcore diff --git a/src/shared/events/EventHandler.h b/src/shared/events/EventHandler.h index eeb30eefc..30b0fba72 100644 --- a/src/shared/events/EventHandler.h +++ b/src/shared/events/EventHandler.h @@ -36,7 +36,7 @@ class EventHandlerBase public: EventHandlerBase() {} - virtual ~EventHandlerBase(){}; + virtual ~EventHandlerBase() {}; virtual void postEvent(const Event& ev) = 0; }; @@ -67,7 +67,7 @@ inline EventHandler::EventHandler(unsigned int stacksize, { } -inline EventHandler::~EventHandler(){}; +inline EventHandler::~EventHandler() {}; inline void EventHandler::postEvent(const Event& ev) { eventList.put(ev); } diff --git a/src/shared/events/HSM.h b/src/shared/events/HSM.h index 59d1b95e8..f071bb01d 100644 --- a/src/shared/events/HSM.h +++ b/src/shared/events/HSM.h @@ -66,7 +66,7 @@ public: temp = initialState; } - virtual ~HSM(){}; + virtual ~HSM() {}; bool start() override { @@ -350,8 +350,10 @@ protected: // Exit target unhandled? if ((static_cast<T*>(this)->*target)( {EV_EXIT}) == HANDLED) + { (static_cast<T*>(this)->*target)( {EV_EMPTY}); + } // Set to super of target target = this->temp; diff --git a/src/shared/events/utils/EventCounter.h b/src/shared/events/utils/EventCounter.h index 9f0914d26..05d98735e 100644 --- a/src/shared/events/utils/EventCounter.h +++ b/src/shared/events/utils/EventCounter.h @@ -74,9 +74,7 @@ public: Lock<FastMutex> l(mutex); if (mapCounter.count(ev) == 1) - { return mapCounter.at(ev); - } return 0; } @@ -93,7 +91,7 @@ public: protected: // Do nothing - void handleEvent(const Event& ev __attribute__((unused))) override{}; + void handleEvent(const Event& ev __attribute__((unused))) override {}; private: EventBroker& broker; diff --git a/src/shared/events/utils/EventSniffer.h b/src/shared/events/utils/EventSniffer.h index 677857742..176fc40c1 100644 --- a/src/shared/events/utils/EventSniffer.h +++ b/src/shared/events/utils/EventSniffer.h @@ -57,9 +57,7 @@ public: : broker(broker), onEventReceived(onEventReceived) { for (uint8_t t : topics) - { sniffers.push_back(new Sniffer(*this, t)); - } } /** @@ -71,17 +69,13 @@ public: : broker(broker), onEventReceived(onEventReceived) { for (int t = 0; t <= 255; t++) - { sniffers.push_back(new Sniffer(*this, (uint8_t)t)); - } } ~EventSniffer() { for (Sniffer* s : sniffers) - { delete s; - } } private: diff --git a/src/shared/hil/HIL.h b/src/shared/hil/HIL.h index bb11d0174..a5e9f9050 100644 --- a/src/shared/hil/HIL.h +++ b/src/shared/hil/HIL.h @@ -53,10 +53,10 @@ public: * situation. * @param simulationPeriod Period of the simulation [ms]. */ - HIL(HILTransceiver<FlightPhases, SimulatorData, ActuatorData> - *hilTransceiver, - HILPhasesManager<FlightPhases, SimulatorData, ActuatorData> - *hilPhasesManager, + HIL(HILTransceiver<FlightPhases, SimulatorData, ActuatorData>* + hilTransceiver, + HILPhasesManager<FlightPhases, SimulatorData, ActuatorData>* + hilPhasesManager, std::function<ActuatorData()> updateActuatorData, int simulationPeriod) : Boardcore::ActiveObject(Boardcore::STACK_MIN_FOR_SKYWARD, miosix::PRIORITY_MAX - 1), @@ -106,13 +106,11 @@ public: { LOG_INFO(logger, "Waiting for simulation to start..."); while (!hilPhasesManager->isSimulationRunning()) - { miosix::Thread::sleep(1); - } } - void registerToFlightPhase(const FlightPhases &flag, - const PhasesCallback &func) + void registerToFlightPhase(const FlightPhases& flag, + const PhasesCallback& func) { hilPhasesManager->registerToFlightPhase(flag, func); } @@ -124,15 +122,15 @@ public: return hilTransceiver->getTimestampSimulatorData(); } - const SimulatorData *getSensorData() const + const SimulatorData* getSensorData() const { return hilTransceiver->getSensorData(); } protected: - HILTransceiver<FlightPhases, SimulatorData, ActuatorData> *hilTransceiver; - HILPhasesManager<FlightPhases, SimulatorData, ActuatorData> - *hilPhasesManager; + HILTransceiver<FlightPhases, SimulatorData, ActuatorData>* hilTransceiver; + HILPhasesManager<FlightPhases, SimulatorData, ActuatorData>* + hilPhasesManager; private: void run() override @@ -151,4 +149,4 @@ private: std::function<ActuatorData()> updateActuatorData; int simulationPeriod; // Simulation period in milliseconds }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/hil/HILPhasesManager.h b/src/shared/hil/HILPhasesManager.h index db00cb7d3..1cf6ffb68 100644 --- a/src/shared/hil/HILPhasesManager.h +++ b/src/shared/hil/HILPhasesManager.h @@ -135,12 +135,8 @@ public: /* calling the callbacks subscribed to the changed flags */ for (unsigned int i = 0; i < changed_flags.size(); i++) - { for (const auto& callback : callbacks[changed_flags[i]]) - { callback(); - } - } prev_flagsFlightPhases = flagsFlightPhases; } @@ -162,12 +158,8 @@ protected: /* calling the callbacks subscribed to the changed flags */ for (unsigned int i = 0; i < changed_flags.size(); i++) - { for (const auto& callback : callbacks[changed_flags[i]]) - { callback(); - } - } prev_flagsFlightPhases = flagsFlightPhases; } @@ -193,4 +185,4 @@ protected: std::map<FlightPhases, std::vector<PhasesCallback>> callbacks; std::map<FlightPhases, Outcomes> outcomes; }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/hil/HILTransceiver.h b/src/shared/hil/HILTransceiver.h index dbd402ef9..48a3fe7e0 100644 --- a/src/shared/hil/HILTransceiver.h +++ b/src/shared/hil/HILTransceiver.h @@ -42,7 +42,7 @@ public: /** * @brief Construct a serial connection attached to a control algorithm */ - explicit HILTransceiverBase(USART &hilSerial) : hilSerial(hilSerial) {} + explicit HILTransceiverBase(USART& hilSerial) : hilSerial(hilSerial) {} /** * @brief Returns the number of lost updates. @@ -65,13 +65,11 @@ protected: { miosix::Lock<miosix::FastMutex> l(mutex); while (!updated) - { condVar.wait(l); - } updated = false; } - USART &hilSerial; + USART& hilSerial; bool receivedFirstPacket = false; bool updated = false; int nLostUpdates = 0; @@ -95,9 +93,9 @@ public: * * @param hilSerial Serial port for the HIL communication. */ - explicit HILTransceiver(USART &hilSerial, + explicit HILTransceiver(USART& hilSerial, HILPhasesManager<FlightPhases, SimulatorData, - ActuatorData> *hilPhasesManager) + ActuatorData>* hilPhasesManager) : HILTransceiverBase(hilSerial), actuatorData(), hilPhasesManager(hilPhasesManager) { @@ -116,9 +114,7 @@ public: // If already updated increment lost updates if (updated) - { nLostUpdates++; - } this->actuatorData = actuatorData; updated = true; @@ -130,15 +126,15 @@ public: * * @return reference to the data simulated by matlab */ - const SimulatorData *getSensorData() const { return &simulatorData; } + const SimulatorData* getSensorData() const { return &simulatorData; } private: void run() override; SimulatorData simulatorData; ActuatorData actuatorData; - HILPhasesManager<FlightPhases, SimulatorData, ActuatorData> - *hilPhasesManager; + HILPhasesManager<FlightPhases, SimulatorData, ActuatorData>* + hilPhasesManager; }; /** @@ -211,4 +207,4 @@ void HILTransceiver<FlightPhases, SimulatorData, ActuatorData>::run() miosix::led2Off(); } } -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/logger/Logger.cpp b/src/shared/logger/Logger.cpp index 714719d89..a2345363c 100644 --- a/src/shared/logger/Logger.cpp +++ b/src/shared/logger/Logger.cpp @@ -300,7 +300,9 @@ void Logger::writeThread() stats.lastWriteError = ferror(file); } else + { stats.buffersWritten++; + } auto interval = system_clock::now() - start; stats.averageWriteTime = diff --git a/src/shared/logger/Logger.h b/src/shared/logger/Logger.h index 088b91fe2..c6507da5f 100644 --- a/src/shared/logger/Logger.h +++ b/src/shared/logger/Logger.h @@ -115,7 +115,7 @@ public: * \return Whether the class has been logged. */ template <typename T> - LoggerResult log(const T &t); + LoggerResult log(const T& t); /** * @brief Log logger stats using the logger itself. @@ -137,9 +137,9 @@ private: static std::string getFileName(int logNumber); - static void packThreadLauncher(void *argv); + static void packThreadLauncher(void* argv); - static void writeThreadLauncher(void *argv); + static void writeThreadLauncher(void* argv); /** * This thread packs logged data into buffers @@ -158,7 +158,7 @@ private: * \param data Pointer to class data. * \param size Class size. */ - LoggerResult logImpl(const char *name, const void *data, unsigned int size); + LoggerResult logImpl(const char* name, const void* data, unsigned int size); static constexpr unsigned int maxFilenameNumber = 10000; ///< Limit on files @@ -204,24 +204,24 @@ private: int fileNumber = -1; - miosix::Queue<Record *, numRecords> fullRecordsQueue; - miosix::Queue<Record *, numRecords> emptyRecordsQueue; - std::queue<Buffer *, std::list<Buffer *>> fullBufferList; - std::queue<Buffer *, std::list<Buffer *>> emptyBufferList; + miosix::Queue<Record*, numRecords> fullRecordsQueue; + miosix::Queue<Record*, numRecords> emptyRecordsQueue; + std::queue<Buffer*, std::list<Buffer*>> fullBufferList; + std::queue<Buffer*, std::list<Buffer*>> emptyBufferList; miosix::FastMutex mutex; ///< To allow concurrent access to the queues. miosix::ConditionVariable cond; ///< To lock when buffers are all empty. - miosix::Thread *packTh = nullptr; ///< Thread packing logged data. - miosix::Thread *writeTh = nullptr; ///< Thread writing data to disk. + miosix::Thread* packTh = nullptr; ///< Thread packing logged data. + miosix::Thread* writeTh = nullptr; ///< Thread writing data to disk. volatile bool started = false; ///< Logger is started and accepting data. - FILE *file = nullptr; ///< Log file. + FILE* file = nullptr; ///< Log file. LoggerStats stats; ///< Logger stats. }; template <typename T> -LoggerResult Logger::log(const T &t) +LoggerResult Logger::log(const T& t) { static_assert( std::is_trivially_copyable<T>::value, diff --git a/src/shared/radio/SX1278/SX1278Common.cpp b/src/shared/radio/SX1278/SX1278Common.cpp index 2628cf7a4..0ceb84e6c 100644 --- a/src/shared/radio/SX1278/SX1278Common.cpp +++ b/src/shared/radio/SX1278/SX1278Common.cpp @@ -68,7 +68,7 @@ void SX1278Common::setDefaultMode(Mode mode, DioMapping mapping, enterMode(mode, mapping, dio1_trigger, tx_frontend, rx_frontend); } -ISX1278::IrqFlags SX1278Common::waitForIrq(LockMode &guard, IrqFlags set_irq, +ISX1278::IrqFlags SX1278Common::waitForIrq(LockMode& guard, IrqFlags set_irq, IrqFlags reset_irq, bool unlock) { IrqFlags ret_irq = 0; @@ -83,9 +83,7 @@ ISX1278::IrqFlags SX1278Common::waitForIrq(LockMode &guard, IrqFlags set_irq, // Check that this hasn't already happened if ((ret_irq = checkForIrqAndReset(set_irq, reset_irq)) != 0) - { break; - } if (!waitForIrqInner(guard, unlock)) { @@ -100,7 +98,7 @@ ISX1278::IrqFlags SX1278Common::waitForIrq(LockMode &guard, IrqFlags set_irq, return ret_irq; } -ISX1278::IrqFlags SX1278Common::waitForIrqBusy(LockMode &_guard, +ISX1278::IrqFlags SX1278Common::waitForIrqBusy(LockMode& _guard, IrqFlags set_irq, IrqFlags reset_irq, int timeout) { @@ -121,9 +119,7 @@ ISX1278::IrqFlags SX1278Common::waitForIrqBusy(LockMode &_guard, { // Check if some of the interrupts triggered if ((ret_irq = checkForIrqAndReset(set_irq, reset_irq)) != 0) - { return ret_irq; - } miosix::delayUs(DELAY); } @@ -132,7 +128,7 @@ ISX1278::IrqFlags SX1278Common::waitForIrqBusy(LockMode &_guard, return 0; } -bool SX1278Common::waitForIrqInner(LockMode &_guard, bool unlock) +bool SX1278Common::waitForIrqInner(LockMode& _guard, bool unlock) { // Take a reference to a _guard to MAKE SURE that the mutex is locked, but // otherwise don't do anything with it @@ -140,9 +136,7 @@ bool SX1278Common::waitForIrqInner(LockMode &_guard, bool unlock) // Release the lock for others to take if (unlock) - { mutex.unlock(); - } int start = Kernel::getOldTick(); miosix::TimedWaitResult result = miosix::TimedWaitResult::NoTimeout; @@ -159,9 +153,7 @@ bool SX1278Common::waitForIrqInner(LockMode &_guard, bool unlock) // Regain ownership of the lock if (unlock) - { mutex.lock(); - } // Check that we didn't have a timeout return result == miosix::TimedWaitResult::NoTimeout; @@ -180,9 +172,9 @@ ISX1278::IrqFlags SX1278Common::checkForIrqAndReset(IrqFlags set_irq, return (cur_irq & set_irq) | (~cur_irq & reset_irq); } -ISX1278Frontend &SX1278Common::getFrontend() { return *frontend; } +ISX1278Frontend& SX1278Common::getFrontend() { return *frontend; } -SPISlave &SX1278Common::getSpiSlave() { return slave; } +SPISlave& SX1278Common::getSpiSlave() { return slave; } SX1278Common::DeviceState SX1278Common::lockMode(Mode mode, DioMapping mapping, InterruptTrigger dio1_trigger, @@ -219,25 +211,17 @@ void SX1278Common::enterMode(Mode mode, DioMapping mapping, // First disable all of the frontend if necessary if (set_tx_frontend_on != state.is_tx_frontend_on && !set_tx_frontend_on) - { getFrontend().disableTx(); - } if (set_rx_frontend_on != state.is_rx_frontend_on && !set_rx_frontend_on) - { getFrontend().disableRx(); - } // Then enable the newly requested ones if (set_tx_frontend_on != state.is_tx_frontend_on && set_tx_frontend_on) - { getFrontend().enableTx(); - } if (set_rx_frontend_on != state.is_rx_frontend_on && set_rx_frontend_on) - { getFrontend().enableRx(); - } state.is_tx_frontend_on = set_tx_frontend_on; state.is_rx_frontend_on = set_rx_frontend_on; diff --git a/src/shared/radio/SX1278/SX1278Common.h b/src/shared/radio/SX1278/SX1278Common.h index 30122331f..c4cbeb889 100644 --- a/src/shared/radio/SX1278/SX1278Common.h +++ b/src/shared/radio/SX1278/SX1278Common.h @@ -110,7 +110,7 @@ private: // Current Dio mapping DioMapping mapping = DioMapping(); // Thread waiting listening for interrupts - miosix::Thread *irq_wait_thread = nullptr; + miosix::Thread* irq_wait_thread = nullptr; // True if the RX frontend is enabled bool is_rx_frontend_on = false; // True if the TX frontend is enabled @@ -129,7 +129,7 @@ public: void handleDioIRQ(); protected: - explicit SX1278Common(SPIBus &bus, miosix::GpioPin cs, miosix::GpioPin dio0, + explicit SX1278Common(SPIBus& bus, miosix::GpioPin cs, miosix::GpioPin dio0, miosix::GpioPin dio1, miosix::GpioPin dio3, SPI::ClockDivider clock_divider, std::unique_ptr<ISX1278Frontend> frontend) @@ -147,12 +147,12 @@ protected: class Lock { public: - explicit Lock(SX1278Common &driver) : driver(driver) { driver.lock(); } + explicit Lock(SX1278Common& driver) : driver(driver) { driver.lock(); } ~Lock() { driver.unlock(); } private: - SX1278Common &driver; + SX1278Common& driver; }; /** @@ -161,7 +161,7 @@ protected: class LockMode { public: - LockMode(SX1278Common &driver, Lock &lock, Mode mode, + LockMode(SX1278Common& driver, Lock& lock, Mode mode, DioMapping mapping, InterruptTrigger dio1_trigger, bool set_tx_frontend_on = false, bool set_rx_frontend_on = false) @@ -175,8 +175,8 @@ protected: ~LockMode() { driver.unlockMode(old_state); } private: - SX1278Common &driver; - Lock &lock; + SX1278Common& driver; + Lock& lock; DeviceState old_state; }; @@ -192,7 +192,7 @@ protected: /** * @brief Wait for generic irq. */ - IrqFlags waitForIrq(LockMode &guard, IrqFlags set_irq, IrqFlags reset_irq, + IrqFlags waitForIrq(LockMode& guard, IrqFlags set_irq, IrqFlags reset_irq, bool unlock = false); /** @@ -200,7 +200,7 @@ protected: * * USE ONLY DURING INITIALIZATION! BAD THINGS *HAVE* HAPPENED DUE TO THIS! */ - IrqFlags waitForIrqBusy(LockMode &guard, IrqFlags set_irq, + IrqFlags waitForIrqBusy(LockMode& guard, IrqFlags set_irq, IrqFlags reset_irq, int timeout); /** @@ -216,15 +216,15 @@ protected: */ IrqFlags checkForIrqAndReset(IrqFlags set_irq, IrqFlags reset_irq); - ISX1278Frontend &getFrontend(); + ISX1278Frontend& getFrontend(); - SPISlave &getSpiSlave(); + SPISlave& getSpiSlave(); private: void enableIrqs(); void disableIrqs(); - bool waitForIrqInner(LockMode &guard, bool unlock); + bool waitForIrqInner(LockMode& guard, bool unlock); DeviceState lockMode(Mode mode, DioMapping mapping, InterruptTrigger dio1_trigger, bool set_tx_frontend_on, diff --git a/src/shared/radio/SX1278/SX1278Defs.h b/src/shared/radio/SX1278/SX1278Defs.h index 1398b00db..b04d84708 100644 --- a/src/shared/radio/SX1278/SX1278Defs.h +++ b/src/shared/radio/SX1278/SX1278Defs.h @@ -119,9 +119,9 @@ struct Mapping } } - bool operator==(const Mapping &other) const { return raw == other.raw; } + bool operator==(const Mapping& other) const { return raw == other.raw; } - bool operator!=(const Mapping &other) const { return raw != other.raw; } + bool operator!=(const Mapping& other) const { return raw != other.raw; } uint16_t raw; }; diff --git a/src/shared/radio/SX1278/SX1278Frontends.h b/src/shared/radio/SX1278/SX1278Frontends.h index 41c90f858..72c9f87d2 100644 --- a/src/shared/radio/SX1278/SX1278Frontends.h +++ b/src/shared/radio/SX1278/SX1278Frontends.h @@ -78,4 +78,4 @@ public: void disableTx() override {} }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/radio/SX1278/SX1278Fsk.cpp b/src/shared/radio/SX1278/SX1278Fsk.cpp index 4ec53f2d6..417146430 100644 --- a/src/shared/radio/SX1278/SX1278Fsk.cpp +++ b/src/shared/radio/SX1278/SX1278Fsk.cpp @@ -43,13 +43,11 @@ long long now() { return Kernel::getOldTick(); } // - TxReady on DIO3 (mode 01) constexpr DioMapping DEFAULT_MAPPING = DioMapping(0, 0, 0, 1, 0, 0, false); -SX1278Fsk::Error SX1278Fsk::init(const Config &config) +SX1278Fsk::Error SX1278Fsk::init(const Config& config) { // First probe for the device if (!checkVersion()) - { return Error::BAD_VALUE; - } Error err; if ((err = configure(config)) != Error::NONE) @@ -75,7 +73,7 @@ bool SX1278Fsk::checkVersion() } } -SX1278Fsk::Error SX1278Fsk::configure(const Config &config) +SX1278Fsk::Error SX1278Fsk::configure(const Config& config) { // Check that the configuration is actually valid bool pa_boost = getFrontend().isOnPaBoost(); @@ -153,17 +151,11 @@ SX1278Fsk::Error SX1278Fsk::configure(const Config &config) // Setup reg over-current protection if (config.ocp == 0) - { spi.writeRegister(REG_OCP, RegOcp::make(0, false)); - } else if (ocp <= 120) - { spi.writeRegister(REG_OCP, RegOcp::make((ocp - 45) / 5, true)); - } else - { spi.writeRegister(REG_OCP, RegOcp::make((ocp + 30) / 10, true)); - } // Setup sync word spi.writeRegister( @@ -256,7 +248,7 @@ SX1278Fsk::Error SX1278Fsk::configure(const Config &config) return Error::NONE; } -ssize_t SX1278Fsk::receive(uint8_t *pkt, size_t max_len) +ssize_t SX1278Fsk::receive(uint8_t* pkt, size_t max_len) { Lock guard(*this); LockMode guard_mode(*this, guard, RegOpMode::MODE_RX, DEFAULT_MAPPING, @@ -281,9 +273,7 @@ ssize_t SX1278Fsk::receive(uint8_t *pkt, size_t max_len) RegIrqFlags::FIFO_LEVEL | RegIrqFlags::PAYLOAD_READY, 0, true); if ((flags & RegIrqFlags::PAYLOAD_READY) != 0 && crc_enabled) - { crc_ok = checkForIrqAndReset(RegIrqFlags::CRC_OK, 0) != 0; - } // Record RSSI here, it's where it is the most accurate last_rx_rssi = getRssi(); @@ -308,9 +298,7 @@ ssize_t SX1278Fsk::receive(uint8_t *pkt, size_t max_len) guard_mode, RegIrqFlags::FIFO_LEVEL | RegIrqFlags::PAYLOAD_READY, 0); if ((flags & RegIrqFlags::PAYLOAD_READY) != 0 && crc_enabled) - { crc_ok = checkForIrqAndReset(RegIrqFlags::CRC_OK, 0) != 0; - } SPITransaction spi(getSpiSlave()); @@ -324,16 +312,14 @@ ssize_t SX1278Fsk::receive(uint8_t *pkt, size_t max_len) } while (len == 0); if (len > max_len || (!crc_ok && crc_enabled)) - { return -1; - } // Finally copy the packet to the destination memcpy(pkt, tmp_pkt, len); return len; } -bool SX1278Fsk::send(uint8_t *pkt, size_t len) +bool SX1278Fsk::send(uint8_t* pkt, size_t len) { if (len > MTU) return false; @@ -422,9 +408,7 @@ void SX1278Fsk::rateLimitTx() long long delta = now() - last_tx; if (delta <= RATE_LIMIT) - { miosix::Thread::sleep(RATE_LIMIT - delta); - } } ISX1278::IrqFlags SX1278Fsk::getIrqFlags() diff --git a/src/shared/radio/SX1278/SX1278Fsk.h b/src/shared/radio/SX1278/SX1278Fsk.h index b25d645e9..4ba9615a3 100644 --- a/src/shared/radio/SX1278/SX1278Fsk.h +++ b/src/shared/radio/SX1278/SX1278Fsk.h @@ -135,7 +135,7 @@ public: /** * @brief Construct a new SX1278 */ - explicit SX1278Fsk(SPIBus &bus, miosix::GpioPin cs, miosix::GpioPin dio0, + explicit SX1278Fsk(SPIBus& bus, miosix::GpioPin cs, miosix::GpioPin dio0, miosix::GpioPin dio1, miosix::GpioPin dio3, SPI::ClockDivider clock_divider, std::unique_ptr<SX1278::ISX1278Frontend> frontend) @@ -148,7 +148,7 @@ public: /** * @brief Setup the device. */ - [[nodiscard]] virtual Error init(const Config &config); + [[nodiscard]] virtual Error init(const Config& config); /* * @brief Check if this device is connected. @@ -158,7 +158,7 @@ public: /** * @brief Configure this device on the fly. */ - [[nodiscard]] virtual Error configure(const Config &config); + [[nodiscard]] virtual Error configure(const Config& config); /** * @brief Wait until a new packet is received. @@ -167,7 +167,7 @@ public: * @param pkt_len Maximum length of the received data. * @return Size of the data received or -1 on failure */ - ssize_t receive(uint8_t *pkt, size_t max_len) override; + ssize_t receive(uint8_t* pkt, size_t max_len) override; /** * @brief Send a packet. @@ -178,7 +178,7 @@ public: * @param pkt_len Length of the packet to be sent. * @return True if the message was sent correctly. */ - bool send(uint8_t *pkt, size_t len) override; + bool send(uint8_t* pkt, size_t len) override; /** * @brief Get the current perceived RSSI in dBm. diff --git a/src/shared/radio/SX1278/SX1278Lora.cpp b/src/shared/radio/SX1278/SX1278Lora.cpp index fe6b5f315..fa99ea849 100644 --- a/src/shared/radio/SX1278/SX1278Lora.cpp +++ b/src/shared/radio/SX1278/SX1278Lora.cpp @@ -130,13 +130,11 @@ struct ErrataRegistersValues } }; -SX1278Lora::Error SX1278Lora::init(const Config &config) +SX1278Lora::Error SX1278Lora::init(const Config& config) { // First probe for the device if (!checkVersion()) - { return Error::BAD_VALUE; - } Error err; if ((err = configure(config)) != Error::NONE) @@ -162,7 +160,7 @@ bool SX1278Lora::checkVersion() } } -SX1278Lora::Error SX1278Lora::configure(const Config &config) +SX1278Lora::Error SX1278Lora::configure(const Config& config) { // Check that the configuration is actually valid bool pa_boost = getFrontend().isOnPaBoost(); @@ -250,17 +248,11 @@ SX1278Lora::Error SX1278Lora::configure(const Config &config) // Setup reg over-current protection if (config.ocp == 0) - { spi.writeRegister(REG_OCP, RegOcp::make(0, false)); - } else if (ocp <= 120) - { spi.writeRegister(REG_OCP, RegOcp::make((ocp - 45) / 5, true)); - } else - { spi.writeRegister(REG_OCP, RegOcp::make((ocp + 30) / 10, true)); - } // Setup generic configuration registers spi.writeRegister(REG_MODEM_CONFIG_1, @@ -281,11 +273,15 @@ SX1278Lora::Error SX1278Lora::configure(const Config &config) // Setup weird errata registers (see errata note) if (errata_values.reg_high_bw_optimize_1 != -1) + { spi.writeRegister(REG_HIGH_BW_OPTIMIZE_1, errata_values.reg_high_bw_optimize_1); + } if (errata_values.reg_high_bw_optimize_2 != -1) + { spi.writeRegister(REG_HIGH_BW_OPTIMIZE_2, errata_values.reg_high_bw_optimize_2); + } if (errata_values.reg_if_freq_1 != -1) spi.writeRegister(REG_IF_FREQ_1, errata_values.reg_if_freq_1); if (errata_values.reg_if_freq_2 != -1) @@ -295,7 +291,7 @@ SX1278Lora::Error SX1278Lora::configure(const Config &config) return Error::NONE; } -ssize_t SX1278Lora::receive(uint8_t *pkt, size_t max_len) +ssize_t SX1278Lora::receive(uint8_t* pkt, size_t max_len) { Lock guard(*this); @@ -316,14 +312,16 @@ ssize_t SX1278Lora::receive(uint8_t *pkt, size_t max_len) if (len > max_len || (crc_enabled && checkForIrqAndReset(RegIrqFlags::PAYLOAD_CRC_ERROR, 0) != 0)) + { return -1; + } // Finally read the contents of the fifo readFifo(FIFO_RX_BASE_ADDR, pkt, len); return len; } -bool SX1278Lora::send(uint8_t *pkt, size_t len) +bool SX1278Lora::send(uint8_t* pkt, size_t len) { if (len > MTU) return false; @@ -393,14 +391,14 @@ void SX1278Lora::enterLoraMode() miosix::Thread::sleep(1); } -void SX1278Lora::readFifo(uint8_t addr, uint8_t *dst, uint8_t size) +void SX1278Lora::readFifo(uint8_t addr, uint8_t* dst, uint8_t size) { SPITransaction spi(getSpiSlave()); spi.writeRegister(REG_FIFO_ADDR_PTR, addr); spi.readRegisters(REG_FIFO, dst, size); } -void SX1278Lora::writeFifo(uint8_t addr, uint8_t *src, uint8_t size) +void SX1278Lora::writeFifo(uint8_t addr, uint8_t* src, uint8_t size) { SPITransaction spi(getSpiSlave()); spi.writeRegister(REG_FIFO_ADDR_PTR, addr); diff --git a/src/shared/radio/SX1278/SX1278Lora.h b/src/shared/radio/SX1278/SX1278Lora.h index edde853ae..8a3bc046a 100644 --- a/src/shared/radio/SX1278/SX1278Lora.h +++ b/src/shared/radio/SX1278/SX1278Lora.h @@ -138,7 +138,7 @@ public: /** * @brief Construct a new SX1278 */ - explicit SX1278Lora(SPIBus &bus, miosix::GpioPin cs, miosix::GpioPin dio0, + explicit SX1278Lora(SPIBus& bus, miosix::GpioPin cs, miosix::GpioPin dio0, miosix::GpioPin dio1, miosix::GpioPin dio3, SPI::ClockDivider clock_divider, std::unique_ptr<SX1278::ISX1278Frontend> frontend) @@ -151,7 +151,7 @@ public: /** * @brief Setup the device. */ - [[nodiscard]] virtual Error init(const Config &config); + [[nodiscard]] virtual Error init(const Config& config); /* * @brief Check if this device is connected. @@ -161,7 +161,7 @@ public: /** * @brief Configure this device on the fly. */ - [[nodiscard]] virtual Error configure(const Config &config); + [[nodiscard]] virtual Error configure(const Config& config); /** * @brief Wait until a new packet is received. @@ -170,7 +170,7 @@ public: * @param pkt_len Maximum length of the received data. * @return Size of the data received or -1 if failure */ - ssize_t receive(uint8_t *pkt, size_t max_len) override; + ssize_t receive(uint8_t* pkt, size_t max_len) override; /** * @brief Send a packet. @@ -181,7 +181,7 @@ public: * @param pkt_len Length of the packet to be sent. * @return True if the message was sent correctly. */ - bool send(uint8_t *pkt, size_t len) override; + bool send(uint8_t* pkt, size_t len) override; /** * @brief Get the RSSI in dBm, during last packet receive. @@ -196,8 +196,8 @@ public: private: void enterLoraMode(); - void readFifo(uint8_t addr, uint8_t *dst, uint8_t size); - void writeFifo(uint8_t addr, uint8_t *src, uint8_t size); + void readFifo(uint8_t addr, uint8_t* dst, uint8_t size); + void writeFifo(uint8_t addr, uint8_t* src, uint8_t size); IrqFlags getIrqFlags() override; void resetIrqFlags(IrqFlags flags) override; diff --git a/src/shared/radio/Xbee/APIFrameParser.cpp b/src/shared/radio/Xbee/APIFrameParser.cpp index dc4f0903c..75dd17cd2 100644 --- a/src/shared/radio/Xbee/APIFrameParser.cpp +++ b/src/shared/radio/Xbee/APIFrameParser.cpp @@ -40,9 +40,7 @@ APIFrameParser::ParseResult APIFrameParser::parse(uint8_t byte, APIFrame* frame) case ParserState::FIND_START: if (byte == START_DELIMITER) - { parserState = ParserState::READ_LENGTH_1; - } break; // Read most significant byte of the length case ParserState::READ_LENGTH_1: @@ -101,13 +99,9 @@ APIFrameParser::ParseResult APIFrameParser::parse(uint8_t byte, APIFrame* frame) } if (parserState != ParserState::FIND_START) - { return ParseResult::PARSING; - } else - { return ParseResult::IDLE; - } } } // namespace Xbee diff --git a/src/shared/radio/Xbee/APIFrames.h b/src/shared/radio/Xbee/APIFrames.h index 7bd73f3dd..cc3b03b64 100644 --- a/src/shared/radio/Xbee/APIFrames.h +++ b/src/shared/radio/Xbee/APIFrames.h @@ -167,9 +167,7 @@ struct APIFrame // significant byte. uint8_t sum = checksum + frameType; for (uint16_t i = 0; i < getFrameDataLength(); ++i) - { sum += frameData[i]; - } return sum == 0xFF; } @@ -177,9 +175,7 @@ struct APIFrame { checksum = frameType; for (uint16_t i = 0; i < getFrameDataLength(); ++i) - { checksum += frameData[i]; - } checksum = 0xFF - checksum; } diff --git a/src/shared/radio/Xbee/APIFramesLog.h b/src/shared/radio/Xbee/APIFramesLog.h index a17b0cea7..074e799e0 100644 --- a/src/shared/radio/Xbee/APIFramesLog.h +++ b/src/shared/radio/Xbee/APIFramesLog.h @@ -81,9 +81,7 @@ struct ATCommandFrameLog static bool toFrameType(APIFrame& api, ATCommandFrameLog* dest) { if (api.frameType != FTYPE_AT_COMMAND) - { return false; - } if (api.getFrameDataLength() < MIN_AT_COMMAND_FRAME_SIZE || api.getFrameDataLength() > @@ -118,16 +116,10 @@ struct ATCommandFrameLog << commandDataLength << ","; if (commandDataLength > 0) - { for (uint16_t i = 0; i < commandDataLength; i++) - { os << (int)commandData[i] << " "; - } - } else - { os << "-"; - } os << "\n"; } @@ -149,9 +141,7 @@ struct TXRequestFrameLog static bool toFrameType(APIFrame& api, TXRequestFrameLog* dest) { if (api.frameType != FTYPE_TX_REQUEST) - { return false; - } if (api.getFrameDataLength() < MIN_TX_REQUEST_FRAME_SIZE || api.getFrameDataLength() > @@ -205,9 +195,7 @@ struct ATCommandResponseFrameLog static bool toFrameType(APIFrame& api, ATCommandResponseFrameLog* dest) { if (api.frameType != FTYPE_AT_COMMAND_RESPONSE) - { return false; - } if (api.getFrameDataLength() < MIN_AT_COMMAND_FRAME_SIZE || api.getFrameDataLength() > @@ -247,16 +235,10 @@ struct ATCommandResponseFrameLog << (int)commandStatus << "," << commandDataLength << ","; if (commandDataLength > 0) - { for (uint16_t i = 0; i < commandDataLength; i++) - { os << (int)commandData[i] << " "; - } - } else - { os << "-"; - } os << "\n"; } @@ -270,14 +252,10 @@ struct ModemStatusFrameLog static bool toFrameType(APIFrame& api, ModemStatusFrameLog* dest) { if (api.frameType != FTYPE_MODEM_STATUS) - { return false; - } if (api.getFrameDataLength() != MODEM_STATUS_FRAME_SIZE) - { return false; - } ModemStatusFrame* modem = api.toFrameType<ModemStatusFrame>(); @@ -306,14 +284,10 @@ struct TXStatusFrameLog static bool toFrameType(APIFrame& api, TXStatusFrameLog* dest) { if (api.frameType != FTYPE_TX_STATUS) - { return false; - } if (api.getFrameDataLength() != TX_STATUS_FRAME_SIZE) - { return false; - } TXStatusFrame* tx = api.toFrameType<TXStatusFrame>(); @@ -353,9 +327,7 @@ struct RXPacketFrameLog static bool toFrameType(APIFrame& api, RXPacketFrameLog* dest) { if (api.frameType != FTYPE_RX_PACKET_FRAME) - { return false; - } if (api.getFrameDataLength() < MIN_RX_PACKET_FRAME_SIZE || api.getFrameDataLength() > diff --git a/src/shared/radio/Xbee/ATCommands.h b/src/shared/radio/Xbee/ATCommands.h index a9bfaeadb..1f3a881ef 100644 --- a/src/shared/radio/Xbee/ATCommands.h +++ b/src/shared/radio/Xbee/ATCommands.h @@ -67,9 +67,7 @@ inline bool setChannelMask(Xbee& xbee, bool channels[30], uint32_t val = 0; for (int i = 0; i < 30; i++) - { val &= ((uint32_t)channels[i]) << i; - } return setChannelMask(xbee, val, timeout); } diff --git a/src/shared/radio/Xbee/Xbee.cpp b/src/shared/radio/Xbee/Xbee.cpp index 1f698c1ee..968830d85 100644 --- a/src/shared/radio/Xbee/Xbee.cpp +++ b/src/shared/radio/Xbee/Xbee.cpp @@ -119,7 +119,9 @@ ssize_t Xbee::receive(uint8_t* buf, size_t bufMaxSize) { // We have data in the buffer pending to be returned if (!rxFramesBuffer.isEmpty() || currRxPayloadPointer >= 0) + { return fillReceiveBuf(buf, bufMaxSize); + } // No data in the buffer, but the xbee has data to return via SPI else if (attn.value() == 0) @@ -222,7 +224,9 @@ void Xbee::handleATTNInterrupt() receiveThread->IRQwakeup(); if (receiveThread->IRQgetPriority() > miosix::Thread::IRQgetCurrentThread()->IRQgetPriority()) + { miosix::Scheduler::IRQfindNextThread(); + } receiveThread = 0; } diff --git a/src/shared/scheduler/TaskScheduler.cpp b/src/shared/scheduler/TaskScheduler.cpp index b7e964501..6336b8d20 100644 --- a/src/shared/scheduler/TaskScheduler.cpp +++ b/src/shared/scheduler/TaskScheduler.cpp @@ -68,9 +68,7 @@ size_t TaskScheduler::addTask(function_t function, nanoseconds period, } if (policy == Policy::ONE_SHOT) - { startTime += period; - } // Insert a new task with the given parameters tasks.emplace_back(function, period.count(), policy, @@ -80,9 +78,7 @@ size_t TaskScheduler::addTask(function_t function, nanoseconds period, // Only add the task to the agenda if the scheduler is running // Otherwise, the agenda will be populated when the scheduler is started if (isRunning()) - { agenda.emplace(id, startTime.time_since_epoch().count()); - } condvar.broadcast(); // Signals the run thread return id; @@ -139,9 +135,7 @@ bool TaskScheduler::start() // This check is necessary to prevent task normalization if the scheduler is // already stopped if (running) - { return false; - } // Populate the agenda with the tasks we have so far populateAgenda(); @@ -167,9 +161,7 @@ vector<TaskStatsResult> TaskScheduler::getTaskStats() { const Task& task = tasks[id]; if (task.enabled) - { result.push_back(fromTaskIdPairToStatsResult(task, id)); - } } return result; @@ -205,15 +197,11 @@ void TaskScheduler::run() while (true) { while (agenda.empty() && !shouldStop()) - { condvar.wait(mutex); - } // Exit if the ActiveObject has been stopped if (shouldStop()) - { return; - } int64_t startTime = miosix::getTime(); Event nextEvent = agenda.top(); diff --git a/src/shared/sensors/ADS1118/ADS1118.cpp b/src/shared/sensors/ADS1118/ADS1118.cpp index d9778c6f1..ffced4e8c 100644 --- a/src/shared/sensors/ADS1118/ADS1118.cpp +++ b/src/shared/sensors/ADS1118/ADS1118.cpp @@ -32,7 +32,7 @@ const ADS1118::ADS1118Config ADS1118::ADS1118_DEFAULT_CONFIG = { SINGLE_SHOT_MODE, FSR_2_048, MUX_AIN0_AIN1, 0, 0, VALID_OPERATION, PULL_UP_EN, ADC_MODE, DR_128}; -ADS1118::ADS1118(SPIBusInterface &bus, miosix::GpioPin cs, +ADS1118::ADS1118(SPIBusInterface& bus, miosix::GpioPin cs, ADS1118Config config_, SPIBusConfig spiConfig) : ADS1118(SPISlave(bus, cs, spiConfig), config_, false) { @@ -93,9 +93,7 @@ void ADS1118::disableInput(ADS1118Mux mux) { channelsConfig[mux].word = 0; } void ADS1118::disableAllInputs() { for (auto i = 0; i < NUM_OF_CHANNELS; i++) - { channelsConfig[i].word = 0; - } } void ADS1118::enableTemperature() @@ -136,13 +134,9 @@ TemperatureData ADS1118::getTemperature() int ADS1118::getConversionTime(int8_t channel) { if (channel >= 0 && channel <= TEMP_CHANNEL) - { return CONV_TIME[channelsConfig[channel].bits.rate]; - } else - { return 0; - } } bool ADS1118::selfTest() @@ -216,7 +210,7 @@ void ADS1118::readChannel(int8_t nextChannel, int8_t prevChannel) transferData = writeData; { SPITransaction transaction(spiSlave); - transaction.transfer((uint8_t *)&transferData, configCheck ? 4 : 2); + transaction.transfer((uint8_t*)&transferData, configCheck ? 4 : 2); } // If enabled and a valid configuration has just been written, check the @@ -286,15 +280,13 @@ void ADS1118::readChannel(int8_t channel) */ int8_t ADS1118::findNextEnabledChannel(int8_t startChannel) { - int8_t &channel = startChannel; // Just a change of name + int8_t& channel = startChannel; // Just a change of name for (auto i = 0; i < 2; i++) { // Go to the first channel if channel is too big if (channel >= NUM_OF_CHANNELS) - { channel = 0; - } // Find next enabled mux config for (; channel < NUM_OF_CHANNELS && channelsConfig[channel].word == 0; @@ -305,13 +297,9 @@ int8_t ADS1118::findNextEnabledChannel(int8_t startChannel) // have to read it based on sampleCounter and tempDivider // If invalid try to search again starting from the first channel if (channel == TEMP_CHANNEL && sampleCounter % tempDivider != 0) - { continue; - } if (channel < NUM_OF_CHANNELS) - { return channel; - } } // If no valid channel has been fount return an invalid channel diff --git a/src/shared/sensors/ADS1118/ADS1118.h b/src/shared/sensors/ADS1118/ADS1118.h index 828cdc9bb..672e4182d 100644 --- a/src/shared/sensors/ADS1118/ADS1118.h +++ b/src/shared/sensors/ADS1118/ADS1118.h @@ -81,7 +81,7 @@ public: MUX_AIN1_GND = 0x5, ///< AINp is AIN1 and AINn is GND MUX_AIN2_GND = 0x6, ///< AINp is AIN2 and AINn is GND MUX_AIN3_GND = 0x7 ///< AINp is AIN3 and AINn is GND - }; ///< Multiplexer values + }; ///< Multiplexer values enum ADS1118Pga { @@ -91,13 +91,13 @@ public: FSR_1_024 = 0x3, ///< FSR is ±1.024 V FSR_0_512 = 0x4, ///< FSR is ±0.512 V FSR_0_256 = 0x5 ///< FSR is ±0.256 V - }; ///< Programmable gain amplifier values + }; ///< Programmable gain amplifier values enum ADS1118Mode { CONTINUOUS_CONV_MODE = 0x0, ///< Continuous-conversion mode SINGLE_SHOT_MODE = 0x1 ///< Power-down and single-shot mode (default) - }; ///< Conversion mode values + }; ///< Conversion mode values enum ADS1118DataRate { @@ -109,19 +109,19 @@ public: DR_250 = 0x5, ///< 250 SPS DR_475 = 0x6, ///< 475 SPS DR_860 = 0x7 ///< 860 SPS - }; ///< Data rate configuration values + }; ///< Data rate configuration values enum ADS1118TempMode { ADC_MODE = 0x0, ///< ADC mode (default) TEMP_SENSOR_MODE = 0x1 ///< Temperature sensor mode - }; ///< Temperature or ADC mode values + }; ///< Temperature or ADC mode values enum ADS1118PullUp { PULL_UP_DIS = 0x0, ///< Pullup resistor disabled on DOUT pin PULL_UP_EN = 0x1 ///< Pullup resistor enabled on DOUT pin (default) - }; ///< Pull up enable or disable values + }; ///< Pull up enable or disable values union ADS1118Config { @@ -145,13 +145,13 @@ public: } byte; ///< Includes the msb and lsb bytes uint16_t word; ///< Representation in word (16-bits) format - }; ///< Structure of configuration word + }; ///< Structure of configuration word struct ADS1118InputConfig { ADS1118Mux mux = MUX_AIN0_AIN1; ///< Input's mux configuration ADS1118DataRate rate = DR_128; ///< Input's data rate configuration - }; ///< Driver's input config + }; ///< Driver's input config static constexpr uint8_t VALID_OPERATION = 0x1; ///< Indicates a valid configuration @@ -169,7 +169,7 @@ public: * @brief Construct a new ADS1118 object specifying spi bus, spi config and * cs pin as well as device configuration. */ - ADS1118(SPIBusInterface &bus, miosix::GpioPin cs, ADS1118Config config_, + ADS1118(SPIBusInterface& bus, miosix::GpioPin cs, ADS1118Config config_, SPIBusConfig spiConfig = getDefaultSPIConfig()); /** diff --git a/src/shared/sensors/ADS131M04/ADS131M04.cpp b/src/shared/sensors/ADS131M04/ADS131M04.cpp index 2f5f7dfda..df8931057 100644 --- a/src/shared/sensors/ADS131M04/ADS131M04.cpp +++ b/src/shared/sensors/ADS131M04/ADS131M04.cpp @@ -32,8 +32,8 @@ using namespace Boardcore::ADS131M04Defs; namespace Boardcore { -ADS131M04::ADS131M04(SPIBusInterface &bus, miosix::GpioPin cs, - SPIBusConfig spiConfig, const Config &config) +ADS131M04::ADS131M04(SPIBusInterface& bus, miosix::GpioPin cs, + SPIBusConfig spiConfig, const Config& config) : spiSlave(bus, cs, spiConfig), config(config) { // Impose the correct spi mode @@ -77,19 +77,13 @@ bool ADS131M04::reset() void ADS131M04::applyConfig(Config config) { for (int i = 0; i < CHANNELS_NUM; i++) - { applyChannelConfig(static_cast<Channel>(i), config.channelsConfig[i]); - } setOversamplingRatio(config.oversamplingRatio); if (config.globalChopModeEnabled) - { enableGlobalChopMode(); - } else - { disableGlobalChopMode(); - } // Save the newly applied configuration this->config = config; @@ -191,9 +185,7 @@ bool ADS131M04::selfTest() } for (int j = 0; j < CHANNELS_NUM; j++) - { averageValues[j] += rawValues[j]; - } realSampleCount++; } @@ -234,9 +226,7 @@ bool ADS131M04::selfTest() // Connect all channels to the negative DC test signal for (int i = 0; i < CHANNELS_NUM; i++) - { setChannelInput(static_cast<Channel>(i), Input::NEGATIVE_DC_TEST); - } // Take some samples realSampleCount = 0; @@ -254,9 +244,7 @@ bool ADS131M04::selfTest() } for (int j = 0; j < CHANNELS_NUM; j++) - { averageValues[j] += rawValues[j]; - } realSampleCount++; } @@ -294,9 +282,7 @@ bool ADS131M04::selfTest() // Reset channels input to default for (int i = 0; i < CHANNELS_NUM; i++) - { setChannelInput(static_cast<Channel>(i), Input::DEFAULT); - } // Reset to previous configuration applyConfig(config); @@ -378,13 +364,9 @@ void ADS131M04::setChannelGain(Channel channel, double gain) { // If the user passes a value outside the range [0, 2] we cap it. if (gain < 0) - { gain = 0; - } else if (gain > 2) - { gain = 2; - } // The ADS131M04 corrects for gain errors by multiplying the ADC conversion // result using the gain calibration registers. @@ -612,7 +594,7 @@ void ADS131M04::changeRegister(Register reg, uint16_t newValue, uint16_t mask) writeRegister(reg, regValue); } -void ADS131M04::sendCommand(SPITransaction &transaction, Command command, +void ADS131M04::sendCommand(SPITransaction& transaction, Command command, uint8_t data[FULL_FRAME_SIZE]) { // All commands (a part from read and write) needs the full 10 words diff --git a/src/shared/sensors/ADS131M08/ADS131M08.cpp b/src/shared/sensors/ADS131M08/ADS131M08.cpp index a1e102483..a1c0abeca 100644 --- a/src/shared/sensors/ADS131M08/ADS131M08.cpp +++ b/src/shared/sensors/ADS131M08/ADS131M08.cpp @@ -32,8 +32,8 @@ using namespace Boardcore::ADS131M08Defs; namespace Boardcore { -ADS131M08::ADS131M08(SPIBusInterface &bus, miosix::GpioPin cs, - SPIBusConfig spiConfig, const Config &config) +ADS131M08::ADS131M08(SPIBusInterface& bus, miosix::GpioPin cs, + SPIBusConfig spiConfig, const Config& config) : spiSlave(bus, cs, spiConfig), config(config) { // Impose the correct spi mode @@ -77,19 +77,13 @@ bool ADS131M08::reset() void ADS131M08::applyConfig(Config config) { for (int i = 0; i < CHANNELS_NUM; i++) - { applyChannelConfig(static_cast<Channel>(i), config.channelsConfig[i]); - } setOversamplingRatio(config.oversamplingRatio); if (config.globalChopModeEnabled) - { enableGlobalChopMode(); - } else - { disableGlobalChopMode(); - } // Save the newly applied configuration this->config = config; @@ -191,9 +185,7 @@ bool ADS131M08::selfTest() } for (int j = 0; j < CHANNELS_NUM; j++) - { averageValues[j] += rawValues[j]; - } realSampleCount++; } @@ -234,9 +226,7 @@ bool ADS131M08::selfTest() // Connect all channels to the negative DC test signal for (int i = 0; i < CHANNELS_NUM; i++) - { setChannelInput(static_cast<Channel>(i), Input::NEGATIVE_DC_TEST); - } // Take some samples realSampleCount = 0; @@ -254,9 +244,7 @@ bool ADS131M08::selfTest() } for (int j = 0; j < CHANNELS_NUM; j++) - { averageValues[j] += rawValues[j]; - } realSampleCount++; } @@ -294,9 +282,7 @@ bool ADS131M08::selfTest() // Reset channels input to default for (int i = 0; i < CHANNELS_NUM; i++) - { setChannelInput(static_cast<Channel>(i), Input::DEFAULT); - } // Reset to previous configuration applyConfig(config); @@ -389,13 +375,9 @@ void ADS131M08::setChannelGain(Channel channel, double gain) { // If the user passes a value outside the range [0, 2] we cap it. if (gain < 0) - { gain = 0; - } else if (gain > 2) - { gain = 2; - } // The ADS131M08 corrects for gain errors by multiplying the ADC conversion // result using the gain calibration registers. @@ -663,7 +645,7 @@ void ADS131M08::changeRegister(Register reg, uint16_t newValue, uint16_t mask) writeRegister(reg, regValue); } -void ADS131M08::sendCommand(SPITransaction &transaction, Command command, +void ADS131M08::sendCommand(SPITransaction& transaction, Command command, uint8_t data[FULL_FRAME_SIZE]) { // All commands (a part from read and write) needs the full 10 words diff --git a/src/shared/sensors/BME280/BME280.cpp b/src/shared/sensors/BME280/BME280.cpp index 1ece0a101..0a34ef287 100644 --- a/src/shared/sensors/BME280/BME280.cpp +++ b/src/shared/sensors/BME280/BME280.cpp @@ -289,7 +289,7 @@ BME280::BME280Config BME280::readConfiguration() BME280Config tmp; SPITransaction transaction(spiSlave); - transaction.readRegisters(REG_CTRL_HUM, (uint8_t *)&tmp, 4); + transaction.readRegisters(REG_CTRL_HUM, (uint8_t*)&tmp, 4); return tmp; } @@ -300,7 +300,7 @@ void BME280::loadCompensationParameters() { SPITransaction transaction(spiSlave); - transaction.readRegisters(REG_CALIB_0, (uint8_t *)&compParams, 25); + transaction.readRegisters(REG_CALIB_0, (uint8_t*)&compParams, 25); } // Read second batch of compensation parameters @@ -308,7 +308,7 @@ void BME280::loadCompensationParameters() SPITransaction transaction(spiSlave); transaction.readRegisters(REG_CALIB_26, - (uint8_t *)&compParams.bits.dig_H2, 7); + (uint8_t*)&compParams.bits.dig_H2, 7); } // Adjust unaligned data @@ -349,9 +349,7 @@ uint32_t BME280::compensatePressure(int32_t adc_P) var1 = ((((int64_t)1) << 47) + var1) * ((int64_t)compParams.bits.dig_P1) >> 33; if (var1 == 0) - { return 0; // avoid exception caused by division by zero - } p = 1048576 - adc_P; p = (((p << 31) - var2) * 3125) / var1; var1 = (((int64_t)compParams.bits.dig_P9) * (p >> 13) * (p >> 13)) >> 25; diff --git a/src/shared/sensors/BME280/BME280I2C.cpp b/src/shared/sensors/BME280/BME280I2C.cpp index 4d0e67c56..9539f7060 100644 --- a/src/shared/sensors/BME280/BME280I2C.cpp +++ b/src/shared/sensors/BME280/BME280I2C.cpp @@ -48,7 +48,7 @@ const BME280I2C::BME280Config BME280I2C::BME280_CONFIG_TEMP_SINGLE = { SKIPPED, 0, 0, FORCED_MODE, SKIPPED, OVERSAMPLING_1, 0, FILTER_OFF, STB_TIME_0_5}; -BME280I2C::BME280I2C(I2C &bus, BME280Config config) : bus(bus), config(config) +BME280I2C::BME280I2C(I2C& bus, BME280Config config) : bus(bus), config(config) { } @@ -63,9 +63,7 @@ bool BME280I2C::init() } if (!reset()) - { return false; - } miosix::Thread::sleep(3); loadCompensationParameters(); @@ -143,7 +141,6 @@ HumidityData BME280I2C::readHumidity() uint8_t buffer[2]; if (bus.readFromRegister(slaveConfig, REG_HUM_MSB, buffer, 2)) { - int32_t adc_H = ((uint32_t)buffer[0] << 8); adc_H |= buffer[1]; @@ -166,7 +163,6 @@ PressureData BME280I2C::readPressure() uint8_t buffer[3]; if (bus.readFromRegister(slaveConfig, REG_PRESS_MSB, buffer, 3)) { - int32_t adc_P = ((uint32_t)buffer[0]) << 12; adc_P |= ((uint32_t)buffer[1]) << 4; adc_P |= (buffer[2] >> 4) & 0x0F; @@ -286,7 +282,6 @@ bool BME280I2C::checkWhoAmI() if (bus.readRegister(slaveConfig, REG_ID, whoAmIValue)) { - return whoAmIValue == REG_ID_VAL; } else @@ -325,7 +320,7 @@ BME280I2C::BME280Config BME280I2C::readConfiguration() { BME280Config tmp; - if (bus.readFromRegister(slaveConfig, REG_CTRL_HUM, (uint8_t *)&tmp, 4)) + if (bus.readFromRegister(slaveConfig, REG_CTRL_HUM, (uint8_t*)&tmp, 4)) { return tmp; } @@ -339,7 +334,7 @@ BME280I2C::BME280Config BME280I2C::readConfiguration() void BME280I2C::loadCompensationParameters() { // Read first batch of compensation parameters - if (!bus.readFromRegister(slaveConfig, REG_CALIB_0, (uint8_t *)&compParams, + if (!bus.readFromRegister(slaveConfig, REG_CALIB_0, (uint8_t*)&compParams, 25)) { lastError = SensorErrors::BUS_FAULT; @@ -348,7 +343,7 @@ void BME280I2C::loadCompensationParameters() // Read second batch of compensation parameters if (!bus.readFromRegister(slaveConfig, REG_CALIB_26, - (uint8_t *)&compParams.bits.dig_H2, 7)) + (uint8_t*)&compParams.bits.dig_H2, 7)) { lastError = SensorErrors::BUS_FAULT; return; @@ -392,9 +387,7 @@ uint32_t BME280I2C::compensatePressure(int32_t adc_P) var1 = ((((int64_t)1) << 47) + var1) * ((int64_t)compParams.bits.dig_P1) >> 33; if (var1 == 0) - { return 0; // avoid exception caused by division by zero - } p = 1048576 - adc_P; p = (((p << 31) - var2) * 3125) / var1; var1 = (((int64_t)compParams.bits.dig_P9) * (p >> 13) * (p >> 13)) >> 25; diff --git a/src/shared/sensors/BMP280/BMP280.cpp b/src/shared/sensors/BMP280/BMP280.cpp index 325ca0982..cd231f0c2 100644 --- a/src/shared/sensors/BMP280/BMP280.cpp +++ b/src/shared/sensors/BMP280/BMP280.cpp @@ -253,7 +253,7 @@ BMP280::BMP280Config BMP280::readConfiguration() BMP280Config tmp; SPITransaction transaction(spiSlave); - transaction.readRegisters(REG_STATUS, (uint8_t *)&tmp, 3); + transaction.readRegisters(REG_STATUS, (uint8_t*)&tmp, 3); return tmp; } @@ -264,7 +264,7 @@ void BMP280::loadCompensationParameters() { SPITransaction transaction(spiSlave); - transaction.readRegisters(REG_CALIB_0, (uint8_t *)&compParams, 25); + transaction.readRegisters(REG_CALIB_0, (uint8_t*)&compParams, 25); } } @@ -299,9 +299,7 @@ uint32_t BMP280::compensatePressure(int32_t adc_P) var1 = ((((int64_t)1) << 47) + var1) * ((int64_t)compParams.bits.dig_P1) >> 33; if (var1 == 0) - { return 0; // avoid exception caused by division by zero - } p = 1048576 - adc_P; p = (((p << 31) - var2) * 3125) / var1; var1 = (((int64_t)compParams.bits.dig_P9) * (p >> 13) * (p >> 13)) >> 25; diff --git a/src/shared/sensors/BMP280/BMP280Data.h b/src/shared/sensors/BMP280/BMP280Data.h index cfd3cecc2..bf3db827a 100644 --- a/src/shared/sensors/BMP280/BMP280Data.h +++ b/src/shared/sensors/BMP280/BMP280Data.h @@ -33,8 +33,8 @@ struct BMP280Data : public TemperatureData, public PressureData BMP280Data(uint64_t timestamp, float temperature, float pressure, float humidity) - : TemperatureData{timestamp, temperature}, PressureData{timestamp, - pressure} + : TemperatureData{timestamp, temperature}, + PressureData{timestamp, pressure} { } @@ -47,8 +47,7 @@ struct BMP280Data : public TemperatureData, public PressureData void print(std::ostream& os) const { os << temperatureTimestamp << "," << temperature << "," - << pressureTimestamp << "," << pressure << "," - << "\n"; + << pressureTimestamp << "," << pressure << "," << "\n"; } }; diff --git a/src/shared/sensors/BMP280/BMP280I2C.cpp b/src/shared/sensors/BMP280/BMP280I2C.cpp index 66c1a1212..e44cf7ffa 100644 --- a/src/shared/sensors/BMP280/BMP280I2C.cpp +++ b/src/shared/sensors/BMP280/BMP280I2C.cpp @@ -46,7 +46,7 @@ const BMP280I2C::BMP280Config BMP280I2C::BMP280_CONFIG_ALL_ENABLED = { const BMP280I2C::BMP280Config BMP280I2C::BMP280_CONFIG_TEMP_SINGLE = { 0, 0, FORCED_MODE, SKIPPED, OVERSAMPLING_1, 0, FILTER_OFF, STB_TIME_0_5}; -BMP280I2C::BMP280I2C(I2C &bus, BMP280Config config) : bus(bus), config(config) +BMP280I2C::BMP280I2C(I2C& bus, BMP280Config config) : bus(bus), config(config) { } @@ -61,9 +61,7 @@ bool BMP280I2C::init() } if (!reset()) - { return false; - } miosix::Thread::sleep(3); loadCompensationParameters(); @@ -133,7 +131,6 @@ PressureData BMP280I2C::readPressure() uint8_t buffer[3]; if (bus.readFromRegister(slaveConfig, REG_PRESS_MSB, buffer, 3)) { - int32_t adc_P = ((uint32_t)buffer[0]) << 12; adc_P |= ((uint32_t)buffer[1]) << 4; adc_P |= (buffer[2] >> 4) & 0x0F; @@ -246,7 +243,6 @@ bool BMP280I2C::checkWhoAmI() if (bus.readRegister(slaveConfig, REG_ID, whoAmIValue)) { - return whoAmIValue == REG_ID_VAL; } else @@ -278,7 +274,7 @@ BMP280I2C::BMP280Config BMP280I2C::readConfiguration() { BMP280Config tmp; - if (bus.readFromRegister(slaveConfig, REG_STATUS, (uint8_t *)&tmp, 3)) + if (bus.readFromRegister(slaveConfig, REG_STATUS, (uint8_t*)&tmp, 3)) { return tmp; } @@ -292,7 +288,7 @@ BMP280I2C::BMP280Config BMP280I2C::readConfiguration() void BMP280I2C::loadCompensationParameters() { // Read first batch of compensation parameters - if (!bus.readFromRegister(slaveConfig, REG_CALIB_0, (uint8_t *)&compParams, + if (!bus.readFromRegister(slaveConfig, REG_CALIB_0, (uint8_t*)&compParams, 25)) { lastError = SensorErrors::BUS_FAULT; @@ -331,9 +327,7 @@ uint32_t BMP280I2C::compensatePressure(int32_t adc_P) var1 = ((((int64_t)1) << 47) + var1) * ((int64_t)compParams.bits.dig_P1) >> 33; if (var1 == 0) - { return 0; // avoid exception caused by division by zero - } p = 1048576 - adc_P; p = (((p << 31) - var2) * 3125) / var1; var1 = (((int64_t)compParams.bits.dig_P9) * (p >> 13) * (p >> 13)) >> 25; diff --git a/src/shared/sensors/BMX160/BMX160.cpp b/src/shared/sensors/BMX160/BMX160.cpp index df7e966bb..ccf1e0fef 100644 --- a/src/shared/sensors/BMX160/BMX160.cpp +++ b/src/shared/sensors/BMX160/BMX160.cpp @@ -106,9 +106,7 @@ void BMX160::IRQupdateTimestamp(uint64_t ts) { // Prevent interrupts while reading fifo if (irqEnabled) - { SensorFIFO::IRQupdateTimestamp(ts); - } } BMX160Data BMX160::sampleImpl() @@ -122,7 +120,9 @@ BMX160Data BMX160::sampleImpl() // Read temperature if (config.temperatureDivider != 0 && tempCounter % config.temperatureDivider == 0) + { readTemp(); + } tempCounter++; @@ -432,13 +432,9 @@ void BMX160::initInt() BMX160Defs::INT_OUT_CTRL_INT1_OUT_EN; if (config.interrupt1Mode == BMX160Config::IntMode::OPEN_DRAIN) - { outCtrl |= BMX160Defs::INT_OUT_CTRL_INT1_OD; - } if (config.interrupt2Mode == BMX160Config::IntMode::OPEN_DRAIN) - { outCtrl |= BMX160Defs::INT_OUT_CTRL_INT2_OD; - } // Enable both interrupt pins, otherwise they'll just float. // We configure both of them as push-pull and active-low @@ -618,13 +614,17 @@ GyroscopeData BMX160::buildGyrData(BMX160Defs::GyrRaw data, uint64_t timestamp) using namespace Constants; if (config.gyroscopeUnit == BMX160Config::GyroscopeMeasureUnit::DEG) + { return GyroscopeData{timestamp, data.x * gyrSensibility, data.y * gyrSensibility, data.z * gyrSensibility}; + } else + { return GyroscopeData{timestamp, data.x * gyrSensibility * DEGREES_TO_RADIANS, data.y * gyrSensibility * DEGREES_TO_RADIANS, data.z * gyrSensibility * DEGREES_TO_RADIANS}; + } } const char* BMX160::debugErr(SPITransaction& spi) @@ -754,7 +754,6 @@ void BMX160::readFifo(bool headerless) int idx = 0; while (idx < len && buf[idx] != BMX160Defs::FIFO_STOP_BYTE) { - if (headerless) { auto magRaw = parseStruct<BMX160Defs::MagRaw>(buf, idx); @@ -769,9 +768,7 @@ void BMX160::readFifo(bool headerless) pushSample(BMX160Data{oldAcc, oldGyr, oldMag}); if (watermarkTimestamp == 0 && idx >= (config.fifoWatermark * 4)) - { watermarkTimestamp = timestamp; - } timestamp += timeOffset; } diff --git a/src/shared/sensors/H3LIS331DL/H3LIS331DL.cpp b/src/shared/sensors/H3LIS331DL/H3LIS331DL.cpp index fa74cc9ea..670b2dfde 100644 --- a/src/shared/sensors/H3LIS331DL/H3LIS331DL.cpp +++ b/src/shared/sensors/H3LIS331DL/H3LIS331DL.cpp @@ -97,7 +97,6 @@ bool H3LIS331DL::init() if (!initialized) { - LOG_ERR(logger, "Control Register 1 After init: {:X}, expected " "value:{:X}", @@ -125,7 +124,6 @@ bool H3LIS331DL::init() if (!initialized) { - LOG_ERR(logger, "Control Register 1 After init: {:X}, expected " "value:{:X}", diff --git a/src/shared/sensors/H3LIS331DL/H3LIS331DL.h b/src/shared/sensors/H3LIS331DL/H3LIS331DL.h index 947709cbd..e80f0e6a3 100644 --- a/src/shared/sensors/H3LIS331DL/H3LIS331DL.h +++ b/src/shared/sensors/H3LIS331DL/H3LIS331DL.h @@ -40,7 +40,6 @@ namespace Boardcore */ class H3LIS331DL : public Sensor<H3LIS331DLData> { - public: /** * @brief Creates an instance of an H3LIS331DL sensor diff --git a/src/shared/sensors/H3LIS331DL/H3LIS331DLData.h b/src/shared/sensors/H3LIS331DL/H3LIS331DLData.h index 054ef30c4..4de0fb983 100644 --- a/src/shared/sensors/H3LIS331DL/H3LIS331DLData.h +++ b/src/shared/sensors/H3LIS331DL/H3LIS331DLData.h @@ -29,13 +29,12 @@ namespace Boardcore struct H3LIS331DLData : public AccelerometerData { - - H3LIS331DLData() : AccelerometerData(0, 0, 0, 0){}; + H3LIS331DLData() : AccelerometerData(0, 0, 0, 0) {}; H3LIS331DLData(uint64_t ts, float aX, float aY, float aZ) - : AccelerometerData(ts, aX, aY, aZ){}; + : AccelerometerData(ts, aX, aY, aZ) {}; - explicit H3LIS331DLData(AccelerometerData acc) : AccelerometerData(acc){}; + explicit H3LIS331DLData(AccelerometerData acc) : AccelerometerData(acc) {}; static std::string header() { diff --git a/src/shared/sensors/HILSensor.h b/src/shared/sensors/HILSensor.h index d69bf9149..64bfadfc1 100644 --- a/src/shared/sensors/HILSensor.h +++ b/src/shared/sensors/HILSensor.h @@ -71,8 +71,8 @@ public: * the sensor current sample. */ HILSensor(T&& sensor, bool enableHw, UpdateFn updateData) - : T{std::move(sensor)}, enableHw{enableHw}, updateData{ - std::move(updateData)} + : T{std::move(sensor)}, enableHw{enableHw}, + updateData{std::move(updateData)} { } @@ -141,4 +141,4 @@ static void hillificator(std::unique_ptr<T>& sensor, bool enableHw, } } -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/sensors/HX711/HX711.cpp b/src/shared/sensors/HX711/HX711.cpp index 0fb1c8765..33b0bd5a6 100644 --- a/src/shared/sensors/HX711/HX711.cpp +++ b/src/shared/sensors/HX711/HX711.cpp @@ -29,7 +29,7 @@ namespace Boardcore { -HX711::HX711(SPIBusInterface &bus, miosix::GpioPin sckPin, SPIBusConfig config, +HX711::HX711(SPIBusInterface& bus, miosix::GpioPin sckPin, SPIBusConfig config, unsigned char sckAlternateFunction) : bus(bus), sckPin(sckPin), config(config), sckAlternateFunction(sckAlternateFunction) diff --git a/src/shared/sensors/LIS2MDL/LIS2MDL.cpp b/src/shared/sensors/LIS2MDL/LIS2MDL.cpp index 9017aaa36..6ec4d6b0c 100644 --- a/src/shared/sensors/LIS2MDL/LIS2MDL.cpp +++ b/src/shared/sensors/LIS2MDL/LIS2MDL.cpp @@ -244,4 +244,4 @@ LIS2MDLData LIS2MDL::sampleImpl() return newData; } -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/sensors/LIS2MDL/LIS2MDLData.h b/src/shared/sensors/LIS2MDL/LIS2MDLData.h index 327a74f21..41eea28fd 100644 --- a/src/shared/sensors/LIS2MDL/LIS2MDLData.h +++ b/src/shared/sensors/LIS2MDL/LIS2MDLData.h @@ -59,4 +59,4 @@ struct LIS2MDLData : public MagnetometerData, public TemperatureData } }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/sensors/LIS331HH/LIS331HH.h b/src/shared/sensors/LIS331HH/LIS331HH.h index 8df1374b5..36c14f80e 100644 --- a/src/shared/sensors/LIS331HH/LIS331HH.h +++ b/src/shared/sensors/LIS331HH/LIS331HH.h @@ -116,4 +116,4 @@ private: }; }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/sensors/LIS3DSH/LIS3DSH.h b/src/shared/sensors/LIS3DSH/LIS3DSH.h index d41962195..2b386779d 100644 --- a/src/shared/sensors/LIS3DSH/LIS3DSH.h +++ b/src/shared/sensors/LIS3DSH/LIS3DSH.h @@ -250,9 +250,7 @@ public: float delta[3] = {0}; for (uint8_t i = 0; i < 3; i++) - { delta[i] = fabs(AVG_NO_ST[i] - AVG_ST[i]); - } LOG_INFO(logger, "Selftest: delta[x] = {}, delta[y] = {}, delta[z] = {}", @@ -336,13 +334,9 @@ private: TemperatureData tempData = readTemperature(); if (lastError != SensorErrors::NO_ERRORS) - { return lastSample; - } else - { return LIS3DSHData(accelData, tempData); - } } /** diff --git a/src/shared/sensors/LIS3MDL/LIS3MDL.cpp b/src/shared/sensors/LIS3MDL/LIS3MDL.cpp index 34b7ce319..43491b494 100644 --- a/src/shared/sensors/LIS3MDL/LIS3MDL.cpp +++ b/src/shared/sensors/LIS3MDL/LIS3MDL.cpp @@ -148,7 +148,6 @@ bool LIS3MDL::selfTest() bool LIS3MDL::applyConfig(Config config) { - SPITransaction spi(slave); uint8_t reg = 0, err = 0; @@ -156,9 +155,7 @@ bool LIS3MDL::applyConfig(Config config) // CTRL_REG1 if (config.temperatureDivider != 0) - { reg = ENABLE_TEMPERATURE; - } reg |= config.odr; // odr <= 80Hz diff --git a/src/shared/sensors/LPS22DF/LPS22DF.h b/src/shared/sensors/LPS22DF/LPS22DF.h index 63a761dd6..3c4180051 100644 --- a/src/shared/sensors/LPS22DF/LPS22DF.h +++ b/src/shared/sensors/LPS22DF/LPS22DF.h @@ -150,4 +150,4 @@ private: PrintLogger logger = Logging::getLogger("lps22df"); }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/sensors/LPS22DF/LPS22DFData.h b/src/shared/sensors/LPS22DF/LPS22DFData.h index 5867f4e52..2f8242c20 100644 --- a/src/shared/sensors/LPS22DF/LPS22DFData.h +++ b/src/shared/sensors/LPS22DF/LPS22DFData.h @@ -32,8 +32,8 @@ struct LPS22DFData : public PressureData, public TemperatureData LPS22DFData() : PressureData{0, 0.0}, TemperatureData{0, 0.0} {} LPS22DFData(uint64_t timestamp, float pressure, float temperature) - : PressureData{timestamp, pressure}, TemperatureData{timestamp, - temperature} + : PressureData{timestamp, pressure}, + TemperatureData{timestamp, temperature} { } diff --git a/src/shared/sensors/LPS22DF/LPS22DFDefs.h b/src/shared/sensors/LPS22DF/LPS22DFDefs.h index 62dc2e0c0..946fcbee6 100644 --- a/src/shared/sensors/LPS22DF/LPS22DFDefs.h +++ b/src/shared/sensors/LPS22DF/LPS22DFDefs.h @@ -121,4 +121,4 @@ enum STATUS : uint8_t } // namespace LPS22DFDefs -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/sensors/LPS28DFW/LPS28DFW.h b/src/shared/sensors/LPS28DFW/LPS28DFW.h index 2f2cf5010..dbb45e556 100644 --- a/src/shared/sensors/LPS28DFW/LPS28DFW.h +++ b/src/shared/sensors/LPS28DFW/LPS28DFW.h @@ -178,4 +178,4 @@ private: PrintLogger logger = Logging::getLogger("lps28dfw"); }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/sensors/LPS28DFW/LPS28DFWData.h b/src/shared/sensors/LPS28DFW/LPS28DFWData.h index 9f3f38d22..844b64e40 100644 --- a/src/shared/sensors/LPS28DFW/LPS28DFWData.h +++ b/src/shared/sensors/LPS28DFW/LPS28DFWData.h @@ -33,7 +33,6 @@ namespace Boardcore */ struct LPS28DFWData : public PressureData, TemperatureData { - LPS28DFWData() : PressureData{0, 0.0}, TemperatureData{0, 0.0} {} LPS28DFWData(uint64_t pressT, float pressure, uint64_t tempT, diff --git a/src/shared/sensors/LPS28DFW/LPS28DFWDefs.h b/src/shared/sensors/LPS28DFW/LPS28DFWDefs.h index d189ca321..9a06fb5f0 100644 --- a/src/shared/sensors/LPS28DFW/LPS28DFWDefs.h +++ b/src/shared/sensors/LPS28DFW/LPS28DFWDefs.h @@ -148,4 +148,4 @@ enum STATUS : uint8_t }; } // namespace LPS28DFWDefs -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/sensors/LPS331AP/LPS331AP.cpp b/src/shared/sensors/LPS331AP/LPS331AP.cpp index 2c46041ab..f8ffe77ab 100644 --- a/src/shared/sensors/LPS331AP/LPS331AP.cpp +++ b/src/shared/sensors/LPS331AP/LPS331AP.cpp @@ -33,9 +33,7 @@ LPS331AP::LPS331AP(I2C& bus, ODR odr) : bus(bus), odr(odr) {} bool LPS331AP::init() { if (!checkWhoAmI()) - { return false; - } uint8_t ctrlReg1 = 0; ctrlReg1 |= 0x80; // Active mode @@ -43,7 +41,6 @@ bool LPS331AP::init() if (!bus.writeRegister(slaveConfig, REG_CTRL_REG1, ctrlReg1)) { - lastError = SensorErrors::BUS_FAULT; return false; } diff --git a/src/shared/sensors/LPS331AP/LPS331APData.h b/src/shared/sensors/LPS331AP/LPS331APData.h index 10bf25b21..7f145ef59 100644 --- a/src/shared/sensors/LPS331AP/LPS331APData.h +++ b/src/shared/sensors/LPS331AP/LPS331APData.h @@ -29,14 +29,12 @@ namespace Boardcore struct LPS331APData : public PressureData, TemperatureData { - LPS331APData() : PressureData{0, 0.0}, TemperatureData{0, 0.0} {} LPS331APData(uint64_t pressureTimestamp, float pressure, uint64_t temperatureTimestamp, float temperature) - : PressureData{pressureTimestamp, pressure}, TemperatureData{ - temperatureTimestamp, - temperature} + : PressureData{pressureTimestamp, pressure}, + TemperatureData{temperatureTimestamp, temperature} { } diff --git a/src/shared/sensors/LSM6DSRX/LSM6DSRX.cpp b/src/shared/sensors/LSM6DSRX/LSM6DSRX.cpp index 3294db578..9508ad896 100644 --- a/src/shared/sensors/LSM6DSRX/LSM6DSRX.cpp +++ b/src/shared/sensors/LSM6DSRX/LSM6DSRX.cpp @@ -52,9 +52,7 @@ LSM6DSRX::LSM6DSRX(SPIBus& bus, miosix::GpioPin csPin, // check that ACC_ODR is set to HZ_1_6 only if OPERATING_MODE is equal to // NORMAL if (config.odrAcc == LSM6DSRXConfig::ACC_ODR::HZ_1_6) - { config.opModeAcc = LSM6DSRXConfig::OPERATING_MODE::NORMAL; - } } bool LSM6DSRX::init() @@ -680,9 +678,7 @@ LSM6DSRXData LSM6DSRX::sampleImpl() lastError = SensorErrors::NO_ERRORS; if (config.fifoMode == LSM6DSRXConfig::FIFO_MODE::BYPASS) - { return getSensorData(); - } readFromFifo(); @@ -831,9 +827,7 @@ void LSM6DSRX::readFromFifo() // Check if we can push into fifo (both samples are present) if (timestamps[timeslotTag].accPresent) - { pushIntoFifo(timestamps[timeslotTag], idxFifo); - } break; case 0x02: @@ -852,9 +846,7 @@ void LSM6DSRX::readFromFifo() // Check if we can push into fifo (both samples are present) if (timestamps[timeslotTag].gyrPresent) - { pushIntoFifo(timestamps[timeslotTag], idxFifo); - } break; case 0x04: diff --git a/src/shared/sensors/LSM6DSRX/LSM6DSRXConfig.h b/src/shared/sensors/LSM6DSRX/LSM6DSRXConfig.h index 2db415c0f..70d4d692c 100644 --- a/src/shared/sensors/LSM6DSRX/LSM6DSRXConfig.h +++ b/src/shared/sensors/LSM6DSRX/LSM6DSRXConfig.h @@ -29,7 +29,6 @@ namespace Boardcore struct LSM6DSRXConfig { - /** * @brief Output data rate definitions for the accelerometer. * diff --git a/src/shared/sensors/MAX31855/MAX31855.h b/src/shared/sensors/MAX31855/MAX31855.h index 9391e6099..0cd761900 100644 --- a/src/shared/sensors/MAX31855/MAX31855.h +++ b/src/shared/sensors/MAX31855/MAX31855.h @@ -43,7 +43,7 @@ namespace Boardcore class MAX31855 : public Sensor<TemperatureData> { public: - MAX31855(SPIBusInterface &bus, miosix::GpioPin cs, + MAX31855(SPIBusInterface& bus, miosix::GpioPin cs, SPIBusConfig config = getDefaultSPIConfig()); static SPIBusConfig getDefaultSPIConfig(); diff --git a/src/shared/sensors/MAX31856/MAX31856.cpp b/src/shared/sensors/MAX31856/MAX31856.cpp index dcafa6376..1f96a8514 100644 --- a/src/shared/sensors/MAX31856/MAX31856.cpp +++ b/src/shared/sensors/MAX31856/MAX31856.cpp @@ -44,7 +44,6 @@ SPIBusConfig MAX31856::getDefaultSPIConfig() bool MAX31856::init() { - // Set thermocouple type setThermocoupleType(type); diff --git a/src/shared/sensors/MAX31856/MAX31856.h b/src/shared/sensors/MAX31856/MAX31856.h index 1b4a408ba..557d9796a 100644 --- a/src/shared/sensors/MAX31856/MAX31856.h +++ b/src/shared/sensors/MAX31856/MAX31856.h @@ -61,7 +61,7 @@ public: GAIN_32 = 0x9, }; - MAX31856(SPIBusInterface &bus, miosix::GpioPin cs, + MAX31856(SPIBusInterface& bus, miosix::GpioPin cs, SPIBusConfig config = getDefaultSPIConfig(), ThermocoupleType type = ThermocoupleType::K_TYPE); diff --git a/src/shared/sensors/MAX31856/MAX31856Data.h b/src/shared/sensors/MAX31856/MAX31856Data.h index ebd5742eb..c3ccd3175 100644 --- a/src/shared/sensors/MAX31856/MAX31856Data.h +++ b/src/shared/sensors/MAX31856/MAX31856Data.h @@ -62,4 +62,4 @@ struct MAX31856Data : public TemperatureData } }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/sensors/MAX6675/MAX6675.cpp b/src/shared/sensors/MAX6675/MAX6675.cpp index e12ecccb2..83c92fa0b 100644 --- a/src/shared/sensors/MAX6675/MAX6675.cpp +++ b/src/shared/sensors/MAX6675/MAX6675.cpp @@ -27,7 +27,7 @@ namespace Boardcore { -MAX6675::MAX6675(SPIBusInterface &bus, miosix::GpioPin cs, SPIBusConfig config) +MAX6675::MAX6675(SPIBusInterface& bus, miosix::GpioPin cs, SPIBusConfig config) : slave(bus, cs, config) { } diff --git a/src/shared/sensors/MAX6675/MAX6675.h b/src/shared/sensors/MAX6675/MAX6675.h index 743a46fc8..647e9dea2 100644 --- a/src/shared/sensors/MAX6675/MAX6675.h +++ b/src/shared/sensors/MAX6675/MAX6675.h @@ -36,7 +36,7 @@ namespace Boardcore class MAX6675 : public Sensor<TemperatureData> { public: - MAX6675(SPIBusInterface &bus, miosix::GpioPin cs, + MAX6675(SPIBusInterface& bus, miosix::GpioPin cs, SPIBusConfig config = getDefaultSPIConfig()); static SPIBusConfig getDefaultSPIConfig(); diff --git a/src/shared/sensors/MBLoadCell/MBLoadCell.cpp b/src/shared/sensors/MBLoadCell/MBLoadCell.cpp index 6fd07f1dd..e80cbcb4b 100644 --- a/src/shared/sensors/MBLoadCell/MBLoadCell.cpp +++ b/src/shared/sensors/MBLoadCell/MBLoadCell.cpp @@ -33,7 +33,7 @@ using ctrlPin2 = miosix::Gpio<GPIOC_BASE, 2>; ///< Control R/W pin 2 namespace Boardcore { -MBLoadCell::MBLoadCell(USARTInterface &serial, LoadCellModes mode) +MBLoadCell::MBLoadCell(USARTInterface& serial, LoadCellModes mode) : serial(serial) { this->settings.mode = mode; @@ -250,7 +250,7 @@ MBLoadCellData MBLoadCell::sampleAsciiModTd() } } -void MBLoadCell::generateRequest(DataAsciiRequest &req, +void MBLoadCell::generateRequest(DataAsciiRequest& req, const LoadCellValuesEnum toRequest, int value) { strcpy(req.req, loadCellValues[toRequest].c_str()); @@ -272,7 +272,7 @@ void MBLoadCell::generateRequest(DataAsciiRequest &req, req.setChecksum(); } -void MBLoadCell::transmitASCII(const std::string &buf) +void MBLoadCell::transmitASCII(const std::string& buf) { // Setting both the control pins to high in order to transmit ctrlPin1::high(); @@ -295,7 +295,7 @@ std::string MBLoadCell::receiveASCII() } template <typename T> -void MBLoadCell::receive(T *buf) +void MBLoadCell::receive(T* buf) { // Setting both the control pins to low in order to receive ctrlPin1::low(); diff --git a/src/shared/sensors/MBLoadCell/MBLoadCell.h b/src/shared/sensors/MBLoadCell/MBLoadCell.h index 1eb6fcdba..cc3f4c063 100644 --- a/src/shared/sensors/MBLoadCell/MBLoadCell.h +++ b/src/shared/sensors/MBLoadCell/MBLoadCell.h @@ -56,7 +56,7 @@ public: * @param mode the mode in which the load cell is in * @param serial the serial port to be used */ - MBLoadCell(USARTInterface &serial, LoadCellModes mode); + MBLoadCell(USARTInterface& serial, LoadCellModes mode); /** * @brief Initializes the serial communication with the load cell. @@ -126,7 +126,7 @@ protected: * @param value The value used in the forging of the "set point" * requests. */ - void generateRequest(DataAsciiRequest &req, + void generateRequest(DataAsciiRequest& req, const LoadCellValuesEnum toRequest, int value = 0); /** @@ -135,7 +135,7 @@ protected: * * @param buf The message to send. */ - void transmitASCII(const std::string &buf); + void transmitASCII(const std::string& buf); /** * @brief Wrapper to the serial recvString method. This also sets the @@ -153,7 +153,7 @@ protected: * stored. */ template <typename T> - void receive(T *buf); + void receive(T* buf); private: MBLoadCellSettings settings; ///< Contains all the configuration @@ -165,7 +165,7 @@ private: bool minPrint; ///< Pointer to the instance of the serial port used for the connection - USARTInterface &serial; + USARTInterface& serial; }; } // namespace Boardcore diff --git a/src/shared/sensors/MBLoadCell/MBLoadCellData.h b/src/shared/sensors/MBLoadCell/MBLoadCellData.h index 3c9c12495..9b7018d58 100644 --- a/src/shared/sensors/MBLoadCell/MBLoadCellData.h +++ b/src/shared/sensors/MBLoadCell/MBLoadCellData.h @@ -220,9 +220,7 @@ struct DataAsciiRequest str.append(req); for (unsigned int i = 0; i < str.length(); i++) - { checksum ^= str[i]; - } sprintf(ck, "%x", checksum); } diff --git a/src/shared/sensors/MPU9250/MPU9250.cpp b/src/shared/sensors/MPU9250/MPU9250.cpp index 512bbbea3..02ff3ee28 100644 --- a/src/shared/sensors/MPU9250/MPU9250.cpp +++ b/src/shared/sensors/MPU9250/MPU9250.cpp @@ -80,9 +80,7 @@ bool MPU9250::init() // Init the AK8963 if (!initAk()) - { return false; - } // Set full scale resolution for gyroscope and accelerometer (they are // enabled by default) diff --git a/src/shared/sensors/MS5803/MS5803Data.h b/src/shared/sensors/MS5803/MS5803Data.h index 10eb959bd..98284b83d 100644 --- a/src/shared/sensors/MS5803/MS5803Data.h +++ b/src/shared/sensors/MS5803/MS5803Data.h @@ -42,14 +42,12 @@ struct MS5803CalibrationData struct MS5803Data : public PressureData, TemperatureData { - MS5803Data() : PressureData{0, 0.0}, TemperatureData{0, 0.0} {} MS5803Data(uint64_t pressureTimestamp, float pressure, uint64_t temperatureTimestamp, float temperature) - : PressureData{pressureTimestamp, pressure}, TemperatureData{ - temperatureTimestamp, - temperature} + : PressureData{pressureTimestamp, pressure}, + TemperatureData{temperatureTimestamp, temperature} { } diff --git a/src/shared/sensors/SensorInfo.h b/src/shared/sensors/SensorInfo.h index 1a08751ac..51f91b3c5 100644 --- a/src/shared/sensors/SensorInfo.h +++ b/src/shared/sensors/SensorInfo.h @@ -96,4 +96,4 @@ struct SensorInfo }; }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/sensors/SensorManager.cpp b/src/shared/sensors/SensorManager.cpp index 20f8861c9..e41342143 100644 --- a/src/shared/sensors/SensorManager.cpp +++ b/src/shared/sensors/SensorManager.cpp @@ -179,9 +179,11 @@ bool SensorManager::init(const SensorMap_t& sensorsMap) samplersMap[sensor] = newSampler; if (currentSamplerId == MAX_TASK_ID) + { LOG_WARN(logger, "Max task ID (255) reached in task scheduler, IDs " "will start again from 0"); + } currentSamplerId++; } diff --git a/src/shared/sensors/SensorSampler.cpp b/src/shared/sensors/SensorSampler.cpp index 30183fd2a..1f76175dd 100644 --- a/src/shared/sensors/SensorSampler.cpp +++ b/src/shared/sensors/SensorSampler.cpp @@ -54,17 +54,13 @@ void SensorSampler::toggleSensor(AbstractSensor* sensor, bool isEnabled) void SensorSampler::enableAllSensors() { for (auto& s : sensors) - { s.second.isEnabled = true; - } } void SensorSampler::disableAllSensors() { for (auto& s : sensors) - { s.second.isEnabled = false; - } } void SensorSampler::sampleAndCallback() @@ -91,12 +87,8 @@ unsigned int SensorSampler::getNumSensors() { return sensors.size(); } const SensorInfo SensorSampler::getSensorInfo(AbstractSensor* sensor) { for (auto it = sensors.begin(); it != sensors.end(); ++it) - { if (it->first == sensor) - { return it->second; - } - } LOG_ERR(logger, "Sampler {}: sensor {} not found", this->id, static_cast<void*>(sensor)); diff --git a/src/shared/sensors/UBXGPS/UBXGPSData.h b/src/shared/sensors/UBXGPS/UBXGPSData.h index 43d0df2a9..f4101357f 100644 --- a/src/shared/sensors/UBXGPS/UBXGPSData.h +++ b/src/shared/sensors/UBXGPS/UBXGPSData.h @@ -51,7 +51,7 @@ struct UBXDateTime return "year,month,day,hour,minute,second,nanosecond,accuracy"; } - void print(std::ostream &os) const + void print(std::ostream& os) const { os << year << "," << (int)month << "," << (int)day << "," << (int)hour << "," << (int)minute << "," << (int)second << "," << nanosecond @@ -71,7 +71,7 @@ struct UBXGPSData : public GPSData UBXDateTime::header() + "\n"; } - void print(std::ostream &os) const + void print(std::ostream& os) const { os << gpsTimestamp << "," << latitude << "," << longitude << "," << height << "," << velocityNorth << "," << velocityEast << "," diff --git a/src/shared/sensors/UBXGPS/UBXGPSSerial.cpp b/src/shared/sensors/UBXGPS/UBXGPSSerial.cpp index 380d959a9..c93061a00 100644 --- a/src/shared/sensors/UBXGPS/UBXGPSSerial.cpp +++ b/src/shared/sensors/UBXGPS/UBXGPSSerial.cpp @@ -174,9 +174,8 @@ bool UBXGPSSerial::setSerialCommunication() miosix::Thread::sleep(100); // Change baudrate if (!setBaudrateAndUBX(false)) - { return false; - }; + ; } miosix::Thread::sleep(100); @@ -275,7 +274,9 @@ bool UBXGPSSerial::readUBXFrame(UBXFrame& frame) usart.read(&frame.payloadLength, 2) <= 0 || usart.read(frame.payload, frame.getRealPayloadLength()) <= 0 || usart.read(frame.checksum, 2) <= 0) + { return false; + } if (!frame.isValid()) { @@ -307,8 +308,10 @@ bool UBXGPSSerial::safeWriteUBXFrame(const UBXFrame& frame) for (unsigned int i = 0; i < MAX_TRIES; i++) { if (i > 0) + { LOG_DEBUG(logger, "Retrying (attempt {:#d} of {:#d})...", i + 1, MAX_TRIES); + } if (!writeUBXFrame(frame)) return false; @@ -321,10 +324,14 @@ bool UBXGPSSerial::safeWriteUBXFrame(const UBXFrame& frame) if (ack.isNack()) { if (ack.getAckMessage() == frame.getMessage()) + { LOG_DEBUG(logger, "Received NAK"); + } else + { LOG_DEBUG(logger, "Received NAK for different UBX frame {:04x}", static_cast<uint16_t>(ack.getPayload().ackMessage)); + } continue; } diff --git a/src/shared/sensors/UBXGPS/UBXGPSSpi.cpp b/src/shared/sensors/UBXGPS/UBXGPSSpi.cpp index 1137164b8..72bc7ad12 100644 --- a/src/shared/sensors/UBXGPS/UBXGPSSpi.cpp +++ b/src/shared/sensors/UBXGPS/UBXGPSSpi.cpp @@ -334,8 +334,10 @@ bool UBXGPSSpi::safeWriteUBXFrame(const UBXFrame& frame) for (unsigned int i = 0; i < MAX_TRIES; i++) { if (i > 0) + { LOG_DEBUG(logger, "Retrying (attempt {:#d} of {:#d})...", i + 1, MAX_TRIES); + } if (!writeUBXFrame(frame)) return false; @@ -348,10 +350,14 @@ bool UBXGPSSpi::safeWriteUBXFrame(const UBXFrame& frame) if (ack.isNack()) { if (ack.getAckMessage() == frame.getMessage()) + { LOG_DEBUG(logger, "Received NAK"); + } else + { LOG_DEBUG(logger, "Received NAK for different UBX frame {:04x}", static_cast<uint16_t>(ack.getPayload().ackMessage)); + } continue; } diff --git a/src/shared/sensors/Vectornav/VN100/VN100Serial.cpp b/src/shared/sensors/Vectornav/VN100/VN100Serial.cpp index e0df012ee..70f7eaa3d 100644 --- a/src/shared/sensors/Vectornav/VN100/VN100Serial.cpp +++ b/src/shared/sensors/Vectornav/VN100/VN100Serial.cpp @@ -28,7 +28,7 @@ namespace Boardcore { -VN100Serial::VN100Serial(USART &usart, int baudRate, CRCOptions crc, +VN100Serial::VN100Serial(USART& usart, int baudRate, CRCOptions crc, uint16_t samplePeriod) : usart(usart), baudRate(baudRate), samplePeriod(samplePeriod), crc(crc) { @@ -165,9 +165,7 @@ string VN100Serial::getLastRawSample() { // If not init i return the void string if (!isInit) - { return string(""); - } return string(recvString, recvStringLength); } @@ -227,9 +225,7 @@ VN100SerialData VN100Serial::sampleData() // Before sampling i check for errors if (lastError != SensorErrors::NO_ERRORS) - { return lastSample; - } // Returns Quaternion, Magnetometer, Accelerometer and Gyro usart.writeString(preSampleImuString->c_str()); @@ -294,15 +290,11 @@ bool VN100Serial::disableAsyncMessages(bool waitResponse) // Send the command if (!sendStringCommand(command)) - { return false; - } // Read the answer if (waitResponse) - { recvStringCommand(recvString, recvStringMaxDimension); - } return true; } @@ -329,9 +321,7 @@ bool VN100Serial::configUserSerialPort() // I can send the command if (!sendStringCommand(command)) - { return false; - } // I can open the serial with user's baud rate usart.setBaudrate(baudRate); @@ -368,29 +358,21 @@ bool VN100Serial::setCrc(bool waitResponse) // Send the command if (!sendStringCommand(command)) - { return false; - } // Read the answer if (waitResponse) - { recvStringCommand(recvString, recvStringMaxDimension); - } crc = CRCOptions::CRC_ENABLE_16; // Send the command if (!sendStringCommand(command)) - { return false; - } // Read the answer if (waitResponse) - { recvStringCommand(recvString, recvStringMaxDimension); - } // Restore the crc crc = backup; @@ -454,7 +436,7 @@ bool VN100Serial::selfTestImpl() QuaternionData VN100Serial::sampleQuaternion() { unsigned int indexStart = 0; - char *nextNumber; + char* nextNumber; QuaternionData data; // Look for the second ',' in the string @@ -463,9 +445,7 @@ QuaternionData VN100Serial::sampleQuaternion() for (int i = 0; i < 2; i++) { while (indexStart < recvStringLength && recvString[indexStart] != ',') - { indexStart++; - } indexStart++; } @@ -482,7 +462,7 @@ QuaternionData VN100Serial::sampleQuaternion() MagnetometerData VN100Serial::sampleMagnetometer() { unsigned int indexStart = 0; - char *nextNumber; + char* nextNumber; MagnetometerData data; // Look for the sixth ',' in the string @@ -491,9 +471,7 @@ MagnetometerData VN100Serial::sampleMagnetometer() for (int i = 0; i < 6; i++) { while (indexStart < recvStringLength && recvString[indexStart] != ',') - { indexStart++; - } indexStart++; } @@ -509,7 +487,7 @@ MagnetometerData VN100Serial::sampleMagnetometer() AccelerometerData VN100Serial::sampleAccelerometer() { unsigned int indexStart = 0; - char *nextNumber; + char* nextNumber; AccelerometerData data; // Look for the ninth ',' in the string @@ -518,9 +496,7 @@ AccelerometerData VN100Serial::sampleAccelerometer() for (int i = 0; i < 9; i++) { while (indexStart < recvStringLength && recvString[indexStart] != ',') - { indexStart++; - } indexStart++; } @@ -536,7 +512,7 @@ AccelerometerData VN100Serial::sampleAccelerometer() GyroscopeData VN100Serial::sampleGyroscope() { unsigned int indexStart = 0; - char *nextNumber; + char* nextNumber; GyroscopeData data; // Look for the twelfth ',' in the string @@ -545,9 +521,7 @@ GyroscopeData VN100Serial::sampleGyroscope() for (int i = 0; i < 12; i++) { while (indexStart < recvStringLength && recvString[indexStart] != ',') - { indexStart++; - } indexStart++; } @@ -571,9 +545,7 @@ TemperatureData VN100Serial::sampleTemperature() for (int i = 0; i < 11; i++) { while (indexStart < recvStringLength && recvString[indexStart] != ',') - { indexStart++; - } indexStart++; } @@ -595,9 +567,7 @@ PressureData VN100Serial::samplePressure() for (int i = 0; i < 12; i++) { while (indexStart < recvStringLength && recvString[indexStart] != ',') - { indexStart++; - } indexStart++; } @@ -614,7 +584,7 @@ bool VN100Serial::sendStringCommand(std::string command) { char checksum[4]; // 2 hex + \n + \0 // I convert the calculated checksum in hex using itoa - itoa(calculateChecksum8((uint8_t *)command.c_str(), command.length()), + itoa(calculateChecksum8((uint8_t*)command.c_str(), command.length()), checksum, 16); checksum[2] = '\n'; checksum[3] = '\0'; @@ -625,7 +595,7 @@ bool VN100Serial::sendStringCommand(std::string command) { char checksum[6]; // 4 hex + \n + \0 // I convert the calculated checksum in hex using itoa - itoa(calculateChecksum16((uint8_t *)command.c_str(), command.length()), + itoa(calculateChecksum16((uint8_t*)command.c_str(), command.length()), checksum, 16); checksum[4] = '\n'; checksum[5] = '\0'; @@ -649,20 +619,16 @@ bool VN100Serial::sendStringCommand(std::string command) return true; } -bool VN100Serial::recvStringCommand(char *command, int maxLength) +bool VN100Serial::recvStringCommand(char* command, int maxLength) { int i = 0; // Read the buffer if (!usart.readBlocking(command, maxLength)) - { return false; - } // Iterate until i reach the end or i find \n then i substitute it with a \0 while (i < maxLength && command[i] != '\n') - { i++; - } // Terminate the string command[i] = '\0'; @@ -673,15 +639,13 @@ bool VN100Serial::recvStringCommand(char *command, int maxLength) return true; } -bool VN100Serial::verifyChecksum(char *command, int length) +bool VN100Serial::verifyChecksum(char* command, int length) { int checksumOffset = 0; // I look for the checksum position while (checksumOffset < length && command[checksumOffset] != '*') - { checksumOffset++; - } if (checksumOffset == length) { @@ -703,7 +667,7 @@ bool VN100Serial::verifyChecksum(char *command, int length) // Calculate the checksum and verify (comparison between numerical // checksum to avoid string bugs e.g 0856 != 865) if (strtol(command + checksumOffset + 1, NULL, 16) != - calculateChecksum16((uint8_t *)(command + 1), checksumOffset - 1)) + calculateChecksum16((uint8_t*)(command + 1), checksumOffset - 1)) { TRACE("Different checksum: %s\n", command); return false; @@ -721,7 +685,7 @@ bool VN100Serial::verifyChecksum(char *command, int length) // Calculate the checksum and verify (comparison between numerical // checksum to avoid string bugs e.g 0856 != 865) if (strtol(command + checksumOffset + 1, NULL, 16) != - calculateChecksum8((uint8_t *)(command + 1), checksumOffset - 1)) + calculateChecksum8((uint8_t*)(command + 1), checksumOffset - 1)) { TRACE("Different checksum: %s\n", command); return false; @@ -731,7 +695,7 @@ bool VN100Serial::verifyChecksum(char *command, int length) return true; } -uint8_t VN100Serial::calculateChecksum8(uint8_t *message, int length) +uint8_t VN100Serial::calculateChecksum8(uint8_t* message, int length) { int i; uint8_t result = 0x00; @@ -746,7 +710,7 @@ uint8_t VN100Serial::calculateChecksum8(uint8_t *message, int length) return result; } -uint16_t VN100Serial::calculateChecksum16(uint8_t *message, int length) +uint16_t VN100Serial::calculateChecksum16(uint8_t* message, int length) { int i; uint16_t result = 0x0000; diff --git a/src/shared/sensors/Vectornav/VN100/VN100Serial.h b/src/shared/sensors/Vectornav/VN100/VN100Serial.h index 36ce97ac4..0c1702cf3 100644 --- a/src/shared/sensors/Vectornav/VN100/VN100Serial.h +++ b/src/shared/sensors/Vectornav/VN100/VN100Serial.h @@ -86,7 +86,7 @@ public: * @param Redundancy check option. * @param samplePeriod Sampling period in ms */ - VN100Serial(USART &usart, int baudrate, + VN100Serial(USART& usart, int baudrate, CRCOptions crc = CRCOptions::CRC_ENABLE_8, uint16_t samplePeriod = 20); @@ -207,7 +207,7 @@ private: * * @return True if operation succeeded. */ - bool recvStringCommand(char *command, int maxLength); + bool recvStringCommand(char* command, int maxLength); /** * @brief Method to verify the crc validity of a command. @@ -217,7 +217,7 @@ private: * * @return True if operation succeeded. */ - bool verifyChecksum(char *command, int maxLength); + bool verifyChecksum(char* command, int maxLength); /** * @brief Calculate the 8bit checksum on the given array. @@ -227,7 +227,7 @@ private: * * @return The 8 bit checksum. */ - uint8_t calculateChecksum8(uint8_t *message, int length); + uint8_t calculateChecksum8(uint8_t* message, int length); /** * @brief Calculate the 16bit array on the given array. @@ -237,13 +237,13 @@ private: * * @return The 16 bit CRC16-CCITT error check. */ - uint16_t calculateChecksum16(uint8_t *message, int length); + uint16_t calculateChecksum16(uint8_t* message, int length); /** * @brief Serial interface that is needed to communicate * with the sensor via ASCII codes. */ - USART &usart; + USART& usart; int baudRate; uint16_t samplePeriod; @@ -253,19 +253,19 @@ private: /** * @brief IMU pre-elaborated sample string for efficiency reasons. */ - string *preSampleImuString = nullptr; + string* preSampleImuString = nullptr; /** * @brief Temperature and pressure pre-elaborated sample string for * efficiency reasons. */ - string *preSampleTempPressString = nullptr; + string* preSampleTempPressString = nullptr; /** * @brief Pointer to the received string by the sensor. Allocated 1 time * only (200 bytes). */ - char *recvString = nullptr; + char* recvString = nullptr; /** * @brief Actual strlen() of the recvString. diff --git a/src/shared/sensors/Vectornav/VN100/VN100SerialData.h b/src/shared/sensors/Vectornav/VN100/VN100SerialData.h index 31e903bda..dc1fa4dbf 100644 --- a/src/shared/sensors/Vectornav/VN100/VN100SerialData.h +++ b/src/shared/sensors/Vectornav/VN100/VN100SerialData.h @@ -37,14 +37,13 @@ struct VN100SerialData : public QuaternionData, public TemperatureData, public PressureData { - /** * @brief Void parameters constructor */ // cppcheck-suppress uninitDerivedMemberVar VN100SerialData() - : QuaternionData{0, 0.0, 0.0, 0.0, 0.0}, MagnetometerData{0, 0.0, 0.0, - 0.0}, + : QuaternionData{0, 0.0, 0.0, 0.0, 0.0}, + MagnetometerData{0, 0.0, 0.0, 0.0}, AccelerometerData{0, 0.0, 0.0, 0.0}, GyroscopeData{0, 0.0, 0.0, 0.0}, TemperatureData{0, 0.0}, PressureData{0, 0.0} { diff --git a/src/shared/sensors/Vectornav/VN100/VN100Spi.cpp b/src/shared/sensors/Vectornav/VN100/VN100Spi.cpp index 7caea2a86..61a899cfa 100644 --- a/src/shared/sensors/Vectornav/VN100/VN100Spi.cpp +++ b/src/shared/sensors/Vectornav/VN100/VN100Spi.cpp @@ -78,9 +78,7 @@ bool VN100Spi::checkModelNumber() int i = 0; char buf[VN100SpiDefs::MODEL_NUMBER_SIZE]; for (i = 0; i < VN100SpiDefs::MODEL_NUMBER_SIZE; ++i) - { buf[i] = 0; - } VN100SpiDefs::VNErrors err = readRegister(VN100SpiDefs::REG_MODEL_NUMBER, reinterpret_cast<uint8_t*>(buf), diff --git a/src/shared/sensors/Vectornav/VN100/VN100SpiData.h b/src/shared/sensors/Vectornav/VN100/VN100SpiData.h index 40376473b..efb7cf2cb 100644 --- a/src/shared/sensors/Vectornav/VN100/VN100SpiData.h +++ b/src/shared/sensors/Vectornav/VN100/VN100SpiData.h @@ -40,10 +40,9 @@ struct VN100SpiData : public QuaternionData, public AccelerometerData, public GyroscopeData { - VN100SpiData() - : QuaternionData{0, 0.0, 0.0, 0.0, 0.0}, MagnetometerData{0, 0.0, 0.0, - 0.0}, + : QuaternionData{0, 0.0, 0.0, 0.0, 0.0}, + MagnetometerData{0, 0.0, 0.0, 0.0}, AccelerometerData{0, 0.0, 0.0, 0.0}, GyroscopeData{0, 0.0, 0.0, 0.0} { } diff --git a/src/shared/sensors/Vectornav/VN300/VN300.cpp b/src/shared/sensors/Vectornav/VN300/VN300.cpp old mode 100755 new mode 100644 index ef7b62bfa..fe1d007b6 --- a/src/shared/sensors/Vectornav/VN300/VN300.cpp +++ b/src/shared/sensors/Vectornav/VN300/VN300.cpp @@ -54,13 +54,9 @@ bool VN300::init() // Allocate the pre loaded strings based on the user selected crc if (crc == CRCOptions::CRC_ENABLE_16) - { preSampleBin1 = "$VNBOM,1*749D\n"; - } else - { preSampleBin1 = "$VNBOM,1*45\n"; - } // Set the error to init fail and if the init process goes without problem // i restore it to the last error @@ -184,18 +180,14 @@ VN300Data VN300::sampleFull() sampleOutcome = getBinaryOutput<VN300Defs::BinaryDataFull>(bindataFull, preSampleBin1); if (!sampleOutcome) - { lastError = NO_NEW_DATA; - } validChecksum = crc == CRCOptions::CRC_NO || calculateChecksum16(reinterpret_cast<uint8_t*>(&bindataFull), sizeof(bindataFull)) == 0; if (sampleOutcome && !validChecksum) - { lastError = SensorErrors::BUS_FAULT; - } // Verify if the sample is valid sampleOutcome = sampleOutcome && validChecksum; @@ -226,18 +218,14 @@ VN300Data VN300::sampleReduced() sampleOutcome = getBinaryOutput<VN300Defs::BinaryDataReduced>( binDataReduced, preSampleBin1); if (!sampleOutcome) - { lastError = NO_NEW_DATA; - } validChecksum = crc == CRCOptions::CRC_NO || calculateChecksum16(reinterpret_cast<uint8_t*>(&binDataReduced), sizeof(binDataReduced)) == 0; if (sampleOutcome && !validChecksum) - { lastError = SensorErrors::BUS_FAULT; - } // Verify if the sample is valid sampleOutcome = sampleOutcome && validChecksum; @@ -337,14 +325,10 @@ bool VN300::setAntennaA(VN300Defs::AntennaPosition antPos) usart.clearQueue(); if (!sendStringCommand(command)) - { return false; - } if (!recvStringCommand(recvString.data(), recvStringMaxDimension)) - { return false; - } if (checkErrorVN(recvString.data())) return false; @@ -362,14 +346,10 @@ bool VN300::setCompassBaseline(VN300Defs::AntennaPosition antPos) usart.clearQueue(); if (!sendStringCommand(command)) - { return false; - } if (!recvStringCommand(recvString.data(), recvStringMaxDimension)) - { return false; - } if (checkErrorVN(recvString.data())) return false; @@ -379,7 +359,6 @@ bool VN300::setCompassBaseline(VN300Defs::AntennaPosition antPos) bool VN300::setReferenceFrame(Eigen::Matrix3f rotMat) { - std::string command = fmt::format("{}{},{},{},{},{},{},{},{},{}", "VNWRG,26,", rotMat(0, 0), rotMat(0, 1), rotMat(0, 2), rotMat(1, 0), rotMat(1, 1), @@ -387,14 +366,10 @@ bool VN300::setReferenceFrame(Eigen::Matrix3f rotMat) usart.clearQueue(); if (!sendStringCommand(command)) - { return false; - } if (!recvStringCommand(recvString.data(), recvStringMaxDimension)) - { return false; - } if (checkErrorVN(recvString.data())) return false; @@ -445,9 +420,7 @@ bool VN300::setBinaryOutput() usart.clearQueue(); if (!sendStringCommand(command)) - { return false; - } if (!recvStringCommand(recvString.data(), recvStringMaxDimension)) { diff --git a/src/shared/sensors/Vectornav/VN300/VN300Data.h b/src/shared/sensors/Vectornav/VN300/VN300Data.h index 5953da14c..df8ab71de 100644 --- a/src/shared/sensors/Vectornav/VN300/VN300Data.h +++ b/src/shared/sensors/Vectornav/VN300/VN300Data.h @@ -49,11 +49,10 @@ struct VN300Data : public QuaternionData, public GyroscopeData, public VN300Defs::INSData { - // cppcheck-suppress uninitDerivedMemberVar VN300Data() - : QuaternionData{0, 0.0, 0.0, 0.0, 0.0}, MagnetometerData{0, 0.0, 0.0, - 0.0}, + : QuaternionData{0, 0.0, 0.0, 0.0, 0.0}, + MagnetometerData{0, 0.0, 0.0, 0.0}, AccelerometerData{0, 0.0, 0.0, 0.0}, GyroscopeData{0, 0.0, 0.0, 0.0}, INSData{0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0} { diff --git a/src/shared/sensors/Vectornav/VNCommonSerial.cpp b/src/shared/sensors/Vectornav/VNCommonSerial.cpp index 599e88905..ad1a8cdd2 100644 --- a/src/shared/sensors/Vectornav/VNCommonSerial.cpp +++ b/src/shared/sensors/Vectornav/VNCommonSerial.cpp @@ -28,8 +28,8 @@ namespace Boardcore { -VNCommonSerial::VNCommonSerial(USART &usart, int baudrate, - const char *sensorName, CRCOptions crc, +VNCommonSerial::VNCommonSerial(USART& usart, int baudrate, + const char* sensorName, CRCOptions crc, const std::chrono::milliseconds timeout) : usart(usart), baudRate(baudrate), crc(crc), logger(Logging::getLogger(sensorName)), maxTimeout(timeout) @@ -38,7 +38,7 @@ VNCommonSerial::VNCommonSerial(USART &usart, int baudrate, VNCommonSerial::~VNCommonSerial() {} -uint8_t VNCommonSerial::calculateChecksum8(const uint8_t *message, int length) +uint8_t VNCommonSerial::calculateChecksum8(const uint8_t* message, int length) { int i; uint8_t result = 0x00; @@ -53,7 +53,7 @@ uint8_t VNCommonSerial::calculateChecksum8(const uint8_t *message, int length) return result; } -uint16_t VNCommonSerial::calculateChecksum16(const uint8_t *message, int length) +uint16_t VNCommonSerial::calculateChecksum16(const uint8_t* message, int length) { int i; uint16_t result = 0x0000; @@ -71,15 +71,13 @@ uint16_t VNCommonSerial::calculateChecksum16(const uint8_t *message, int length) return result; } -bool VNCommonSerial::verifyChecksum(char *command, int length) +bool VNCommonSerial::verifyChecksum(char* command, int length) { int checksumOffset = 0; // I look for the checksum position while (checksumOffset < length && command[checksumOffset] != '*') - { checksumOffset++; - } if (checksumOffset == length) { @@ -101,7 +99,7 @@ bool VNCommonSerial::verifyChecksum(char *command, int length) // Calculate the checksum and verify (comparison between numerical // checksum to avoid string bugs e.g 0856 != 865) if (strtol(command + checksumOffset + 1, NULL, 16) != - calculateChecksum16((uint8_t *)(command + 1), checksumOffset - 1)) + calculateChecksum16((uint8_t*)(command + 1), checksumOffset - 1)) { TRACE("Different checksum: %s\n", command); return false; @@ -119,7 +117,7 @@ bool VNCommonSerial::verifyChecksum(char *command, int length) // Calculate the checksum and verify (comparison between numerical // checksum to avoid string bugs e.g 0856 != 865) if (strtol(command + checksumOffset + 1, NULL, 16) != - calculateChecksum8((uint8_t *)(command + 1), checksumOffset - 1)) + calculateChecksum8((uint8_t*)(command + 1), checksumOffset - 1)) { TRACE("Different checksum: %s\n", command); return false; @@ -138,21 +136,15 @@ bool VNCommonSerial::disableAsyncMessages(bool waitResponse) usart.clearQueue(); if (!sendStringCommand(command)) - { return false; - } if (waitResponse) { if (!recvStringCommand(recvString.data(), recvStringMaxDimension)) - { return false; - } if (checkErrorVN(recvString.data())) - { return false; - } } return true; @@ -186,34 +178,26 @@ bool VNCommonSerial::setCrc(bool waitResponse) // Send the command if (!sendStringCommand(command)) - { return false; - } // Read the answer if (waitResponse) { if (!recvStringCommand(recvString.data(), recvStringMaxDimension)) - { return false; - } } crc = CRCOptions::CRC_ENABLE_16; // Send the command if (!sendStringCommand(command)) - { return false; - } // Read the answer if (waitResponse) { if (!recvStringCommand(recvString.data(), recvStringMaxDimension)) - { return false; - } } // Restore the crc @@ -237,9 +221,7 @@ bool VNCommonSerial::configUserSerialPort() // I can send the command if (!sendStringCommand(command)) - { return false; - } // I can open the serial with user's baud rate usart.setBaudrate(baudRate); @@ -248,7 +230,7 @@ bool VNCommonSerial::configUserSerialPort() return true; } -bool VNCommonSerial::verifyModelNumber(const char *expectedModelNumber) +bool VNCommonSerial::verifyModelNumber(const char* expectedModelNumber) { // The model number starts from the 10th position const int modelNumberOffset = 10; @@ -290,7 +272,7 @@ bool VNCommonSerial::verifyModelNumber(const char *expectedModelNumber) QuaternionData VNCommonSerial::sampleQuaternion() { unsigned int indexStart = 0; - char *nextNumber; + char* nextNumber; QuaternionData data; // Look for the second ',' in the string @@ -299,9 +281,7 @@ QuaternionData VNCommonSerial::sampleQuaternion() for (int i = 0; i < 2; i++) { while (indexStart < recvStringLength && recvString[indexStart] != ',') - { indexStart++; - } indexStart++; } @@ -318,7 +298,7 @@ QuaternionData VNCommonSerial::sampleQuaternion() MagnetometerData VNCommonSerial::sampleMagnetometer() { unsigned int indexStart = 0; - char *nextNumber; + char* nextNumber; MagnetometerData data; // Look for the sixth ',' in the string @@ -327,9 +307,7 @@ MagnetometerData VNCommonSerial::sampleMagnetometer() for (int i = 0; i < 6; i++) { while (indexStart < recvStringLength && recvString[indexStart] != ',') - { indexStart++; - } indexStart++; } @@ -346,7 +324,7 @@ MagnetometerData VNCommonSerial::sampleMagnetometer() AccelerometerData VNCommonSerial::sampleAccelerometer() { unsigned int indexStart = 0; - char *nextNumber; + char* nextNumber; AccelerometerData data; // Look for the ninth ',' in the string @@ -355,9 +333,7 @@ AccelerometerData VNCommonSerial::sampleAccelerometer() for (int i = 0; i < 9; i++) { while (indexStart < recvStringLength && recvString[indexStart] != ',') - { indexStart++; - } indexStart++; } @@ -374,7 +350,7 @@ AccelerometerData VNCommonSerial::sampleAccelerometer() GyroscopeData VNCommonSerial::sampleGyroscope() { unsigned int indexStart = 0; - char *nextNumber; + char* nextNumber; GyroscopeData data; // Look for the twelfth ',' in the string @@ -383,9 +359,7 @@ GyroscopeData VNCommonSerial::sampleGyroscope() for (int i = 0; i < 12; i++) { while (indexStart < recvStringLength && recvString[indexStart] != ',') - { indexStart++; - } indexStart++; } @@ -399,7 +373,7 @@ GyroscopeData VNCommonSerial::sampleGyroscope() return data; } -uint8_t VNCommonSerial::checkErrorVN(const char *message) +uint8_t VNCommonSerial::checkErrorVN(const char* message) { if (strncmp(message, "$VNERR,", 7) == 0) { @@ -431,7 +405,7 @@ bool VNCommonSerial::sendStringCommand(std::string command) { char checksum[4]; // 2 hex + \n + \0 // I convert the calculated checksum in hex using itoa - itoa(calculateChecksum8((uint8_t *)command.c_str(), command.length()), + itoa(calculateChecksum8((uint8_t*)command.c_str(), command.length()), checksum, 16); checksum[2] = '\n'; checksum[3] = '\0'; @@ -442,7 +416,7 @@ bool VNCommonSerial::sendStringCommand(std::string command) { char checksum[6]; // 4 hex + \n + \0 // I convert the calculated checksum in hex using itoa - itoa(calculateChecksum16((uint8_t *)command.c_str(), command.length()), + itoa(calculateChecksum16((uint8_t*)command.c_str(), command.length()), checksum, 16); checksum[4] = '\n'; checksum[5] = '\0'; @@ -476,20 +450,16 @@ bool VNCommonSerial::sendStringCommand(std::string command) return true; } -bool VNCommonSerial::recvStringCommand(char *command, int maxLength) +bool VNCommonSerial::recvStringCommand(char* command, int maxLength) { int i = 0; // Read the buffer if (!usart.readBlocking(command, maxLength, maxTimeout)) - { return false; - } // Iterate until i reach the end or i find \n then i substitute it with a \0 while (i < maxLength && command[i] != '\n') - { i++; - } // Terminate the string command[i] = '\0'; diff --git a/src/shared/sensors/Vectornav/VNCommonSerial.h b/src/shared/sensors/Vectornav/VNCommonSerial.h index e25b6d225..66ab3a6ac 100644 --- a/src/shared/sensors/Vectornav/VNCommonSerial.h +++ b/src/shared/sensors/Vectornav/VNCommonSerial.h @@ -49,7 +49,7 @@ public: * @param timeout The maximum time that will be waited when reading from the * sensor. */ - VNCommonSerial(USART &usart, int baudrate, const char *sensorName, + VNCommonSerial(USART& usart, int baudrate, const char* sensorName, CRCOptions crc, const std::chrono::milliseconds timeout); ~VNCommonSerial(); @@ -71,7 +71,7 @@ protected: * * @return The 8 bit checksum. */ - uint8_t calculateChecksum8(const uint8_t *message, int length); + uint8_t calculateChecksum8(const uint8_t* message, int length); /** * @brief Calculate the 16bit array on the given array. @@ -81,7 +81,7 @@ protected: * * @return The 16 bit CRC16-CCITT error check. */ - uint16_t calculateChecksum16(const uint8_t *message, int length); + uint16_t calculateChecksum16(const uint8_t* message, int length); /** * @brief Method to verify the crc validity of a command. @@ -91,7 +91,7 @@ protected: * * @return True if operation succeeded. */ - bool verifyChecksum(char *command, int maxLength); + bool verifyChecksum(char* command, int maxLength); /** * @brief Disables the async messages that the sensor is default configured @@ -132,7 +132,7 @@ protected: * @return True if the model number received from the sensor corresponds * with the expected one. */ - bool verifyModelNumber(const char *expectedModelNumber); + bool verifyModelNumber(const char* expectedModelNumber); /** * @brief Utility function used to retrieve the binary output from the @@ -143,7 +143,7 @@ protected: * @return True if operation successful, false otherwise. */ template <typename T> - bool getBinaryOutput(T &binaryData, const char *const sampleCommand); + bool getBinaryOutput(T& binaryData, const char* const sampleCommand); /** * @brief Utility function used to extract quaternion data from the @@ -177,7 +177,7 @@ protected: * @return Returns 0 if no error was found, else returns the actual error * code. */ - uint8_t checkErrorVN(const char *message); + uint8_t checkErrorVN(const char* message); /** * @brief Sends the command to the sensor with the correct checksum added @@ -202,13 +202,13 @@ protected: * * @return True if operation succeeded. */ - bool recvStringCommand(char *command, int maxLength); + bool recvStringCommand(char* command, int maxLength); /** * @brief Serial interface that is needed to communicate * with the sensor via ASCII codes. */ - USART &usart; + USART& usart; int baudRate; CRCOptions crc; @@ -246,8 +246,8 @@ private: }; template <typename T> -bool VNCommonSerial::getBinaryOutput(T &binaryData, - const char *const sampleCommand) +bool VNCommonSerial::getBinaryOutput(T& binaryData, + const char* const sampleCommand) { uint8_t initByte = 0; @@ -260,9 +260,7 @@ bool VNCommonSerial::getBinaryOutput(T &binaryData, if (usart.readBlocking(&initByte, 1, maxTimeout) && initByte == 0xFA) { if (usart.readBlocking(&binaryData, sizeof(T), maxTimeout)) - { return true; - } } return false; diff --git a/src/shared/sensors/analog/CurrentSensor.h b/src/shared/sensors/analog/CurrentSensor.h index d871b9182..e57b8e8f6 100644 --- a/src/shared/sensors/analog/CurrentSensor.h +++ b/src/shared/sensors/analog/CurrentSensor.h @@ -57,9 +57,7 @@ protected: ADCData adc_data = getVoltage(); if (lastSample.current == 0) - { lastSample.current = voltageToCurrent(adc_data.voltage); - } CurrentData current_data; current_data.currentTimestamp = adc_data.voltageTimestamp; diff --git a/src/shared/sensors/analog/TrafagPressureSensor.h b/src/shared/sensors/analog/TrafagPressureSensor.h index a0539c62f..876734e70 100644 --- a/src/shared/sensors/analog/TrafagPressureSensor.h +++ b/src/shared/sensors/analog/TrafagPressureSensor.h @@ -49,8 +49,8 @@ public: float shuntResistance, float maxPressure, float minCurrent = 4, float maxCurrent = 20) : getVoltage{getVoltage}, shuntResistance{shuntResistance}, - maxPressure{maxPressure}, minCurrent{minCurrent}, maxCurrent{ - maxCurrent} + maxPressure{maxPressure}, minCurrent{minCurrent}, + maxCurrent{maxCurrent} { } @@ -86,4 +86,4 @@ private: const float maxCurrent; }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/sensors/analog/TwoPointAnalogLoadCell.h b/src/shared/sensors/analog/TwoPointAnalogLoadCell.h index fa620b6d1..0a2051d61 100644 --- a/src/shared/sensors/analog/TwoPointAnalogLoadCell.h +++ b/src/shared/sensors/analog/TwoPointAnalogLoadCell.h @@ -47,8 +47,8 @@ public: */ TwoPointAnalogLoadCell(std::function<ADCData()> getVoltage, float p0Voltage, float p0Mass, float p1Voltage, float p1Mass) - : getVoltage{getVoltage}, staticScale{(p1Mass - p0Mass) / - (p1Voltage - p0Voltage)}, + : getVoltage{getVoltage}, + staticScale{(p1Mass - p0Mass) / (p1Voltage - p0Voltage)}, staticOffset{p0Mass - staticScale * p0Voltage} { } @@ -113,4 +113,4 @@ private: const float staticOffset; }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/sensors/calibration/SoftAndHardIronCalibration/SoftAndHardIronCalibration.cpp b/src/shared/sensors/calibration/SoftAndHardIronCalibration/SoftAndHardIronCalibration.cpp index 4f28da12f..ccb1e5cd6 100644 --- a/src/shared/sensors/calibration/SoftAndHardIronCalibration/SoftAndHardIronCalibration.cpp +++ b/src/shared/sensors/calibration/SoftAndHardIronCalibration/SoftAndHardIronCalibration.cpp @@ -63,11 +63,13 @@ SixParametersCorrector SoftAndHardIronCalibration::computeResult() int minIdx = 0; for (int i = 0; i < eigenValues.rows(); i++) + { if (minValue > eigenValues[i]) { minValue = eigenValues[i]; minIdx = i; } + } Eigen::Matrix<float, 7, 1> vec = solver.eigenvectors().col(minIdx); // Invert the vector if necessary diff --git a/src/shared/units/Acceleration.h b/src/shared/units/Acceleration.h index 92351a547..aa61a369f 100644 --- a/src/shared/units/Acceleration.h +++ b/src/shared/units/Acceleration.h @@ -37,7 +37,7 @@ template <class Ratio = std::ratio<1>> using Acceleration = Unit<UnitKind::Acceleration, Ratio>; template <class ToAcceleration, class FromAcceleration> -ToAcceleration acceleration_cast(FromAcceleration const &from) +ToAcceleration acceleration_cast(FromAcceleration const& from) { return ToAcceleration(from); } @@ -63,4 +63,4 @@ constexpr auto operator""_g(unsigned long long n) } // namespace Acceleration } // namespace Units -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/units/Angle.h b/src/shared/units/Angle.h index a8cef5827..b2ef8ae3e 100644 --- a/src/shared/units/Angle.h +++ b/src/shared/units/Angle.h @@ -37,7 +37,7 @@ template <class Ratio = std::ratio<1>> using Angle = Unit<UnitKind::Angle, Ratio>; template <class ToAngle, class FromAngle> -ToAngle angle_cast(FromAngle const &from) +ToAngle angle_cast(FromAngle const& from) { return ToAngle(from); } @@ -68,4 +68,4 @@ constexpr auto operator""_deg(unsigned long long n) } // namespace Angle } // namespace Units -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/units/Length.h b/src/shared/units/Length.h index 6e0f99521..a5870752d 100644 --- a/src/shared/units/Length.h +++ b/src/shared/units/Length.h @@ -37,7 +37,7 @@ template <class Ratio = std::ratio<1>> using Length = Unit<UnitKind::Length, Ratio>; template <class ToLength, class FromLength> -ToLength length_cast(FromLength const &from) +ToLength length_cast(FromLength const& from) { return ToLength(from); } @@ -93,4 +93,4 @@ constexpr auto operator""_km(unsigned long long n) } // namespace Length } // namespace Units -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/units/Pressure.h b/src/shared/units/Pressure.h index a2cfa6e8b..02b1e403e 100644 --- a/src/shared/units/Pressure.h +++ b/src/shared/units/Pressure.h @@ -37,7 +37,7 @@ template <class Ratio = std::ratio<1>> using Pressure = Unit<UnitKind::Pressure, Ratio>; template <class ToPressure, class FromPressure> -ToPressure pressure_cast(FromPressure const &from) +ToPressure pressure_cast(FromPressure const& from) { return ToPressure(from); } @@ -75,4 +75,4 @@ constexpr auto operator""_atm(unsigned long long n) } // namespace Pressure } // namespace Units -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/units/Speed.h b/src/shared/units/Speed.h index 06f04c824..0dbb279a8 100644 --- a/src/shared/units/Speed.h +++ b/src/shared/units/Speed.h @@ -37,7 +37,7 @@ template <class Ratio = std::ratio<1>> using Speed = Unit<UnitKind::Speed, Ratio>; template <class ToSpeed, class FromSpeed> -ToSpeed speed_cast(FromSpeed const &from) +ToSpeed speed_cast(FromSpeed const& from) { return ToSpeed(from); } @@ -67,4 +67,4 @@ constexpr auto operator""_kmh(unsigned long long n) } // namespace Speed } // namespace Units -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/units/Time.h b/src/shared/units/Time.h index 70ff0971d..767877a3f 100644 --- a/src/shared/units/Time.h +++ b/src/shared/units/Time.h @@ -38,12 +38,12 @@ template <class Ratio = std::ratio<1>> using Time = Unit<UnitKind::Time, Ratio>; template <class ToTime, class FromTime> -ToTime time_cast(FromTime const &from) +ToTime time_cast(FromTime const& from) { return ToTime(from); } -std::chrono::duration<float> to_chrono(Time<> const &from) +std::chrono::duration<float> to_chrono(Time<> const& from) { return std::chrono::duration<float>(from.value()); } @@ -108,4 +108,4 @@ constexpr auto operator""_h(unsigned long long n) } // namespace Time } // namespace Units -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/units/Units.h b/src/shared/units/Units.h index 44fea2e8b..f4f382139 100644 --- a/src/shared/units/Units.h +++ b/src/shared/units/Units.h @@ -51,7 +51,7 @@ public: constexpr explicit Unit(float val) : _value(val) {} template <UnitKind FromKind, class FromRatio> - constexpr explicit Unit(Unit<FromKind, FromRatio> const &from) + constexpr explicit Unit(Unit<FromKind, FromRatio> const& from) : _value(from.template value<Ratio>()) { } @@ -80,112 +80,112 @@ private: // Sum, Subtraction, Multiplication, Division template <UnitKind Kind, class Ratio> -constexpr auto operator+(const Unit<Kind, Ratio> &lhs, - const Unit<Kind, Ratio> &rhs) +constexpr auto operator+(const Unit<Kind, Ratio>& lhs, + const Unit<Kind, Ratio>& rhs) { return Unit<Kind, Ratio>(lhs.template value() + rhs.template value()); } template <UnitKind Kind, class Ratio> -constexpr auto operator-(const Unit<Kind, Ratio> &lhs, - const Unit<Kind, Ratio> &rhs) +constexpr auto operator-(const Unit<Kind, Ratio>& lhs, + const Unit<Kind, Ratio>& rhs) { return Unit<Kind, Ratio>(lhs.template value() - rhs.template value()); } template <UnitKind Kind, class Ratio> -constexpr auto operator*(const Unit<Kind, Ratio> &lhs, float rhs) +constexpr auto operator*(const Unit<Kind, Ratio>& lhs, float rhs) { return Unit<Kind, Ratio>(lhs.template value() * rhs); } template <UnitKind Kind, class Ratio> -constexpr auto operator*(float lhs, const Unit<Kind, Ratio> &rhs) +constexpr auto operator*(float lhs, const Unit<Kind, Ratio>& rhs) { return Unit<Kind, Ratio>(lhs * rhs.template value()); } template <UnitKind Kind, class Ratio> -constexpr auto operator/(const Unit<Kind, Ratio> &lhs, float rhs) +constexpr auto operator/(const Unit<Kind, Ratio>& lhs, float rhs) { return Unit<Kind, Ratio>(lhs.template value() / rhs); } template <UnitKind Kind, class Ratio> -constexpr auto operator/(float lhs, const Unit<Kind, Ratio> &rhs) +constexpr auto operator/(float lhs, const Unit<Kind, Ratio>& rhs) { return Unit<Kind, Ratio>(lhs / rhs.template value()); } // Comparison operators template <UnitKind Kind, class Ratio> -constexpr bool operator==(const Unit<Kind, Ratio> &lhs, - const Unit<Kind, Ratio> &rhs) +constexpr bool operator==(const Unit<Kind, Ratio>& lhs, + const Unit<Kind, Ratio>& rhs) { return lhs.template value() == rhs.template value(); } template <UnitKind Kind, class Ratio> -constexpr bool operator!=(const Unit<Kind, Ratio> &lhs, - const Unit<Kind, Ratio> &rhs) +constexpr bool operator!=(const Unit<Kind, Ratio>& lhs, + const Unit<Kind, Ratio>& rhs) { return lhs.template value() != rhs.template value(); } template <UnitKind Kind, class Ratio> -constexpr bool operator<(const Unit<Kind, Ratio> &lhs, - const Unit<Kind, Ratio> &rhs) +constexpr bool operator<(const Unit<Kind, Ratio>& lhs, + const Unit<Kind, Ratio>& rhs) { return lhs.template value() < rhs.template value(); } template <UnitKind Kind, class Ratio> -constexpr bool operator>(const Unit<Kind, Ratio> &lhs, - const Unit<Kind, Ratio> &rhs) +constexpr bool operator>(const Unit<Kind, Ratio>& lhs, + const Unit<Kind, Ratio>& rhs) { return lhs.template value() > rhs.template value(); } template <UnitKind Kind, class Ratio> -constexpr bool operator<=(const Unit<Kind, Ratio> &lhs, - const Unit<Kind, Ratio> &rhs) +constexpr bool operator<=(const Unit<Kind, Ratio>& lhs, + const Unit<Kind, Ratio>& rhs) { return lhs.template value() <= rhs.template value(); } template <UnitKind Kind, class Ratio> -constexpr bool operator>=(const Unit<Kind, Ratio> &lhs, - const Unit<Kind, Ratio> &rhs) +constexpr bool operator>=(const Unit<Kind, Ratio>& lhs, + const Unit<Kind, Ratio>& rhs) { return lhs.template value() >= rhs.template value(); } // Direct assignment operators template <UnitKind Kind, class Ratio> -constexpr Unit<Kind, Ratio> &operator+=(Unit<Kind, Ratio> &lhs, - const Unit<Kind, Ratio> &rhs) +constexpr Unit<Kind, Ratio>& operator+=(Unit<Kind, Ratio>& lhs, + const Unit<Kind, Ratio>& rhs) { lhs = lhs + rhs; return lhs; } template <UnitKind Kind, class Ratio> -constexpr Unit<Kind, Ratio> &operator-=(Unit<Kind, Ratio> &lhs, - const Unit<Kind, Ratio> &rhs) +constexpr Unit<Kind, Ratio>& operator-=(Unit<Kind, Ratio>& lhs, + const Unit<Kind, Ratio>& rhs) { lhs = lhs - rhs; return lhs; } template <UnitKind Kind, class Ratio> -constexpr Unit<Kind, Ratio> &operator*=(Unit<Kind, Ratio> &lhs, float rhs) +constexpr Unit<Kind, Ratio>& operator*=(Unit<Kind, Ratio>& lhs, float rhs) { lhs = lhs * rhs; return lhs; } template <UnitKind Kind, class Ratio> -constexpr Unit<Kind, Ratio> &operator/=(Unit<Kind, Ratio> &lhs, float rhs) +constexpr Unit<Kind, Ratio>& operator/=(Unit<Kind, Ratio>& lhs, float rhs) { lhs = lhs / rhs; return lhs; diff --git a/src/shared/utils/ButtonHandler/ButtonHandler.cpp b/src/shared/utils/ButtonHandler/ButtonHandler.cpp index 89c20e726..f15607942 100644 --- a/src/shared/utils/ButtonHandler/ButtonHandler.cpp +++ b/src/shared/utils/ButtonHandler/ButtonHandler.cpp @@ -66,9 +66,9 @@ void ButtonHandler::periodicButtonValueCheck(miosix::GpioPin pin) return; // Retrieve the pin information - const ButtonCallback &callback = std::get<0>(callbacks[pin]); - bool &wasPressed = std::get<1>(callbacks[pin]); - unsigned int &pressedTicks = std::get<2>(callbacks[pin]); + const ButtonCallback& callback = std::get<0>(callbacks[pin]); + bool& wasPressed = std::get<1>(callbacks[pin]); + unsigned int& pressedTicks = std::get<2>(callbacks[pin]); // Read the current button status // Note: The button is assumed to be pressed if the pin value is low diff --git a/src/shared/utils/CRC.h b/src/shared/utils/CRC.h index 67e8af9bf..e215cfdcf 100644 --- a/src/shared/utils/CRC.h +++ b/src/shared/utils/CRC.h @@ -39,7 +39,7 @@ namespace CRCUtils * @return Computed CRC value */ template <uint16_t poly, uint16_t init> -uint16_t generiCrc16(const uint8_t *buffer, size_t count) +uint16_t generiCrc16(const uint8_t* buffer, size_t count) { uint16_t crc = init; @@ -48,12 +48,10 @@ uint16_t generiCrc16(const uint8_t *buffer, size_t count) crc ^= static_cast<uint16_t>(buffer[i]) << 8; for (uint8_t ii = 0; ii < 8; ii++) - { if (crc & 0x8000) crc = (crc << 1) ^ poly; else crc <<= 1; - } } return crc; diff --git a/src/shared/utils/CSVReader/CSVReader.h b/src/shared/utils/CSVReader/CSVReader.h index 0db89a16b..a5bf9882d 100644 --- a/src/shared/utils/CSVReader/CSVReader.h +++ b/src/shared/utils/CSVReader/CSVReader.h @@ -142,8 +142,10 @@ public: { // If the file has the header, ignore everithing in the first line if (hasHeader) + { fileStream.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); + } } ~CSVParser() { fileStream.close(); } @@ -158,8 +160,7 @@ public: { std::vector<Data> fileData; - std::for_each(begin(), end(), - [&fileData](const Data& data) + std::for_each(begin(), end(), [&fileData](const Data& data) { fileData.push_back(data); }); return fileData; diff --git a/src/shared/utils/ClockUtils.h b/src/shared/utils/ClockUtils.h index 0527a5b11..1f446b385 100644 --- a/src/shared/utils/ClockUtils.h +++ b/src/shared/utils/ClockUtils.h @@ -91,9 +91,7 @@ inline uint32_t ClockUtils::getAPBPeripheralsClock(APB bus) #endif if (RCC->CFGR & RCC_CFGR_PPRE1_2) - { inputFrequency /= 2 << ((RCC->CFGR >> ppre1) & 0b11); - } } else { @@ -107,9 +105,7 @@ inline uint32_t ClockUtils::getAPBPeripheralsClock(APB bus) #endif if (RCC->CFGR & RCC_CFGR_PPRE2_2) - { inputFrequency /= 2 << ((RCC->CFGR >> ppre2) & 0b11); - } } return inputFrequency; @@ -136,9 +132,7 @@ inline uint32_t ClockUtils::getAPBTimersClock(APB bus) #endif if (RCC->CFGR & RCC_CFGR_PPRE1_2) - { inputFrequency /= 1 << ((RCC->CFGR >> ppre1) & 0b11); - } } else { @@ -152,9 +146,7 @@ inline uint32_t ClockUtils::getAPBTimersClock(APB bus) #endif if (RCC->CFGR & RCC_CFGR_PPRE2_2) - { inputFrequency /= 1 << ((RCC->CFGR >> ppre2) & 0b11); - } } return inputFrequency; diff --git a/src/shared/utils/DependencyManager/DependencyManager.cpp b/src/shared/utils/DependencyManager/DependencyManager.cpp index 4899b2967..dfdd3f8d8 100644 --- a/src/shared/utils/DependencyManager/DependencyManager.cpp +++ b/src/shared/utils/DependencyManager/DependencyManager.cpp @@ -35,10 +35,8 @@ int32_t Boardcore::getNextDependencyId() int32_t next_id = NEXT_ID; while (next_id <= 256) - { if (NEXT_ID.compare_exchange_weak(next_id, next_id + 1)) return next_id; - } return -1; } @@ -58,9 +56,7 @@ void DependencyManager::graphviz(std::ostream& os) // First print out all of the nodes for (auto& module : modules) - { os << fmt::format(" \"{}\"", module.second.name) << std::endl; - } // Then print out the arcs for (auto& module : modules) @@ -88,13 +84,9 @@ bool DependencyManager::inject() } if (load_success) - { LOG_INFO(logger, "Configuring successful!"); - } else - { LOG_ERR(logger, "Failed to inject modules!"); - } return load_success; } @@ -115,13 +107,9 @@ void* DependencyManager::getImpl(int32_t id) { auto iter = modules.find(id); if (iter == modules.end()) - { return nullptr; - } else - { return iter->second.raw; - } } void* DependencyInjector::getImpl(int32_t id) diff --git a/src/shared/utils/DependencyManager/DependencyManager.h b/src/shared/utils/DependencyManager/DependencyManager.h index 10637d78e..ff95097ce 100644 --- a/src/shared/utils/DependencyManager/DependencyManager.h +++ b/src/shared/utils/DependencyManager/DependencyManager.h @@ -70,7 +70,7 @@ public: * * @param injector Proxy class used to obtain dependencies. */ - virtual void inject(DependencyInjector &injector) {} + virtual void inject(DependencyInjector& injector) {} }; /** @@ -119,9 +119,9 @@ private: struct ModuleInfo { std::string name; //< Name of the type. - void *raw; ///< Pointer to the dependency's concrete type, returned + void* raw; ///< Pointer to the dependency's concrete type, returned ///< when retrieving this dependency - Injectable *injectable; ///< Pointer to the dependency as an + Injectable* injectable; ///< Pointer to the dependency as an ///< Injectable, needed for dynamic dispatching ///< of the inject method std::vector<int32_t> deps; ///< List of dependencies @@ -140,11 +140,11 @@ public: */ template <typename T, typename = std::enable_if_t< std::is_base_of<Injectable, T>::value>> - [[nodiscard]] bool insert(T *dependency) + [[nodiscard]] bool insert(T* dependency) { return insertImpl( - getDependencyId<T>(), reinterpret_cast<void *>(dependency), - static_cast<Injectable *>(dependency), typeid(T).name()); + getDependencyId<T>(), reinterpret_cast<void*>(dependency), + static_cast<Injectable*>(dependency), typeid(T).name()); } /** @@ -153,7 +153,7 @@ public: * * @param os Output stream to write to. */ - void graphviz(std::ostream &os); + void graphviz(std::ostream& os); /** * @brief Inject all dependencies into all inserted . @@ -163,10 +163,10 @@ public: [[nodiscard]] bool inject(); private: - [[nodiscard]] bool insertImpl(int32_t id, void *raw, Injectable *injectable, - const char *name); + [[nodiscard]] bool insertImpl(int32_t id, void* raw, Injectable* injectable, + const char* name); - void *getImpl(int32_t id); + void* getImpl(int32_t id); Boardcore::PrintLogger logger = Boardcore::Logging::getLogger("DependencyManager"); @@ -184,8 +184,8 @@ class DependencyInjector friend class DependencyManager; private: - DependencyInjector(DependencyManager &manager, - DependencyManager::ModuleInfo &info) + DependencyInjector(DependencyManager& manager, + DependencyManager::ModuleInfo& info) : manager(manager), info(info) { } @@ -198,19 +198,19 @@ public: * @returns The requested dependency or nullptr if not found. */ template <typename T> - T *get() + T* get() { - return reinterpret_cast<T *>(getImpl(getDependencyId<T>())); + return reinterpret_cast<T*>(getImpl(getDependencyId<T>())); } private: - void *getImpl(int32_t id); + void* getImpl(int32_t id); Boardcore::PrintLogger logger = Boardcore::Logging::getLogger("DependencyManager"); - DependencyManager &manager; - DependencyManager::ModuleInfo &info; + DependencyManager& manager; + DependencyManager::ModuleInfo& info; }; namespace DependencyManagerDetails @@ -221,11 +221,11 @@ template <typename... Types> struct Storage { // No-op, base case - void inject(DependencyInjector &injector) {} + void inject(DependencyInjector& injector) {} // No-op, dummy get (this should never be reached) template <typename T> - T *get() + T* get() { return nullptr; } @@ -237,9 +237,9 @@ struct Storage<Type, Types...> : public Storage<Types...> using Super = Storage<Types...>; // Recursive implementation - Type *item = nullptr; + Type* item = nullptr; - void inject(DependencyInjector &injector) + void inject(DependencyInjector& injector) { item = injector.get<Type>(); // Call parent function @@ -247,13 +247,13 @@ struct Storage<Type, Types...> : public Storage<Types...> } template <typename T> - typename std::enable_if_t<std::is_same<T, Type>::value, T *> get() + typename std::enable_if_t<std::is_same<T, Type>::value, T*> get() { return item; } template <typename T> - typename std::enable_if_t<!std::is_same<T, Type>::value, T *> get() + typename std::enable_if_t<!std::is_same<T, Type>::value, T*> get() { return Super::template get<T>(); } @@ -293,7 +293,7 @@ protected: using Super = InjectableWithDeps<Types...>; public: - virtual void inject(DependencyInjector &injector) override + virtual void inject(DependencyInjector& injector) override { storage.inject(injector); } @@ -307,7 +307,7 @@ public: template <typename T, typename = std::enable_if_t< DependencyManagerDetails::Contains<T, Types...>::value>> - T *getModule() + T* getModule() { return storage.template get<T>(); } @@ -337,7 +337,7 @@ public: static_assert(std::is_base_of<Injectable, Base>::value, "Base must be Injectable"); - virtual void inject(DependencyInjector &injector) override + virtual void inject(DependencyInjector& injector) override { Base::inject(injector); storage.inject(injector); @@ -352,7 +352,7 @@ public: template <typename T, typename = std::enable_if_t< DependencyManagerDetails::Contains<T, Types...>::value>> - T *getModule() + T* getModule() { return storage.template get<T>(); } diff --git a/src/shared/utils/KernelTime.h b/src/shared/utils/KernelTime.h index 55c751bd5..a41087e1e 100644 --- a/src/shared/utils/KernelTime.h +++ b/src/shared/utils/KernelTime.h @@ -85,7 +85,7 @@ inline void sleepUntil(long long absoluteTimeMs) * migrate to using nanoseconds. */ inline miosix::TimedWaitResult IRQenableIrqAndTimedWaitMs( - miosix::FastInterruptDisableLock &dLock, long long absoluteTimeMs) + miosix::FastInterruptDisableLock& dLock, long long absoluteTimeMs) { return miosix::Thread::IRQenableIrqAndTimedWait(dLock, msToNs(absoluteTimeMs)); diff --git a/src/shared/utils/Numeric.h b/src/shared/utils/Numeric.h index e87cf933b..b4d3be8ed 100644 --- a/src/shared/utils/Numeric.h +++ b/src/shared/utils/Numeric.h @@ -48,18 +48,12 @@ constexpr auto add_sat(T x, T y) noexcept -> bool overflow = __builtin_add_overflow(x, y, &result); if (!overflow) - { return result; - } if (x < 0) - { return std::numeric_limits<T>::min(); - } else - { return std::numeric_limits<T>::max(); - } } } // namespace Boardcore diff --git a/src/shared/utils/PinObserver/PinObserver.cpp b/src/shared/utils/PinObserver/PinObserver.cpp index 34e7d00d3..9480f1f27 100644 --- a/src/shared/utils/PinObserver/PinObserver.cpp +++ b/src/shared/utils/PinObserver/PinObserver.cpp @@ -44,9 +44,13 @@ bool PinObserver::registerPinCallback(miosix::GpioPin pin, PinCallback callback, if (scheduler.addTask( std::bind(&PinObserver::periodicPinValueCheck, this, pin), pollInterval, TaskScheduler::Policy::RECOVER)) + { return true; + } else + { callbacks.erase(pin); + } } return false; @@ -65,10 +69,10 @@ void PinObserver::periodicPinValueCheck(miosix::GpioPin pin) if (callbacks.find(pin) == callbacks.end()) return; - auto &pinData = callbacks[pin]; + auto& pinData = callbacks[pin]; // Retrieve the pin information - uint32_t &count = pinData.periodCount; + uint32_t& count = pinData.periodCount; // Read the current pin status const bool newState = pin.value() != pinData.reverted; diff --git a/src/shared/utils/PinObserver/PinObserver.h b/src/shared/utils/PinObserver/PinObserver.h index b87d58e29..ffac6d595 100644 --- a/src/shared/utils/PinObserver/PinObserver.h +++ b/src/shared/utils/PinObserver/PinObserver.h @@ -74,7 +74,7 @@ public: * @param scheduler Scheduler to be used by this PinObserver. * @param pollInterval Pin transition polling interval, defaults to 20 [ms]. */ - explicit PinObserver(TaskScheduler &scheduler, uint32_t pollInterval = 20) + explicit PinObserver(TaskScheduler& scheduler, uint32_t pollInterval = 20) : scheduler{scheduler}, pollInterval{pollInterval} { } @@ -113,7 +113,7 @@ private: */ void periodicPinValueCheck(miosix::GpioPin pin); - TaskScheduler &scheduler; + TaskScheduler& scheduler; uint32_t pollInterval; /// Map of all the callbacks registered in the PinObserver. diff --git a/src/shared/utils/Registry/Backend/FileBackend.h b/src/shared/utils/Registry/Backend/FileBackend.h index 71d39f338..460484cf4 100644 --- a/src/shared/utils/Registry/Backend/FileBackend.h +++ b/src/shared/utils/Registry/Backend/FileBackend.h @@ -42,4 +42,4 @@ private: std::string path; }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/utils/Registry/RegistryBackend.h b/src/shared/utils/Registry/RegistryBackend.h index 3a4980ff0..545af6326 100644 --- a/src/shared/utils/Registry/RegistryBackend.h +++ b/src/shared/utils/Registry/RegistryBackend.h @@ -78,4 +78,4 @@ public: bool save(std::vector<uint8_t>& buf) override { return true; } }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/utils/Registry/RegistryFrontend.cpp b/src/shared/utils/Registry/RegistryFrontend.cpp index 87bed26e8..2439331c6 100644 --- a/src/shared/utils/Registry/RegistryFrontend.cpp +++ b/src/shared/utils/Registry/RegistryFrontend.cpp @@ -57,9 +57,7 @@ void RegistryFrontend::forEach(const EntryFunc& predicate) { const std::lock_guard<std::recursive_mutex> lock(mutexForRegistry); for (auto& it : configuration) - { predicate(it.first, it.second); - } } RegistryError RegistryFrontend::load() @@ -113,4 +111,4 @@ void RegistryFrontend::clear() configuration.clear(); }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/utils/Registry/RegistryFrontend.h b/src/shared/utils/Registry/RegistryFrontend.h index b1d79c67b..21955e085 100644 --- a/src/shared/utils/Registry/RegistryFrontend.h +++ b/src/shared/utils/Registry/RegistryFrontend.h @@ -158,12 +158,12 @@ public: std::lock_guard<std::recursive_mutex> lock(mutexForRegistry); T returnValue; if (getUnsafe(configurationIndex, returnValue) == RegistryError::OK) - { return returnValue; - } if (setUnsafe(configurationIndex, defaultValue) != RegistryError::OK) + { LOG_ERR(logger, "Registry - Could not insert the default configuration"); + } return defaultValue; } diff --git a/src/shared/utils/Registry/RegistrySerializer.cpp b/src/shared/utils/Registry/RegistrySerializer.cpp index 4cea30426..255bc025e 100644 --- a/src/shared/utils/Registry/RegistrySerializer.cpp +++ b/src/shared/utils/Registry/RegistrySerializer.cpp @@ -112,7 +112,9 @@ RegistryError RegistrySerializer::deserializeConfiguration( // Case the vector is empty/not have even the vector size if (serializationVector.size() < sizeof(RegistryHeader) + sizeof(RegistryFooter)) + { return RegistryError::MALFORMED_SERIALIZED_DATA; + } RegistryHeader header; success &= (deserialize(header) == RegistryError::OK); @@ -120,9 +122,7 @@ RegistryError RegistrySerializer::deserializeConfiguration( return RegistryError::MALFORMED_SERIALIZED_DATA; if (header.startBytes != 1) - { return RegistryError::WRONG_ENDIANESS; - } // Save the current vector position before jumping to the footer uint32_t previousPos = vectorWritePosition; @@ -229,4 +229,4 @@ size_t RegistrySerializer::size(RegistryConfiguration& configuration) return totalSize; } -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/utils/Registry/RegistrySerializer.h b/src/shared/utils/Registry/RegistrySerializer.h index 1f1685d00..1fbaa2644 100644 --- a/src/shared/utils/Registry/RegistrySerializer.h +++ b/src/shared/utils/Registry/RegistrySerializer.h @@ -192,4 +192,4 @@ private: size_t size(RegistryConfiguration& configuration); }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/utils/Registry/RegistryTypes.h b/src/shared/utils/Registry/RegistryTypes.h index c9f619a49..3f81dc0b6 100644 --- a/src/shared/utils/Registry/RegistryTypes.h +++ b/src/shared/utils/Registry/RegistryTypes.h @@ -87,7 +87,6 @@ enum class RegistryError */ struct EntryStructsUnion { - /** * @brief Default constructor to construct a new Entry Structs Union object */ @@ -227,4 +226,4 @@ private: } }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/shared/utils/SkyQuaternion/SkyQuaternion.cpp b/src/shared/utils/SkyQuaternion/SkyQuaternion.cpp index 1c6f25286..b51177c80 100644 --- a/src/shared/utils/SkyQuaternion/SkyQuaternion.cpp +++ b/src/shared/utils/SkyQuaternion/SkyQuaternion.cpp @@ -150,47 +150,44 @@ Vector4f rotationMatrix2quat(const Matrix3f& rtm) qz = (r12 - r21) / (2.0 * sqtrp1); qw = 0.5 * sqtrp1; } - else + else if ((r22 > r11) && (r22 > r33)) { - if ((r22 > r11) && (r22 > r33)) - { - float sqdip1 = sqrt(r22 - r11 - r33 + 1.0); + float sqdip1 = sqrt(r22 - r11 - r33 + 1.0); - qy = 0.5 * sqdip1; + qy = 0.5 * sqdip1; - if (sqdip1 != 0) - sqdip1 = 0.5 / sqdip1; + if (sqdip1 != 0) + sqdip1 = 0.5 / sqdip1; - qx = (r12 + r21) * sqdip1; - qz = (r23 + r32) * sqdip1; - qw = (r31 - r13) * sqdip1; - } - else if (r33 > r11) - { - float sqdip1 = sqrt(r33 - r11 - r22 + 1.0); + qx = (r12 + r21) * sqdip1; + qz = (r23 + r32) * sqdip1; + qw = (r31 - r13) * sqdip1; + } + else if (r33 > r11) + { + float sqdip1 = sqrt(r33 - r11 - r22 + 1.0); - qz = 0.5 * sqdip1; + qz = 0.5 * sqdip1; - if (sqdip1 != 0) - sqdip1 = 0.5 / sqdip1; + if (sqdip1 != 0) + sqdip1 = 0.5 / sqdip1; - qx = (r31 + r13) * sqdip1; - qy = (r23 + r32) * sqdip1; - qw = (r12 - r21) * sqdip1; - } - else - { - float sqdip1 = sqrt(r11 - r22 - r33 + 1.0); + qx = (r31 + r13) * sqdip1; + qy = (r23 + r32) * sqdip1; + qw = (r12 - r21) * sqdip1; + } + else + { + float sqdip1 = sqrt(r11 - r22 - r33 + 1.0); - qx = 0.5 * sqdip1; + qx = 0.5 * sqdip1; - if (sqdip1 != 0) - sqdip1 = 0.5 / sqdip1; + if (sqdip1 != 0) + sqdip1 = 0.5 / sqdip1; - qy = (r12 + r21) * sqdip1; - qz = (r31 + r13) * sqdip1; - qw = (r23 - r32) * sqdip1; - } + qy = (r12 + r21) * sqdip1; + qz = (r31 + r13) * sqdip1; + qw = (r23 - r32) * sqdip1; } return Vector4f(qx, qy, qz, qw); diff --git a/src/shared/utils/TestUtils/MockSPIBus.h b/src/shared/utils/TestUtils/MockSPIBus.h index 2fdf6a948..90c9725f5 100644 --- a/src/shared/utils/TestUtils/MockSPIBus.h +++ b/src/shared/utils/TestUtils/MockSPIBus.h @@ -157,7 +157,6 @@ public: */ virtual bool isSelected() { - Lock<FastMutex> l(mutex); return selected; } @@ -211,13 +210,9 @@ inline bool MockSPIBus::canCommunicate() { TRACE("Error, cannot communicato on MockSPIBus: "); if (!selected) - { TRACE("Chip select not asserted\n"); - } else - { TRACE("Incorrect configuration\n"); - } } return result; } @@ -225,13 +220,9 @@ inline bool MockSPIBus::canCommunicate() inline void MockSPIBus::_write(uint8_t byte) { if (canCommunicate()) - { outBuffer.push_back(byte); - } else - { outBuffer.push_back(0); - } } inline void MockSPIBus::write(uint8_t byte) @@ -252,9 +243,7 @@ inline void MockSPIBus::write(uint8_t* data, size_t size) Lock<FastMutex> l(mutex); for (size_t i = 0; i < size; i++) - { _write(data[i]); - } } inline void MockSPIBus::write(uint16_t* data, size_t size) @@ -262,9 +251,7 @@ inline void MockSPIBus::write(uint16_t* data, size_t size) Lock<FastMutex> l(mutex); for (size_t i = 0; i < size * 2; i++) - { _write(((uint8_t*)data)[i]); - } } inline uint8_t MockSPIBus::_read() @@ -272,9 +259,7 @@ inline uint8_t MockSPIBus::_read() if (canCommunicate()) { if (inBufPosCntr < inBuf.size()) - { return inBuf[inBufPosCntr++]; - } } return 0; } @@ -295,19 +280,14 @@ inline void MockSPIBus::read(uint8_t* data, size_t size) { Lock<FastMutex> l(mutex); for (size_t i = 0; i < size; i++) - { data[i] = _read(); - } } inline void MockSPIBus::read(uint16_t* data, size_t size) { - Lock<FastMutex> l(mutex); for (size_t i = 0; i < size * 2; i++) - { data[i] = _read(); - } } inline uint8_t MockSPIBus::transfer(uint8_t data) @@ -319,7 +299,6 @@ inline uint8_t MockSPIBus::transfer(uint8_t data) inline uint16_t MockSPIBus::transfer(uint16_t data) { - Lock<FastMutex> l(mutex); _write(data >> 8); _write(data); diff --git a/src/shared/utils/TestUtils/ThroughputCalculator.h b/src/shared/utils/TestUtils/ThroughputCalculator.h index bc61cdaf0..24d34ed6a 100644 --- a/src/shared/utils/TestUtils/ThroughputCalculator.h +++ b/src/shared/utils/TestUtils/ThroughputCalculator.h @@ -80,9 +80,7 @@ public: unsigned int interval = 0; if (packets.size() > 0) - { interval = static_cast<unsigned int>(ts - packets.back().timestamp); - } packets.push_back({ts, packetSize, interval}); @@ -102,9 +100,7 @@ public: float sum = 0; for (size_t i = 0; i < packets.size(); i++) - { sum += packets[i].size; - } return sum / (windowDuration / 1000.0f); } @@ -123,9 +119,7 @@ public: { avgInterval = packets[0].interval; for (size_t i = 1; i < packets.size(); i++) - { avgInterval += packets[i].interval; - } avgInterval /= packets.size(); } diff --git a/src/shared/utils/collections/CircularBuffer.h b/src/shared/utils/collections/CircularBuffer.h index 94a3828ed..41d2b47f0 100644 --- a/src/shared/utils/collections/CircularBuffer.h +++ b/src/shared/utils/collections/CircularBuffer.h @@ -92,7 +92,9 @@ public: return buffer[ptr]; } else + { throw range_error("Circular buffer index out of range"); + } } /** @@ -123,7 +125,9 @@ public: return buffer[ptr]; } else + { throw range_error("Circular buffer is empty!"); + } } /** @@ -136,13 +140,9 @@ public: if (empty) return 0; if (writePtr > readPtr) - { return writePtr - readPtr; - } else - { return Size - readPtr + writePtr; - } } bool isEmpty() const { return empty; } diff --git a/src/shared/utils/collections/IRQCircularBuffer.h b/src/shared/utils/collections/IRQCircularBuffer.h index aa634fe61..266916729 100644 --- a/src/shared/utils/collections/IRQCircularBuffer.h +++ b/src/shared/utils/collections/IRQCircularBuffer.h @@ -146,7 +146,9 @@ public: { if (waiting && (waiting->IRQgetPriority() > Thread::IRQgetCurrentThread()->IRQgetPriority())) + { hppw = true; + } IRQwakeWaitingThread(); buffer.put(elem); diff --git a/src/shared/utils/collections/SyncCircularBuffer.h b/src/shared/utils/collections/SyncCircularBuffer.h index 0dc899116..a89fc61e4 100644 --- a/src/shared/utils/collections/SyncCircularBuffer.h +++ b/src/shared/utils/collections/SyncCircularBuffer.h @@ -126,9 +126,7 @@ public: { Lock<FastMutex> l(mutex); while (buffer.isEmpty()) - { cv.wait(l); - } } /** diff --git a/src/shared/utils/collections/SyncPacketQueue.h b/src/shared/utils/collections/SyncPacketQueue.h index b786f7f29..638fccace 100644 --- a/src/shared/utils/collections/SyncPacketQueue.h +++ b/src/shared/utils/collections/SyncPacketQueue.h @@ -54,7 +54,6 @@ namespace Boardcore template <unsigned int len> class Packet { - public: /** * @brief Reserves a fixed length for the packet. @@ -328,10 +327,14 @@ public: Lock<FastMutex> l(mutex); if (!buffer.isEmpty()) + { return buffer.last().isReady() ? buffer.count() : buffer.count() - 1; + } else + { return 0; + } } /** diff --git a/src/shared/utils/gui/GridLayout.h b/src/shared/utils/gui/GridLayout.h index 91412b370..346c00bb2 100644 --- a/src/shared/utils/gui/GridLayout.h +++ b/src/shared/utils/gui/GridLayout.h @@ -64,9 +64,7 @@ public: void setCell(View* child, uint8_t row, uint8_t col) { if (row >= numRows || col >= numCols) - { return; - } mapChilds[GridPosition(row, col)] = child; @@ -162,9 +160,7 @@ public: { std::vector<View*> out; for (auto it = mapChilds.begin(); it != mapChilds.end(); it++) - { out.push_back(it->second); - } return out; } @@ -192,9 +188,7 @@ private: mapChildBounds[pos] = childBounds; if (mapChilds.count(pos) > 0) - { mapChilds[pos]->setBounds(childBounds); - } } } } diff --git a/src/shared/utils/gui/NavController.h b/src/shared/utils/gui/NavController.h index 617af98d7..8d93d4aa1 100644 --- a/src/shared/utils/gui/NavController.h +++ b/src/shared/utils/gui/NavController.h @@ -51,9 +51,7 @@ public: void updateViewTree(View* root) { if (selectedIndex < vecSelectable.size()) - { vecSelectable.at(selectedIndex)->setSelected(false); - } vecSelectable.clear(); selectedIndex = 0; @@ -61,9 +59,7 @@ public: updateSelectableViews(root); if (vecSelectable.size() > 0) - { vecSelectable.at(0)->setSelected(true); - } } void onButtonEvent(ButtonEvent press) @@ -72,29 +68,37 @@ public: { case ButtonEvent::PRESSED: if (selectedIndex < vecSelectable.size()) + { vecSelectable.at(selectedIndex) ->performInteraction(Interaction::BTN_DOWN); + } if (vecSelectable.size() > 0) selectNext(); break; case ButtonEvent::SHORT_PRESS: if (selectedIndex < vecSelectable.size()) + { vecSelectable.at(selectedIndex) ->performInteraction(Interaction::BTN_UP); + } if (vecSelectable.size() > 0) selectNext(); break; case ButtonEvent::LONG_PRESS: if (selectedIndex < vecSelectable.size()) + { vecSelectable.at(selectedIndex) ->performInteraction(Interaction::CLICK); + } if (vecSelectable.size() > 0) selectNext(); break; case ButtonEvent::VERY_LONG_PRESS: if (selectedIndex < vecSelectable.size()) + { vecSelectable.at(selectedIndex) ->performInteraction(Interaction::LONG_CLICK); + } if (vecSelectable.size() > 0) selectNext(); break; @@ -108,9 +112,7 @@ private: { // Deselect old drawble if (selectedIndex < vecSelectable.size()) - { vecSelectable.at(selectedIndex)->setSelected(false); - } if (vecSelectable.size() > 0) { @@ -122,9 +124,7 @@ private: dynamic_cast<TextView*>(vecSelectable.at(selectedIndex)); if (text) - { LOG_DEBUG(logger, "{}", text->getText().c_str()); - } } } @@ -134,9 +134,7 @@ private: for (auto child : childs) { if (child->isSelectable()) - { vecSelectable.push_back(child); - } updateSelectableViews(child); } } diff --git a/src/shared/utils/gui/OptionView.h b/src/shared/utils/gui/OptionView.h index 113f6bfca..8691325e3 100644 --- a/src/shared/utils/gui/OptionView.h +++ b/src/shared/utils/gui/OptionView.h @@ -46,9 +46,7 @@ public: { uint8_t numRows = options.size() / numCols; if (options.size() % numCols != 0) - { ++numRows; - } gridOptions = new GridLayout(numRows, numCols); @@ -69,9 +67,7 @@ public: gridOptions->setCell(tvOpt, gridPos++); if (i == defaultOption) - { selectOption(tvOpt); - } ++i; } @@ -82,9 +78,7 @@ public: delete gridOptions; delete tvTitle; for (auto it = mapOptions.begin(); it != mapOptions.end(); it++) - { delete it->first; - } } void setBounds(Bounds bounds) override @@ -132,9 +126,7 @@ private: void selectOption(TextView* opt) { if (selectedOption != nullptr) - { selectedOption->setBackgroundColor(colBgNormal); - } selectedOption = opt; @@ -150,12 +142,8 @@ private: selectOption(textview); for (auto l : optListeners) - { if (l != nullptr) - { l(mapOptions[textview]); - } - } } } diff --git a/src/shared/utils/gui/ScreenManager.h b/src/shared/utils/gui/ScreenManager.h index 8e69bb22c..c2185c118 100644 --- a/src/shared/utils/gui/ScreenManager.h +++ b/src/shared/utils/gui/ScreenManager.h @@ -61,9 +61,7 @@ public: root->setBounds({{0, 0}, {dc.getWidth(), dc.getHeight()}}); if (screens.size() == 1) - { showScreen(id); - } } void onButtonEvent(ButtonEvent press) { controller.onButtonEvent(press); } @@ -112,9 +110,7 @@ private: view->draw(dc); for (View* c : view->getChilds()) - { viewsDc.push_back(c); - } } } diff --git a/src/shared/utils/gui/TextView.h b/src/shared/utils/gui/TextView.h index 2647a669d..db0fe942f 100644 --- a/src/shared/utils/gui/TextView.h +++ b/src/shared/utils/gui/TextView.h @@ -159,13 +159,9 @@ protected: if (c >= font.getStartChar() && c <= font.getEndChar()) { if (font.isFixedWidth()) - { w += font.getWidth(); - } else - { w += font.getWidths()[c - font.getStartChar()]; - } } } return w; diff --git a/src/shared/utils/gui/VerticalLayout.h b/src/shared/utils/gui/VerticalLayout.h index 2eae2370c..af9c87c85 100644 --- a/src/shared/utils/gui/VerticalLayout.h +++ b/src/shared/utils/gui/VerticalLayout.h @@ -73,9 +73,7 @@ public: View::draw(dc); for (auto view : childs) - { view.drawable->draw(dc); - } } virtual std::vector<View*> getChilds() override @@ -83,9 +81,7 @@ public: std::vector<View*> out; out.reserve(childs.size()); for (auto v : childs) - { out.push_back(v.drawable); - } return out; } diff --git a/src/shared/utils/gui/View.h b/src/shared/utils/gui/View.h index 6c9aba9dc..87634bc85 100644 --- a/src/shared/utils/gui/View.h +++ b/src/shared/utils/gui/View.h @@ -148,9 +148,7 @@ public: void invalidate() { if (!invalidated) - { invalidated = true; - } } /** @@ -162,9 +160,7 @@ public: std::vector<View*> childs = getChilds(); for (auto child : childs) - { child->invalidateTree(); - } } /** @@ -234,12 +230,8 @@ public: virtual void performInteraction(Interaction action) { for (auto lst : listeners) - { if (lst) - { lst(this, action); - } - } } protected: diff --git a/src/tests/actuators/test-hbridge.cpp b/src/tests/actuators/test-hbridge.cpp index 64cd57ba8..73ff47481 100644 --- a/src/tests/actuators/test-hbridge.cpp +++ b/src/tests/actuators/test-hbridge.cpp @@ -56,9 +56,7 @@ void wait() t = Kernel::getOldTick(); if (print) - { TRACE("Elapsed time : %.2f \n", (t - t0) / 1000.0); - } } measuredTime = t - t0; @@ -88,9 +86,7 @@ int main() stringstream(temp) >> duty; if (!(freq >= 1 && freq <= 30000 && duty >= 0.0f && duty <= 100.0f)) - { TRACE("Invalid inputs!\n"); - } } while ( !(freq >= 1 && freq <= 30000 && duty >= 0.0f && duty <= 100.0f)); diff --git a/src/tests/actuators/test-stepper-pwm.cpp b/src/tests/actuators/test-stepper-pwm.cpp index a9e23e585..1b2a24cb6 100644 --- a/src/tests/actuators/test-stepper-pwm.cpp +++ b/src/tests/actuators/test-stepper-pwm.cpp @@ -144,4 +144,4 @@ int main() doRoutine(stepper); Thread::sleep(10 * 1000); } -} \ No newline at end of file +} diff --git a/src/tests/algorithms/ADA/ValueFollower.h b/src/tests/algorithms/ADA/ValueFollower.h index 4b1b0ab76..396090910 100644 --- a/src/tests/algorithms/ADA/ValueFollower.h +++ b/src/tests/algorithms/ADA/ValueFollower.h @@ -28,7 +28,7 @@ class ValueFollower { public: - ValueFollower(Boardcore::PressureData *data, size_t length, + ValueFollower(Boardcore::PressureData* data, size_t length, uint64_t timestampOffset = 0, float pressureOffset = 0) : data(data), length(length), timestampOffset(timestampOffset), pressureOffset(pressureOffset) @@ -48,9 +48,13 @@ public: return data[currentIndex].pressure + pressureOffset; for (; currentIndex < length; currentIndex++) + { if (data[currentIndex + 1].pressureTimestamp + timestampOffset > timestamp) + { return data[currentIndex].pressure + pressureOffset; + } + } return data[length - 1].pressure + pressureOffset; } @@ -60,7 +64,7 @@ public: u_int64_t getDataDuration() { return dataDuration; } private: - Boardcore::PressureData *data; + Boardcore::PressureData* data; size_t length; uint64_t timestampOffset; diff --git a/src/tests/algorithms/ADA/test-ada.cpp b/src/tests/algorithms/ADA/test-ada.cpp index 646604c67..0b243858f 100644 --- a/src/tests/algorithms/ADA/test-ada.cpp +++ b/src/tests/algorithms/ADA/test-ada.cpp @@ -41,7 +41,7 @@ uint64_t currentTimestamp = 0; constexpr uint64_t DELTA_T = 50 * 1e3; // 50ms = 20Hz constexpr float SAMPLING_PERIOD = 0.05; -ADA *ada; +ADA* ada; void step() { diff --git a/src/tests/algorithms/Airbrakes/test-airbrakesInterp-data.h b/src/tests/algorithms/Airbrakes/test-airbrakesInterp-data.h index 4da18d85d..931559120 100644 --- a/src/tests/algorithms/Airbrakes/test-airbrakesInterp-data.h +++ b/src/tests/algorithms/Airbrakes/test-airbrakesInterp-data.h @@ -11744,4 +11744,4 @@ static const std::vector<float> ABK = { 1, }; -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/tests/algorithms/Airbrakes/test-airbrakesInterp-references.h b/src/tests/algorithms/Airbrakes/test-airbrakesInterp-references.h index 325e1e984..e12c9e18b 100644 --- a/src/tests/algorithms/Airbrakes/test-airbrakesInterp-references.h +++ b/src/tests/algorithms/Airbrakes/test-airbrakesInterp-references.h @@ -6728,4 +6728,4 @@ Boardcore::Trajectory t_open[] = { const Boardcore::TrajectorySet CLOSED_TRAJECTORY_SET(t_closed, 11); const Boardcore::TrajectorySet OPEN_TRAJECTORY_SET(t_open, 11); -} // namespace Boardcore \ No newline at end of file +} // namespace Boardcore diff --git a/src/tests/algorithms/NAS/test-nas-parafoil.cpp b/src/tests/algorithms/NAS/test-nas-parafoil.cpp index ed36658da..cdc08233a 100644 --- a/src/tests/algorithms/NAS/test-nas-parafoil.cpp +++ b/src/tests/algorithms/NAS/test-nas-parafoil.cpp @@ -165,7 +165,9 @@ void step() nas->predictGyro(angularSpeed); if (gpsPos[0] < 1e3 && gpsPos[0] > -1e3 && gpsPos[1] < 1e3 && gpsPos[1] > -1e3) + { nas->predictAcc(acceleration); + } // Correct step magneticField.normalize(); diff --git a/src/tests/algorithms/NAS/test-triad-parafoil.cpp b/src/tests/algorithms/NAS/test-triad-parafoil.cpp index e8b323f2e..05498c830 100644 --- a/src/tests/algorithms/NAS/test-triad-parafoil.cpp +++ b/src/tests/algorithms/NAS/test-triad-parafoil.cpp @@ -71,8 +71,10 @@ int main() auto kalmanState = state.getInitX(); if (!std::isnan(kalmanState(9))) + { printf("w%fwa%fab%fbc%fc\n", kalmanState(9), kalmanState(6), kalmanState(7), kalmanState(8)); + } Kernel::Thread::sleepUntil(lastTick + 20); lastTick = Kernel::getOldTick(); diff --git a/src/tests/algorithms/NAS/test-triad.cpp b/src/tests/algorithms/NAS/test-triad.cpp index c9f7b6d11..c0204ce97 100644 --- a/src/tests/algorithms/NAS/test-triad.cpp +++ b/src/tests/algorithms/NAS/test-triad.cpp @@ -70,8 +70,10 @@ int main() auto kalmanState = state.getInitX(); if (!std::isnan(kalmanState(9))) + { printf("w%fwa%fab%fbc%fc\n", kalmanState(9), kalmanState(6), kalmanState(7), kalmanState(8)); + } Kernel::Thread::sleepUntil(lastTick + 20); lastTick = Kernel::getOldTick(); diff --git a/src/tests/boards/test-compute-unit.cpp b/src/tests/boards/test-compute-unit.cpp index 6bb8a4874..b8304bb11 100644 --- a/src/tests/boards/test-compute-unit.cpp +++ b/src/tests/boards/test-compute-unit.cpp @@ -66,4 +66,4 @@ int main() delayUs(500); } } -} \ No newline at end of file +} diff --git a/src/tests/catch/catch-tests-entry.cpp b/src/tests/catch/catch-tests-entry.cpp index 1acb03098..ba7c60ffe 100644 --- a/src/tests/catch/catch-tests-entry.cpp +++ b/src/tests/catch/catch-tests-entry.cpp @@ -105,9 +105,7 @@ static vector<string> splitSpaces(const string& str) size_t len = p2 - p; // Length of the substring if (len > 0) - { out.push_back(str.substr(p, len)); - } p = p2 + 1; } while (!end); @@ -152,18 +150,14 @@ int main() // Clear memory for (size_t i = 0; i < argc; i++) - { delete[] argv[i]; - } delete[] argv; printf("End.\n"); // Infinite loop to avoid board reset each time we return while (true) - { Thread::sleep(10000); - } } #endif // COMPILE_FOR_HOST diff --git a/src/tests/catch/propagator/test-propagator-data.h b/src/tests/catch/propagator/test-propagator-data.h index 0ce932d05..f2044e98d 100644 --- a/src/tests/catch/propagator/test-propagator-data.h +++ b/src/tests/catch/propagator/test-propagator-data.h @@ -89,106 +89,106 @@ namespace TestPropagator1 std::chrono::milliseconds dt = 20ms; int n = 100; Boardcore::NASState nas[] = { - {1, {0, 42, 0, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {2, {-0.02, 42, 0.02, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {3, {-0.04, 42, 0.04, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {4, {-0.06, 42, 0.06, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {5, {-0.08, 42, 0.08, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {6, {-0.1, 42, 0.1, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {7, {-0.12, 42, 0.12, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {8, {-0.14, 42, 0.14, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {9, {-0.16, 42, 0.16, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {10, {-0.18, 42, 0.18, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {11, {-0.2, 42, 0.2, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {12, {-0.22, 42, 0.22, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {13, {-0.24, 42, 0.24, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {14, {-0.26, 42, 0.26, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {15, {-0.28, 42, 0.28, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {16, {-0.3, 42, 0.3, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {17, {-0.32, 42, 0.32, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {18, {-0.34, 42, 0.34, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {19, {-0.36, 42, 0.36, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {20, {-0.38, 42, 0.38, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {21, {-0.4, 42, 0.4, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {22, {-0.42, 42, 0.42, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {23, {-0.44, 42, 0.44, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {24, {-0.46, 42, 0.46, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {25, {-0.48, 42, 0.48, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {26, {-0.5, 42, 0.5, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {27, {-0.52, 42, 0.52, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {28, {-0.54, 42, 0.54, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {29, {-0.56, 42, 0.56, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {30, {-0.58, 42, 0.58, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {31, {-0.6, 42, 0.6, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {32, {-0.62, 42, 0.62, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {33, {-0.64, 42, 0.64, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {34, {-0.66, 42, 0.66, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {35, {-0.68, 42, 0.68, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {36, {-0.7, 42, 0.7, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {37, {-0.72, 42, 0.72, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {38, {-0.74, 42, 0.74, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {39, {-0.76, 42, 0.76, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {40, {-0.78, 42, 0.78, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {41, {-0.8, 42, 0.8, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {42, {-0.82, 42, 0.82, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {43, {-0.84, 42, 0.84, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {44, {-0.86, 42, 0.86, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {45, {-0.88, 42, 0.88, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {46, {-0.9, 42, 0.9, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {47, {-0.92, 42, 0.92, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {48, {-0.94, 42, 0.94, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {49, {-0.96, 42, 0.96, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {50, {-0.98, 42, 0.98, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {51, {-1, 42, 1, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {52, {-1.02, 42, 1.02, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {53, {-1.04, 42, 1.04, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {54, {-1.06, 42, 1.06, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {55, {-1.08, 42, 1.08, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {56, {-1.1, 42, 1.1, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {57, {-1.12, 42, 1.12, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {58, {-1.14, 42, 1.14, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {59, {-1.16, 42, 1.16, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {60, {-1.18, 42, 1.18, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {61, {-1.2, 42, 1.2, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {62, {-1.22, 42, 1.22, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {63, {-1.24, 42, 1.24, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {64, {-1.26, 42, 1.26, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {65, {-1.28, 42, 1.28, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {66, {-1.3, 42, 1.3, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {67, {-1.32, 42, 1.32, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {68, {-1.34, 42, 1.34, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {69, {-1.36, 42, 1.36, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {70, {-1.38, 42, 1.38, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {71, {-1.4, 42, 1.4, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {72, {-1.42, 42, 1.42, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {73, {-1.44, 42, 1.44, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {74, {-1.46, 42, 1.46, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {75, {-1.48, 42, 1.48, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {76, {-1.5, 42, 1.5, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {77, {-1.52, 42, 1.52, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {78, {-1.54, 42, 1.54, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {79, {-1.56, 42, 1.56, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {80, {-1.58, 42, 1.58, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {81, {-1.6, 42, 1.6, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {82, {-1.62, 42, 1.62, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {83, {-1.64, 42, 1.64, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {84, {-1.66, 42, 1.66, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {85, {-1.68, 42, 1.68, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {86, {-1.7, 42, 1.7, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {87, {-1.72, 42, 1.72, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {88, {-1.74, 42, 1.74, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {89, {-1.76, 42, 1.76, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {90, {-1.78, 42, 1.78, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {91, {-1.8, 42, 1.8, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {92, {-1.82, 42, 1.82, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {93, {-1.84, 42, 1.84, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {94, {-1.86, 42, 1.86, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {95, {-1.88, 42, 1.88, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {96, {-1.9, 42, 1.9, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {97, {-1.92, 42, 1.92, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {98, {-1.94, 42, 1.94, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {99, {-1.96, 42, 1.96, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, - {100, {-1.98, 42, 1.98, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}}; + {1, {0, 42, 0, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {2, {-0.02, 42, 0.02, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {3, {-0.04, 42, 0.04, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {4, {-0.06, 42, 0.06, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {5, {-0.08, 42, 0.08, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {6, {-0.1, 42, 0.1, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {7, {-0.12, 42, 0.12, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {8, {-0.14, 42, 0.14, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {9, {-0.16, 42, 0.16, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {10, {-0.18, 42, 0.18, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {11, {-0.2, 42, 0.2, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {12, {-0.22, 42, 0.22, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {13, {-0.24, 42, 0.24, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {14, {-0.26, 42, 0.26, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {15, {-0.28, 42, 0.28, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {16, {-0.3, 42, 0.3, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {17, {-0.32, 42, 0.32, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {18, {-0.34, 42, 0.34, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {19, {-0.36, 42, 0.36, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {20, {-0.38, 42, 0.38, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {21, {-0.4, 42, 0.4, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {22, {-0.42, 42, 0.42, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {23, {-0.44, 42, 0.44, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {24, {-0.46, 42, 0.46, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {25, {-0.48, 42, 0.48, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {26, {-0.5, 42, 0.5, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {27, {-0.52, 42, 0.52, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {28, {-0.54, 42, 0.54, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {29, {-0.56, 42, 0.56, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {30, {-0.58, 42, 0.58, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {31, {-0.6, 42, 0.6, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {32, {-0.62, 42, 0.62, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {33, {-0.64, 42, 0.64, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {34, {-0.66, 42, 0.66, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {35, {-0.68, 42, 0.68, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {36, {-0.7, 42, 0.7, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {37, {-0.72, 42, 0.72, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {38, {-0.74, 42, 0.74, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {39, {-0.76, 42, 0.76, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {40, {-0.78, 42, 0.78, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {41, {-0.8, 42, 0.8, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {42, {-0.82, 42, 0.82, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {43, {-0.84, 42, 0.84, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {44, {-0.86, 42, 0.86, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {45, {-0.88, 42, 0.88, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {46, {-0.9, 42, 0.9, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {47, {-0.92, 42, 0.92, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {48, {-0.94, 42, 0.94, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {49, {-0.96, 42, 0.96, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {50, {-0.98, 42, 0.98, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {51, {-1, 42, 1, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {52, {-1.02, 42, 1.02, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {53, {-1.04, 42, 1.04, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {54, {-1.06, 42, 1.06, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {55, {-1.08, 42, 1.08, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {56, {-1.1, 42, 1.1, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {57, {-1.12, 42, 1.12, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {58, {-1.14, 42, 1.14, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {59, {-1.16, 42, 1.16, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {60, {-1.18, 42, 1.18, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {61, {-1.2, 42, 1.2, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {62, {-1.22, 42, 1.22, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {63, {-1.24, 42, 1.24, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {64, {-1.26, 42, 1.26, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {65, {-1.28, 42, 1.28, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {66, {-1.3, 42, 1.3, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {67, {-1.32, 42, 1.32, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {68, {-1.34, 42, 1.34, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {69, {-1.36, 42, 1.36, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {70, {-1.38, 42, 1.38, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {71, {-1.4, 42, 1.4, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {72, {-1.42, 42, 1.42, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {73, {-1.44, 42, 1.44, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {74, {-1.46, 42, 1.46, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {75, {-1.48, 42, 1.48, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {76, {-1.5, 42, 1.5, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {77, {-1.52, 42, 1.52, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {78, {-1.54, 42, 1.54, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {79, {-1.56, 42, 1.56, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {80, {-1.58, 42, 1.58, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {81, {-1.6, 42, 1.6, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {82, {-1.62, 42, 1.62, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {83, {-1.64, 42, 1.64, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {84, {-1.66, 42, 1.66, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {85, {-1.68, 42, 1.68, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {86, {-1.7, 42, 1.7, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {87, {-1.72, 42, 1.72, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {88, {-1.74, 42, 1.74, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {89, {-1.76, 42, 1.76, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {90, {-1.78, 42, 1.78, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {91, {-1.8, 42, 1.8, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {92, {-1.82, 42, 1.82, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {93, {-1.84, 42, 1.84, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {94, {-1.86, 42, 1.86, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {95, {-1.88, 42, 1.88, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {96, {-1.9, 42, 1.9, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {97, {-1.92, 42, 1.92, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {98, {-1.94, 42, 1.94, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {99, {-1.96, 42, 1.96, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}, + {100, {-1.98, 42, 1.98, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0}}}; Boardcore::PropagatorState STATE0(0, 0, nas[0]); @@ -199,224 +199,224 @@ namespace TestPropagator2 std::chrono::milliseconds dt = 20ms; int n = 100; Boardcore::NASState nas[] = { - {1, {12, -24, -48, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {2, {11.994, -23.976, -47.932, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {3, {11.988, -23.952, -47.864, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {4, {11.982, -23.928, -47.796, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {5, {11.976, -23.904, -47.728, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {6, {11.97, -23.88, -47.66, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {7, {11.964, -23.856, -47.592, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {8, {11.958, -23.832, -47.524, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {9, {11.952, -23.808, -47.456, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {10, {11.946, -23.784, -47.388, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {11, {11.94, -23.76, -47.32, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {12, {11.934, -23.736, -47.252, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {13, {11.928, -23.712, -47.184, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {14, {11.922, -23.688, -47.116, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {15, {11.916, -23.664, -47.048, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {16, {11.91, -23.64, -46.98, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {17, {11.904, -23.616, -46.912, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {18, {11.898, -23.592, -46.844, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {19, {11.892, -23.568, -46.776, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {20, {11.886, -23.544, -46.708, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {21, {11.88, -23.52, -46.64, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {22, {11.874, -23.496, -46.572, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {23, {11.868, -23.472, -46.504, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {24, {11.862, -23.448, -46.436, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {25, + {1, {12, -24, -48, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {2, {11.994, -23.976, -47.932, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {3, {11.988, -23.952, -47.864, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {4, {11.982, -23.928, -47.796, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {5, {11.976, -23.904, -47.728, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {6, {11.97, -23.88, -47.66, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {7, {11.964, -23.856, -47.592, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {8, {11.958, -23.832, -47.524, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {9, {11.952, -23.808, -47.456, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {10, {11.946, -23.784, -47.388, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {11, {11.94, -23.76, -47.32, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {12, {11.934, -23.736, -47.252, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {13, {11.928, -23.712, -47.184, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {14, {11.922, -23.688, -47.116, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {15, {11.916, -23.664, -47.048, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {16, {11.91, -23.64, -46.98, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {17, {11.904, -23.616, -46.912, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {18, {11.898, -23.592, -46.844, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {19, {11.892, -23.568, -46.776, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {20, {11.886, -23.544, -46.708, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {21, {11.88, -23.52, -46.64, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {22, {11.874, -23.496, -46.572, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {23, {11.868, -23.472, -46.504, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {24, {11.862, -23.448, -46.436, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {25, {11.856, -23.424, -46.3680000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {26, + {26, {11.85, -23.4, -46.3000000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {27, + {27, {11.844, -23.376, -46.2320000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {28, + {28, {11.838, -23.352, -46.1640000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {29, + {29, {11.832, -23.328, -46.0960000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {30, + {30, {11.826, -23.304, -46.0280000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {31, + {31, {11.82, -23.28, -45.9600000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {32, + {32, {11.814, -23.256, -45.8920000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {33, + {33, {11.808, -23.232, -45.8240000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {34, + {34, {11.802, -23.208, -45.7560000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {35, + {35, {11.796, -23.184, -45.6880000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {36, + {36, {11.79, -23.16, -45.6200000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {37, + {37, {11.784, -23.136, -45.5520000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {38, + {38, {11.778, -23.112, -45.4840000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {39, + {39, {11.772, -23.088, -45.4160000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {40, + {40, {11.766, -23.064, -45.3480000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {41, + {41, {11.76, -23.04, -45.2800000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {42, + {42, {11.754, -23.016, -45.2120000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {43, + {43, {11.748, -22.992, -45.1440000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {44, + {44, {11.742, -22.968, -45.0760000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {45, + {45, {11.736, -22.944, -45.0080000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {46, + {46, {11.73, -22.92, -44.9400000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {47, + {47, {11.724, -22.896, -44.8720000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {48, + {48, {11.718, -22.872, -44.8040000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {49, + {49, {11.712, -22.848, -44.7360000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {50, + {50, {11.706, -22.824, -44.6680000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {51, {11.7, -22.8, -44.6000000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {52, + {51, {11.7, -22.8, -44.6000000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, + {52, {11.694, -22.776, -44.5320000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {53, + {53, {11.688, -22.752, -44.4640000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {54, + {54, {11.682, -22.728, -44.3960000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {55, + {55, {11.676, -22.704, -44.3280000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {56, + {56, {11.67, -22.6799999999999, -44.2600000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {57, + {57, {11.664, -22.6559999999999, -44.1920000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {58, + {58, {11.658, -22.6319999999999, -44.1240000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {59, + {59, {11.652, -22.6079999999999, -44.0560000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {60, + {60, {11.646, -22.5839999999999, -43.9880000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {61, + {61, {11.64, -22.5599999999999, -43.9200000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {62, + {62, {11.634, -22.5359999999999, -43.8520000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {63, + {63, {11.628, -22.5119999999999, -43.7840000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {64, + {64, {11.622, -22.4879999999999, -43.7160000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {65, + {65, {11.616, -22.4639999999999, -43.6480000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {66, + {66, {11.61, -22.4399999999999, -43.5800000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {67, + {67, {11.604, -22.4159999999999, -43.5120000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {68, + {68, {11.598, -22.3919999999999, -43.4440000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {69, + {69, {11.592, -22.3679999999999, -43.3760000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {70, + {70, {11.586, -22.3439999999999, -43.3080000000001, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {71, + {71, {11.58, -22.3199999999999, -43.2400000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {72, + {72, {11.574, -22.2959999999999, -43.1720000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {73, + {73, {11.568, -22.2719999999999, -43.1040000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {74, + {74, {11.562, -22.2479999999999, -43.0360000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {75, + {75, {11.556, -22.2239999999999, -42.9680000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {76, + {76, {11.55, -22.1999999999999, -42.9000000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {77, + {77, {11.544, -22.1759999999999, -42.8320000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {78, + {78, {11.538, -22.1519999999999, -42.7640000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {79, + {79, {11.532, -22.1279999999999, -42.6960000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {80, + {80, {11.526, -22.1039999999999, -42.6280000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {81, + {81, {11.52, -22.0799999999999, -42.5600000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {82, + {82, {11.514, -22.0559999999999, -42.4920000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {83, + {83, {11.508, -22.0319999999999, -42.4240000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {84, + {84, {11.502, -22.0079999999999, -42.3560000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {85, + {85, {11.496, -21.9839999999999, -42.2880000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {86, + {86, {11.49, -21.9599999999999, -42.2200000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {87, + {87, {11.484, -21.9359999999999, -42.1520000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {88, + {88, {11.478, -21.9119999999999, -42.0840000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {89, + {89, {11.472, -21.8879999999999, -42.0160000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {90, + {90, {11.466, -21.8639999999999, -41.9480000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {91, + {91, {11.46, -21.8399999999999, -41.8800000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {92, + {92, {11.454, -21.8159999999999, -41.8120000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {93, + {93, {11.448, -21.7919999999999, -41.7440000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {94, + {94, {11.442, -21.7679999999999, -41.6760000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {95, + {95, {11.436, -21.7439999999999, -41.6080000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {96, + {96, {11.43, -21.7199999999999, -41.5400000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {97, + {97, {11.424, -21.6959999999999, -41.4720000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {98, + {98, {11.418, -21.6719999999999, -41.4040000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {99, + {99, {11.412, -21.6479999999999, -41.3360000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}, - {100, + {100, {11.406, -21.6239999999999, -41.2680000000002, -0.3, 1.2, 3.4, 0, 0, 0, 1, 0, 0, 0}}}; @@ -429,274 +429,274 @@ namespace TestPropagator3 std::chrono::milliseconds dt = 500ms; int n = 100; Boardcore::NASState nas[] = { - {1, {12, -24, -48, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {2, {11.85, -23.4, -46.3, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {3, {11.7, -22.8, -44.6, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {4, {11.55, -22.2, -42.9, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {5, {11.4, -21.6, -41.2, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {6, {11.25, -21, -39.5, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {7, {11.1, -20.4, -37.8, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {8, {10.95, -19.8, -36.1, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {9, {10.8, -19.2, -34.4, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {10, {10.65, -18.6, -32.7, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {11, {10.5, -18, -31, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {12, {10.35, -17.4, -29.3, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {13, {10.2, -16.8, -27.6, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {14, {10.05, -16.2, -25.9, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {15, {9.9, -15.6, -24.2, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {16, + {1, {12, -24, -48, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, + {2, {11.85, -23.4, -46.3, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, + {3, {11.7, -22.8, -44.6, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, + {4, {11.55, -22.2, -42.9, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, + {5, {11.4, -21.6, -41.2, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, + {6, {11.25, -21, -39.5, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, + {7, {11.1, -20.4, -37.8, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, + {8, {10.95, -19.8, -36.1, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, + {9, {10.8, -19.2, -34.4, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, + {10, {10.65, -18.6, -32.7, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, + {11, {10.5, -18, -31, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, + {12, {10.35, -17.4, -29.3, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, + {13, {10.2, -16.8, -27.6, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, + {14, {10.05, -16.2, -25.9, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, + {15, {9.9, -15.6, -24.2, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, + {16, {9.74999999999999, -15, -22.5, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {17, + {17, {9.59999999999999, -14.4, -20.8, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {18, + {18, {9.44999999999999, -13.8, -19.1, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {19, + {19, {9.29999999999999, -13.2, -17.4, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {20, + {20, {9.14999999999999, -12.6, -15.7, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {21, + {21, {8.99999999999999, -12, -14, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {22, + {22, {8.84999999999999, -11.4, -12.3, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {23, + {23, {8.69999999999999, -10.8, -10.6, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {24, + {24, {8.54999999999999, -10.2, -8.89999999999998, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {25, + {25, {8.39999999999999, -9.59999999999999, -7.19999999999998, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {26, + {26, {8.24999999999999, -8.99999999999999, -5.49999999999998, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {27, + {27, {8.09999999999999, -8.39999999999999, -3.79999999999998, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {28, + {28, {7.94999999999999, -7.79999999999999, -2.09999999999998, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {29, + {29, {7.79999999999999, -7.19999999999999, -0.399999999999984, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {30, + {30, {7.64999999999999, -6.59999999999999, 1.30000000000002, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {31, + {31, {7.49999999999999, -5.99999999999999, 3.00000000000002, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {32, + {32, {7.34999999999999, -5.39999999999999, 4.70000000000002, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {33, + {33, {7.19999999999999, -4.79999999999999, 6.40000000000002, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {34, + {34, {7.04999999999999, -4.19999999999999, 8.10000000000002, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {35, + {35, {6.89999999999999, -3.59999999999999, 9.80000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {36, + {36, {6.74999999999999, -2.99999999999999, 11.5, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {37, + {37, {6.59999999999999, -2.39999999999999, 13.2, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {38, + {38, {6.44999999999999, -1.79999999999999, 14.9, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {39, + {39, {6.29999999999999, -1.19999999999999, 16.6, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {40, + {40, {6.14999999999999, -0.599999999999988, 18.3, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {41, + {41, {5.99999999999999, 1.17683640610267e-14, 20, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {42, + {42, {5.84999999999999, 0.600000000000012, 21.7, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {43, + {43, {5.69999999999999, 1.20000000000001, 23.4, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {44, + {44, {5.54999999999998, 1.80000000000001, 25.1, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {45, + {45, {5.39999999999998, 2.40000000000001, 26.8, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {46, + {46, {5.24999999999998, 3.00000000000001, 28.5, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {47, + {47, {5.09999999999998, 3.60000000000001, 30.2, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {48, + {48, {4.94999999999998, 4.20000000000001, 31.9, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {49, + {49, {4.79999999999998, 4.80000000000001, 33.6, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {50, + {50, {4.64999999999998, 5.40000000000001, 35.3, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {51, + {51, {4.49999999999998, 6.00000000000001, 37, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {52, + {52, {4.34999999999998, 6.60000000000001, 38.7, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {53, + {53, {4.19999999999998, 7.20000000000001, 40.4, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {54, + {54, {4.04999999999998, 7.80000000000001, 42.1, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {55, + {55, {3.89999999999998, 8.40000000000001, 43.8, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {56, + {56, {3.74999999999998, 9.00000000000001, 45.5, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {57, + {57, {3.59999999999998, 9.60000000000001, 47.2, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {58, + {58, {3.44999999999998, 10.2, 48.9, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {59, + {59, {3.29999999999998, 10.8, 50.6, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {60, + {60, {3.14999999999998, 11.4, 52.3, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {61, + {61, {2.99999999999998, 12, 54, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {62, + {62, {2.84999999999998, 12.6, 55.7, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {63, + {63, {2.69999999999998, 13.2, 57.4, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {64, + {64, {2.54999999999998, 13.8, 59.1000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {65, + {65, {2.39999999999998, 14.4, 60.8000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {66, + {66, {2.24999999999998, 15, 62.5000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {67, + {67, {2.09999999999998, 15.6, 64.2000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {68, + {68, {1.94999999999998, 16.2, 65.9000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {69, + {69, {1.79999999999998, 16.8, 67.6000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {70, + {70, {1.64999999999998, 17.4, 69.3000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {71, + {71, {1.49999999999998, 18, 71.0000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {72, + {72, {1.34999999999998, 18.6, 72.7000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {73, + {73, {1.19999999999998, 19.2, 74.4000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {74, + {74, {1.04999999999998, 19.8, 76.1000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {75, + {75, {0.899999999999983, 20.4, 77.8000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {76, + {76, {0.749999999999983, 21, 79.5000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {77, + {77, {0.599999999999983, 21.6, 81.2000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {78, + {78, {0.449999999999983, 22.2, 82.9000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {79, + {79, {0.299999999999983, 22.8, 84.6000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {80, + {80, {0.149999999999983, 23.4, 86.3000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {81, + {81, {-1.71529457304587e-14, 24, 88.0000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {82, + {82, {-0.150000000000017, 24.6, 89.7000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {83, + {83, {-0.300000000000017, 25.2, 91.4000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {84, + {84, {-0.450000000000017, 25.8, 93.1000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {85, + {85, {-0.600000000000017, 26.4, 94.8000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {86, + {86, {-0.750000000000017, 27, 96.5000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {87, + {87, {-0.900000000000017, 27.6, 98.2000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {88, + {88, {-1.05000000000002, 28.2, 99.9000000000001, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {89, + {89, {-1.20000000000002, 28.8, 101.6, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {90, + {90, {-1.35000000000002, 29.4, 103.3, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {91, + {91, {-1.50000000000002, 30, 105, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {92, + {92, {-1.65000000000002, 30.6, 106.7, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {93, + {93, {-1.80000000000002, 31.2, 108.4, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {94, + {94, {-1.95000000000002, 31.8, 110.1, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {95, + {95, {-2.10000000000002, 32.4, 111.8, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {96, + {96, {-2.25000000000002, 33, 113.5, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {97, + {97, {-2.40000000000002, 33.6, 115.2, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {98, + {98, {-2.55000000000002, 34.2, 116.9, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {99, + {99, {-2.70000000000002, 34.8, 118.6, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}, - {100, + {100, {-2.85000000000002, 35.4, 120.3, -0.3, 1.2, 3.4, 0.5, 0.5, 0.5, 0.5, 1, 2, 3}}}; Boardcore::PropagatorState STATE0(0, 0, nas[0]); -} // namespace TestPropagator3 \ No newline at end of file +} // namespace TestPropagator3 diff --git a/src/tests/catch/propagator/test-propagator.cpp b/src/tests/catch/propagator/test-propagator.cpp index d2559cc1c..1877221bd 100644 --- a/src/tests/catch/propagator/test-propagator.cpp +++ b/src/tests/catch/propagator/test-propagator.cpp @@ -116,4 +116,4 @@ TEST_CASE("Propagator Update Test 3") using namespace TestPropagator3; testPropagator(dt, STATE0, nas, n); -} \ No newline at end of file +} diff --git a/src/tests/catch/skyQuaternion/test-skyquaternion.cpp b/src/tests/catch/skyQuaternion/test-skyquaternion.cpp index 4b9aab4aa..f30c4aabc 100644 --- a/src/tests/catch/skyQuaternion/test-skyquaternion.cpp +++ b/src/tests/catch/skyQuaternion/test-skyquaternion.cpp @@ -32,7 +32,7 @@ using namespace Eigen; using namespace Boardcore; using namespace SkyQuaternion; -void testEulerAngles(const Vector3f &actual, const Vector3f &expected) +void testEulerAngles(const Vector3f& actual, const Vector3f& expected) { REQUIRE(actual[0] == Approx(expected[0]).margin(0.0001)); REQUIRE(actual[1] == Approx(expected[1]).margin(0.0001)); @@ -50,4 +50,4 @@ TEST_CASE("quat2stepperAngles") Boardcore::SkyQuaternion::quat2stepperAngles(Vector4f(inputs[i])); testEulerAngles(euler, outputs[i]); } -} \ No newline at end of file +} diff --git a/src/tests/catch/test-MEA.cpp b/src/tests/catch/test-MEA.cpp index c644a6ff2..c0bcda372 100644 --- a/src/tests/catch/test-MEA.cpp +++ b/src/tests/catch/test-MEA.cpp @@ -121,4 +121,4 @@ TEST_CASE("MEA Update Test") << " != " << ESTIMATED_PRESSURE[i]); } } -} \ No newline at end of file +} diff --git a/src/tests/catch/test-aero.cpp b/src/tests/catch/test-aero.cpp index d1f52a663..942244bce 100644 --- a/src/tests/catch/test-aero.cpp +++ b/src/tests/catch/test-aero.cpp @@ -66,7 +66,6 @@ TEST_CASE("[AeroUtils] relPressure") TEST_CASE("[AeroUtils] relDensity") { - REQUIRE(relDensity(101325) == Approx(1.225).epsilon(0.0001)); REQUIRE(relDensity(100129.438691069) == Approx(1.21328277727309).epsilon(0.0001)); @@ -186,12 +185,13 @@ TEST_CASE("[AeroUtils] computeMach") float mach[] = {0, 0.2955, 0.2972, 0.2990, 0.3007, 0.3025, 0.3043, 0}; for (int i = 0; i < sizeof(d) / sizeof(float); i++) + { REQUIRE(computeMach(d[i], vtot[i], t0) == Approx(mach[i]).epsilon(0.001)); + } } { - // Test for a different t0 from atmosisa const float t0 = 287.11; float d[] = {0, -315.556, -631.111, -946.667, -1262.222, @@ -219,7 +219,9 @@ TEST_CASE("[AeroUtils] computeMach") 1.14129591962841}; for (int i = 0; i < sizeof(d) / sizeof(float); i++) + { REQUIRE(computeMach(d[i], vtot[i], t0) == Approx(mach[i]).epsilon(0.001)); + } } -} \ No newline at end of file +} diff --git a/src/tests/catch/test-airbrakesInterp.cpp b/src/tests/catch/test-airbrakesInterp.cpp index 20137849b..e2549c990 100644 --- a/src/tests/catch/test-airbrakesInterp.cpp +++ b/src/tests/catch/test-airbrakesInterp.cpp @@ -96,7 +96,5 @@ TEST_CASE("ABK Update Test") abk.begin(28.8); for (size_t i = 0; i < Z.size(); i++) - { abk.update(); - } -} \ No newline at end of file +} diff --git a/src/tests/catch/test-buttonhandler.cpp b/src/tests/catch/test-buttonhandler.cpp index 64a06d45c..e26a94f0c 100644 --- a/src/tests/catch/test-buttonhandler.cpp +++ b/src/tests/catch/test-buttonhandler.cpp @@ -87,7 +87,6 @@ using ButtonHandler_t = ButtonHandler<ButtonMock>; class ButtonHandlerTestFixture { - public: ButtonHandlerTestFixture() : handler(nullptr) { @@ -118,9 +117,7 @@ protected: void callback(int id, ButtonPress pressType) { if (id != 0x5E) - { return; - } switch (pressType) { case ButtonPress::DOWN: diff --git a/src/tests/catch/test-dependencymanager.cpp b/src/tests/catch/test-dependencymanager.cpp index 1b1691390..65c8d68a4 100644 --- a/src/tests/catch/test-dependencymanager.cpp +++ b/src/tests/catch/test-dependencymanager.cpp @@ -40,10 +40,10 @@ public: bool bong_a() { return value; } - void inject(DependencyInjector &getter) { b = getter.get<B>(); } + void inject(DependencyInjector& getter) { b = getter.get<B>(); } private: - B *b = nullptr; + B* b = nullptr; bool value = false; }; @@ -134,8 +134,8 @@ TEST_CASE("DependencyManager - Circular dependencies") { DependencyManager manager; - Boardcore::A *a = new Boardcore::A(); - Boardcore::B *b = new Boardcore::B(); + Boardcore::A* a = new Boardcore::A(); + Boardcore::B* b = new Boardcore::B(); REQUIRE(manager.insert(a)); REQUIRE(manager.insert(b)); @@ -160,10 +160,10 @@ TEST_CASE("DependencyManager - Virtual Dependencies") { DependencyManager manager; - Boardcore::A *a = new Boardcore::A(); - Boardcore::B *b = new Boardcore::B(); - Boardcore::C *c = new Boardcore::C(); - Boardcore::D *d = new Boardcore::D(); + Boardcore::A* a = new Boardcore::A(); + Boardcore::B* b = new Boardcore::B(); + Boardcore::C* c = new Boardcore::C(); + Boardcore::D* d = new Boardcore::D(); REQUIRE(manager.insert<Boardcore::A>(a)); REQUIRE(manager.insert<Boardcore::B>(b)); @@ -194,7 +194,7 @@ TEST_CASE("DependencyManager - Inject fail") { DependencyManager manager; - Boardcore::A *a = new Boardcore::A(); + Boardcore::A* a = new Boardcore::A(); REQUIRE(manager.insert(a)); REQUIRE_FALSE(manager.inject()); @@ -204,8 +204,8 @@ TEST_CASE("DependencyManager - Insert two instances fail") { DependencyManager manager; - Boardcore::A *a1 = new Boardcore::A(); - Boardcore::A *a2 = new Boardcore::A(); + Boardcore::A* a1 = new Boardcore::A(); + Boardcore::A* a2 = new Boardcore::A(); REQUIRE(manager.insert(a1)); REQUIRE_FALSE(manager.insert(a2)); @@ -215,10 +215,10 @@ TEST_CASE("DependencyManager - Dependency tree") { DependencyManager manager; - Boardcore::E *e = new Boardcore::E(); - Boardcore::F *f = new Boardcore::F(); - Boardcore::H *h = new Boardcore::H(); - Boardcore::I *i = new Boardcore::I(); + Boardcore::E* e = new Boardcore::E(); + Boardcore::F* f = new Boardcore::F(); + Boardcore::H* h = new Boardcore::H(); + Boardcore::I* i = new Boardcore::I(); REQUIRE(manager.insert(e)); REQUIRE(manager.insert(f)); @@ -229,4 +229,4 @@ TEST_CASE("DependencyManager - Dependency tree") REQUIRE(i->get_ultimate_true_answer() == 111); manager.graphviz(std::cout); -} \ No newline at end of file +} diff --git a/src/tests/catch/test-kalman.cpp b/src/tests/catch/test-kalman.cpp index e44e3fb2e..227fa4eee 100644 --- a/src/tests/catch/test-kalman.cpp +++ b/src/tests/catch/test-kalman.cpp @@ -101,9 +101,7 @@ TEST_CASE("Update test") filter.predictUpdateF(F_new); if (!filter.correct(y)) - { FAIL("Correction failed at iteration : " << i << " \n"); - } if (filter.getState()(0, 0) != Approx(STATE_1[i]).epsilon(0.01)) { diff --git a/src/tests/catch/test-modulemanager.cpp b/src/tests/catch/test-modulemanager.cpp index 9b0b96f5c..3edfc3576 100644 --- a/src/tests/catch/test-modulemanager.cpp +++ b/src/tests/catch/test-modulemanager.cpp @@ -34,7 +34,7 @@ protected: public: virtual int getDummy() { return dummy; }; - virtual void toggleDummy(){}; + virtual void toggleDummy() {}; }; class HILSensors : public SensorsModule @@ -110,4 +110,4 @@ TEST_CASE("ModuleManager - Insertion after get call") // Verify that the initially inserted module didn't change modules.get<Radio>()->setDummy(345); REQUIRE(modules.get<Radio>()->getDummy() == 345); -} \ No newline at end of file +} diff --git a/src/tests/catch/test-packetqueue.cpp b/src/tests/catch/test-packetqueue.cpp index 0b7eecdc0..db347dee3 100644 --- a/src/tests/catch/test-packetqueue.cpp +++ b/src/tests/catch/test-packetqueue.cpp @@ -75,9 +75,7 @@ TEST_CASE("Packet tests") REQUIRE(p.getMsgCount() == 0); // REQUIRE(p.dump(buf) == 0); for (int i = 0; i < BUF_LEN; i++) - { REQUIRE(buf[i] == 0); - } } SECTION("Adding stuff to packet") diff --git a/src/tests/catch/test-pitot.cpp b/src/tests/catch/test-pitot.cpp index 6fef5533f..3b84e6098 100644 --- a/src/tests/catch/test-pitot.cpp +++ b/src/tests/catch/test-pitot.cpp @@ -70,4 +70,4 @@ TEST_CASE("Pitot Test") << pitot.getLastSample().airspeed << " != " << results[i]); } } -} \ No newline at end of file +} diff --git a/src/tests/catch/test-registry-frontend.cpp b/src/tests/catch/test-registry-frontend.cpp index aa989018e..cfaa741e5 100644 --- a/src/tests/catch/test-registry-frontend.cpp +++ b/src/tests/catch/test-registry-frontend.cpp @@ -51,7 +51,7 @@ static constexpr uint32_t FLOAT_VALUE_ID = 13; * @param entryId The id of the configuration entry * @param entry The EntryStructsUnion structure of the configuration entry */ -void visitFunction(ConfigurationId entryId, EntryStructsUnion &entry) +void visitFunction(ConfigurationId entryId, EntryStructsUnion& entry) { switch (entryId) { @@ -88,7 +88,7 @@ class FakeBackend : public RegistryBackend public: int &startCount, &saveCount, &loadCount; - FakeBackend(int &startCount, int &saveCount, int &loadCount) + FakeBackend(int& startCount, int& saveCount, int& loadCount) : startCount(startCount), saveCount(saveCount), loadCount(loadCount) { } @@ -99,13 +99,13 @@ public: return true; } - bool load(std::vector<uint8_t> &) override + bool load(std::vector<uint8_t>&) override { loadCount++; return true; } - bool save(std::vector<uint8_t> &) override + bool save(std::vector<uint8_t>&) override { saveCount++; return true; @@ -393,4 +393,4 @@ TEST_CASE("RegistryFrontend test - Backend test") REQUIRE(startCount == 1); REQUIRE(saveCount == 1); REQUIRE(loadCount == 1); -} \ No newline at end of file +} diff --git a/src/tests/catch/test-sensormanager-catch.cpp b/src/tests/catch/test-sensormanager-catch.cpp index 01ca815a3..78828284c 100644 --- a/src/tests/catch/test-sensormanager-catch.cpp +++ b/src/tests/catch/test-sensormanager-catch.cpp @@ -96,40 +96,40 @@ private: SensorSampler* samplerSensor5; TestSensor s1; - SensorInfo s1_info{ - /*ID=*/"s1", - /*Period=*/1000, - /*Callback=*/[]() { std::cout << "Callback 1!" << std::endl; }, - /*Enabled=*/true}; + SensorInfo s1_info{/*ID=*/"s1", + /*Period=*/1000, + /*Callback=*/[]() + { std::cout << "Callback 1!" << std::endl; }, + /*Enabled=*/true}; TestSensor s2; - SensorInfo s2_info{ - /*ID=*/"s2", - /*Period=*/1000ms, - /*Callback=*/[]() { std::cout << "Callback 2!" << std::endl; }, - /*Enabled=*/false}; + SensorInfo s2_info{/*ID=*/"s2", + /*Period=*/1000ms, + /*Callback=*/[]() + { std::cout << "Callback 2!" << std::endl; }, + /*Enabled=*/false}; TestSensor s3; - SensorInfo s3_info{ - /*ID=*/"s3", - /*Period=*/500, - /*Callback=*/[]() { std::cout << "Callback 3!" << std::endl; }, - /*Enabled=*/true}; + SensorInfo s3_info{/*ID=*/"s3", + /*Period=*/500, + /*Callback=*/[]() + { std::cout << "Callback 3!" << std::endl; }, + /*Enabled=*/true}; TestSensor s4; - SensorInfo s4_info{ - /*ID=*/"s4", - /*Period=*/1_hz, - /*Callback=*/[]() { std::cout << "Callback 4!" << std::endl; }, - /*Enabled=*/true}; + SensorInfo s4_info{/*ID=*/"s4", + /*Period=*/1_hz, + /*Callback=*/[]() + { std::cout << "Callback 4!" << std::endl; }, + /*Enabled=*/true}; // always failing self-test FailingSensorCatch s5; - SensorInfo s5_info{ - /*ID=*/"s5", - /*Period=*/2000, - /*Callback=*/[]() { std::cout << "Callback 5!" << std::endl; }, - /*Enabled=*/true}; + SensorInfo s5_info{/*ID=*/"s5", + /*Period=*/2000, + /*Callback=*/[]() + { std::cout << "Callback 5!" << std::endl; }, + /*Enabled=*/true}; }; TEST_CASE_METHOD(SensorManagerFixture, diff --git a/src/tests/catch/test-units.cpp b/src/tests/catch/test-units.cpp index 1daa16ba8..b461d9fed 100644 --- a/src/tests/catch/test-units.cpp +++ b/src/tests/catch/test-units.cpp @@ -34,7 +34,7 @@ using namespace Boardcore; template <class T> -bool eq(T const &a, T const &b) +bool eq(T const& a, T const& b) { return std::fabs(a.value() - b.value()) < 1e-6; } @@ -103,4 +103,4 @@ TEST_CASE("Units Test") REQUIRE(a == Radian(2 * PI)); a /= 2; REQUIRE(a == Radian(PI)); -} \ No newline at end of file +} diff --git a/src/tests/catch/xbee/MockXbeeSPIBus.h b/src/tests/catch/xbee/MockXbeeSPIBus.h index 44c48d141..23f4e2af2 100644 --- a/src/tests/catch/xbee/MockXbeeSPIBus.h +++ b/src/tests/catch/xbee/MockXbeeSPIBus.h @@ -87,9 +87,7 @@ protected: uint8_t r = MockSPIBus::_read(); if (inBufPosCntr == inBuf.size()) - { resetATTN(); - } return r; } diff --git a/src/tests/catch/xbee/test-xbee-parser.cpp b/src/tests/catch/xbee/test-xbee-parser.cpp index 26867ab7a..412e27eb2 100644 --- a/src/tests/catch/xbee/test-xbee-parser.cpp +++ b/src/tests/catch/xbee/test-xbee-parser.cpp @@ -51,18 +51,14 @@ void calcChecksum(uint8_t* frame, size_t frameSize) { frame[frameSize - 1] = 0; for (size_t i = 3; i < frameSize - 1; i++) - { frame[frameSize - 1] += frame[i]; - } frame[frameSize - 1] = 0xFF - frame[frameSize - 1]; } void printHex(uint8_t* frame, size_t frameSize) { for (size_t i = 0; i < frameSize; i++) - { printf("%02X ", frame[i]); - } printf("\n"); } @@ -79,9 +75,7 @@ void printu64(uint64_t v) void printBuf(uint8_t* buf, size_t size) { for (size_t i = 0; i < size; i++) - { printf("%02X ", buf[i]); - } printf("\n"); } @@ -538,9 +532,7 @@ TEST_CASE("Parser edge cases") REQUIRE_FALSE(res == APIFrameParser::ParseResult::SUCCESS); if (i == len - 1) - { REQUIRE(res == APIFrameParser::ParseResult::FAIL); - } } } diff --git a/src/tests/drivers/canbus/CanDriver/SimpleCanManager.h b/src/tests/drivers/canbus/CanDriver/SimpleCanManager.h index 991c9b96a..0059bfc6c 100644 --- a/src/tests/drivers/canbus/CanDriver/SimpleCanManager.h +++ b/src/tests/drivers/canbus/CanDriver/SimpleCanManager.h @@ -84,9 +84,7 @@ private: parent.txPackets.waitUntilNotEmpty(); if (shouldStop()) - { return; - } Boardcore::Canbus::CanPacket p = parent.txPackets.pop(); parent.canbus.send(p); p.timestamp = Boardcore::Kernel::getOldTick(); diff --git a/src/tests/drivers/canbus/CanDriver/test-can-2way.cpp b/src/tests/drivers/canbus/CanDriver/test-can-2way.cpp index 446127e97..372fc4b2b 100644 --- a/src/tests/drivers/canbus/CanDriver/test-can-2way.cpp +++ b/src/tests/drivers/canbus/CanDriver/test-can-2way.cpp @@ -98,9 +98,7 @@ void sendNewRequest() packet.id = seq++; if (packet.id % 2 == 0) - { packet.id = 0xFFFFFFF - packet.id; - } packet.ext = 1; packet.length = 8; @@ -108,9 +106,7 @@ void sendNewRequest() packet.data[0] = 0x44; for (int i = 1; i < 8; ++i) - { packet.data[i] = seq + i; - } { Lock<FastMutex> l(mutexMsgs); @@ -132,9 +128,7 @@ public: { Lock<FastMutex> l(mutexMsgs); if (msgs.isFull()) - { ++bufferFull; - } while (!msgs.isEmpty()) { CanMsg msg = msgs.get(); @@ -147,9 +141,7 @@ public: { msgstats.add(msg.ts * 1.0f); if (msg.ts > MSG_DEADLINE) - { ++missedDeadline; - } } else { diff --git a/src/tests/drivers/canbus/CanDriver/test-can-loopback.cpp b/src/tests/drivers/canbus/CanDriver/test-can-loopback.cpp index 0002deca0..4c06c8513 100644 --- a/src/tests/drivers/canbus/CanDriver/test-can-loopback.cpp +++ b/src/tests/drivers/canbus/CanDriver/test-can-loopback.cpp @@ -121,7 +121,6 @@ int main() p.data[i] = 1 << i; for (;;) { - // printPacket("TX", p); p.timestamp = Kernel::getOldTick(); c->send(p); @@ -133,9 +132,7 @@ int main() // c->send(p); while (!c->getRXBuffer().isEmpty()) - { load.addPacket(c->getRXBuffer().pop().packet); - } // c->getRXBuffer().waitUntilNotEmpty(); // CanRXPacket prx = c->getRXBuffer().pop(); // printRXPacket("RX", prx); diff --git a/src/tests/drivers/i2c/test-i2c-driver.cpp b/src/tests/drivers/i2c/test-i2c-driver.cpp index 2519269de..92e0ed686 100644 --- a/src/tests/drivers/i2c/test-i2c-driver.cpp +++ b/src/tests/drivers/i2c/test-i2c-driver.cpp @@ -98,7 +98,7 @@ I2CDriver::I2CSlaveConfig OLEDConfig{OLED.addressSensor, I2CDriver::I2CSlaveConfig LPSConfig{ LPS.addressSensor, I2CDriver::Addressing::BIT7, I2CDriver::Speed::STANDARD}; -bool i2cDriver(I2CDriver &i2c, I2CSensor sensor, +bool i2cDriver(I2CDriver& i2c, I2CSensor sensor, I2CDriver::I2CSlaveConfig sensorConfig) { const size_t nRead = 300; diff --git a/src/tests/drivers/i2c/test-i2c.cpp b/src/tests/drivers/i2c/test-i2c.cpp index a84942dfb..b47b8248f 100644 --- a/src/tests/drivers/i2c/test-i2c.cpp +++ b/src/tests/drivers/i2c/test-i2c.cpp @@ -97,7 +97,7 @@ I2CDriver::I2CSlaveConfig OLEDConfig{OLED.addressSensor, I2CDriver::I2CSlaveConfig LPSConfig{ LPS.addressSensor, I2CDriver::Addressing::BIT7, I2CDriver::Speed::STANDARD}; -bool i2cDriver(I2C &i2c, I2CSensor sensor, +bool i2cDriver(I2C& i2c, I2CSensor sensor, I2CDriver::I2CSlaveConfig sensorConfig) { buffer = 48; diff --git a/src/tests/drivers/test-MBLoadCell.cpp b/src/tests/drivers/test-MBLoadCell.cpp index 6b94d3879..7420314b3 100644 --- a/src/tests/drivers/test-MBLoadCell.cpp +++ b/src/tests/drivers/test-MBLoadCell.cpp @@ -41,15 +41,17 @@ const uint8_t btnUserId = 1; * button is pressed for a long time, resets the minimum and maximum values of * the recorded weights */ -void buttonCallback(ButtonEvent btnPress, MBLoadCell *loadcell) +void buttonCallback(ButtonEvent btnPress, MBLoadCell* loadcell) { if (btnPress == ButtonEvent::PRESSED) + { TRACE( "## MAX: %.2f [Kg] (ts: %.3f)\t##\tMIN: %.2f [Kg] (ts: %.3f) ##\n", loadcell->getMaxWeight().load, loadcell->getMaxWeight().loadTimestamp / 1000000.0, loadcell->getMinWeight().load, loadcell->getMinWeight().load / 1000000.0); + } if (btnPress == ButtonEvent::LONG_PRESS) loadcell->resetMaxMinWeights(); diff --git a/src/tests/drivers/test-wiz5500.cpp b/src/tests/drivers/test-wiz5500.cpp index e1805e4ad..34067d4ca 100644 --- a/src/tests/drivers/test-wiz5500.cpp +++ b/src/tests/drivers/test-wiz5500.cpp @@ -76,7 +76,7 @@ void setupBoard() {} #error "Target not supported" #endif -Wiz5500 *wiz = nullptr; +Wiz5500* wiz = nullptr; #ifdef INTN_IRQ void __attribute__((used)) INTN_IRQ() @@ -95,7 +95,7 @@ void socket0SendLoop() size_t len = sprintf(msg, "Suca palle (DIO0) (0 %d)\n", i); printf("[wiz5500] Sending though socket 0...\n"); - wiz->send(0, reinterpret_cast<uint8_t *>(msg), len); + wiz->send(0, reinterpret_cast<uint8_t*>(msg), len); Thread::sleep(2000); i += 1; } @@ -107,7 +107,7 @@ void socket0RecvLoop() { char msg[1024]; ssize_t len = - wiz->recv(0, reinterpret_cast<uint8_t *>(msg), sizeof(msg)); + wiz->recv(0, reinterpret_cast<uint8_t*>(msg), sizeof(msg)); if (len != -1) { @@ -149,7 +149,7 @@ void socket1SendLoop() size_t len = sprintf(msg, "Suca palle (DIO0) (1 %d)\n", i); printf("[wiz5500] Sending though socket 1...\n"); - wiz->send(1, reinterpret_cast<uint8_t *>(msg), len); + wiz->send(1, reinterpret_cast<uint8_t*>(msg), len); Thread::sleep(1333); i += 1; } @@ -161,7 +161,7 @@ void socket1RecvLoop() { char msg[1024]; ssize_t len = - wiz->recv(1, reinterpret_cast<uint8_t *>(msg), sizeof(msg)); + wiz->recv(1, reinterpret_cast<uint8_t*>(msg), sizeof(msg)); if (len != -1) { @@ -199,7 +199,7 @@ void socket2SendLoop() size_t len = sprintf(msg, "Suca palle (DIO0) (2 %d)\n", i); printf("[wiz5500] Sending though socket 2...\n"); - wiz->send(2, reinterpret_cast<uint8_t *>(msg), len); + wiz->send(2, reinterpret_cast<uint8_t*>(msg), len); Thread::sleep(1666); i += 1; } @@ -212,7 +212,7 @@ void socket2RecvLoop() char msg[1024]; WizIp dst_ip; uint16_t dst_port; - ssize_t len = wiz->recvfrom(2, reinterpret_cast<uint8_t *>(msg), + ssize_t len = wiz->recvfrom(2, reinterpret_cast<uint8_t*>(msg), sizeof(msg), dst_ip, dst_port); std::cout << dst_ip << " " << dst_port << std::endl; @@ -327,4 +327,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/src/tests/drivers/timer/test-timer-utils.cpp b/src/tests/drivers/timer/test-timer-utils.cpp index 5824d9d3e..ffdde2be7 100644 --- a/src/tests/drivers/timer/test-timer-utils.cpp +++ b/src/tests/drivers/timer/test-timer-utils.cpp @@ -34,7 +34,7 @@ void printInputClock(APB bus); void testGetTimerInputClock(); -void testTimerUtils(TIM_TypeDef *timer); +void testTimerUtils(TIM_TypeDef* timer); int main() { @@ -98,16 +98,12 @@ int main() void printInputClock(APB bus) { if (bus == APB::APB1) - { printf("APB1"); - } else - { printf("APB2"); - } } -void testTimerUtils(TIM_TypeDef *timer) +void testTimerUtils(TIM_TypeDef* timer) { // Print the timer clock source printInputClock(getTimerInputClock(timer)); diff --git a/src/tests/drivers/timer/test-timestamptimer.cpp b/src/tests/drivers/timer/test-timestamptimer.cpp index de3ed4696..b3e4da399 100644 --- a/src/tests/drivers/timer/test-timestamptimer.cpp +++ b/src/tests/drivers/timer/test-timestamptimer.cpp @@ -32,7 +32,7 @@ using namespace ClockUtils; void printInputClock(APB bus); -void testTimerUtils(TIM_TypeDef *timer); +void testTimerUtils(TIM_TypeDef* timer); int main() { @@ -72,16 +72,12 @@ int main() void printInputClock(APB bus) { if (bus == APB::APB1) - { printf("Timer input clock from APB1\n"); - } else - { printf("Timer input clock from APB2\n"); - } } -void testTimerUtils(TIM_TypeDef *timer) +void testTimerUtils(TIM_TypeDef* timer) { // Print the timer clock source printInputClock(getTimerInputClock(timer)); diff --git a/src/tests/drivers/usart/test-usart.cpp b/src/tests/drivers/usart/test-usart.cpp index f13bbf1a2..8e9c924f8 100644 --- a/src/tests/drivers/usart/test-usart.cpp +++ b/src/tests/drivers/usart/test-usart.cpp @@ -128,7 +128,7 @@ int baudrates[] = {2400, 9600, 19200, 38400, 57600, * Communication: src -> dst * tests the writeString, write and read methods of the USART drivers */ -bool testCommunicationSequential(USARTInterface *src, USARTInterface *dst) +bool testCommunicationSequential(USARTInterface* src, USARTInterface* dst) { char buf_rx[64] = {0}; StructToSend struct_rx{0}; @@ -195,8 +195,8 @@ bool testCommunicationSequential(USARTInterface *src, USARTInterface *dst) } // Testing the non blocking read only if USART class - if ((dynamic_cast<const USART *>(dst) != nullptr) && - !dynamic_cast<USART *>(dst)->read(&struct_rx, sizeof(StructToSend))) + if ((dynamic_cast<const USART*>(dst) != nullptr) && + !dynamic_cast<USART*>(dst)->read(&struct_rx, sizeof(StructToSend))) { printf("Non blocking read passed!\n"); } @@ -204,7 +204,7 @@ bool testCommunicationSequential(USARTInterface *src, USARTInterface *dst) return passed; } -bool testClearQueue(USART *src, USART *dst) +bool testClearQueue(USART* src, USART* dst) { char buf[128]; unsigned int nReads{0}; @@ -238,7 +238,7 @@ bool testClearQueue(USART *src, USART *dst) return true; } -bool testReadTimeout(USART *src, USART *dst) +bool testReadTimeout(USART* src, USART* dst) { using namespace std::chrono; @@ -298,13 +298,9 @@ bool testReadTimeout(USART *src, USART *dst) printf("\t%d<-- received: \t'%s'\n", dst->getId(), buf); if (!result) - { printf("\tTimed out after %lldms\n", measuredTime.count()); - } else - { printf("\tNo timeout\n"); - } if (strcmp(buf, testString) != 0) { @@ -387,9 +383,7 @@ int main() } while (true) - { Thread::wait(); - } return 0; } diff --git a/src/tests/drivers/xbee/EnergyScanData.h b/src/tests/drivers/xbee/EnergyScanData.h index ab3dbc305..19488aac3 100644 --- a/src/tests/drivers/xbee/EnergyScanData.h +++ b/src/tests/drivers/xbee/EnergyScanData.h @@ -43,18 +43,14 @@ struct EnergyScanData EnergyScanData(long long ts, array<int, 30> scan) { for (int i = 0; i < 30; i++) - { channelData[i] = scan[i]; - } } static string header() { string out = "timestamp"; for (int i = 0; i < 30; i++) - { out += ",channel_" + to_string(i); - } return out + "\n"; } @@ -63,9 +59,7 @@ struct EnergyScanData os << timestamp; for (int i = 0; i < 30; i++) - { os << "," << channelData[i]; - } os << "\n"; } diff --git a/src/tests/drivers/xbee/XbeeTestData.h b/src/tests/drivers/xbee/XbeeTestData.h index cde8e70c9..e44fcd01a 100644 --- a/src/tests/drivers/xbee/XbeeTestData.h +++ b/src/tests/drivers/xbee/XbeeTestData.h @@ -125,9 +125,7 @@ struct EnergyScanData EnergyScanData(long long ts, const array<int, 30> scan) { for (int i = 0; i < 30; i++) - { channelData[i] = scan[i]; - } timestamp = ts; } @@ -136,9 +134,7 @@ struct EnergyScanData { string out = "timestamp"; for (int i = 0; i < 30; i++) - { out += ",channel_" + to_string(i); - } return out + "\n"; } @@ -147,9 +143,7 @@ struct EnergyScanData os << timestamp; for (int i = 0; i < 30; i++) - { os << "," << channelData[i]; - } os << "\n"; } diff --git a/src/tests/drivers/xbee/XbeeTransceiver.h b/src/tests/drivers/xbee/XbeeTransceiver.h index 085e218a0..78a78f04b 100644 --- a/src/tests/drivers/xbee/XbeeTransceiver.h +++ b/src/tests/drivers/xbee/XbeeTransceiver.h @@ -233,9 +233,7 @@ private: while (i <= (int)packetSize - (int)sizeof(expectedNum)) { if (memcmp(packet + i, &expectedNum, sizeof(expectedNum)) != 0) - { return false; - } i += sizeof(expectedNum); } memcpy(packet + i, &expectedNum, packetSize % sizeof(expectedNum)); @@ -286,13 +284,9 @@ public: void start() { if (senderEnabled) - { sender->start(); - } if (receiverEnabled) - { receiver->start(); - } } void stop() @@ -317,9 +311,7 @@ private: logAPIFrame(frame); if (frameListener) - { frameListener(frame); - } if (frame.frameType == Xbee::FTYPE_AT_COMMAND_RESPONSE) { @@ -327,9 +319,7 @@ private: frame.toFrameType<Xbee::ATCommandResponseFrame>(); if (strncmp(at->getATCommand(), "DB", 2) == 0) - { receiver->data.RSSI = -*at->getCommandDataPointer(); - } if (strncmp(at->getATCommand(), "ER", 2) == 0) { @@ -351,9 +341,7 @@ private: ATCommandFrameLog dest; logged = ATCommandFrameLog::toFrameType(frame, &dest); if (logged) - { logger.log(dest); - } break; } case FTYPE_AT_COMMAND_RESPONSE: @@ -361,9 +349,7 @@ private: ATCommandResponseFrameLog dest; logged = ATCommandResponseFrameLog::toFrameType(frame, &dest); if (logged) - { logger.log(dest); - } break; } case FTYPE_MODEM_STATUS: @@ -371,9 +357,7 @@ private: ModemStatusFrameLog dest; logged = ModemStatusFrameLog::toFrameType(frame, &dest); if (logged) - { logger.log(dest); - } break; } case FTYPE_TX_REQUEST: @@ -381,9 +365,7 @@ private: TXRequestFrameLog dest; logged = TXRequestFrameLog::toFrameType(frame, &dest); if (logged) - { logger.log(dest); - } break; } case FTYPE_TX_STATUS: @@ -391,9 +373,7 @@ private: TXStatusFrameLog dest; logged = TXStatusFrameLog::toFrameType(frame, &dest); if (logged) - { logger.log(dest); - } break; } case FTYPE_RX_PACKET_FRAME: @@ -401,9 +381,7 @@ private: RXPacketFrameLog dest; logged = RXPacketFrameLog::toFrameType(frame, &dest); if (logged) - { logger.log(dest); - } break; } } diff --git a/src/tests/drivers/xbee/gui/EnergyScanScreen.h b/src/tests/drivers/xbee/gui/EnergyScanScreen.h index 49259f2d8..9a6f5338e 100644 --- a/src/tests/drivers/xbee/gui/EnergyScanScreen.h +++ b/src/tests/drivers/xbee/gui/EnergyScanScreen.h @@ -118,9 +118,7 @@ struct EnergyScanScreen ~EnergyScanScreen() { for (unsigned int i = 0; i < NUM_COLS; i++) - { delete colTitles[i]; - } for (unsigned int i = 0; i < NUM_CHANNELS; ++i) { @@ -161,9 +159,7 @@ struct EnergyScanScreen void resetStats() { for (unsigned int i = 0; i < NUM_CHANNELS; i++) - { chStats[i].reset(); - } absMax = std::numeric_limits<float>::lowest(); absMin = std::numeric_limits<float>::max(); @@ -198,17 +194,11 @@ private: { float delta = absMax - absMin; if (val >= absMax - delta * COLOR_PERCENTILE) - { tv->setTextColor(mxgui::green); - } else if (val <= absMin + delta * COLOR_PERCENTILE) - { tv->setTextColor(0xFDC0); // Light orange - } else - { tv->setTextColor(mxgui::white); - } } float absMax = std::numeric_limits<float>::lowest(); float absMin = std::numeric_limits<float>::max(); diff --git a/src/tests/drivers/xbee/gui/StatusScreen.h b/src/tests/drivers/xbee/gui/StatusScreen.h index b79055d9b..fb16295a4 100644 --- a/src/tests/drivers/xbee/gui/StatusScreen.h +++ b/src/tests/drivers/xbee/gui/StatusScreen.h @@ -209,17 +209,13 @@ struct StatusScreen tvLogBufDropped.setText(to_string(stats.droppedSamples)); if (stats.droppedSamples > 0) - { tvLogBufDropped.setBackgroundColor(mxgui::red); - } tvLogBufFailed.setText(to_string(stats.writesFailed) + " (" + to_string(stats.lastWriteError) + ")"); if (stats.lastWriteError != 0) - { tvLogBufFailed.setBackgroundColor(mxgui::red); - } tvLogBufWritten.setText(to_string(stats.buffersWritten)); tvLogBufTtw.setText(to_string(stats.averageWriteTime) + " ms"); diff --git a/src/tests/drivers/xbee/test-xbee-bidir.cpp b/src/tests/drivers/xbee/test-xbee-bidir.cpp index 0aa00c84a..f34e57e85 100644 --- a/src/tests/drivers/xbee/test-xbee-bidir.cpp +++ b/src/tests/drivers/xbee/test-xbee-bidir.cpp @@ -82,9 +82,7 @@ void __attribute__((used)) EXTI5_IRQHandlerImpl() #endif { if (xbeeDriver != nullptr) - { xbeeDriver->handleATTNInterrupt(); - } } int getUserBtnValue() @@ -139,17 +137,13 @@ void setupXbee(XbeeConfig config) if (config.dataRate80k) { if (!Xbee::setDataRate(*xbeeDriver, true)) - { TRACE("[main] Error setting xbeeDriver data rate!\n"); - } } if (!config.freqHop) { if (!Xbee::disableFrequencyHopping(*xbeeDriver)) - { TRACE("[main] Error disabling frequency hop!\n"); - } } } } @@ -199,13 +193,9 @@ int main() XbeeTransceiver* trans = new XbeeTransceiver(*xbeeDriver, logger, intv, 256, 333); if (!config.txEnabled) - { trans->disableSender(); - } if (!RUN_RECEIVER) - { trans->disableReceiver(); - } trans->start(); // cppcheck-suppress knownConditionTrueFalse diff --git a/src/tests/drivers/xbee/test-xbee-gui.cpp b/src/tests/drivers/xbee/test-xbee-gui.cpp index 6b3099ff5..e31d38a3b 100644 --- a/src/tests/drivers/xbee/test-xbee-gui.cpp +++ b/src/tests/drivers/xbee/test-xbee-gui.cpp @@ -100,9 +100,7 @@ protected: array<int, 30> scan; for (uint16_t i = 0; i < response.getCommandDataLength(); i++) - { scan[i] = -(int)(*(response.getCommandDataPointer() + i)); - } gui->screenEnergy.updateScan(scan); @@ -218,7 +216,6 @@ void onStartButtonClick(View* btn __attribute__((unused)), Interaction action) { if (action == Interaction::CLICK) { - XbeeConfig cfg = gui->screenConfig.config; cfg.timestamp = Kernel::getOldTick(); logger.log(cfg); @@ -242,19 +239,13 @@ void onStopButtonClick(View* btn, Interaction action) TextView* tvBtn = dynamic_cast<TextView*>(btn); if (tvBtn) - { tvBtn->setText("Stopping..."); - } if (trans) - { trans->stop(); - } if (energyScanner.isRunning()) - { energyScanner.stop(); - } logger.stop(); @@ -271,9 +262,7 @@ void onMarkButtonClick(View* btn __attribute__((unused)), Interaction action) TextView* tvBtn = dynamic_cast<TextView*>(btn); if (tvBtn) - { tvBtn->setText("Mark Log (" + to_string(markCounter) + ")"); - } } } @@ -293,9 +282,7 @@ void startTransceiver(XbeeConfig config) config.sendInterval); if (!config.txEnabled) - { trans->disableSender(); - } trans->start(); } @@ -352,7 +339,5 @@ void configure() void __attribute__((used)) EXTI5_IRQHandlerImpl() { if (xbee) - { xbee->handleATTNInterrupt(); - } } diff --git a/src/tests/events/fsm/test-fsm.cpp b/src/tests/events/fsm/test-fsm.cpp index b6f2dc4f7..085a5be9b 100644 --- a/src/tests/events/fsm/test-fsm.cpp +++ b/src/tests/events/fsm/test-fsm.cpp @@ -62,9 +62,7 @@ int main() printf("End\n"); for (;;) - { Thread::sleep(10000); - } // Stop the threds, even though we will never reach this point, but just for // correctness ;) diff --git a/src/tests/hil/BoardScheduler.cpp b/src/tests/hil/BoardScheduler.cpp index b8acb5a4f..0e959c708 100644 --- a/src/tests/hil/BoardScheduler.cpp +++ b/src/tests/hil/BoardScheduler.cpp @@ -62,4 +62,4 @@ bool BoardScheduler::isStarted() return scheduler1->isRunning() && scheduler2->isRunning() && scheduler3->isRunning() && scheduler4->isRunning(); } -} // namespace HILTest \ No newline at end of file +} // namespace HILTest diff --git a/src/tests/hil/BoardScheduler.h b/src/tests/hil/BoardScheduler.h index 5664a8095..4cdc2f510 100644 --- a/src/tests/hil/BoardScheduler.h +++ b/src/tests/hil/BoardScheduler.h @@ -59,4 +59,4 @@ private: Boardcore::TaskScheduler* scheduler3; Boardcore::TaskScheduler* scheduler4; }; -} // namespace HILTest \ No newline at end of file +} // namespace HILTest diff --git a/src/tests/hil/Buses.h b/src/tests/hil/Buses.h index 33dffab57..6ccc02181 100644 --- a/src/tests/hil/Buses.h +++ b/src/tests/hil/Buses.h @@ -53,4 +53,4 @@ public: { } }; -} // namespace HILTest \ No newline at end of file +} // namespace HILTest diff --git a/src/tests/hil/HILSimulationConfig.h b/src/tests/hil/HILSimulationConfig.h index 2e9e218db..fbbd393d7 100644 --- a/src/tests/hil/HILSimulationConfig.h +++ b/src/tests/hil/HILSimulationConfig.h @@ -527,4 +527,4 @@ private: } }; -} // namespace HILConfig \ No newline at end of file +} // namespace HILConfig diff --git a/src/tests/hil/Sensors/HILSensors.h b/src/tests/hil/Sensors/HILSensors.h index 7d642072a..e3dca2dec 100644 --- a/src/tests/hil/Sensors/HILSensors.h +++ b/src/tests/hil/Sensors/HILSensors.h @@ -357,4 +357,4 @@ private: std::unique_ptr<Boardcore::Pitot> pitot; bool enableHw; }; -} // namespace HILTest \ No newline at end of file +} // namespace HILTest diff --git a/src/tests/hil/Sensors/Sensors.cpp b/src/tests/hil/Sensors/Sensors.cpp index 1877bd5c7..bc1edb3d9 100644 --- a/src/tests/hil/Sensors/Sensors.cpp +++ b/src/tests/hil/Sensors/Sensors.cpp @@ -447,16 +447,13 @@ Sensors::getSensorInfo() { // Check wether the lambda is existent if (sensorsInit[i]) - { sensorState[i] = sensorsInit[i](); - } } return sensorState; } void Sensors::lps22dfCreation() { - // Get the correct SPI configuration SPIBusConfig config = LPS22DF::getDefaultSPIConfig(); config.clockDivider = SPI::ClockDivider::DIV_16; @@ -473,7 +470,6 @@ void Sensors::lps22dfCreation() } void Sensors::lps28dfw_1Creation() { - // Configure the sensor LPS28DFW::SensorConfig config{false, LPS28DFW_FSR, LPS28DFW_AVG, LPS28DFW_ODR, false}; @@ -483,7 +479,6 @@ void Sensors::lps28dfw_1Creation() } void Sensors::lps28dfw_2Creation() { - // Configure the sensor LPS28DFW::SensorConfig config{true, LPS28DFW_FSR, LPS28DFW_AVG, LPS28DFW_ODR, false}; @@ -493,7 +488,6 @@ void Sensors::lps28dfw_2Creation() } void Sensors::h3lis331dlCreation() { - // Get the correct SPI configuration SPIBusConfig config = H3LIS331DL::getDefaultSPIConfig(); config.clockDivider = SPI::ClockDivider::DIV_16; @@ -505,7 +499,6 @@ void Sensors::h3lis331dlCreation() } void Sensors::lis2mdlCreation() { - // Get the correct SPI configuration SPIBusConfig config = LIS2MDL::getDefaultSPIConfig(); config.clockDivider = SPI::ClockDivider::DIV_16; @@ -524,7 +517,6 @@ void Sensors::lis2mdlCreation() void Sensors::ubxgpsCreation() { - // Get the correct SPI configuration SPIBusConfig config = UBXGPSSpi::getDefaultSPIConfig(); config.clockDivider = SPI::ClockDivider::DIV_64; @@ -536,7 +528,6 @@ void Sensors::ubxgpsCreation() void Sensors::lsm6dsrxCreation() { - // Configure the SPI SPIBusConfig config; config.clockDivider = SPI::ClockDivider::DIV_32; @@ -569,7 +560,6 @@ void Sensors::lsm6dsrxCreation() void Sensors::ads131m08Creation() { - // Configure the SPI SPIBusConfig config; config.clockDivider = SPI::ClockDivider::DIV_32; @@ -690,9 +680,7 @@ void Sensors::lsm6dsrxCallback() // For every instance inside the fifo log the sample for (uint16_t i = 0; i < fifoSize; i++) - { Logger::getInstance().log(fifo.at(i)); - } } void Sensors::ads131m08Callback() { @@ -722,4 +710,4 @@ void Sensors::imuCallback() Logger::getInstance().log(lastSample); } -} // namespace HILTest \ No newline at end of file +} // namespace HILTest diff --git a/src/tests/hil/Sensors/Sensors.h b/src/tests/hil/Sensors/Sensors.h index b487b7cd6..9b5dedf26 100644 --- a/src/tests/hil/Sensors/Sensors.h +++ b/src/tests/hil/Sensors/Sensors.h @@ -229,4 +229,4 @@ protected: std::unique_ptr<Boardcore::HSCMRNN015PA> hscmrnn015pa_1; std::unique_ptr<Boardcore::HSCMRNN015PA> hscmrnn015pa_2; }; -} // namespace HILTest \ No newline at end of file +} // namespace HILTest diff --git a/src/tests/hil/Sensors/SensorsConfig.h b/src/tests/hil/Sensors/SensorsConfig.h index 09c6cb3e2..fdfaf8055 100644 --- a/src/tests/hil/Sensors/SensorsConfig.h +++ b/src/tests/hil/Sensors/SensorsConfig.h @@ -118,4 +118,4 @@ constexpr unsigned int CALIBRATION_PERIOD = 100; constexpr unsigned int NUMBER_OF_SENSORS = 8; } // namespace SensorsConfig -} // namespace HILTest \ No newline at end of file +} // namespace HILTest diff --git a/src/tests/hil/Sensors/SensorsData.h b/src/tests/hil/Sensors/SensorsData.h index 8bc5ca1ef..e8e6abc50 100644 --- a/src/tests/hil/Sensors/SensorsData.h +++ b/src/tests/hil/Sensors/SensorsData.h @@ -114,8 +114,7 @@ struct HSCMRNN015PA_1Data : Boardcore::HSCMRNN015PAData void print(std::ostream& os) const { - os << pressureTimestamp << "," << pressure << "," - << "\n"; + os << pressureTimestamp << "," << pressure << "," << "\n"; } }; @@ -132,9 +131,8 @@ struct HSCMRNN015PA_2Data : Boardcore::HSCMRNN015PAData void print(std::ostream& os) const { - os << pressureTimestamp << "," << pressure << "," - << "\n"; + os << pressureTimestamp << "," << pressure << "," << "\n"; } }; -} // namespace HILTest \ No newline at end of file +} // namespace HILTest diff --git a/src/tests/hil/test-hil.cpp b/src/tests/hil/test-hil.cpp index 2b5790f6c..fb0d2b9bf 100644 --- a/src/tests/hil/test-hil.cpp +++ b/src/tests/hil/test-hil.cpp @@ -77,9 +77,7 @@ int main() SIMULATION_PERIOD); if (HIL_TEST) - { initResult &= ModuleManager::getInstance().insert<MainHIL>(hil); - } sensors = new HILSensors(&scheduler, buses, hil, false); } else @@ -121,4 +119,4 @@ int main() } return 0; -} \ No newline at end of file +} diff --git a/src/tests/logger/test-logger.cpp b/src/tests/logger/test-logger.cpp index 49f61ff2e..891c54bfc 100644 --- a/src/tests/logger/test-logger.cpp +++ b/src/tests/logger/test-logger.cpp @@ -74,9 +74,7 @@ int main() puts("stopped"); for (;;) - { Thread::sleep(1000); - } return 0; } diff --git a/src/tests/radio/sx1278/fsk/common.h b/src/tests/radio/sx1278/fsk/common.h index 9106da46a..48560e623 100644 --- a/src/tests/radio/sx1278/fsk/common.h +++ b/src/tests/radio/sx1278/fsk/common.h @@ -24,7 +24,7 @@ #include <radio/SX1278/SX1278Fsk.h> -static const char *stringFromErr(Boardcore::SX1278Fsk::Error err) +static const char* stringFromErr(Boardcore::SX1278Fsk::Error err) { switch (err) { @@ -39,7 +39,7 @@ static const char *stringFromErr(Boardcore::SX1278Fsk::Error err) } } -static const char *stringFromRxBw(Boardcore::SX1278Fsk::Config::RxBw rx_bw) +static const char* stringFromRxBw(Boardcore::SX1278Fsk::Config::RxBw rx_bw) { switch (rx_bw) { @@ -90,7 +90,7 @@ static const char *stringFromRxBw(Boardcore::SX1278Fsk::Config::RxBw rx_bw) } } -static void printConfig(const Boardcore::SX1278Fsk::Config &config) +static void printConfig(const Boardcore::SX1278Fsk::Config& config) { printf("config.freq_rf = %d\n", config.freq_rf); printf("config.freq_dev = %d\n", config.freq_dev); diff --git a/src/tests/radio/sx1278/fsk/test-sx1278-bidir.cpp b/src/tests/radio/sx1278/fsk/test-sx1278-bidir.cpp index 1d3670053..dfc0c9f11 100644 --- a/src/tests/radio/sx1278/fsk/test-sx1278-bidir.cpp +++ b/src/tests/radio/sx1278/fsk/test-sx1278-bidir.cpp @@ -58,7 +58,7 @@ using rxen = Gpio<GPIOD_BASE, 4>; #error "Target not supported" #endif -SX1278Fsk *sx1278 = nullptr; +SX1278Fsk* sx1278 = nullptr; void __attribute__((used)) SX1278_IRQ_DIO0() { @@ -103,7 +103,7 @@ void recvLoop() while (1) { ssize_t res = - sx1278->receive(reinterpret_cast<uint8_t *>(buf), sizeof(buf)); + sx1278->receive(reinterpret_cast<uint8_t*>(buf), sizeof(buf)); if (res != -1) { // Make sure there is a terminator somewhere @@ -114,7 +114,7 @@ void recvLoop() } } -void sendLoop(int interval, const char *data) +void sendLoop(int interval, const char* data) { char buf[SX1278Fsk::MTU]; strncpy(buf, data, sizeof(buf) - 1); @@ -123,7 +123,7 @@ void sendLoop(int interval, const char *data) { miosix::Thread::sleep(interval); - sx1278->send(reinterpret_cast<uint8_t *>(buf), strlen(buf) + 1); + sx1278->send(reinterpret_cast<uint8_t*>(buf), strlen(buf) + 1); printf("[sx1278] Sent '%s'\n", buf); } } @@ -156,7 +156,7 @@ int main() printf("\n[sx1278] Initialization complete!\n"); - const char *msg = + const char* msg = "Very very very very very very very very very very very " "very very very very very very very very very very very " "very very very very very very very very very very very " diff --git a/src/tests/radio/sx1278/gui/GUI.h b/src/tests/radio/sx1278/gui/GUI.h index 9f317e8df..cb9f2cd77 100644 --- a/src/tests/radio/sx1278/gui/GUI.h +++ b/src/tests/radio/sx1278/gui/GUI.h @@ -112,7 +112,7 @@ public: status.setText("READY"); } - void updateStats(Data &stats) + void updateStats(Data& stats) { tx_bitrate.setText(format_link_speed(stats.tx_bitrate)); sent_count.setText(fmt::format("{}", stats.sent_count)); diff --git a/src/tests/radio/sx1278/lora/test-sx1278-bidir.cpp b/src/tests/radio/sx1278/lora/test-sx1278-bidir.cpp index 673354430..73f165c29 100644 --- a/src/tests/radio/sx1278/lora/test-sx1278-bidir.cpp +++ b/src/tests/radio/sx1278/lora/test-sx1278-bidir.cpp @@ -61,7 +61,7 @@ using rxen = Gpio<GPIOD_BASE, 4>; #error "Target not supported" #endif -SX1278Lora *sx1278 = nullptr; +SX1278Lora* sx1278 = nullptr; void __attribute__((used)) SX1278_IRQ_DIO0() { @@ -91,26 +91,22 @@ void initBoard() #endif } -bool isByteBuf(uint8_t *buf, ssize_t len) +bool isByteBuf(uint8_t* buf, ssize_t len) { for (ssize_t i = 0; i < len; i++) - { if (!isprint(buf[i])) return true; - } return false; } -void formatByteBuf(uint8_t *buf, ssize_t len, char *out) +void formatByteBuf(uint8_t* buf, ssize_t len, char* out) { for (ssize_t i = 0; i < len; i++) - { if (i == 0) out += sprintf(out, "%02X", buf[i]); else out += sprintf(out, ":%02X", buf[i]); - } // Put terminator at the end *out = '\0'; @@ -144,7 +140,7 @@ void recvLoop() } } -void sendLoop(int interval, const char *data) +void sendLoop(int interval, const char* data) { char buf[SX1278Lora::MTU]; strncpy(buf, data, sizeof(buf) - 1); @@ -153,7 +149,7 @@ void sendLoop(int interval, const char *data) { miosix::Thread::sleep(interval); - sx1278->send(reinterpret_cast<uint8_t *>(buf), strlen(buf)); + sx1278->send(reinterpret_cast<uint8_t*>(buf), strlen(buf)); printf("[sx1278] Sent '%s'\n", buf); } } @@ -192,7 +188,7 @@ int main() printf("\n[sx1278] Initialization complete!\n"); - const char *msg = + const char* msg = "Very very very very very very very very very very very " "very very very very very very very very very very very " "very very very very very very very very very very very " diff --git a/src/tests/radio/sx1278/lora/test-sx1278-simple.cpp b/src/tests/radio/sx1278/lora/test-sx1278-simple.cpp index efca424cc..569fcb468 100644 --- a/src/tests/radio/sx1278/lora/test-sx1278-simple.cpp +++ b/src/tests/radio/sx1278/lora/test-sx1278-simple.cpp @@ -57,7 +57,7 @@ using rxen = Gpio<GPIOD_BASE, 4>; #error "Target not supported" #endif -SX1278Lora *sx1278 = nullptr; +SX1278Lora* sx1278 = nullptr; void __attribute__((used)) SX1278_IRQ_DIO0() { @@ -89,7 +89,6 @@ void initBoard() int main() { - initBoard(); SX1278Lora::Config config = {}; diff --git a/src/tests/radio/sx1278/sx1278-init.h b/src/tests/radio/sx1278/sx1278-init.h index 04b5d5053..527a6774d 100644 --- a/src/tests/radio/sx1278/sx1278-init.h +++ b/src/tests/radio/sx1278/sx1278-init.h @@ -146,10 +146,10 @@ using rst = miosix::radio2::nrst; #ifdef SX1278_IS_LORA static constexpr size_t SX1278_MTU = Boardcore::SX1278Lora::MTU; -Boardcore::SX1278Lora *sx1278 = nullptr; +Boardcore::SX1278Lora* sx1278 = nullptr; #else static constexpr size_t SX1278_MTU = Boardcore::SX1278Fsk::MTU; -Boardcore::SX1278Fsk *sx1278 = nullptr; +Boardcore::SX1278Fsk* sx1278 = nullptr; #endif volatile int dio0_cnt = 0; diff --git a/src/tests/radio/sx1278/test-sx1278-bench-gui.cpp b/src/tests/radio/sx1278/test-sx1278-bench-gui.cpp index c07aea5c2..cea238a17 100644 --- a/src/tests/radio/sx1278/test-sx1278-bench-gui.cpp +++ b/src/tests/radio/sx1278/test-sx1278-bench-gui.cpp @@ -27,7 +27,7 @@ using namespace mxgui; -GUI *gui = nullptr; +GUI* gui = nullptr; void initGUI() { @@ -46,10 +46,8 @@ int main() initBoard(); initGUI(); if (!initRadio()) - { while (1) ; - } // Set display to ready gui->stats_screen.updateReady(); diff --git a/src/tests/radio/sx1278/test-sx1278-bench-serial.cpp b/src/tests/radio/sx1278/test-sx1278-bench-serial.cpp index da250f7fe..ed5947dd6 100644 --- a/src/tests/radio/sx1278/test-sx1278-bench-serial.cpp +++ b/src/tests/radio/sx1278/test-sx1278-bench-serial.cpp @@ -27,10 +27,8 @@ int main() { initBoard(); if (!initRadio()) - { while (1) ; - } // Initialize backgrounds threads spawnThreads(); diff --git a/src/tests/radio/sx1278/test-sx1278-bench.cpp b/src/tests/radio/sx1278/test-sx1278-bench.cpp index 67d02cecb..8f819bd7e 100644 --- a/src/tests/radio/sx1278/test-sx1278-bench.cpp +++ b/src/tests/radio/sx1278/test-sx1278-bench.cpp @@ -113,7 +113,7 @@ void recvLoop() { TestMsg msg = {}; - sx1278->receive((uint8_t *)&msg, sizeof(msg)); + sx1278->receive((uint8_t*)&msg, sizeof(msg)); if (msg.validate()) { stats.recv_count++; @@ -142,7 +142,7 @@ void sendLoop() TestMsg msg = {}; msg.generate(); - sx1278->send((uint8_t *)&msg, sizeof(msg)); + sx1278->send((uint8_t*)&msg, sizeof(msg)); stats.sent_count++; uint32_t cur = TimestampTimer::getTimestamp(); diff --git a/src/tests/scheduler/test-taskscheduler.cpp b/src/tests/scheduler/test-taskscheduler.cpp index 07ef20a1c..8986af9ee 100644 --- a/src/tests/scheduler/test-taskscheduler.cpp +++ b/src/tests/scheduler/test-taskscheduler.cpp @@ -52,9 +52,7 @@ void task2Hz() pin1.low(); if (taskLogEnabled) - { printf("2 Hz tick\n"); - } } void task5Hz() @@ -64,9 +62,7 @@ void task5Hz() pin2.low(); if (taskLogEnabled) - { printf("5 Hz tick\n"); - } } void task500Hz() @@ -216,9 +212,7 @@ void test_fill_scheduler() size_t lastId = scheduler.addTask(f2Hz, 500, TaskScheduler::Policy::ONE_SHOT); if (!lastId) - { break; - } taskCount++; } while (true); @@ -271,9 +265,7 @@ void test_runtime_add_task() printf("Adding a new task (5Hz)\n"); if (!scheduler.addTask(f5Hz, 200)) - { printf("Error adding task while the scheduler is running\n"); - } Thread::sleep(4 * 1000); @@ -338,9 +330,7 @@ void test_edge_cases() printf("Starting the scheduler again\n"); if (scheduler.start()) - { printf("Error: started the scheduler twice\n"); - } Thread::sleep(1000); diff --git a/src/tests/sensors/analog/test-analog-pressure-sensors.cpp b/src/tests/sensors/analog/test-analog-pressure-sensors.cpp index d64e113db..417ed6a10 100644 --- a/src/tests/sensors/analog/test-analog-pressure-sensors.cpp +++ b/src/tests/sensors/analog/test-analog-pressure-sensors.cpp @@ -97,13 +97,9 @@ int main() // Self test if (ads1118.selfTest()) - { TRACE("Self test successful!\n"); - } else - { TRACE("Self test failed :( error: %d\n", ads1118.getLastError()); - } // Read samples with sample() while (1) diff --git a/src/tests/sensors/calibration/test-calibration-stats.cpp b/src/tests/sensors/calibration/test-calibration-stats.cpp index 25989ca65..1b114ba9f 100644 --- a/src/tests/sensors/calibration/test-calibration-stats.cpp +++ b/src/tests/sensors/calibration/test-calibration-stats.cpp @@ -192,9 +192,7 @@ int main() data.accelerationY, data.accelerationZ); if (sleepTime > 0) - { Thread::sleep(sleepTime); - } } } } diff --git a/src/tests/sensors/test-ads1118.cpp b/src/tests/sensors/test-ads1118.cpp index 4932da3b6..6aaf53e9d 100644 --- a/src/tests/sensors/test-ads1118.cpp +++ b/src/tests/sensors/test-ads1118.cpp @@ -103,13 +103,9 @@ int main() // Self test if (ads1118.selfTest()) - { TRACE("Self test successful!\n"); - } else - { TRACE("Self test failed :( error: %d\n", ads1118.getLastError()); - } // Read the two channels indipendently TRACE("\nNow reading the two channels with 'readInputAndWait()'\n"); diff --git a/src/tests/sensors/test-ads131m04.cpp b/src/tests/sensors/test-ads131m04.cpp index 1e073ee6e..435f9c85f 100644 --- a/src/tests/sensors/test-ads131m04.cpp +++ b/src/tests/sensors/test-ads131m04.cpp @@ -65,13 +65,9 @@ int main() printf("Now performing self test...\n"); if (ads131.selfTest()) - { printf("Self test succeeded\n"); - } else - { printf("Self test failed!\n"); - } // ads131.calibrateOffset(ADS131M04Defs::Channel::CHANNEL_0); // ads131.calibrateOffset(ADS131M04Defs::Channel::CHANNEL_1); diff --git a/src/tests/sensors/test-ads131m08.cpp b/src/tests/sensors/test-ads131m08.cpp index ea36065dc..688d4b1bd 100644 --- a/src/tests/sensors/test-ads131m08.cpp +++ b/src/tests/sensors/test-ads131m08.cpp @@ -65,13 +65,9 @@ int main() printf("Now performing self test...\n"); if (ads131.selfTest()) - { printf("Self test succeeded\n"); - } else - { printf("Self test failed!\n"); - } ads131.calibrateOffset(ADS131M08Defs::Channel::CHANNEL_0); ads131.calibrateOffset(ADS131M08Defs::Channel::CHANNEL_1); diff --git a/src/tests/sensors/test-bmp280-i2c.cpp b/src/tests/sensors/test-bmp280-i2c.cpp index a913521be..4b5161476 100644 --- a/src/tests/sensors/test-bmp280-i2c.cpp +++ b/src/tests/sensors/test-bmp280-i2c.cpp @@ -35,14 +35,10 @@ int main() BMP280I2C bmp280(bus); if (!bmp280.init()) - { printf("Init failed\n"); - } if (!bmp280.selfTest()) - { printf("Self test failed\n"); - } while (true) { diff --git a/src/tests/sensors/test-bmx160.cpp b/src/tests/sensors/test-bmx160.cpp index 43e3cc976..6557645cd 100644 --- a/src/tests/sensors/test-bmx160.cpp +++ b/src/tests/sensors/test-bmx160.cpp @@ -35,16 +35,14 @@ GpioPin spiSck(GPIOA_BASE, 5); GpioPin spiMiso(GPIOA_BASE, 6); GpioPin spiMosi(GPIOA_BASE, 7); -BMX160 *sensor = nullptr; +BMX160* sensor = nullptr; uint32_t tick = 0; void __attribute__((used)) EXTI5_IRQHandlerImpl() { tick = TimestampTimer::getTimestamp(); if (sensor) - { sensor->IRQupdateTimestamp(tick); - } } int main() diff --git a/src/tests/sensors/test-h3lis331dl.cpp b/src/tests/sensors/test-h3lis331dl.cpp index 042f56645..7cc8a6137 100644 --- a/src/tests/sensors/test-h3lis331dl.cpp +++ b/src/tests/sensors/test-h3lis331dl.cpp @@ -69,9 +69,7 @@ int main() { printf("Failed init!\n"); if (sensor.getLastError() == SensorErrors::INVALID_WHOAMI) - { printf("Invalid WHOAMI\n"); - } return -1; } diff --git a/src/tests/sensors/test-l3gd20-fifo.cpp b/src/tests/sensors/test-l3gd20-fifo.cpp index 03d6677eb..76e9186c0 100644 --- a/src/tests/sensors/test-l3gd20-fifo.cpp +++ b/src/tests/sensors/test-l3gd20-fifo.cpp @@ -120,9 +120,7 @@ void __attribute__((used)) EXTI2_IRQHandlerImpl() // Pass timestamp to the sensor if (gyro != nullptr) - { gyro->IRQupdateTimestamp(currentTimestamp); - } } void configure() @@ -195,9 +193,7 @@ int main() // Stop if we have enough data if (dataCounter >= NUM_SAMPLES) - { break; - } } ++fifoNum; @@ -230,7 +226,5 @@ int main() printf("\n\n\nend.\n"); for (;;) - { Thread::sleep(1000); - } } diff --git a/src/tests/sensors/test-l3gd20.cpp b/src/tests/sensors/test-l3gd20.cpp index e9deb8b5c..b9bfbfdaa 100644 --- a/src/tests/sensors/test-l3gd20.cpp +++ b/src/tests/sensors/test-l3gd20.cpp @@ -91,9 +91,7 @@ void __attribute__((used)) EXTI2_IRQHandlerImpl() // Pass timestamp to sensor if (gyro != nullptr) - { gyro->IRQupdateTimestamp(currentTimestamp); - } } void configure() @@ -176,7 +174,5 @@ int main() printf("\n\n\nend.\n"); for (;;) - { Thread::sleep(1000); - } } diff --git a/src/tests/sensors/test-lis2mdl.cpp b/src/tests/sensors/test-lis2mdl.cpp index a0060c76e..1239e4787 100644 --- a/src/tests/sensors/test-lis2mdl.cpp +++ b/src/tests/sensors/test-lis2mdl.cpp @@ -68,9 +68,7 @@ int main() printf("Doing self test!\n"); if (!sensor.selfTest()) - { printf("Error: selfTest() returned false!\n"); - } printf("selfTest returned true\n"); printf("Now printing some sensor data:\n"); diff --git a/src/tests/sensors/test-lis3dsh.cpp b/src/tests/sensors/test-lis3dsh.cpp index 7588e9cca..2672c0ae0 100644 --- a/src/tests/sensors/test-lis3dsh.cpp +++ b/src/tests/sensors/test-lis3dsh.cpp @@ -65,13 +65,9 @@ int main() if (!sensor.init()) { if (sensor.getLastError() == SensorErrors::INVALID_WHOAMI) - { printf("TEST FAILED: invalid WHO_AM_I value, init failed \n"); - } else - { printf("TEST FAILED: init failed \n"); - } return -1; } @@ -91,9 +87,7 @@ int main() sensor.sample(); if (sensor.getLastError() == SensorErrors::NO_NEW_DATA) - { printf("\nWarning: no new data to be read \n"); - } data = sensor.getLastSample(); diff --git a/src/tests/sensors/test-lis3mdl.cpp b/src/tests/sensors/test-lis3mdl.cpp index 1298c92ae..0d53896b6 100644 --- a/src/tests/sensors/test-lis3mdl.cpp +++ b/src/tests/sensors/test-lis3mdl.cpp @@ -66,9 +66,7 @@ int main() TRACE("Doing self test!\n"); bool ok = sensor.selfTest(); if (!ok) - { TRACE("Error: selfTest() returned false!\n"); - } TRACE("Now printing some sensor data:\n"); Thread::sleep(100); diff --git a/src/tests/sensors/test-lps28dfw.cpp b/src/tests/sensors/test-lps28dfw.cpp index e5a287d1f..a5568d554 100644 --- a/src/tests/sensors/test-lps28dfw.cpp +++ b/src/tests/sensors/test-lps28dfw.cpp @@ -46,7 +46,7 @@ uint8_t nSamples = 10; * ODR1 | AVG4 : 127.8 us/samp (W1+R1+W1+R5) @1Hz: 2.5 uA [FROM DS] * ODR1 | AVG512 : 127.8 us/samp (W1+R1+W1+R5) @1Hz: 32.8 uA [FROM DS] */ -miosix::Thread *waiting = 0; +miosix::Thread* waiting = 0; bool sampleAvailable = false; void __attribute__((used)) EXTI5_IRQHandlerImpl() { @@ -57,7 +57,7 @@ void __attribute__((used)) EXTI5_IRQHandlerImpl() } } -void sampleOneShotMode(I2C &i2c) +void sampleOneShotMode(I2C& i2c) { printf("Start One-Shot\n"); @@ -77,20 +77,16 @@ void sampleOneShotMode(I2C &i2c) lps28dfw.sample(); if (lps28dfw.getLastError() == SensorErrors::NO_ERRORS) - { lps28dfw.getLastSample().print(std::cout); - } else - { printf("Error: %d\n", lps28dfw.getLastError()); - } Thread::sleep(100); } printf("End One-Shot\n"); } -void sampleContinuousMode(I2C &i2c) +void sampleContinuousMode(I2C& i2c) { printf("Start Continuous\n"); @@ -112,19 +108,15 @@ void sampleContinuousMode(I2C &i2c) lps28dfw.sample(); if (lps28dfw.getLastError() == SensorErrors::NO_ERRORS) - { lps28dfw.getLastSample().print(std::cout); - } else - { printf("Error: %d\n", lps28dfw.getLastError()); - } } printf("End Continuous\n"); } -void sampleInterruptMode(I2C &i2c) +void sampleInterruptMode(I2C& i2c) { printf("Start Interrupt\n"); // Setting up the Sensor @@ -140,23 +132,16 @@ void sampleInterruptMode(I2C &i2c) for (uint8_t i = 0; i < nSamples; i++) { - while (!sampleAvailable) - { waiting->wait(); - } sampleAvailable = false; lps28dfw.sample(); if (lps28dfw.getLastError() == SensorErrors::NO_ERRORS) - { lps28dfw.getLastSample().print(std::cout); - } else - { printf("Error: %d\n", lps28dfw.getLastError()); - } } printf("End Interrupt\n"); diff --git a/src/tests/sensors/test-lps331ap.cpp b/src/tests/sensors/test-lps331ap.cpp index b7e07db1a..d2beac56f 100644 --- a/src/tests/sensors/test-lps331ap.cpp +++ b/src/tests/sensors/test-lps331ap.cpp @@ -35,14 +35,10 @@ int main() LPS331AP lps331(bus); if (!lps331.init()) - { printf("Init failed\n"); - } if (!lps331.selfTest()) - { printf("Self test failed\n"); - } while (true) { diff --git a/src/tests/sensors/test-lsm6dsrx.cpp b/src/tests/sensors/test-lsm6dsrx.cpp index ebaa8d668..a979fe0f4 100644 --- a/src/tests/sensors/test-lsm6dsrx.cpp +++ b/src/tests/sensors/test-lsm6dsrx.cpp @@ -56,7 +56,6 @@ void testFifoRead(SPIBus& bus, miosix::GpioPin csPin, int main() { - SPIBus bus(SPI3); GpioPin csPin(GPIOE_BASE, 3); // PE3 CS @@ -115,9 +114,7 @@ int main() // testFifoFillingTime(bus, csPin, busConfiguration, sensConfig, int2Pin); while (true) - { Thread::sleep(5000); - } return 0; } @@ -205,9 +202,7 @@ void testSampleImplTime(SPIBus& bus, miosix::GpioPin csPin, { TRACE("Self test failed\n\n"); while (true) - { Thread::sleep(2000); - } } std::cout << "sensor initialized\n"; @@ -255,9 +250,7 @@ void testFifoRead(SPIBus& bus, miosix::GpioPin csPin, { std::cout << "Self test failed\n\n"; while (true) - { Thread::sleep(2000); - } } while (true) @@ -299,9 +292,7 @@ void testFifoRead(SPIBus& bus, miosix::GpioPin csPin, // Check that gyr and acc timestamps are equal if (buf[i].accelerationTimestamp != buf[i].angularSpeedTimestamp) - { std::cout << "Error, timestamps not equal\n\n"; - } } std::cout << "Extraction completed\n\n" << std::endl; diff --git a/src/tests/sensors/test-max31855.cpp b/src/tests/sensors/test-max31855.cpp index 71e9022d4..a4e7613ca 100644 --- a/src/tests/sensors/test-max31855.cpp +++ b/src/tests/sensors/test-max31855.cpp @@ -57,9 +57,7 @@ int main() printf("Starting process verification!\n"); if (!sensor.checkConnected()) - { printf("Sensor not connected!\n"); - } while (true) { diff --git a/src/tests/sensors/test-max31856.cpp b/src/tests/sensors/test-max31856.cpp index 11908d34b..d3a1bb54e 100644 --- a/src/tests/sensors/test-max31856.cpp +++ b/src/tests/sensors/test-max31856.cpp @@ -52,13 +52,9 @@ int main() sensor.init(); if (!sensor.checkConnected()) - { printf("The thermocouple is not connected\n"); - } else - { printf("The thermocouple is connected\n"); - } // Wait for one sample to be made Thread::sleep(100); diff --git a/src/tests/sensors/test-max6675.cpp b/src/tests/sensors/test-max6675.cpp index be541c114..97091f189 100644 --- a/src/tests/sensors/test-max6675.cpp +++ b/src/tests/sensors/test-max6675.cpp @@ -53,9 +53,7 @@ int main() printf("Starting process verification!\n"); if (!sensor.selfTest()) - { printf("Sensor self test failed!\n"); - } while (true) { diff --git a/src/tests/sensors/test-ms5803-i2c.cpp b/src/tests/sensors/test-ms5803-i2c.cpp index 7a7b83ddb..e724a75a0 100644 --- a/src/tests/sensors/test-ms5803-i2c.cpp +++ b/src/tests/sensors/test-ms5803-i2c.cpp @@ -34,14 +34,10 @@ int main() MS5803I2C ms5803(bus, 10); if (!ms5803.init()) - { printf("MS5803 Init failed\n"); - } if (!ms5803.selfTest()) - { printf("Self test failed\n"); - } while (true) { diff --git a/src/tests/sensors/test-ms5803-spi.cpp b/src/tests/sensors/test-ms5803-spi.cpp index 811dfcc18..f49fe9252 100644 --- a/src/tests/sensors/test-ms5803-spi.cpp +++ b/src/tests/sensors/test-ms5803-spi.cpp @@ -44,9 +44,7 @@ int main() Thread::sleep(100); if (!sensor.init()) - { printf("MS5803 Init failed\n"); - } Thread::sleep(100); printf("pressureTimestamp,press,temperatureTimestamp,temp\n"); diff --git a/src/tests/sensors/test-ubxgps-serial.cpp b/src/tests/sensors/test-ubxgps-serial.cpp index 0039317c1..4e293db96 100644 --- a/src/tests/sensors/test-ubxgps-serial.cpp +++ b/src/tests/sensors/test-ubxgps-serial.cpp @@ -54,23 +54,15 @@ int main() // Init the gps if (gps.init()) - { printf("Successful gps initialization\n"); - } else - { printf("Failed gps initialization\n"); - } // Perform the selftest if (gps.selfTest()) - { printf("Successful gps selftest\n"); - } else - { printf("Failed gps selftest\n"); - } // Start the gps thread gps.start(); diff --git a/src/tests/test-hsm.cpp b/src/tests/test-hsm.cpp index 6e54aa78e..6390f38ef 100644 --- a/src/tests/test-hsm.cpp +++ b/src/tests/test-hsm.cpp @@ -115,13 +115,9 @@ State HSMUTTest::state_S(const Event& e) break; case EV_I: if (this->foo == false) - { this->foo = true; - } else - { retState = UNHANDLED; - } break; case EV_E: retState = transition(&HSMUTTest::state_S11); @@ -236,13 +232,9 @@ State HSMUTTest::state_S2(const Event& e) break; case EV_I: if (this->foo == false) - { this->foo = true; - } else - { retState = UNHANDLED; - } break; default: retState = tranSuper(&HSMUTTest::state_S); @@ -307,7 +299,6 @@ State HSMUTTest::state_S211(const Event& e) int main() { - EventBroker::getInstance().start(); HSMUTTest& hsm = HSMUTTest::getInstance(); diff --git a/src/tests/test-max485.cpp b/src/tests/test-max485.cpp index 61a7068b1..f21701e2f 100644 --- a/src/tests/test-max485.cpp +++ b/src/tests/test-max485.cpp @@ -79,12 +79,12 @@ int baudrates[] = {2400, 9600, 19200, 38400, 57600, 115200, 230400, 256000, 460800, 921600}; // function for the thread that has to read from serial -void readSer(USARTInterface &s) {} +void readSer(USARTInterface& s) {} // Communicatio: src -> dst template <typename GPIO1_src, typename GPIO2_src, typename GPIO1_dst, typename GPIO2_dst> -void testCommunication(char *data, USARTInterface &src, USARTInterface &dst) +void testCommunication(char* data, USARTInterface& src, USARTInterface& dst) { // resetting the buffer so precedent tests won't affect this one memset(rcv, 0, strlen(rcv) + 1); @@ -110,13 +110,9 @@ void testCommunication(char *data, USARTInterface &src, USARTInterface &dst) t.join(); if (strcmp(data, rcv) == 0) - { printf("*** %d -> %d WORKING!\n", src.getId(), dst.getId()); - } else - { printf("### ERROR: %d -> %d!\n", src.getId(), dst.getId()); - } } int main() diff --git a/src/tests/test-sensormanager.cpp b/src/tests/test-sensormanager.cpp index 1b4f55c5d..b67326b5b 100644 --- a/src/tests/test-sensormanager.cpp +++ b/src/tests/test-sensormanager.cpp @@ -40,7 +40,6 @@ using namespace std; // Data produced by the MySensor sensor. struct MySensorData : public PressureData, public TemperatureData { - MySensorData() : PressureData{0, 0.0}, TemperatureData{0, 0.0} {} MySensorData(float p, float t) @@ -95,7 +94,6 @@ private: struct MySensorDataFIFO : public AccelerometerData, public GyroscopeData { - MySensorDataFIFO() : AccelerometerData{TimestampTimer::getTimestamp(), 0.0, 0.0, 0.0}, GyroscopeData{TimestampTimer::getTimestamp(), 0.0, 0.0, 0.0} @@ -166,9 +164,7 @@ public: FIFOData getLastSample() override { if (index < FifoSize - 1) - { index++; - } TRACE("Index : %d \n", index); diff --git a/src/tests/test-trace-logger.cpp b/src/tests/test-trace-logger.cpp index 631e77f7a..b8d680266 100644 --- a/src/tests/test-trace-logger.cpp +++ b/src/tests/test-trace-logger.cpp @@ -46,9 +46,7 @@ int main() LOG_ERR(logger, "This is a message {}", 52); LOG_INFO(log2, "Ops, there was an {}!", "error"); for (int i = 0; i < 4; i++) - { LOG_INFO(log4, "This is an async log! {:d}", asyncCtr++); - } LOG_DEBUG(log3, "This is a verbose debug message {:.3f}", 1.234f); LOG_CRIT(log3, "Float {:.1f} {:05.2f} {:f}", 1.234f, 1234.1234, -9876.98765432f); diff --git a/src/tests/utils/test-buttonhandler.cpp b/src/tests/utils/test-buttonhandler.cpp index a47acd7bf..47f403921 100644 --- a/src/tests/utils/test-buttonhandler.cpp +++ b/src/tests/utils/test-buttonhandler.cpp @@ -69,4 +69,4 @@ void buttonCallback(ButtonEvent event, int buttonId) default: break; } -} \ No newline at end of file +} -- GitLab