Skip to content

Commit 23b82fa

Browse files
committed
drop ctxt, rename crate to mcu
1 parent a19e406 commit 23b82fa

File tree

4 files changed

+29
-178
lines changed

4 files changed

+29
-178
lines changed

Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
[package]
2-
name = "common"
3-
version = "0.1.0"
42
authors = ["Jorge Aparicio <[email protected]>"]
3+
categories = ["embedded", "hardware-support", "no-std"]
4+
description = "Abstractions common to microcontrollers"
5+
documentation = "https://docs.rs/mcu"
6+
keywords = ["mcu", "register", "peripheral", "interrupt"]
7+
license = "MIT OR Apache-2.0"
8+
name = "mcu"
9+
repository = "https://github.com/japaric/mcu"
10+
version = "0.1.0"
511

612
[dependencies]

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# `common`
1+
# `mcu`
22

3-
> Bits extracted from the `cortex-m` crate that may be reusable for other
4-
> architecture crates
3+
> Abstractions common to microcontrollers
54
65
## License
76

src/ctxt.rs

Lines changed: 0 additions & 160 deletions
This file was deleted.

src/lib.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
//! Abstractions common to microcontrollers
2+
3+
#![deny(missing_docs)]
4+
#![deny(warnings)]
15
#![feature(const_fn)]
26
#![no_std]
37

4-
use core::cell::UnsafeCell;
58
use core::marker::PhantomData;
6-
7-
pub mod ctxt;
9+
use core::cell::UnsafeCell;
810

911
/// A peripheral
1012
#[derive(Debug)]
@@ -46,6 +48,10 @@ pub struct CriticalSection {
4648
}
4749

4850
impl CriticalSection {
51+
/// Creates a critical section token
52+
///
53+
/// This method is meant to be used to create safe abstractions rather than
54+
/// meant to be directly used in applications.
4955
pub unsafe fn new() -> Self {
5056
CriticalSection { _0: () }
5157
}
@@ -65,22 +71,22 @@ impl<T> Mutex<T> {
6571

6672
impl<T> Mutex<T> {
6773
/// Borrows the data for the duration of the critical section
68-
pub fn borrow<'cs>(&self, _ctxt: &'cs CriticalSection) -> &'cs T {
74+
pub fn borrow<'cs>(&self, _cs: &'cs CriticalSection) -> &'cs T {
6975
unsafe { &*self.inner.get() }
7076
}
7177
}
7278

73-
// NOTE `Mutex` can be used as a channel so, the protected data must be `Send`
74-
// to prevent sending non-Sendable stuff (e.g. interrupt tokens) across
75-
// different execution contexts (e.g. interrupts)
79+
/// Interrupt number
80+
pub unsafe trait Nr {
81+
/// Returns the number associated with an interrupt
82+
fn nr(&self) -> u8;
83+
}
84+
85+
// NOTE A `Mutex` can be used as a channel so the protected data must be `Send`
86+
// to prevent sending non-Sendable stuff (e.g. access tokens) across different
87+
// execution contexts (e.g. interrupts)
7688
unsafe impl<T> Sync for Mutex<T>
7789
where
7890
T: Send,
7991
{
8092
}
81-
82-
/// Interrupt number
83-
pub unsafe trait Nr {
84-
/// Returns the number associated with this interrupt
85-
fn nr(&self) -> u8;
86-
}

0 commit comments

Comments
 (0)