Skip to content
Snippets Groups Projects
Commit dd032be5 authored by Per's avatar Per
Browse files

examples and documentation

parent 23972ce1
No related branches found
No related tags found
No related merge requests found
Pipeline #90 failed
......@@ -7,6 +7,11 @@
Adds debug to volatile register when compiled with `--features debug-fmt`.
## Caveats
Notice, the current implementation requres a nightly toolchain (`feature(specilization`)).
This can be
``` rust
extern crate volatile_register;
use std::mem;
......
//! Example to show the use of debug output for small register arrays
//!
//! > cargo run --example example2 --features debug-fmt
//!
extern crate volatile_register;
use std::mem;
use volatile_register::{RW};
use volatile_register::RW;
#[repr(C)]
#[derive(Debug)]
pub struct Nvic {
/// Interrupt Set-Enable
pub iser: [RW<u32>; 8],
reserved0: [u32; 24],
/// Interrupt Clear-Enable
pub icer: [RW<u32>; 8],
reserved1: [u32; 24],
// .. more registers ..
#[repr(C)]
#[derive(Debug)]
pub struct Nvic {
/// Interrupt Set-Enable
pub iser: [RW<u32>; 8],
reserved0: [u32; 24],
/// Interrupt Clear-Enable
pub icer: [RW<u32>; 8],
reserved1: [u32; 24],
// .. more registers ..
}
fn main() {
let r : Nvic = unsafe {mem::uninitialized() };
let r: Nvic = unsafe { mem::uninitialized() };
println!("{:?}", r);
}
\ No newline at end of file
}
//! Example to show the use of debug output for big register arrays
//!
//! > cargo run --example example2 --features debug-fmt
//!
extern crate array_debug;
extern crate volatile_register;
......
......@@ -27,14 +27,13 @@
#![deny(missing_docs)]
#![no_std]
#![feature(specialization)]
#![cfg_attr(feature = "debug-fmt", feature(specialization))]
extern crate vcell;
#[cfg(feature = "debug-fmt")]
use core::fmt;
use core::fmt::{self, Debug, UpperHex};
#[cfg(feature = "debug-fmt")]
use core::fmt::{Debug, UpperHex};
use vcell::VolatileCell;
/// Read-Only register
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment