lib: fix no_std
compiling
Add a conditional check to enable `no_std` if the target_os is "none". Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
9a96cbbf4f
commit
03bfd901f8
@ -1,4 +1,5 @@
|
|||||||
use std::convert::TryInto;
|
#![cfg_attr(target_os = "none", no_std)]
|
||||||
|
use core::convert::TryInto;
|
||||||
pub struct Register {
|
pub struct Register {
|
||||||
/// Offset of this register within this CSR
|
/// Offset of this register within this CSR
|
||||||
offset: usize,
|
offset: usize,
|
||||||
@ -78,7 +79,7 @@ pub struct CSR<T> {
|
|||||||
|
|
||||||
impl<T> CSR<T>
|
impl<T> CSR<T>
|
||||||
where
|
where
|
||||||
T: std::convert::TryFrom<usize> + std::convert::TryInto<usize> + std::default::Default,
|
T: core::convert::TryFrom<usize> + core::convert::TryInto<usize> + core::default::Default,
|
||||||
{
|
{
|
||||||
pub fn new(base: *mut T) -> Self {
|
pub fn new(base: *mut T) -> Self {
|
||||||
CSR { base }
|
CSR { base }
|
||||||
@ -131,11 +132,11 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn compile_check() {
|
fn compile_check() {
|
||||||
use super::*;
|
use super::*;
|
||||||
let mut audio = CSR::new(0x0000_0000 as *mut u32);
|
let mut audio = CSR::new(0x1000_0000 as *mut u32);
|
||||||
audio.r(pac::audio::RX_CTL_ENABLE);
|
audio.r(pac::audio::RX_CTL_ENABLE);
|
||||||
audio.rw(pac::audio::RX_CTL_RESET, 1);
|
audio.rw(pac::audio::RX_CTL_RESET, 1);
|
||||||
|
|
||||||
let mut uart = CSR::new(0x0001_0000 as *mut u8);
|
let mut uart = CSR::new(0x1001_0000 as *mut u8);
|
||||||
uart.ow(pac::uart::RXTX_RXTX, b'a');
|
uart.ow(pac::uart::RXTX_RXTX, b'a');
|
||||||
assert_ne!(uart.r(pac::uart::TXFULL_TXFULL), 1);
|
assert_ne!(uart.r(pac::uart::TXFULL_TXFULL), 1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user