Slightly clean up embassy HIL tests (#1937)
This commit is contained in:
parent
c53ba38c43
commit
6b6e628940
@ -39,8 +39,6 @@ use esp_hal::{
|
|||||||
use esp_hal::{interrupt::Priority, timer::systimer::SystemTimer};
|
use esp_hal::{interrupt::Priority, timer::systimer::SystemTimer};
|
||||||
#[cfg(not(feature = "esp32"))]
|
#[cfg(not(feature = "esp32"))]
|
||||||
use esp_hal_embassy::InterruptExecutor;
|
use esp_hal_embassy::InterruptExecutor;
|
||||||
#[cfg(not(feature = "esp32"))]
|
|
||||||
use static_cell::StaticCell;
|
|
||||||
|
|
||||||
macro_rules! mk_static {
|
macro_rules! mk_static {
|
||||||
($t:ty,$val:expr) => {{
|
($t:ty,$val:expr) => {{
|
||||||
@ -60,68 +58,58 @@ unsafe fn __make_static<T>(t: &mut T) -> &'static mut T {
|
|||||||
mod task_invokers {
|
mod task_invokers {
|
||||||
use test_helpers::*;
|
use test_helpers::*;
|
||||||
|
|
||||||
use crate::*;
|
use super::*;
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
pub async fn test_one_shot_timg_invoker() {
|
pub async fn test_one_shot_timg_invoker() {
|
||||||
let outcome;
|
let outcome = test_helpers::test_one_shot_timg().await;
|
||||||
{
|
|
||||||
outcome = test_helpers::test_one_shot_timg().await;
|
|
||||||
}
|
|
||||||
embedded_test::export::check_outcome(outcome);
|
embedded_test::export::check_outcome(outcome);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
#[cfg(not(feature = "esp32"))]
|
#[cfg(not(feature = "esp32"))]
|
||||||
pub async fn test_one_shot_systimer_invoker() {
|
pub async fn test_one_shot_systimer_invoker() {
|
||||||
let outcome;
|
let outcome = task_invokers::test_one_shot_systimer().await;
|
||||||
{
|
|
||||||
outcome = task_invokers::test_one_shot_systimer().await;
|
|
||||||
}
|
|
||||||
embedded_test::export::check_outcome(outcome);
|
embedded_test::export::check_outcome(outcome);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
pub async fn test_join_timg_invoker() {
|
pub async fn test_join_timg_invoker() {
|
||||||
let outcome;
|
let outcome = test_join_timg().await;
|
||||||
{
|
|
||||||
outcome = test_join_timg().await;
|
|
||||||
}
|
|
||||||
embedded_test::export::check_outcome(outcome);
|
embedded_test::export::check_outcome(outcome);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
#[cfg(not(feature = "esp32"))]
|
#[cfg(not(feature = "esp32"))]
|
||||||
pub async fn test_join_systimer_invoker() {
|
pub async fn test_join_systimer_invoker() {
|
||||||
let outcome;
|
let outcome = test_join_systimer().await;
|
||||||
{
|
|
||||||
outcome = test_join_systimer().await;
|
|
||||||
}
|
|
||||||
embedded_test::export::check_outcome(outcome);
|
embedded_test::export::check_outcome(outcome);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
#[cfg(not(feature = "esp32"))]
|
#[cfg(not(feature = "esp32"))]
|
||||||
pub async fn test_interrupt_executor_invoker() {
|
pub async fn test_interrupt_executor_invoker() {
|
||||||
let outcome;
|
let outcome = test_interrupt_executor().await;
|
||||||
{
|
|
||||||
outcome = test_interrupt_executor().await;
|
|
||||||
}
|
|
||||||
embedded_test::export::check_outcome(outcome);
|
embedded_test::export::check_outcome(outcome);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
pub async fn test_tick_and_increment_invoker() {
|
pub async fn test_tick_and_increment_invoker() {
|
||||||
let outcome;
|
let outcome = tick_and_increment().await;
|
||||||
{
|
|
||||||
outcome = tick_and_increment().await;
|
|
||||||
}
|
|
||||||
embedded_test::export::check_outcome(outcome);
|
embedded_test::export::check_outcome(outcome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of the functions that are ACTUALLY TESTS but are called in the invokers
|
// List of the functions that are ACTUALLY TESTS but are called in the invokers
|
||||||
mod test_helpers {
|
mod test_helpers {
|
||||||
use crate::*;
|
use super::*;
|
||||||
|
|
||||||
pub async fn test_one_shot_timg() {
|
pub async fn test_one_shot_timg() {
|
||||||
let peripherals = unsafe { Peripherals::steal() };
|
let peripherals = unsafe { Peripherals::steal() };
|
||||||
let system = SystemControl::new(peripherals.SYSTEM);
|
let system = SystemControl::new(peripherals.SYSTEM);
|
||||||
@ -457,10 +445,10 @@ mod test {
|
|||||||
let timers = mk_static!([OneShotTimer<ErasedTimer>; 2], timers);
|
let timers = mk_static!([OneShotTimer<ErasedTimer>; 2], timers);
|
||||||
esp_hal_embassy::init(&clocks, timers);
|
esp_hal_embassy::init(&clocks, timers);
|
||||||
|
|
||||||
static EXECUTOR: StaticCell<InterruptExecutor<2>> = StaticCell::new();
|
let executor = mk_static!(
|
||||||
let executor =
|
InterruptExecutor<2>,
|
||||||
InterruptExecutor::new(system.software_interrupt_control.software_interrupt2);
|
InterruptExecutor::new(system.software_interrupt_control.software_interrupt2)
|
||||||
let executor = EXECUTOR.init(executor);
|
);
|
||||||
|
|
||||||
let spawner_int = executor.start(Priority::Priority3);
|
let spawner_int = executor.start(Priority::Priority3);
|
||||||
spawner_int.must_spawn(test_interrupt_executor_invoker());
|
spawner_int.must_spawn(test_interrupt_executor_invoker());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user