Add common types
This commit is contained in:
parent
a2da2a6db2
commit
ee9f67fa01
@ -1,4 +1,4 @@
|
||||
pub use super::common::*;
|
||||
pub use super::types::*;
|
||||
use crate::pac;
|
||||
use crate::peripherals::{self, RCC};
|
||||
use crate::rcc::{get_freqs, set_freqs, Clocks};
|
||||
|
@ -1,4 +1,4 @@
|
||||
pub use super::common::*;
|
||||
pub use super::types::*;
|
||||
use crate::pac;
|
||||
use crate::peripherals::{self, CRS, RCC, SYSCFG};
|
||||
use crate::rcc::{get_freqs, set_freqs, Clocks};
|
||||
|
@ -1,4 +1,4 @@
|
||||
pub use super::common::*;
|
||||
pub use super::types::*;
|
||||
use crate::pac;
|
||||
use crate::peripherals::{self, RCC};
|
||||
use crate::rcc::{get_freqs, set_freqs, Clocks};
|
||||
|
@ -3,7 +3,7 @@
|
||||
use crate::peripherals;
|
||||
use crate::time::Hertz;
|
||||
use core::mem::MaybeUninit;
|
||||
mod common;
|
||||
mod types;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Clocks {
|
||||
|
94
embassy-stm32/src/rcc/types.rs
Normal file
94
embassy-stm32/src/rcc/types.rs
Normal file
@ -0,0 +1,94 @@
|
||||
#![allow(dead_code)]
|
||||
/// Most of clock setup is copied from stm32l0xx-hal, and adopted to the generated PAC,
|
||||
/// and with the addition of the init function to configure a system clock.
|
||||
use crate::time::Hertz;
|
||||
|
||||
/// System clock mux source
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum ClockSrc {
|
||||
MSI(MSIRange),
|
||||
PLL(PLLSource, PLLMul, PLLDiv),
|
||||
HSE(Hertz),
|
||||
HSI16,
|
||||
}
|
||||
|
||||
/// MSI Clock Range
|
||||
///
|
||||
/// These ranges control the frequency of the MSI. Internally, these ranges map
|
||||
/// to the `MSIRANGE` bits in the `RCC_ICSCR` register.
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum MSIRange {
|
||||
/// Around 65.536 kHz
|
||||
Range0,
|
||||
/// Around 131.072 kHz
|
||||
Range1,
|
||||
/// Around 262.144 kHz
|
||||
Range2,
|
||||
/// Around 524.288 kHz
|
||||
Range3,
|
||||
/// Around 1.048 MHz
|
||||
Range4,
|
||||
/// Around 2.097 MHz (reset value)
|
||||
Range5,
|
||||
/// Around 4.194 MHz
|
||||
Range6,
|
||||
}
|
||||
|
||||
impl Default for MSIRange {
|
||||
fn default() -> MSIRange {
|
||||
MSIRange::Range5
|
||||
}
|
||||
}
|
||||
|
||||
/// PLL divider
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum PLLDiv {
|
||||
Div2,
|
||||
Div3,
|
||||
Div4,
|
||||
}
|
||||
|
||||
/// PLL multiplier
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum PLLMul {
|
||||
Mul3,
|
||||
Mul4,
|
||||
Mul6,
|
||||
Mul8,
|
||||
Mul12,
|
||||
Mul16,
|
||||
Mul24,
|
||||
Mul32,
|
||||
Mul48,
|
||||
}
|
||||
|
||||
/// AHB prescaler
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum AHBPrescaler {
|
||||
NotDivided,
|
||||
Div2,
|
||||
Div4,
|
||||
Div8,
|
||||
Div16,
|
||||
Div64,
|
||||
Div128,
|
||||
Div256,
|
||||
Div512,
|
||||
}
|
||||
|
||||
/// APB prescaler
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum APBPrescaler {
|
||||
NotDivided,
|
||||
Div2,
|
||||
Div4,
|
||||
Div8,
|
||||
Div16,
|
||||
}
|
||||
|
||||
/// PLL clock input source
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum PLLSource {
|
||||
HSI16,
|
||||
HSE(Hertz),
|
||||
}
|
Loading…
Reference in New Issue
Block a user