Add HAL for SubGhz peripheral for STM32 WL series

Based on the HAL from stm32wl, the peripheral driver has been
modified to fit into embassy, using the embassy APIs, providing
operation of the radio peripheral.

The initial version does not offer any async APIs, but the example
shows how the radio IRQ can be used to perform async TX of the radio.
This commit is contained in:
Ulf Lilleengen
2021-08-31 14:32:48 +02:00
parent db3cb02032
commit 7ad6280e65
42 changed files with 7110 additions and 9 deletions

View File

@ -2,7 +2,6 @@ pub use super::types::*;
use crate::pac;
use crate::peripherals::{self, RCC};
use crate::rcc::{get_freqs, set_freqs, Clocks};
use crate::time::Hertz;
use crate::time::U32Ext;
use core::marker::PhantomData;
use embassy::util::Unborrow;
@ -16,10 +15,12 @@ use embassy_hal_common::unborrow;
/// HSI speed
pub const HSI_FREQ: u32 = 16_000_000;
pub const HSE32_FREQ: u32 = 32_000_000;
/// System clock mux source
#[derive(Clone, Copy)]
pub enum ClockSrc {
HSE(Hertz),
HSE32,
HSI16,
}
@ -137,14 +138,17 @@ impl RccExt for RCC {
(HSI_FREQ, 0x01)
}
ClockSrc::HSE(freq) => {
// Enable HSE
ClockSrc::HSE32 => {
// Enable HSE32
unsafe {
rcc.cr().write(|w| w.set_hseon(true));
rcc.cr().write(|w| {
w.set_hsebyppwr(true);
w.set_hseon(true);
});
while !rcc.cr().read().hserdy() {}
}
(freq.0, 0x02)
(HSE32_FREQ, 0x02)
}
};