diff --git a/README.md b/README.md index 9ebae6a9616717a41e5ee891840ee6c249f51585..2ba9516b8ceada523e77fc41a62700721d0a9e20 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,35 @@ -# R2A OBSW +# R2A OBSW [](https://git.skywarder.eu/r2a/skyward-boardcore/commits/master) + *Software for Rocksanne2-Alpha* -This is a test for exporting boardcore as submodule. +This repository contains the On-Board Software for Rocksanne2-Alpha. + +To clone, use the `--recursive` option. + +To build, use `make` or `skyward-boardcore/sbs` (for more info, type `skyward-boardcore/sbs --help`). + + + +## Folder Structure + +| src/ | sources! | +| ---------------------- | --------------------------------------------------- | +| boards/ | Classes source files, divided per board. | +| entrypoints/ | Each file here is a "*main*" to be built with SBS. | +| tests/ | Tests that can be built with SBS. | +| **skyward-boardcore/** | Provides the build system (SBS) and common drivers. | +| **bin/** | Compiled binaries, to be flashed on boards. | +| **build/** | MIOSIX Makefiles generated by SBS (*not important*) | +| **obj/** | Building stuff (*not important*) | + +## Content + +This repo contains software components that are specific to R2A. Please refer to [R2A-OBSW-SDD](https://docs.google.com/document/d/1ZR1zA4Dz7wDNBRiWThYC5OAfe9hZfSOdGBmbz2ConWU/edit) and [R2A-OBSW-SRS](https://docs.google.com/document/d/1yGYri5w8BWR6EBI6hym_Pu-zaps5E749E4Xsp1WGpJw/edit) documents for details. + +The other common components (*EventBroker*, *Logger*, basic drivers etc...) are located in the `skyward-boardcore` repository, as well as the build system (SBS) and the operating system (MIOSIX). Please refer to that repo's documentation for more info. + +The Ignition Board software is developed in a [dedicated repository](https://git.skywarder.eu/r2a/skyward-r2x-ignition), for safety reasons. + +## Contributing -To use sbs type `skyward-boardcore/sbs -h` or create a symlink. - +If you are developing new features, branch off from the `testing` branch and then merge back. \ No newline at end of file diff --git a/src/boards/AnakinBoard.cpp b/src/boards/AnakinBoard.cpp deleted file mode 100644 index f65f8f5ebaeb2bacc4be57bcd0bdc3a2f7f98860..0000000000000000000000000000000000000000 --- a/src/boards/AnakinBoard.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* Copyright (c) 2015-2017 Skyward Experimental Rocketry - * Authors: Alain Carlucci, Federico Terraneo - * - * 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 "AnakinBoard.h" - -#define INIT_AND_CHECK(x) \ - do \ - { \ - if (!x->init()) \ - { \ - sLog->logString("=== ERR: CANNOT INIT " #x); \ - } \ - } while (0) - -AnakinBoard::AnakinBoard() -{ - mInited = false; - mS_MPU9250 = nullptr; - mS_INEMO = nullptr; - mS_FXAS = nullptr; - mS_LPS331AP = nullptr; - mS_MAX21105 = nullptr; -} - -bool AnakinBoard::init() -{ - sLog->start(); - - if (mInited) - return false; - - spiMPU9250::init(); - spiINEMOA::init(); - spiINEMOG::init(); - spiFXAS21002::init(); - spiLPS331AP::init(); - spiMAX21105::init(); - spiMS580301BA07::init(); - - // Raw sensors - mInited = true; - mS_MAX21105 = - new max21105_t(max21105_t::ACC_FS_16G, max21105_t::GYRO_FS_250); - mS_MPU9250 = new mpu_t(mpu_t::ACC_FS_16G, mpu_t::GYRO_FS_250); - mS_INEMO = new inemo_t(inemo_t::ACC_FS_16G, inemo_t::GYRO_FS_245, - inemo_t::COMPASS_FS_2); - mS_FXAS = new fxas_t(fxas_t::DPS500); - mS_LPS331AP = new lps331ap_t(lps331ap_t::SS_25HZ); - mS_MS580 = new ms580_t(); - - // The MAX21105 has to be initialized first as it is prone to listening - // to the initialization of the other sensors and switch by mistake to - // I2C mode - INIT_AND_CHECK(mS_MAX21105); - INIT_AND_CHECK(mS_MPU9250); - INIT_AND_CHECK(mS_INEMO); - INIT_AND_CHECK(mS_FXAS); - INIT_AND_CHECK(mS_LPS331AP); - INIT_AND_CHECK(mS_MS580); - - // clang-format off - AddSensor(ACCEL_MPU9250, DATA_VEC3, mS_MPU9250->accelDataPtr()); - AddSensor(GYRO_MPU9250, DATA_VEC3, mS_MPU9250->gyroDataPtr()); - AddSensor(COMPASS_MPU9250, DATA_VEC3, mS_MPU9250->compassDataPtr()); - AddSensor(TEMP_MPU9250, DATA_FLOAT, mS_MPU9250->tempDataPtr()); - - AddSensor(ACCEL_INEMO, DATA_VEC3, mS_INEMO->accelDataPtr()); - AddSensor(GYRO_INEMO, DATA_VEC3, mS_INEMO->gyroDataPtr()); - AddSensor(COMPASS_INEMO, DATA_VEC3, mS_INEMO->compassDataPtr()); - AddSensor(TEMP_INEMO, DATA_FLOAT, mS_INEMO->tempDataPtr()); - - AddSensor(GYRO_FXAS21002, DATA_VEC3, mS_FXAS->gyroDataPtr()); - - AddSensor(PRESS_LPS331AP, DATA_FLOAT, mS_LPS331AP->pressureDataPtr()); - AddSensor(TEMP_LPS331AP, DATA_FLOAT, mS_LPS331AP->tempDataPtr()); - - AddSensor(ACCEL_MAX21105, DATA_VEC3, mS_MAX21105->accelDataPtr()); - AddSensor(GYRO_MAX21105, DATA_VEC3, mS_MAX21105->gyroDataPtr()); - AddSensor(TEMP_MAX21105, DATA_FLOAT, mS_MAX21105->tempDataPtr()); - - AddSensor(PRESS_MS580, DATA_FLOAT, mS_MS580->pressureDataPtr()); - AddSensor(TEMP_MS580, DATA_FLOAT, mS_MS580->tempDataPtr()); - // clang-format on - - sLog->logString("Adding sensors to 100Hz DMA sampler\n"); - m100HzDMA.AddSensor(mS_MPU9250); - m100HzDMA.AddSensor(mS_INEMO); - m100HzDMA.AddSensor(mS_FXAS); - m100HzDMA.AddSensor(mS_MAX21105); - - sLog->logString("Adding sensors to 25Hz DMA sampler\n"); - m25HzDMA.AddSensor(mS_LPS331AP); - - sLog->logString("Adding sensors to 10Hz Simple sampler\n"); - m10HzSimple.AddSensor(mS_MPU9250); - m10HzSimple.AddSensor(mS_MS580); - - sLog->logString("Adding samplers to scheduler\n"); -#define ADD_SAMPLER(type, name, rate) \ - sEventScheduler->add(std::bind(&type##SensorSampler::Update, name), rate, \ - #name "-" #rate "ms", start) - - int64_t start = miosix::getTick(); // Synchronize activation - ADD_SAMPLER(DMA, m100HzDMA, 10); // 10ms - ADD_SAMPLER(DMA, m25HzDMA, 40); // 25ms - ADD_SAMPLER(Simple, m10HzSimple, 100); // 100ms - - return true; -} - -#undef INIT_AND_CHECK -#undef ADD_SAMPLER diff --git a/src/boards/AnakinBoard.h b/src/boards/AnakinBoard.h deleted file mode 100644 index 0adbdd3b62654e8462bad6dd706352f9c242f7ac..0000000000000000000000000000000000000000 --- a/src/boards/AnakinBoard.h +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright (c) 2015-2017 Skyward Experimental Rocketry - * Authors: Alain Carlucci - * - * 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. - */ - -#ifndef BOARDS_ANAKINBOARD_H -#define BOARDS_ANAKINBOARD_H - -#include <events/Scheduler.h> -#include <diagnostic/Log.h> -#include "Board.h" - -#include <sensors/FXAS21002.h> -#include <sensors/LPS331AP.h> -#include <sensors/MAX21105.h> -#include <sensors/MPU9250.h> -#include <sensors/MS580301BA07.h> -#include <sensors/iNemo.h> - -#include <drivers/spi/SensorSpi.h> -#include <sensors/SensorSampling.h> - -typedef miosix::Gpio<GPIOA_BASE, 5> GpioSck; -typedef miosix::Gpio<GPIOA_BASE, 6> GpioMiso; -typedef miosix::Gpio<GPIOA_BASE, 7> GpioMosi; -typedef BusSPI<1, GpioMosi, GpioMiso, GpioSck> busSPI1; - -typedef ProtocolSPI<busSPI1, miosix::Gpio<GPIOD_BASE, 13>> spiMPU9250; -typedef ProtocolSPI<busSPI1, miosix::Gpio<GPIOG_BASE, 11>> spiINEMOA; -typedef ProtocolSPI<busSPI1, miosix::Gpio<GPIOG_BASE, 9>> spiINEMOG; -typedef ProtocolSPI<busSPI1, miosix::Gpio<GPIOG_BASE, 10>> spiFXAS21002; -typedef ProtocolSPI<busSPI1, miosix::Gpio<GPIOE_BASE, 4>> spiLPS331AP; -typedef ProtocolSPI<busSPI1, miosix::Gpio<GPIOE_BASE, 2>> spiMAX21105; -typedef ProtocolSPI<busSPI1, miosix::Gpio<GPIOB_BASE, 10>> spiMS580301BA07; -// typedef ProtocolSPI<busSPI1, miosix::Gpio<GPIOB_BASE, 11>> spiMAX31856; - -typedef MPU9250<spiMPU9250> mpu_t; -typedef iNEMOLSM9DS0<spiINEMOG, spiINEMOA> inemo_t; -typedef FXAS21002<spiFXAS21002> fxas_t; -typedef LPS331AP<spiLPS331AP> lps331ap_t; -typedef MAX21105<spiMAX21105> max21105_t; -typedef MS580301BA07<spiMS580301BA07> ms580_t; - -// AnakinSensor numbers must be in range 0 <= x <= 65535 (uint16_t) -enum AnakinSensor -{ - ACCEL_MPU9250 = 0, - ACCEL_INEMO = 1, - ACCEL_MAX21105 = 2, - - GYRO_MPU9250 = 3, - GYRO_INEMO = 4, - GYRO_FXAS21002 = 5, - GYRO_MAX21105 = 6, - - COMPASS_MPU9250 = 7, - COMPASS_INEMO = 8, - - TEMP_MPU9250 = 9, - TEMP_INEMO = 10, - TEMP_LPS331AP = 11, - TEMP_MAX21105 = 12, - TEMP_MS580 = 13, - - PRESS_LPS331AP = 14, - PRESS_MS580 = 15, - - UNUSED_16 = 16, - RESERVED_17 = 17, - RESERVED_18 = 18, -}; - -class AnakinBoard : public Singleton<AnakinBoard>, public Board -{ - friend class Singleton<AnakinBoard>; - -public: - bool init() override; - - const std::vector<SingleSensor>& debugGetSensors() const - { - return mSensorData; - } - -private: - DMASensorSampler m100HzDMA, m25HzDMA; - SimpleSensorSampler m10HzSimple; - mpu_t* mS_MPU9250; - inemo_t* mS_INEMO; - fxas_t* mS_FXAS; - lps331ap_t* mS_LPS331AP; - max21105_t* mS_MAX21105; - ms580_t* mS_MS580; - - AnakinBoard(); -}; - -#ifdef sBoard -#error YOU ARE TRYING TO USE MULTIPLE BOARDS. -#else -#define sBoard AnakinBoard::getInstance() -#endif - -#endif /* ifndef BOARDS_ANAKINBOARD_H */ diff --git a/src/boards/Board.h b/src/boards/Board.h deleted file mode 100644 index 863061d4d87e382a3d9383c8ea0855e3d294ce30..0000000000000000000000000000000000000000 --- a/src/boards/Board.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (c) 2015-2016 Skyward Experimental Rocketry - * Authors: Alain Carlucci - * - * 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. - */ - -#ifndef BOARD_H -#define BOARD_H - -#include <Common.h> -#include <Singleton.h> -#include <drivers/BusTemplate.h> -#include <sensors/Sensor.h> - -enum DataType -{ - DATA_VEC3 = 0, - DATA_QUAT = 1, - DATA_FLOAT = 2, - DATA_INT = 3, -}; - -struct SingleSensor -{ - uint16_t sensor; - DataType data; - const void* value; - - SingleSensor() {} - SingleSensor(uint16_t sensor, DataType data, const void* value) - : sensor(sensor), data(data), value(value) - { - } -}; - -class Board -{ -public: - Board() : mInited(false) {} - virtual bool init() = 0; - -protected: - bool mInited; - std::vector<SingleSensor> mSensorData; - std::vector<Sensor*> mRawSensors; - - void AddSensor(uint16_t sensor, DataType data, const void* value) - { - mSensorData.push_back(SingleSensor(sensor, data, value)); - } -}; - -#endif /* BOARD_H */