aboutsummaryrefslogtreecommitdiff
path: root/embassy-mspm0/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-mspm0/src/lib.rs')
-rw-r--r--embassy-mspm0/src/lib.rs107
1 files changed, 107 insertions, 0 deletions
diff --git a/embassy-mspm0/src/lib.rs b/embassy-mspm0/src/lib.rs
new file mode 100644
index 000000000..1191b1010
--- /dev/null
+++ b/embassy-mspm0/src/lib.rs
@@ -0,0 +1,107 @@
1#![no_std]
2// Doc feature labels can be tested locally by running RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc
3#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg_hide), doc(cfg_hide(doc, docsrs)))]
4
5// This mod MUST go first, so that the others see its macros.
6pub(crate) mod fmt;
7
8pub mod gpio;
9pub mod timer;
10
11#[cfg(feature = "_time-driver")]
12mod time_driver;
13
14// Interrupt group handlers.
15#[cfg_attr(feature = "mspm0c110x", path = "int_group/c110x.rs")]
16#[cfg_attr(feature = "mspm0g110x", path = "int_group/g110x.rs")]
17#[cfg_attr(feature = "mspm0g150x", path = "int_group/g150x.rs")]
18#[cfg_attr(feature = "mspm0g151x", path = "int_group/g151x.rs")]
19#[cfg_attr(feature = "mspm0g310x", path = "int_group/g310x.rs")]
20#[cfg_attr(feature = "mspm0g350x", path = "int_group/g350x.rs")]
21#[cfg_attr(feature = "mspm0g351x", path = "int_group/g351x.rs")]
22#[cfg_attr(feature = "mspm0l110x", path = "int_group/l110x.rs")]
23#[cfg_attr(feature = "mspm0l122x", path = "int_group/l122x.rs")]
24#[cfg_attr(feature = "mspm0l130x", path = "int_group/l130x.rs")]
25#[cfg_attr(feature = "mspm0l134x", path = "int_group/l134x.rs")]
26#[cfg_attr(feature = "mspm0l222x", path = "int_group/l222x.rs")]
27mod int_group;
28
29pub(crate) mod _generated {
30 #![allow(dead_code)]
31 #![allow(unused_imports)]
32 #![allow(non_snake_case)]
33 #![allow(missing_docs)]
34
35 include!(concat!(env!("OUT_DIR"), "/_generated.rs"));
36}
37
38// Reexports
39pub(crate) use _generated::gpio_pincm;
40pub use _generated::{peripherals, Peripherals};
41pub use embassy_hal_internal::{into_ref, Peripheral, PeripheralRef};
42#[cfg(feature = "unstable-pac")]
43pub use mspm0_metapac as pac;
44#[cfg(not(feature = "unstable-pac"))]
45pub(crate) use mspm0_metapac as pac;
46
47pub use crate::_generated::interrupt;
48
49/// `embassy-mspm0` global configuration.
50#[non_exhaustive]
51#[derive(Clone, Copy)]
52pub struct Config {
53 // TODO
54}
55
56impl Default for Config {
57 fn default() -> Self {
58 Self {
59 // TODO
60 }
61 }
62}
63
64pub fn init(_config: Config) -> Peripherals {
65 critical_section::with(|cs| {
66 let peripherals = Peripherals::take_with_cs(cs);
67
68 // TODO: Further clock configuration
69
70 pac::SYSCTL.mclkcfg().modify(|w| {
71 // Enable MFCLK
72 w.set_usemftick(true);
73 // MDIV must be disabled if MFCLK is enabled.
74 w.set_mdiv(0);
75 });
76
77 // Enable MFCLK for peripheral use
78 //
79 // TODO: Optional?
80 pac::SYSCTL.genclken().modify(|w| {
81 w.set_mfpclken(true);
82 });
83
84 pac::SYSCTL.borthreshold().modify(|w| {
85 w.set_level(0);
86 });
87
88 gpio::init(pac::GPIOA);
89 #[cfg(gpio_pb)]
90 gpio::init(pac::GPIOB);
91 #[cfg(gpio_pc)]
92 gpio::init(pac::GPIOC);
93
94 _generated::enable_group_interrupts(cs);
95
96 #[cfg(feature = "mspm0c110x")]
97 unsafe {
98 use crate::_generated::interrupt::typelevel::Interrupt;
99 crate::interrupt::typelevel::GPIOA::enable();
100 }
101
102 #[cfg(feature = "_time-driver")]
103 time_driver::init(cs);
104
105 peripherals
106 })
107}