-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathlib.rs
More file actions
68 lines (60 loc) · 1.68 KB
/
Copy pathlib.rs
File metadata and controls
68 lines (60 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! HAL for the K210 SoC
//!
//! This is an implementation of the [`embedded-hal`] traits for the K210 SoC
// #![deny(missing_docs)] // uncomment for every releases
#![no_std]
pub use k210_pac as pac;
pub mod aes;
pub mod apu;
pub mod cache;
pub mod clint;
pub mod clock;
pub mod dmac;
pub mod fft;
pub mod fpioa;
pub mod gpio;
pub mod gpiohs;
pub mod plic;
pub mod serial;
pub mod sha256;
pub mod spi;
pub mod stdout;
pub mod sysctl;
pub mod time;
pub mod timer;
/// Prelude
pub mod prelude {
pub use crate::fpioa::FpioaExt as _k210_hal_fpioa_FpioaExt;
pub use crate::gpio::GpioExt as _k210_hal_gpio_GpioExt;
pub use crate::gpiohs::GpiohsExt as _k210_hal_gpiohs_GpiohsExt;
pub use crate::plic::PlicExt as _k210_hal_plic_PlicExt;
pub use crate::serial::SerialExt as _k210_hal_serial_SerialExt;
pub use crate::stdout::Write as _k210_hal_stdout_Write;
pub use crate::sysctl::SysctlExt as _k210_hal_sysctl_SysctlExt;
pub use crate::time::U32Ext as _k210_hal_time_U32Ext;
pub use embedded_hal::prelude::*;
}
mod bit_utils {
#[inline(always)]
pub(crate) unsafe fn u32_set_bit(p: *mut u32, bit: bool, index: usize) {
let mask = 1 << index;
if bit {
*p |= mask;
} else {
*p &= !mask;
}
}
#[inline(always)]
pub(crate) unsafe fn u32_toggle_bit(p: *mut u32, index: usize) {
let mask = 1 << index;
*p ^= mask;
}
#[inline(always)]
pub(crate) unsafe fn u32_bit_is_set(r: *const u32, index: usize) -> bool {
(*r & 1 << index) != 0
}
#[inline(always)]
pub(crate) unsafe fn u32_bit_is_clear(r: *const u32, index: usize) -> bool {
(*r & 1 << index) == 0
}
}