added SPI code
This commit is contained in:
@ -1,21 +1,28 @@
|
||||
#include "InitMission.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include "objects/systemObjectList.h"
|
||||
#include "pollingsequence/pollingSequenceFactory.h"
|
||||
|
||||
#include "mission/utility/TaskCreation.h"
|
||||
#include "mission/assemblies/TestAssembly.h"
|
||||
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/tasks/FixedTimeslotTaskIF.h"
|
||||
#include "fsfw/tasks/PeriodicTaskIF.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
|
||||
#include "fsfw/modes/HasModesIF.h"
|
||||
#include "fsfw/modes/ModeMessage.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
#include <objects/systemObjectList.h>
|
||||
#include <mission/utility/TaskCreation.h>
|
||||
#include <pollingsequence/pollingSequenceFactory.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
|
||||
#include <fsfw/tasks/PeriodicTaskIF.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
|
||||
void InitMission::createTasks() {
|
||||
TaskFactory* taskFactory = TaskFactory::instance();
|
||||
|
||||
#if OBSW_ADD_CORE_COMPONENTS == 1
|
||||
/* TMTC Distribution */
|
||||
PeriodicTaskIF* distributerTask = TaskFactory::instance()->createPeriodicTask(
|
||||
PeriodicTaskIF* distributerTask = taskFactory->createPeriodicTask(
|
||||
"DIST", 5, 1024 * 2, 0.2, nullptr);
|
||||
ReturnValue_t result = distributerTask->addComponent(objects::CCSDS_DISTRIBUTOR);
|
||||
if(result!=HasReturnvaluesIF::RETURN_OK) {
|
||||
@ -30,7 +37,6 @@ void InitMission::createTasks() {
|
||||
task::printInitError("TM funnel", objects::TM_FUNNEL);
|
||||
}
|
||||
|
||||
#if OBSW_ADD_LWIP_COMPONENTS == 1
|
||||
/* UDP bridge */
|
||||
PeriodicTaskIF* udpBridgeTask = TaskFactory::instance()->createPeriodicTask(
|
||||
"UDP_UNIX_BRIDGE", 6, 1024 * 2, 0.2, nullptr);
|
||||
@ -44,7 +50,6 @@ void InitMission::createTasks() {
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("UDP polling task", objects::UDP_POLLING_TASK);
|
||||
}
|
||||
#endif /* OBSW_ADD_LWIP_COMPONENTS == 1 */
|
||||
|
||||
PeriodicTaskIF* eventManagerTask = TaskFactory::instance()->createPeriodicTask(
|
||||
"EVENT_MGMT", 4, 1024 * 2, 0.1, nullptr);
|
||||
@ -119,7 +124,7 @@ void InitMission::createTasks() {
|
||||
|
||||
#if OBSW_ADD_DEVICE_HANDLER_DEMO == 1
|
||||
FixedTimeslotTaskIF* testDevicesTask = TaskFactory::instance()->createFixedTimeslotTask(
|
||||
"PST_TEST_TASK", 10, 1024 * 2, 1.0, nullptr);
|
||||
"PST_TEST_TASK", 7, 1024 * 2, 1.0, nullptr);
|
||||
result = pst::pollingSequenceDevices(testDevicesTask);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
@ -128,6 +133,15 @@ void InitMission::createTasks() {
|
||||
sif::printError("InitMission::createTasks: Test PST initialization faiedl!\n");
|
||||
#endif
|
||||
}
|
||||
PeriodicTaskIF* assemblyTask = taskFactory->createPeriodicTask("ASS_TASK", 3,
|
||||
1024, 2.0, nullptr);
|
||||
if(assemblyTask == nullptr){
|
||||
task::printInitError("ASS_TASK", objects::TEST_ASSEMBLY);
|
||||
}
|
||||
result = assemblyTask->addComponent(objects::TEST_ASSEMBLY);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
task::printInitError("ASS_TASK", objects::TEST_ASSEMBLY);
|
||||
}
|
||||
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO == 1 */
|
||||
|
||||
PeriodicTaskIF* testTask = TaskFactory::instance()->createPeriodicTask(
|
||||
@ -137,6 +151,19 @@ void InitMission::createTasks() {
|
||||
task::printInitError("Test Task", objects::TEST_TASK);
|
||||
}
|
||||
|
||||
#if OBSW_PERIPHERAL_PST == 1
|
||||
FixedTimeslotTaskIF* peripheralPst = TaskFactory::instance()->createFixedTimeslotTask(
|
||||
"PST_PERIPHERAL_TASK", 9, 1024 * 2, 2.0, nullptr);
|
||||
result = pst::pstPeripheralsTest(peripheralPst);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "InitMission::createTasks: Test PST initialization failed!" << std::endl;
|
||||
#else
|
||||
sif::printError("InitMission::createTasks: Test PST initialization faiedl!\n");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "Starting tasks.." << std::endl;
|
||||
#else
|
||||
@ -146,10 +173,8 @@ void InitMission::createTasks() {
|
||||
#if OBSW_ADD_CORE_COMPONENTS == 1
|
||||
distributerTask->startTask();
|
||||
eventManagerTask->startTask();
|
||||
#if OBSW_ADD_LWIP_COMPONENTS == 1
|
||||
udpBridgeTask->startTask();
|
||||
udpPollingTask->startTask();
|
||||
#endif /* OBSW_ADD_LWIP_COMPONENTS == 1 */
|
||||
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
|
||||
|
||||
#if OBSW_ADD_PUS_STACK == 1
|
||||
@ -166,8 +191,13 @@ void InitMission::createTasks() {
|
||||
|
||||
#if OBSW_ADD_DEVICE_HANDLER_DEMO == 1
|
||||
testDevicesTask->startTask();
|
||||
assemblyTask->startTask();
|
||||
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO == 1 */
|
||||
|
||||
#if OBSW_PERIPHERAL_PST == 1
|
||||
peripheralPst->startTask();
|
||||
#endif /* OBSW_PERIPHERAL_PST == 1 */
|
||||
|
||||
testTask->startTask();
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
@ -179,5 +209,29 @@ void InitMission::createTasks() {
|
||||
static_cast<unsigned long>(xPortGetFreeHeapSize()));
|
||||
sif::printInfo("Tasks started..\n");
|
||||
#endif
|
||||
|
||||
#if OBSW_ADD_DEVICE_HANDLER_DEMO
|
||||
HasModesIF* assembly = ObjectManager::instance()->get<HasModesIF>(objects::TEST_ASSEMBLY);
|
||||
if (assembly == nullptr){
|
||||
return;
|
||||
}
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "Waiting 5 Seconds and then command Test Assembly to Normal, Dual" << std::endl;
|
||||
#else
|
||||
sif::printInfo("Waiting 5 Seconds and then command Test Assembly to Normal, Dual \n");
|
||||
#endif
|
||||
|
||||
TaskFactory::delayTask(5000);
|
||||
CommandMessage modeMessage;
|
||||
ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND,
|
||||
DeviceHandlerIF::MODE_NORMAL, TestAssembly::submodes::DUAL);
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "Commanding Test Assembly to Normal, Dual" << std::endl;
|
||||
#else
|
||||
sif::printInfo("Commanding Test Assembly to Normal, Dual \n");
|
||||
#endif
|
||||
MessageQueueSenderIF::sendMessage(assembly->getCommandQueue(), &modeMessage,
|
||||
MessageQueueIF::NO_QUEUE);
|
||||
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO */
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,32 @@
|
||||
#include "ObjectFactory.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include <objects/systemObjectList.h>
|
||||
#include "devices/devAddresses.h"
|
||||
#include "objects/systemObjectList.h"
|
||||
|
||||
#include <mission/utility/TmFunnel.h>
|
||||
#include <mission/core/GenericFactory.h>
|
||||
#include "mission/utility/TmFunnel.h"
|
||||
#include "mission/core/GenericFactory.h"
|
||||
|
||||
#if OBSW_ADD_LWIP_COMPONENTS == 1
|
||||
#include "example_common/stm32h7/networking/UdpTcLwIpPollingTask.h"
|
||||
#include "example_common/stm32h7/networking/TmTcLwIpUdpBridge.h"
|
||||
#endif /* OBSW_ADD_LWIP_COMPONENTS == 1 */
|
||||
|
||||
#include "example_common/stm32h7/STM32TestTask.h"
|
||||
|
||||
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
|
||||
#include <fsfw/monitoring/MonitoringMessageContent.h>
|
||||
#include <fsfw/storagemanager/PoolManager.h>
|
||||
#include <fsfw/tmtcpacket/pus/tm.h>
|
||||
#include <fsfw/tmtcservices/CommandingServiceBase.h>
|
||||
#include <fsfw/tmtcservices/PusServiceBase.h>
|
||||
#include "fsfw/datapoollocal/LocalDataPoolManager.h"
|
||||
#include "fsfw/monitoring/MonitoringMessageContent.h"
|
||||
#include "fsfw/storagemanager/PoolManager.h"
|
||||
#include "fsfw/tmtcpacket/pus/tm.h"
|
||||
#include "fsfw/tmtcservices/CommandingServiceBase.h"
|
||||
#include "fsfw/tmtcservices/PusServiceBase.h"
|
||||
|
||||
|
||||
#if OBSW_PERFORM_L3GD20H_TEST == 1
|
||||
#include "fsfw_hal/stm32h7/spi/SpiCookie.h"
|
||||
#include "fsfw_hal/stm32h7/spi/SpiComIF.h"
|
||||
#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h"
|
||||
#include "fsfw_hal/stm32h7/spi/stm32h743ziSpi.h"
|
||||
#include "fsfw_hal/stm32h7/spi/spiCore.h"
|
||||
DMA_HandleTypeDef* txHandle = nullptr;
|
||||
DMA_HandleTypeDef* rxHandle = nullptr;
|
||||
#endif
|
||||
|
||||
void ObjectFactory::produce(void* args) {
|
||||
/* Located inside GenericFactory source file */
|
||||
@ -45,16 +54,47 @@ void ObjectFactory::produce(void* args) {
|
||||
new PoolManager(objects::IPC_STORE, poolCfg);
|
||||
}
|
||||
|
||||
#if OBSW_ADD_LWIP_COMPONENTS == 1
|
||||
/* UDP Server */
|
||||
new TmTcLwIpUdpBridge(objects::UDP_BRIDGE,
|
||||
objects::CCSDS_DISTRIBUTOR, objects::TM_STORE, objects::TC_STORE);
|
||||
new UdpTcLwIpPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE);
|
||||
#endif /* OBSW_ADD_LWIP_COMPONENTS == 1 */
|
||||
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
|
||||
|
||||
ObjectFactory::produceGenericObjects();
|
||||
|
||||
/* Test Device Handler */
|
||||
new STM32TestTask(objects::TEST_TASK, false, true);
|
||||
|
||||
#if OBSW_PERFORM_L3GD20H_TEST == 1
|
||||
|
||||
spi::MspCfgBase* mspCfg = nullptr;
|
||||
spi::TransferModes transferMode = spi::TransferModes::DMA;
|
||||
if(transferMode == spi::TransferModes::POLLING) {
|
||||
auto typedCfg = new spi::MspPollingConfigStruct();
|
||||
spi::h743zi::standardPollingCfg(*typedCfg);
|
||||
mspCfg = typedCfg;
|
||||
}
|
||||
else if(transferMode == spi::TransferModes::INTERRUPT) {
|
||||
auto typedCfg = new spi::MspIrqConfigStruct();
|
||||
spi::h743zi::standardInterruptCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS);
|
||||
mspCfg = typedCfg;
|
||||
}
|
||||
else if(transferMode == spi::TransferModes::DMA) {
|
||||
auto typedCfg = new spi::MspDmaConfigStruct();
|
||||
txHandle = new DMA_HandleTypeDef();
|
||||
rxHandle = new DMA_HandleTypeDef();
|
||||
spi::setDmaHandles(txHandle, rxHandle);
|
||||
spi::h743zi::standardDmaCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS,
|
||||
IrqPriorities::HIGHEST_FREERTOS, IrqPriorities::HIGHEST_FREERTOS);
|
||||
mspCfg = typedCfg;
|
||||
}
|
||||
|
||||
new SpiComIF(objects::SPI_COM_IF);
|
||||
auto spiCookie = new SpiCookie(devaddress::L3GD20H, spi::SpiBus::SPI_1, transferMode, mspCfg,
|
||||
3900000, spi::SpiModes::MODE_3, GPIO_PIN_14, GPIOD, 32);
|
||||
auto gyroDevice = new GyroHandlerL3GD20H(objects::SPI_DEVICE_TEST, objects::SPI_COM_IF,
|
||||
spiCookie);
|
||||
gyroDevice->setStartUpImmediately();
|
||||
gyroDevice->setGoNormalModeAtStartup();
|
||||
#endif
|
||||
}
|
||||
|
@ -6,18 +6,23 @@
|
||||
#ifndef FSFWCONFIG_OBSWCONFIG_H_
|
||||
#define FSFWCONFIG_OBSWCONFIG_H_
|
||||
|
||||
// Specify whether lwIP components are added. TMTC commanding is not possible without them
|
||||
#define STM_USE_PERIPHERAL_TX_BUFFER_MPU_PROTECTION 1
|
||||
|
||||
//! Specify whether lwIP components are added. These are necessary for TMTC commanding
|
||||
#define OBSW_ADD_LWIP_COMPONENTS 1
|
||||
|
||||
// Specify whether TMTC commanding via Ethernet is possible
|
||||
//! Specify whether TMTC commanding via Ethernet is possible
|
||||
#define OBSW_ETHERNET_TMTC_COMMANDING 1
|
||||
|
||||
// Only applies if TMTC commanding is enabled.
|
||||
// Specify whether LEDs are used to display Ethernet connection status.
|
||||
//! Only applies if TMTC commanding is enabled.
|
||||
//! Specify whether LEDs are used to display Ethernet connection status.
|
||||
#define OBSW_ETHERNET_USE_LED1_LED2 0
|
||||
|
||||
#define OBSW_ATTEMPT_DHCP_CONN 1
|
||||
|
||||
#define OBSW_PERIPHERAL_PST 0
|
||||
#define OBSW_PERFORM_SPI_TEST 0
|
||||
|
||||
#define OBSW_PERFORM_L3GD20H_TEST 0
|
||||
|
||||
#if OBSW_ATTEMPT_DHCP_CONN == 0
|
||||
#define MAX_DHCP_TRIES 0
|
||||
#else
|
||||
@ -29,7 +34,7 @@
|
||||
|
||||
#include "events/subsystemIdRanges.h"
|
||||
#include "objects/systemObjectList.h"
|
||||
#include "commonConfig.h"
|
||||
#include <commonConfig.h>
|
||||
|
||||
namespace config {
|
||||
#endif
|
||||
|
14
bsp_stm32h7_freertos/fsfwconfig/devices/devAddresses.h
Normal file
14
bsp_stm32h7_freertos/fsfwconfig/devices/devAddresses.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef BSP_STM32_FREERTOS_FSFWCONFIG_DEVICES_DEVADDRESSES_H_
|
||||
#define BSP_STM32_FREERTOS_FSFWCONFIG_DEVICES_DEVADDRESSES_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace devaddress {
|
||||
enum devaddress: uint32_t {
|
||||
L3GD20H = 1
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* BSP_STM32_FREERTOS_FSFWCONFIG_DEVICES_DEVADDRESSES_H_ */
|
@ -8,6 +8,10 @@ enum mission_objects {
|
||||
/* 0x62 ('b') Board and mission specific objects */
|
||||
UDP_BRIDGE = 0x62000300,
|
||||
UDP_POLLING_TASK = 0x62000400,
|
||||
|
||||
SPI_COM_IF = 0x63001000,
|
||||
SPI_DEVICE_TEST = 0x74001000,
|
||||
|
||||
/* Generic name for FSFW static ID setter */
|
||||
DOWNLINK_DESTINATION = UDP_BRIDGE
|
||||
};
|
||||
|
@ -2,4 +2,32 @@
|
||||
* Add polling sequence initialization which are not common to every BSP here.
|
||||
*/
|
||||
#include "pollingSequenceFactory.h"
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
||||
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
|
||||
|
||||
ReturnValue_t pst::pstPeripheralsTest(FixedTimeslotTaskIF *thisSequence) {
|
||||
uint32_t length = thisSequence->getPeriodMs();
|
||||
static_cast<void>(length);
|
||||
|
||||
#if OBSW_PERFORM_L3GD20H_TEST == 1
|
||||
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.3, DeviceHandlerIF::SEND_WRITE);
|
||||
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.45 * length,
|
||||
DeviceHandlerIF::GET_WRITE);
|
||||
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.6 * length, DeviceHandlerIF::SEND_READ);
|
||||
thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.8 * length, DeviceHandlerIF::GET_READ);
|
||||
#endif
|
||||
|
||||
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "pst::pollingSequenceInitFunction: Initialization errors!" << std::endl;
|
||||
#else
|
||||
sif::printError("pst::pollingSequenceInitFunction: Initialization errors!\n");
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
|
||||
}
|
||||
|
@ -2,11 +2,12 @@
|
||||
#define POLLINGSEQUENCE_POLLINGSEQUENCFACTORY_H_
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
class FixedTimeslotTaskIF;
|
||||
|
||||
namespace pst {
|
||||
ReturnValue_t pstPeripheralsTest(FixedTimeslotTaskIF *thisSequence);
|
||||
ReturnValue_t pollingSequenceExamples(FixedTimeslotTaskIF *thisSequence);
|
||||
ReturnValue_t pollingSequenceDevices(FixedTimeslotTaskIF* thisSequence);
|
||||
}
|
||||
|
Reference in New Issue
Block a user