diff --git a/CMakeLists.txt b/CMakeLists.txt index f98a0eec04ecf88930fa3ae2ce949894eda41600..a013cb2a0cbccb8904b40f631bcd2d00ead24c70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,6 +99,7 @@ target_compile_definitions(payload-entry-hil PRIVATE PAYLOAD_ENTRY HILSimulation sbs_target(payload-entry-hil stm32f429zi_skyward_death_stack_x) add_executable(groundstation-entry src/entrypoints/Groundstation/groundstation-entry.cpp) +target_include_directories(groundstation-entry PRIVATE ${OBSW_INCLUDE_DIRS}) sbs_target(groundstation-entry stm32f429zi_skyward_groundstation_v2) #-----------------------------------------------------------------------------# diff --git a/skyward-boardcore b/skyward-boardcore index 47b91f1082569678e327ac24cf947d6e0b3f9a89..cb195bf7c6263d81228e9647892806cdeddd5cb3 160000 --- a/skyward-boardcore +++ b/skyward-boardcore @@ -1 +1 @@ -Subproject commit 47b91f1082569678e327ac24cf947d6e0b3f9a89 +Subproject commit cb195bf7c6263d81228e9647892806cdeddd5cb3 diff --git a/src/boards/Main/Radio/Radio.cpp b/src/boards/Main/Radio/Radio.cpp index d04033c35fcb56e3bcddd6082b312629074101fe..a8b4a27d238fa2332fbdd5c65318c8cca313c04d 100644 --- a/src/boards/Main/Radio/Radio.cpp +++ b/src/boards/Main/Radio/Radio.cpp @@ -32,6 +32,7 @@ #include <Main/StateMachines/FlightModeManager/FlightModeManager.h> #include <Main/StateMachines/NASController/NASController.h> #include <Main/TMRepository/TMRepository.h> +#include <common/SX1278Config.h> #include <common/events/Events.h> #include <drivers/interrupt/external_interrupts.h> #include <interfaces-impl/hwmapping.h> @@ -114,18 +115,8 @@ Radio::Radio() transceiver = new SX1278(Buses::getInstance().spi5, sensors::sx127x::cs::getPin()); - SX1278::Config config = {}; - config.freq_rf = 412000000; - config.freq_dev = 25000; - config.bitrate = 19200; - config.rx_bw = SX1278::RxBw::HZ_83300; - config.afc_bw = SX1278::RxBw::HZ_125000; - config.ocp = 120; - config.power = 17; - config.shaping = SX1278::Shaping::GAUSSIAN_BT_0_5; - // Use default configuration - transceiver->init(config); + transceiver->init(SX1278_CONFIG); enableExternalInterrupt(GPIOF_BASE, 10, InterruptTrigger::RISING_EDGE); #endif diff --git a/src/boards/common/SX1278Config.h b/src/boards/common/SX1278Config.h new file mode 100644 index 0000000000000000000000000000000000000000..91b676ea02104b7a260c5dcf79a4623857fd5409 --- /dev/null +++ b/src/boards/common/SX1278Config.h @@ -0,0 +1,39 @@ +/* Copyright (c) 2022 Skyward Experimental Rocketry + * Author: Davide Mor + * + * 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 <radio/SX1278/SX1278.h> + +namespace Common +{ + +Boardcore::SX1278::Config SX1278_CONFIG = { + .freq_rf = 412000000, + .freq_dev = 25000, + .bitrate = 38400, + .rx_bw = Boardcore::SX1278::RxBw::HZ_83300, + .afc_bw = Boardcore::SX1278::RxBw::HZ_125000, + .ocp = 120, + .power = 17, + .shaping = Boardcore::SX1278::Shaping::GAUSSIAN_BT_0_5, +}; + +} // namespace Common diff --git a/src/entrypoints/Groundstation/groundstation-entry.cpp b/src/entrypoints/Groundstation/groundstation-entry.cpp index dcc91d5cba639fad56df4c97f531f07d203100c8..e6d264118f8d0131d6620d95f0edd7c75e523577 100644 --- a/src/entrypoints/Groundstation/groundstation-entry.cpp +++ b/src/entrypoints/Groundstation/groundstation-entry.cpp @@ -20,6 +20,7 @@ * THE SOFTWARE. */ +#include <common/SX1278Config.h> #include <drivers/interrupt/external_interrupts.h> #include <drivers/usart/USART.h> #include <filesystem/console/console_device.h> @@ -35,6 +36,7 @@ using namespace miosix; using namespace Boardcore; +using namespace Common; SX1278 *sx1278 = nullptr; USART *usart = nullptr; @@ -134,17 +136,6 @@ int main() initBoard(); initGUI(); - // Run default configuration - SX1278::Config config; - config.freq_rf = 412000000; - config.freq_dev = 25000; - config.bitrate = 19200; - config.rx_bw = SX1278::RxBw::HZ_83300; - config.afc_bw = SX1278::RxBw::HZ_125000; - config.ocp = 120; - config.power = 17; - config.shaping = SX1278::Shaping::GAUSSIAN_BT_0_5; - SPIBus bus(SPI4); #ifdef USE_RA01_PC13 GpioPin cs = peripherals::ra01::pc13::cs::getPin(); @@ -156,7 +147,7 @@ int main() printf("[sx1278] Configuring sx1278...\n"); SX1278::Error err; - if ((err = sx1278->init(config)) != SX1278::Error::NONE) + if ((err = sx1278->init(SX1278_CONFIG)) != SX1278::Error::NONE) { gui->stats_screen.updateError(err); while (true)