mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/cmake-demo.git
synced 2025-09-28 23:57:33 +00:00
Initial Commit
This commit is contained in:
94
App/Inc/shared.hpp
Normal file
94
App/Inc/shared.hpp
Normal file
@@ -0,0 +1,94 @@
|
||||
#ifndef INC_SHARED_HPP_
|
||||
#define INC_SHARED_HPP_
|
||||
|
||||
#include <cmsis_os2.h>
|
||||
#include <states.hpp>
|
||||
|
||||
namespace rres
|
||||
{
|
||||
struct LoggingData
|
||||
{
|
||||
uint32_t hash;
|
||||
uint32_t timestamp;
|
||||
|
||||
uint8_t state;
|
||||
uint8_t sense_fire;
|
||||
uint16_t sense_adc[6];
|
||||
uint8_t fired;
|
||||
};
|
||||
|
||||
enum Event
|
||||
{
|
||||
TICK_10HZ = 1 << 0,
|
||||
TOCK_10HZ = 1 << 1,
|
||||
START_LOGGING = 1 << 2,
|
||||
DUMP_FLASH = 1 << 3,
|
||||
CLEAR_FLASH = 1 << 4,
|
||||
FLASH_EVENT = DUMP_FLASH | CLEAR_FLASH
|
||||
};
|
||||
|
||||
void init();
|
||||
|
||||
/**
|
||||
* @brief Wait for any of the provided flags to be set.
|
||||
*
|
||||
* @note Example usage: waitForAny(GYRO | TICK_20HZ); to either wait for the 20Hz tick or new gyro data.
|
||||
*
|
||||
* @param event An integer with every bit representing a specific event.
|
||||
* @param timeout An optional timeout for additional safety.
|
||||
* @return uint32_t Returns the flags that were set.
|
||||
*/
|
||||
uint32_t waitForAny(uint32_t event, uint32_t timeout = osWaitForever);
|
||||
|
||||
/**
|
||||
* @brief Wait for all of the provided flags to be set.
|
||||
*
|
||||
* @note Example usage: waitForAny(GYRO | TICK_20HZ); to wait for both the 20Hz tick as well as new gyro data.
|
||||
*
|
||||
* @param event An integer with every bit representing a specific event.
|
||||
* @param timeout An optional timeout for additional safety.
|
||||
* @return uint32_t Returns the flags that were set.
|
||||
*/
|
||||
uint32_t waitForAll(uint32_t event, uint32_t timeout = osWaitForever);
|
||||
|
||||
LoggingData getData();
|
||||
|
||||
/**
|
||||
* @brief Set the sensed fire bits.
|
||||
*
|
||||
* @param sense_fire The sensed fire bits.
|
||||
*/
|
||||
void setSenseFire(uint8_t sense_fire);
|
||||
|
||||
/**
|
||||
* @brief Set Capacitor Voltages.
|
||||
*
|
||||
* @param sense_adc The sensed ADC values.
|
||||
*/
|
||||
void setSenseADC(uint16_t sense_adc[6]);
|
||||
|
||||
/**
|
||||
* @brief Set fired event.
|
||||
*
|
||||
* @param fired The fired event.
|
||||
*/
|
||||
void setFired(uint8_t fired);
|
||||
|
||||
/**
|
||||
* @brief Start logging data to the flash memory.
|
||||
*/
|
||||
void startLogging();
|
||||
|
||||
/**
|
||||
* @brief Dump the flash memory to the console.
|
||||
*/
|
||||
void dumpFlash();
|
||||
|
||||
/**
|
||||
* @brief Clear the flash memory.
|
||||
*/
|
||||
void clearFlash();
|
||||
|
||||
} // namespace grsm
|
||||
|
||||
#endif /* INC_SHARED_HPP_ */
|
126
App/Inc/sta/config.hpp
Normal file
126
App/Inc/sta/config.hpp
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Configuration file for STA-Core.
|
||||
*
|
||||
* Created on: Aug 30, 2023
|
||||
* Author: Dario
|
||||
*/
|
||||
|
||||
#ifndef INC_STA_CONFIG_HPP_
|
||||
#define INC_STA_CONFIG_HPP_
|
||||
|
||||
#define STA_STM32_ASEAG
|
||||
#include <sta/devices/stm32/mcu/STM32F407xx.hpp>
|
||||
|
||||
// Doesn't really do too much right now. Has to be added for successful compilation.
|
||||
#define STA_PRINTF_USE_STDLIB
|
||||
|
||||
#define STA_MCU_LITTLE_ENDIAN
|
||||
#define STA_PLATFORM_STM32
|
||||
|
||||
// Enable debug serial output and assertions.
|
||||
//#define STA_ASSERT_FORCE
|
||||
#define STA_DEBUGGING_ENABLED
|
||||
|
||||
// Activate the timer for microsecond delays.
|
||||
// #define STA_STM32_DELAY_ENABLE
|
||||
// #define STA_STM32_DELAY_US_TIM htim1
|
||||
|
||||
// Settings for the rtos-utils
|
||||
#define STA_RTOS_SYSTEM_EVENTS_ENABLE
|
||||
// #define STA_RTOS_SYSTEM_WATCHDOG_ENABLE
|
||||
#define STA_TACOS_CAN_BUS_ENABLED
|
||||
#define STA_CAN_BUS_ENABLE
|
||||
|
||||
// Uses the default configuration for TACOS.
|
||||
#include <sta/tacos/configs/default.hpp>
|
||||
#include <states.hpp>
|
||||
#include <can_ids.hpp>
|
||||
#include <modules.hpp>
|
||||
|
||||
// Pin Definitions:
|
||||
// Arming pins
|
||||
// Hatch arming
|
||||
#define ARMING_GROUPA GPIOE
|
||||
#define ARMING_PIN_A GPIO_PIN_15
|
||||
|
||||
#define ARMING_GROUPB GPIOG
|
||||
#define ARMING_PIN_B GPIO_PIN_0
|
||||
|
||||
// Main arming
|
||||
#define ARMING_GROUPC GPIOA
|
||||
#define ARMING_PIN_C GPIO_PIN_6
|
||||
|
||||
#define ARMING_GROUPD GPIOE
|
||||
#define ARMING_PIN_D GPIO_PIN_0
|
||||
|
||||
// Main dereefing
|
||||
#define ARMING_GROUPE GPIOB
|
||||
#define ARMING_PIN_E GPIO_PIN_6
|
||||
|
||||
#define ARMING_GROUPF GPIOG
|
||||
#define ARMING_PIN_F GPIO_PIN_11
|
||||
|
||||
// Shorting pins
|
||||
// Hatch shorting
|
||||
#define SHORTING_GROUPA GPIOE
|
||||
#define SHORTING_PIN_A GPIO_PIN_13
|
||||
|
||||
#define SHORTING_GROUPB GPIOC
|
||||
#define SHORTING_PIN_B GPIO_PIN_5
|
||||
|
||||
// Main shorting
|
||||
#define SHORTING_GROUPC GPIOA
|
||||
#define SHORTING_PIN_C GPIO_PIN_4
|
||||
|
||||
#define SHORTING_GROUPD GPIOB
|
||||
#define SHORTING_PIN_D GPIO_PIN_8
|
||||
|
||||
// Main dereefing
|
||||
#define SHORTING_GROUPE GPIOB
|
||||
#define SHORTING_PIN_E GPIO_PIN_4
|
||||
|
||||
#define SHORTING_GROUPF GPIOG
|
||||
#define SHORTING_PIN_F GPIO_PIN_9
|
||||
|
||||
// Fire pins
|
||||
// Hatch fire
|
||||
#define FIRE_DEREEFING_GROUP1 GPIOB
|
||||
#define FIRE_DEREEFING_PIN_1 GPIO_PIN_10
|
||||
|
||||
#define FIRE_DEREEFING_GROUP2 GPIOE
|
||||
#define FIRE_DEREEFING_PIN_2 GPIO_PIN_7
|
||||
|
||||
// Main fire
|
||||
#define FIRE_MAIN_GROUP1 GPIOA
|
||||
#define FIRE_MAIN_PIN_1 GPIO_PIN_7
|
||||
|
||||
#define FIRE_MAIN_GROUP2 GPIOE
|
||||
#define FIRE_MAIN_PIN_2 GPIO_PIN_1
|
||||
|
||||
// Main dereefing
|
||||
#define FIRE_HATCH_GROUP1 GPIOB
|
||||
#define FIRE_HATCH_PIN_1 GPIO_PIN_7
|
||||
|
||||
#define FIRE_HATCH_GROUP2 GPIOG
|
||||
#define FIRE_HATCH_PIN_2 GPIO_PIN_12
|
||||
|
||||
// Sense fire pins
|
||||
#define SENSE_FIRE_GROUP1 GPIOE
|
||||
#define SENSE_FIRE_PIN_1 GPIO_PIN_14
|
||||
|
||||
#define SENSE_FIRE_GROUP2 GPIOF
|
||||
#define SENSE_FIRE_PIN_2 GPIO_PIN_15
|
||||
|
||||
#define SENSE_FIRE_GROUP3 GPIOA
|
||||
#define SENSE_FIRE_PIN_3 GPIO_PIN_5
|
||||
|
||||
#define SENSE_FIRE_GROUP4 GPIOB
|
||||
#define SENSE_FIRE_PIN_4 GPIO_PIN_9
|
||||
|
||||
#define SENSE_FIRE_GROUP5 GPIOB
|
||||
#define SENSE_FIRE_PIN_5 GPIO_PIN_5
|
||||
|
||||
#define SENSE_FIRE_GROUP6 GPIOG
|
||||
#define SENSE_FIRE_PIN_6 GPIO_PIN_10
|
||||
|
||||
#endif /* INC_STA_CONFIG_HPP_ */
|
26
App/Inc/tasks/arming.hpp
Normal file
26
App/Inc/tasks/arming.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* arming.hpp
|
||||
*
|
||||
* Created on: Jun 17, 2024
|
||||
* Author: carlos
|
||||
*/
|
||||
|
||||
#ifndef INC_TASKS_ARMING_HPP_
|
||||
#define INC_TASKS_ARMING_HPP_
|
||||
|
||||
#include <sta/tacos.hpp>
|
||||
|
||||
namespace tasks
|
||||
{
|
||||
class ArmingTask : public sta::tacos::TacosThread
|
||||
{
|
||||
public:
|
||||
ArmingTask();
|
||||
|
||||
void init() override;
|
||||
|
||||
void func() override;
|
||||
};
|
||||
} // namespace tasks
|
||||
|
||||
#endif /* INC_TASKS_ARMING_HPP_ */
|
27
App/Inc/tasks/fire.hpp
Normal file
27
App/Inc/tasks/fire.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* fire.hpp
|
||||
*
|
||||
* Created on: Jun 17, 2024
|
||||
* Author: carlos
|
||||
*/
|
||||
|
||||
#ifndef INC_TASKS_FIRE_HPP_
|
||||
#define INC_TASKS_FIRE_HPP_
|
||||
|
||||
#include <sta/tacos.hpp>
|
||||
#include <sta/devices/stm32/can.hpp>
|
||||
|
||||
namespace tasks
|
||||
{
|
||||
class FireTask : public sta::tacos::TacosThread
|
||||
{
|
||||
public:
|
||||
FireTask();
|
||||
|
||||
void init() override;
|
||||
|
||||
void func() override;
|
||||
};
|
||||
} // namespace tasks
|
||||
|
||||
#endif /* INC_TASKS_FIRE_HPP_ */
|
37
App/Inc/tasks/sense.hpp
Normal file
37
App/Inc/tasks/sense.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* sense.hpp
|
||||
*
|
||||
* Created on: Jun 17, 2024
|
||||
* Author: carlos
|
||||
*/
|
||||
|
||||
#ifndef INC_TASKS_SENSE_HPP_
|
||||
#define INC_TASKS_SENSE_HPP_
|
||||
|
||||
#include <sta/tacos.hpp>
|
||||
#include <sta/devices/stm32/adc.hpp>
|
||||
#include <sta/devices/stm32/bus/spi.hpp>
|
||||
|
||||
namespace tasks
|
||||
{
|
||||
class SenseTask : public sta::tacos::TacosThread
|
||||
{
|
||||
public:
|
||||
SenseTask(ADC_HandleTypeDef *handle);
|
||||
|
||||
void init() override;
|
||||
|
||||
void func() override;
|
||||
|
||||
private:
|
||||
sta::STM32ADC adc_;
|
||||
uint16_t dmaBuffer_[6];
|
||||
size_t bufferSize_ = 6;
|
||||
uint16_t result_[6];
|
||||
|
||||
CanSysMsg msg_;
|
||||
uint16_t result_counter_ = 0;
|
||||
};
|
||||
} // namespace tasks
|
||||
|
||||
#endif /* INC_TASKS_SENSE_HPP_ */
|
Reference in New Issue
Block a user