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