cargo fix
+ cargo fmt
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch panics
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use driver_and_task_library::{
|
||||
setup_board, Function, Pin, Port, PortOptions, ReadablePinOptions, WritablePinOptions, H, L,
|
||||
};
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
let board = setup_board();
|
||||
let port_f = board.setup_gpio_port(Port::F, PortOptions);
|
||||
|
||||
let switches = port_f.setup_readable_pins(
|
||||
[Pin::Zero, Pin::Four],
|
||||
ReadablePinOptions {
|
||||
function: Function::Digital,
|
||||
pull_up: Some(true),
|
||||
},
|
||||
);
|
||||
let [_sw1, _sw2] = switches.pins();
|
||||
|
||||
let mut rgb_led = port_f.setup_writable_pins(
|
||||
[Pin::One, Pin::Three, Pin::Two],
|
||||
WritablePinOptions {
|
||||
function: Function::Digital,
|
||||
},
|
||||
);
|
||||
|
||||
let white = [H, H, H];
|
||||
let _black = [L, L, L];
|
||||
|
||||
let red = [H, L, L];
|
||||
let yellow = [H, H, L];
|
||||
let green = [L, H, L];
|
||||
let cyan = [L, H, H];
|
||||
let blue = [L, L, H];
|
||||
let magenta = [H, L, H];
|
||||
|
||||
let _rainbow = [red, yellow, green, cyan, blue, magenta];
|
||||
|
||||
loop {
|
||||
match switches.read_all() {
|
||||
[L, L] => rgb_led.write_all(white),
|
||||
[L, H] => rgb_led.write_all(blue),
|
||||
[H, L] => rgb_led.write_all(red),
|
||||
[H, H] => rgb_led.write_all(green),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
use crate::gpio::ports::{Port, PortOptions, UsablePort, setup_gpio_port};
|
||||
use crate::gpio::ports::{setup_gpio_port, Port, PortOptions, UsablePort};
|
||||
|
||||
pub struct UsableBoard;
|
||||
impl UsableBoard {
|
||||
|
@@ -298,7 +298,10 @@ pub fn setup_writable_pins<const N: usize>(
|
||||
|
||||
let data_address = port.data(&pins);
|
||||
|
||||
let pins: [WritablePin; N] = pins.map(|pin| WritablePin { data_address, bit: pin });
|
||||
let pins: [WritablePin; N] = pins.map(|pin| WritablePin {
|
||||
data_address,
|
||||
bit: pin,
|
||||
});
|
||||
|
||||
WritablePins { data_address, pins }
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
memory, Pin, ReadablePinOptions, ReadablePins, registers, WritablePinOptions, WritablePins,
|
||||
memory, registers, Pin, ReadablePinOptions, ReadablePins, WritablePinOptions, WritablePins,
|
||||
};
|
||||
|
||||
use super::pins::{setup_readable_pins, setup_writable_pins};
|
||||
@@ -160,7 +160,7 @@ impl UsablePort {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn setup_gpio_port(port: Port, options: PortOptions) -> UsablePort {
|
||||
pub fn setup_gpio_port(port: Port, _options: PortOptions) -> UsablePort {
|
||||
unsafe {
|
||||
memory::set_bits(
|
||||
registers::system::RCGCGPIO,
|
||||
|
@@ -6,7 +6,10 @@ mod memory;
|
||||
mod registers;
|
||||
|
||||
pub use board::setup_board;
|
||||
pub use gpio::pins::{Function, Pin, ReadablePin, ReadablePinOptions, ReadablePins, WritablePin, WritablePinOptions, WritablePins};
|
||||
pub use gpio::pins::{
|
||||
Function, Pin, ReadablePin, ReadablePinOptions, ReadablePins, WritablePin, WritablePinOptions,
|
||||
WritablePins,
|
||||
};
|
||||
pub use gpio::ports::{Port, PortOptions, UsablePort};
|
||||
|
||||
pub const H: bool = true;
|
||||
|
@@ -20,7 +20,7 @@ fn main() -> ! {
|
||||
pull_up: Some(true),
|
||||
},
|
||||
);
|
||||
let [sw1, sw2] = switches.pins();
|
||||
let [_sw1, _sw2] = switches.pins();
|
||||
|
||||
let mut rgb_led = port_f.setup_writable_pins(
|
||||
[Pin::One, Pin::Three, Pin::Two],
|
||||
@@ -30,7 +30,7 @@ fn main() -> ! {
|
||||
);
|
||||
|
||||
let white = [H, H, H];
|
||||
let black = [L, L, L];
|
||||
let _black = [L, L, L];
|
||||
|
||||
let red = [H, L, L];
|
||||
let yellow = [H, H, L];
|
||||
@@ -39,7 +39,7 @@ fn main() -> ! {
|
||||
let blue = [L, L, H];
|
||||
let magenta = [H, L, H];
|
||||
|
||||
let rainbow = [red, yellow, green, cyan, blue, magenta];
|
||||
let _rainbow = [red, yellow, green, cyan, blue, magenta];
|
||||
|
||||
loop {
|
||||
match switches.read_all() {
|
||||
|
Reference in New Issue
Block a user