escw_mcu/
lib.rs

1//! Trats for RUST to wrap the MCU C libraries.
2
3#![no_std]
4
5pub mod common;
6pub mod peripheral;
7
8/// Trait for one MCU chip.
9///
10/// All types in this trait has combined with peripheral trait.
11/// So, when you want to define a components with some peripherals, you can only set this trait as
12/// the only one trait bound.
13///
14/// # Examples
15///
16/// Define a key with an IO.
17///
18/// ```rust
19/// struct key<T: Mcu> {
20///     io: <T::IO>
21/// }
22///
23/// impl key {
24///     fn new(io: T::IO) -> Self {
25///         key { io }    
26///     }
27///
28///     fn state(&self) -> IoState {
29///         self.io.state()
30///     }
31/// }
32/// ```
33pub trait Mcu {
34    #[cfg(feature = "io")]
35    type Io: peripheral::io::Io;
36
37    #[cfg(feature = "uart")]
38    type Uart: peripheral::uart::Uart;
39}