refactor(firmware): centralize configuration and diagnostics
This commit is contained in:
1 parent
7048ed89d0
commit
387fdaad23
140 files changed
+6891
-4541
No files matched your search
@@ -3,8 +3,10 @@
|
||||
/// Defines the F722 application in the platform crate. All interrupt bindings
|
||||
/// are the finite platform-owned superset. Profile activation determines which
|
||||
/// acknowledged route has initialized hardware.
|
||||
macro_rules! f722_flight_application {
|
||||
($routes:path, $config:path) => {
|
||||
#[doc(hidden)]
|
||||
#[macro_export]
|
||||
macro_rules! __f722_flight_application {
|
||||
($board:ty) => {
|
||||
#[allow(unused_imports)]
|
||||
use $crate::__platform_internal::cmrt as _;
|
||||
#[allow(unused_imports)]
|
||||
@@ -36,12 +38,29 @@ macro_rules! f722_flight_application {
|
||||
#[allow(unused_imports)]
|
||||
use $crate::__platform_internal::rtic_app::Mutex;
|
||||
|
||||
type BoardUserConfig = <$board as $crate::F7Board>::UserConfig;
|
||||
type BoardImmutableConfig = <$board as $crate::F7Board>::ImmutableConfig;
|
||||
const CONFIG_PAYLOAD_BYTES: usize = $crate::config_snapshot_length::<
|
||||
BoardUserConfig,
|
||||
>();
|
||||
type BoardInitResources = F722InitResources<
|
||||
BoardUserConfig,
|
||||
BoardImmutableConfig,
|
||||
CONFIG_PAYLOAD_BYTES,
|
||||
>;
|
||||
type BoardMavlinkState = F722MavlinkState<
|
||||
BoardUserConfig,
|
||||
BoardImmutableConfig,
|
||||
CONFIG_PAYLOAD_BYTES,
|
||||
>;
|
||||
|
||||
const IMU_EVENT_DRDY: u8 = 1 << 0;
|
||||
const IMU_EVENT_TRANSFER_COMPLETE: u8 = 1 << 1;
|
||||
const IMU_EVENT_TRANSFER_FAULT: u8 = 1 << 2;
|
||||
const IMU_EVENT_TIMER: u8 = 1 << 3;
|
||||
const IMU_EVENT_START: u8 = 1 << 4;
|
||||
const MAVLINK_EVENT_TIMER: u8 = 1 << 0;
|
||||
const MAVLINK_EVENT_RECEIVED: u8 = 1 << 1;
|
||||
const MAVLINK_EVENT_DMA: u8 = 1 << 2;
|
||||
|
||||
// Hardware IRQs and both software workers coalesce event bits.
|
||||
@@ -55,7 +74,7 @@ macro_rules! f722_flight_application {
|
||||
|
||||
#[shared]
|
||||
struct Shared {
|
||||
mavlink: F722MavlinkState,
|
||||
mavlink: BoardMavlinkState,
|
||||
lidar: F722LidarState,
|
||||
}
|
||||
|
||||
@@ -69,16 +88,20 @@ macro_rules! f722_flight_application {
|
||||
|
||||
#[init]
|
||||
fn init(context: init::Context) -> (Shared, Local) {
|
||||
let routes = $routes().unwrap_or_else(|_| safe_idle());
|
||||
let F722InitResources {
|
||||
let BoardInitResources {
|
||||
imu,
|
||||
mtf01,
|
||||
mtf01_uart,
|
||||
timer,
|
||||
lidar,
|
||||
mavlink,
|
||||
} = initialize(context.core, context.device, $config(), routes)
|
||||
.unwrap_or_else(|_| safe_idle());
|
||||
} = initialize::<BoardUserConfig, BoardImmutableConfig, CONFIG_PAYLOAD_BYTES>(
|
||||
context.core,
|
||||
context.device,
|
||||
<$board as $crate::F7Board>::FACTORY_USER_CONFIG,
|
||||
<$board as $crate::F7Board>::IMMUTABLE_CONFIG,
|
||||
)
|
||||
.unwrap_or_else(|_| safe_idle());
|
||||
schedule_imu(IMU_EVENT_START);
|
||||
(
|
||||
Shared {
|
||||
@@ -200,20 +223,28 @@ macro_rules! f722_flight_application {
|
||||
}
|
||||
}
|
||||
|
||||
#[task(binds = USART1, priority = 8)]
|
||||
fn mavlink_rx_usart1(_: mavlink_rx_usart1::Context) {
|
||||
// `ExternalControlOnly` is rejected and production signing is
|
||||
// not implemented, so this image has no inbound authority
|
||||
// path. Acknowledge every RX condition to keep the peripheral
|
||||
// quiescent without taking any RTIC-shared flight state.
|
||||
let _ = acknowledge_mavlink_rx_usart1();
|
||||
#[task(binds = USART1, priority = 8, shared = [mavlink])]
|
||||
fn mavlink_rx_usart1(mut context: mavlink_rx_usart1::Context) {
|
||||
let event = acknowledge_mavlink_rx_usart1();
|
||||
if context
|
||||
.shared
|
||||
.mavlink
|
||||
.lock(|mavlink| mavlink.receive_config_interrupt(event))
|
||||
{
|
||||
schedule_mavlink(MAVLINK_EVENT_RECEIVED);
|
||||
}
|
||||
}
|
||||
|
||||
#[task(binds = USART2, priority = 8)]
|
||||
fn mavlink_rx_usart2(_: mavlink_rx_usart2::Context) {
|
||||
// See USART1: inbound bytes are drained but never decoded or
|
||||
// dispatched by the telemetry-only image.
|
||||
let _ = acknowledge_mavlink_rx_usart2();
|
||||
#[task(binds = USART2, priority = 8, shared = [mavlink])]
|
||||
fn mavlink_rx_usart2(mut context: mavlink_rx_usart2::Context) {
|
||||
let event = acknowledge_mavlink_rx_usart2();
|
||||
if context
|
||||
.shared
|
||||
.mavlink
|
||||
.lock(|mavlink| mavlink.receive_config_interrupt(event))
|
||||
{
|
||||
schedule_mavlink(MAVLINK_EVENT_RECEIVED);
|
||||
}
|
||||
}
|
||||
|
||||
#[task(binds = TIM2, priority = 4, local = [timer], shared = [lidar])]
|
||||
@@ -276,5 +307,3 @@ macro_rules! f722_flight_application {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) use f722_flight_application;
|
||||
Reference in new issue
Block a user