pull/1/head
Astro 2019-09-02 00:01:18 +02:00
parent 3f7da6e328
commit c5dfaf0ee2
4 changed files with 6 additions and 19 deletions

View File

@ -1,4 +1,3 @@
use core::mem::transmute;
use core::slice::{from_raw_parts, from_raw_parts_mut};
use embedded_hal::digital::v2::{InputPin, OutputPin};
@ -14,13 +13,13 @@ macro_rules! def_gpio {
($PORT: tt, $PIN: tt, $idx: expr) => (
impl $PIN {
fn data(&self) -> &u32 {
let gpio = unsafe { tm4c129x::$PORT::ptr() };
let gpio = tm4c129x::$PORT::ptr();
let data = unsafe { from_raw_parts(gpio as *const _ as *mut u32, 0x100) };
&data[(1 << $idx) as usize]
}
fn data_mut(&mut self) -> &mut u32 {
let gpio = unsafe { tm4c129x::$PORT::ptr() };
let gpio = tm4c129x::$PORT::ptr();
let data = unsafe { from_raw_parts_mut(gpio as *const _ as *mut u32, 0x100) };
&mut data[(1 << $idx) as usize]
}
@ -73,9 +72,3 @@ pub struct PE4;
def_gpio!(GPIO_PORTE_AHB, PE4, 4);
pub struct PE5;
def_gpio!(GPIO_PORTE_AHB, PE5, 5);
/// Setting of GPIO pins is optimized by address masking
fn masked_data<'a>(data: *mut u32, bits: u8) -> &'a mut u32 {
let data = unsafe { from_raw_parts_mut(data, 0x400) };
&mut data[usize::from(bits)]
}

View File

@ -6,11 +6,6 @@ pub mod softspi;
pub mod delay;
const LED1: u8 = 0x10; // PK4
const LED2: u8 = 0x40; // PK6
pub const PWM_LOAD: u16 = (/*pwmclk*/120_000_000u32 / /*freq*/100_000) as u16;
const UART_DIV: u32 = (((/*sysclk*/120_000_000 * 8) / /*baud*/115200) + 1) / 2;
pub fn init() {

View File

@ -1,7 +1,6 @@
use embedded_hal::spi::FullDuplex;
use embedded_hal::digital::v2::{InputPin, OutputPin};
use embedded_hal::blocking::spi::Transfer;
use embedded_hal::blocking::delay::DelayUs;
use nb::Error::WouldBlock;
/// Bit-banged Mode3 SPI

View File

@ -84,9 +84,9 @@ macro_rules! create_socket {
#[entry]
fn main() -> ! {
let mut stdout = hio::hstdout().unwrap();
writeln!(stdout, "ionpak boot");
writeln!(stdout, "ionpak boot").unwrap();
board::init();
writeln!(stdout, "board initialized");
writeln!(stdout, "board initialized").unwrap();
println!(r#"
_ _
@ -120,7 +120,7 @@ fn main() -> ! {
None =>
writeln!(stdout, "Cannot identify ADC!").unwrap(),
Some(id) if id & 0xFFF0 == 0x00D0 => {
writeln!(stdout, "ADC id: {:04X}", id);
writeln!(stdout, "ADC id: {:04X}", id).unwrap();
break;
}
Some(id) =>
@ -183,7 +183,7 @@ fn main() -> ! {
.map(|channel| {
adc.read_data()
.map(|new_data| {
writeln!(stdout, "adc data: {:?}", new_data);
writeln!(stdout, "adc data: {:?}", new_data).unwrap();
data = new_data;
if channel == 0 {
for p in socket_pending.iter_mut() {