diff --git a/CMakeLists.txt b/CMakeLists.txt index cdbc08614f50f7d21b57c0a4f332df58e4477b91..32c94c6923756a95a03ab1a667ea03b535f0b72a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,13 +46,13 @@ add_executable(mxgui-helloworld src/entrypoints/examples/mxgui-helloworld.cpp) sbs_target(mxgui-helloworld stm32f429zi_stm32f4discovery) add_executable(kernel-testsuite src/entrypoints/kernel-testsuite.cpp) -sbs_target(kernel-testsuite stm32f429zi_stm32f4discovery) +sbs_target(kernel-testsuite stm32f205rc_skyward_ciuti) add_executable(runcam-settings src/entrypoints/runcam-settings.cpp) sbs_target(runcam-settings stm32f407vg_stm32f4discovery) add_executable(sdcard-benchmark src/entrypoints/sdcard-benchmark.cpp) -sbs_target(sdcard-benchmark stm32f429zi_skyward_death_stack_x) +sbs_target(sdcard-benchmark stm32f205rc_skyward_ciuti) #-----------------------------------------------------------------------------# # Tests # diff --git a/cmake/boardcore.cmake b/cmake/boardcore.cmake index 120f7bc5e0143d8e5cb78cd3c578603ca66f844e..21fc12ef98d913aca0e8accc6c7f91959a210015 100644 --- a/cmake/boardcore.cmake +++ b/cmake/boardcore.cmake @@ -80,6 +80,7 @@ foreach(OPT_BOARD ${BOARDS}) ${SBS_BASE}/src/shared/sensors/BMX160/BMX160WithCorrection.cpp ${SBS_BASE}/src/shared/sensors/HX711/HX711.cpp ${SBS_BASE}/src/shared/sensors/LIS3MDL/LIS3MDL.cpp + ${SBS_BASE}/src/shared/sensors/LIS331HH/LIS331HH.cpp ${SBS_BASE}/src/shared/sensors/calibration/SensorDataExtra.cpp ${SBS_BASE}/src/shared/sensors/MAX6675/MAX6675.cpp ${SBS_BASE}/src/shared/sensors/MAX31855/MAX31855.cpp diff --git a/src/shared/diagnostic/SkywardStack.h b/src/shared/diagnostic/SkywardStack.h index 8b85e44b0965153080f462b80cd08aaac55c6f5b..6a27d747f85267406a2c73daa1b727e8b70bc77e 100644 --- a/src/shared/diagnostic/SkywardStack.h +++ b/src/shared/diagnostic/SkywardStack.h @@ -27,7 +27,11 @@ namespace Boardcore { +#ifndef _ARCH_CORTEXM3_STM32F2 static const unsigned int STACK_MIN_FOR_SKYWARD = 16 * 1024; +#else +static const unsigned int STACK_MIN_FOR_SKYWARD = 1024; +#endif inline unsigned int skywardStack(unsigned int stack) { diff --git a/src/shared/sensors/LIS331HH/LIS331HH.cpp b/src/shared/sensors/LIS331HH/LIS331HH.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0eacca533d0abb6d48371c9986869ac1655ebcef --- /dev/null +++ b/src/shared/sensors/LIS331HH/LIS331HH.cpp @@ -0,0 +1,75 @@ +/* Copyright (c) 2022 Skyward Experimental Rocketry + * Author: Alberto Nidasio + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "LIS331HH.h" + +#include <drivers/timer/TimestampTimer.h> + +namespace Boardcore +{ + +LIS331HH::LIS331HH(SPIBusInterface& bus, miosix::GpioPin cs, + SPIBusConfig spiConfig) + : slave(bus, cs, spiConfig) +{ +} + +bool LIS331HH::init() +{ + SPITransaction spi(slave); + + spi.writeRegister(CTRL_REG1, 0x20); + printf("CTRL_REG1: %X\n", spi.readRegister(CTRL_REG1)); + + return true; +} + +bool LIS331HH::selfTest() { return true; } + +LIS331HHData LIS331HH::sampleImpl() +{ + uint16_t val; + LIS331HHData data; + + data.accelerationTimestamp = TimestampTimer::getTimestamp(); + + SPITransaction spi(slave); + + val = spi.readRegister(OUT_X_L); + val |= spi.readRegister(OUT_X_H) << 8; + data.accelerationX = 6.0 / 65536.0 * val; + printf("%X\t", val); + + val = spi.readRegister(OUT_Y_L); + val |= spi.readRegister(OUT_Y_H) << 8; + data.accelerationX = 6.0 / 65536.0 * val; + printf("%X\t", val); + + val = spi.readRegister(OUT_Z_L); + val |= spi.readRegister(OUT_Z_H) << 8; + data.accelerationX = 6.0 / 65536.0 * val; + printf("%X\t", val); + + return data; +} + +} // namespace Boardcore \ No newline at end of file diff --git a/src/shared/sensors/LIS331HH/LIS331HH.h b/src/shared/sensors/LIS331HH/LIS331HH.h new file mode 100644 index 0000000000000000000000000000000000000000..d91cb3d904eae391ce4f3e7ac16a4deb1820104f --- /dev/null +++ b/src/shared/sensors/LIS331HH/LIS331HH.h @@ -0,0 +1,74 @@ +/* Copyright (c) 2022 Skyward Experimental Rocketry + * Author: Alberto Nidasio + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include <drivers/spi/SPIDriver.h> +#include <sensors/Sensor.h> + +#include "LIS331HHData.h" + +namespace Boardcore +{ + +class LIS331HH : public Sensor<LIS331HHData> +{ +public: + LIS331HH(SPIBusInterface& bus, miosix::GpioPin cs, SPIBusConfig spiConfig); + + bool init() override; + + bool selfTest() override; + +private: + LIS331HHData sampleImpl() override; + + SPISlave slave; + + enum Registers : uint8_t + { + CTRL_REG1 = 0x20, + CTRL_REG2 = 0x21, + CTRL_REG3 = 0x22, + CTRL_REG4 = 0x23, + CTRL_REG5 = 0x24, + HP_FILTER_RESET = 0x25, + REFERENCE = 0x26, + STATUS_REG = 0x27, + OUT_X_L = 0x28, + OUT_X_H = 0x29, + OUT_Y_L = 0x2a, + OUT_Y_H = 0x2b, + OUT_Z_L = 0x2c, + OUT_Z_H = 0x2d, + INT1_CFG = 0x30, + INT1_SOURCE = 0x31, + INT1_THS = 0x32, + INT1_DURATION = 0x33, + INT2_CFG = 0x34, + INT2_SOURCE = 0x35, + INT2_THS = 0x36, + INT2_DURATION = 0x37, + }; +}; + +} // namespace Boardcore \ No newline at end of file diff --git a/src/shared/sensors/LIS331HH/LIS331HHData.h b/src/shared/sensors/LIS331HH/LIS331HHData.h new file mode 100644 index 0000000000000000000000000000000000000000..72a57214106d2c3475abe59e9baef9b0701ef2c8 --- /dev/null +++ b/src/shared/sensors/LIS331HH/LIS331HHData.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2022 Skyward Experimental Rocketry + * Author: Alberto Nidasio + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include <sensors/SensorData.h> + +namespace Boardcore +{ + +struct LIS331HHData : public AccelerometerData +{ + static std::string header() + { + return "accelerationTimestamp,accelerationX,accelerationY," + "accelerationZ,temp_" + "timestamp," + "temp\n"; + } + + void print(std::ostream& os) const + { + os << accelerationTimestamp << "," << accelerationX << "," + << accelerationY << "," << accelerationZ << "\n"; + } +}; + +} // namespace Boardcore diff --git a/src/shared/sensors/LIS3DSH/LIS3DSH.h b/src/shared/sensors/LIS3DSH/LIS3DSH.h index 89404d1fcc68ecdc4e92d9374f6a8e14fcce8566..4c048dc25e2fe3a39db5333368d4e5a8ead6be6c 100644 --- a/src/shared/sensors/LIS3DSH/LIS3DSH.h +++ b/src/shared/sensors/LIS3DSH/LIS3DSH.h @@ -318,9 +318,10 @@ public: private: /** * @brief Read new data from the accelerometer. - * Acceleretions are returned in g. * - * @return boolean value indicating whether the operation succeded or not + * Accelerations are returned in g. + * + * @return boolean value indicating whether the operation succeeded or not */ LIS3DSHData sampleImpl() override { @@ -346,9 +347,9 @@ private: } /** - * @brief Read accelrometer data. + * @brief Read accelerometer data. * - * @return the read accelrometer sample + * @return the read accelerometer sample */ AccelerometerData readAccelData() {