larger GPIO refactoring and Async UART update
This commit is contained in:
@ -5,8 +5,8 @@
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
use cortex_m_rt::entry;
|
||||
use embedded_hal::delay::DelayNs;
|
||||
use embedded_hal::spi::{SpiBus, MODE_3};
|
||||
use embedded_hal::{delay::DelayNs, digital::OutputPin};
|
||||
use panic_rtt_target as _;
|
||||
use rtt_target::{rprintln, rtt_init_print};
|
||||
use va108xx_hal::spi::SpiClkConfig;
|
||||
@ -41,9 +41,7 @@ fn main() -> ! {
|
||||
|
||||
// Need to set the ADC chip select low
|
||||
let mut adc_cs = pinsa.pa17.into_push_pull_output();
|
||||
adc_cs
|
||||
.set_high()
|
||||
.expect("Setting ADC chip select high failed");
|
||||
adc_cs.set_high();
|
||||
|
||||
let spi_cfg = SpiConfig::default()
|
||||
.clk_cfg(
|
||||
|
@ -43,18 +43,16 @@ fn main() -> ! {
|
||||
|
||||
// Configure an edge interrupt on the button and route it to interrupt vector 15
|
||||
let mut button = Button::new(pinsa.pa11.into_floating_input());
|
||||
button.configure_edge_interrupt(
|
||||
edge_irq,
|
||||
InterruptConfig::new(pac::interrupt::OC15, true, true),
|
||||
Some(&mut dp.sysconfig),
|
||||
Some(&mut dp.irqsel),
|
||||
);
|
||||
|
||||
if PRESS_MODE == PressMode::Toggle {
|
||||
// This filter debounces the switch for edge based interrupts
|
||||
button.configure_filter_type(FilterType::FilterFourClockCycles, FilterClkSel::Clk1);
|
||||
set_clk_div_register(&mut dp.sysconfig, FilterClkSel::Clk1, 50_000);
|
||||
}
|
||||
button.configure_and_enable_edge_interrupt(
|
||||
edge_irq,
|
||||
InterruptConfig::new(pac::interrupt::OC15, true, true),
|
||||
);
|
||||
|
||||
set_up_ms_tick(
|
||||
InterruptConfig::new(pac::Interrupt::OC0, true, true),
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use embedded_hal::delay::DelayNs;
|
||||
use embedded_hal::digital::{OutputPin, StatefulOutputPin};
|
||||
use panic_halt as _;
|
||||
use va108xx_hal::{gpio::PinsA, pac, prelude::*, timer::set_up_ms_delay_provider};
|
||||
use vorago_reb1::leds::Leds;
|
||||
@ -67,22 +66,19 @@ fn main() -> ! {
|
||||
let mut led3 = pins.pa6.into_readable_push_pull_output();
|
||||
let mut delay = set_up_ms_delay_provider(&mut dp.sysconfig, 50.MHz(), dp.tim0);
|
||||
for _ in 0..10 {
|
||||
led1.set_low().ok();
|
||||
led2.set_low().ok();
|
||||
led3.set_low().ok();
|
||||
led1.set_low();
|
||||
led2.set_low();
|
||||
led3.set_low();
|
||||
delay.delay_ms(200);
|
||||
led1.set_high().ok();
|
||||
led2.set_high().ok();
|
||||
led3.set_high().ok();
|
||||
led1.set_high();
|
||||
led2.set_high();
|
||||
led3.set_high();
|
||||
delay.delay_ms(200);
|
||||
}
|
||||
loop {
|
||||
led1.toggle().ok();
|
||||
led1.toggle();
|
||||
delay.delay_ms(200);
|
||||
led2.toggle().ok();
|
||||
delay.delay_ms(200);
|
||||
// Alternatively use deidscted register.
|
||||
led3.toggle_with_toggle_reg();
|
||||
led2.toggle();
|
||||
delay.delay_ms(200);
|
||||
}
|
||||
}
|
||||
|
@ -8,13 +8,13 @@
|
||||
use core::convert::Infallible;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use embedded_hal::digital::OutputPin;
|
||||
use embedded_hal::spi::{SpiBus, SpiDevice, MODE_0};
|
||||
use embedded_hal::{delay::DelayNs, spi};
|
||||
use max116xx_10bit::VoltageRefMode;
|
||||
use max116xx_10bit::{AveragingConversions, AveragingResults};
|
||||
use panic_rtt_target as _;
|
||||
use rtt_target::{rprintln, rtt_init_print};
|
||||
use va108xx_hal::gpio::Port;
|
||||
use va108xx_hal::spi::{OptionalHwCs, SpiClkConfig};
|
||||
use va108xx_hal::timer::CountdownTimer;
|
||||
use va108xx_hal::{
|
||||
@ -24,7 +24,7 @@ use va108xx_hal::{
|
||||
spi::{Spi, SpiBase, SpiConfig},
|
||||
timer::{default_ms_irq_handler, set_up_ms_tick, DelayMs, InterruptConfig},
|
||||
};
|
||||
use va108xx_hal::{port_function_select, FunSel, PortSel};
|
||||
use va108xx_hal::{port_function_select, FunSel};
|
||||
use vorago_reb1::max11619::{
|
||||
max11619_externally_clocked_no_wakeup, max11619_externally_clocked_with_wakeup,
|
||||
max11619_internally_clocked, EocPin, AN2_CHANNEL, POTENTIOMETER_CHANNEL,
|
||||
@ -135,16 +135,14 @@ fn main() -> ! {
|
||||
);
|
||||
|
||||
if MUX_MODE == MuxMode::PortB19to17 {
|
||||
port_function_select(&mut dp.ioconfig, PortSel::PortB, 19, FunSel::Sel1).ok();
|
||||
port_function_select(&mut dp.ioconfig, PortSel::PortB, 18, FunSel::Sel2).ok();
|
||||
port_function_select(&mut dp.ioconfig, PortSel::PortB, 17, FunSel::Sel1).ok();
|
||||
port_function_select(&mut dp.ioconfig, PortSel::PortB, 16, FunSel::Sel1).ok();
|
||||
port_function_select(&mut dp.ioconfig, Port::B, 19, FunSel::Sel1).ok();
|
||||
port_function_select(&mut dp.ioconfig, Port::B, 18, FunSel::Sel2).ok();
|
||||
port_function_select(&mut dp.ioconfig, Port::B, 17, FunSel::Sel1).ok();
|
||||
port_function_select(&mut dp.ioconfig, Port::B, 16, FunSel::Sel1).ok();
|
||||
}
|
||||
// Set the accelerometer chip select low in case the board slot is populated
|
||||
let mut accel_cs = pinsa.pa16.into_push_pull_output();
|
||||
accel_cs
|
||||
.set_high()
|
||||
.expect("Setting accelerometer chip select high failed");
|
||||
accel_cs.set_high();
|
||||
|
||||
let spi = Spi::new(
|
||||
&mut dp.sysconfig,
|
||||
|
Reference in New Issue
Block a user