re-worked GPIO implementation
This commit is contained in:
@ -11,7 +11,7 @@ keywords = ["no-std", "arm", "cortex-a", "amd", "zynq7000"]
|
||||
categories = ["embedded", "no-std", "hardware-support"]
|
||||
|
||||
[dependencies]
|
||||
cortex-ar = { git = "https://github.com/us-irs/cortex-ar.git", branch = "cortex-a-addition", features = ["critical-section-single-core"] }
|
||||
cortex-ar = { git = "https://github.com/rust-embedded/cortex-ar", branch = "main", features = ["critical-section-single-core"] }
|
||||
zynq7000-rt = { path = "../../zynq7000-rt" }
|
||||
zynq7000 = { path = "../../zynq7000" }
|
||||
zynq7000-hal = { path = "../../zynq7000-hal" }
|
||||
|
@ -22,7 +22,7 @@ use zynq7000_hal::{
|
||||
clocks::Clocks,
|
||||
configure_level_shifter,
|
||||
gic::{GicConfigurator, GicInterruptHelper, Interrupt},
|
||||
gpio::{EmioPin, GpioPins, PinState},
|
||||
gpio::{GpioPins, Output, PinState},
|
||||
gtc::Gtc,
|
||||
i2c,
|
||||
time::Hertz,
|
||||
@ -73,12 +73,10 @@ async fn main(_spawner: Spawner) -> ! {
|
||||
let uart_clk_config = uart::ClkConfigRaw::new_autocalc_with_error(clocks.io_clocks(), 115200)
|
||||
.unwrap()
|
||||
.0;
|
||||
let uart_tx = gpio_pins.mio.mio48.into_uart();
|
||||
let uart_rx = gpio_pins.mio.mio49.into_uart();
|
||||
let mut uart = uart::Uart::new_with_mio(
|
||||
dp.uart_1,
|
||||
uart::UartConfig::new_with_clk_config(uart_clk_config),
|
||||
(uart_tx, uart_rx),
|
||||
(gpio_pins.mio.mio48, gpio_pins.mio.mio49),
|
||||
)
|
||||
.unwrap();
|
||||
uart.write_all(b"-- Zynq 7000 Zedboard I2C L3GD20H example --\n\r")
|
||||
@ -95,45 +93,48 @@ async fn main(_spawner: Spawner) -> ! {
|
||||
let boot_mode = BootMode::new();
|
||||
info!("Boot mode: {:?}", boot_mode);
|
||||
|
||||
let sck_pin = gpio_pins.mio.mio12.into_i2c();
|
||||
let sda_pin = gpio_pins.mio.mio13.into_i2c();
|
||||
let pin_sel = match I2C_ADDR_SEL {
|
||||
I2cAddr::Sa0Low => PinState::Low,
|
||||
I2cAddr::Sa0High => PinState::High,
|
||||
};
|
||||
let _sa0_pin = gpio_pins.mio.mio11.into_output(pin_sel);
|
||||
let _sa0_pin = Output::new_for_mio(gpio_pins.mio.mio11, pin_sel);
|
||||
// The CS pin must be pulled high.
|
||||
let _cs_pin = gpio_pins.mio.mio10.into_output(PinState::High);
|
||||
let _cs_pin = Output::new_for_mio(gpio_pins.mio.mio10, PinState::High);
|
||||
|
||||
let clk_config = i2c::calculate_divisors(
|
||||
clocks.arm_clocks().cpu_1x_clk(),
|
||||
i2c::I2cSpeed::Normal100kHz,
|
||||
)
|
||||
.unwrap();
|
||||
let i2c = i2c::I2c::new_with_mio(dp.i2c_1, clk_config, (sck_pin, sda_pin)).unwrap();
|
||||
let i2c = i2c::I2c::new_with_mio(
|
||||
dp.i2c_1,
|
||||
clk_config,
|
||||
(gpio_pins.mio.mio12, gpio_pins.mio.mio13),
|
||||
)
|
||||
.unwrap();
|
||||
let mut l3gd20 = l3gd20::i2c::L3gd20::new(i2c, l3gd20::i2c::I2cAddr::Sa0Low).unwrap();
|
||||
let who_am_i = l3gd20.who_am_i().unwrap();
|
||||
info!("L3GD20 WHO_AM_I: 0x{:02X}", who_am_i);
|
||||
|
||||
let mut delay = Delay;
|
||||
let mut ticker = Ticker::every(Duration::from_millis(400));
|
||||
let mut mio_led = gpio_pins.mio.mio7.into_output(PinState::Low);
|
||||
let mut mio_led = Output::new_for_mio(gpio_pins.mio.mio7, PinState::Low);
|
||||
|
||||
let mut emio_leds: [EmioPin; 8] = [
|
||||
gpio_pins.emio.take(0).unwrap(),
|
||||
gpio_pins.emio.take(1).unwrap(),
|
||||
gpio_pins.emio.take(2).unwrap(),
|
||||
gpio_pins.emio.take(3).unwrap(),
|
||||
gpio_pins.emio.take(4).unwrap(),
|
||||
gpio_pins.emio.take(5).unwrap(),
|
||||
gpio_pins.emio.take(6).unwrap(),
|
||||
gpio_pins.emio.take(7).unwrap(),
|
||||
let mut emio_leds: [Output; 8] = [
|
||||
Output::new_for_emio(gpio_pins.emio.take(0).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(1).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(2).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(3).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(4).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(5).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(6).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(7).unwrap(), PinState::Low),
|
||||
];
|
||||
for (idx, led) in emio_leds.iter_mut().enumerate() {
|
||||
if idx % 2 == 0 {
|
||||
led.into_output(PinState::High);
|
||||
led.set_high();
|
||||
} else {
|
||||
led.into_output(PinState::Low);
|
||||
led.set_low();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ use zynq7000_hal::{
|
||||
clocks::Clocks,
|
||||
configure_level_shifter,
|
||||
gic::{GicConfigurator, GicInterruptHelper, Interrupt},
|
||||
gpio::{DynMioPin, EmioPin, GpioPins, PinState},
|
||||
gpio::{GpioPins, Output, PinState},
|
||||
gtc::Gtc,
|
||||
spi::{self, SpiAsync, SpiId, SpiWithHwCs, SpiWithHwCsAsync, on_interrupt},
|
||||
time::Hertz,
|
||||
@ -82,12 +82,10 @@ async fn main(spawner: Spawner) -> ! {
|
||||
let uart_clk_config = uart::ClkConfigRaw::new_autocalc_with_error(clocks.io_clocks(), 115200)
|
||||
.unwrap()
|
||||
.0;
|
||||
let uart_tx = gpio_pins.mio.mio48.into_uart();
|
||||
let uart_rx = gpio_pins.mio.mio49.into_uart();
|
||||
let mut uart = uart::Uart::new_with_mio(
|
||||
dp.uart_1,
|
||||
uart::UartConfig::new_with_clk_config(uart_clk_config),
|
||||
(uart_tx, uart_rx),
|
||||
(gpio_pins.mio.mio48, gpio_pins.mio.mio49),
|
||||
)
|
||||
.unwrap();
|
||||
uart.write_all(b"-- Zynq 7000 Zedboard SPI L3GD20H example --\n\r")
|
||||
@ -106,10 +104,6 @@ async fn main(spawner: Spawner) -> ! {
|
||||
spi_ref_clk_div
|
||||
);
|
||||
}
|
||||
let sck_pin = gpio_pins.mio.mio12.into_spi();
|
||||
let mosi_pin = gpio_pins.mio.mio10.into_spi();
|
||||
let miso_pin = gpio_pins.mio.mio11.into_spi();
|
||||
let ss_pin = gpio_pins.mio.mio13.into_spi();
|
||||
|
||||
let mut spi = spi::Spi::new_one_hw_cs(
|
||||
dp.spi_1,
|
||||
@ -121,8 +115,12 @@ async fn main(spawner: Spawner) -> ! {
|
||||
embedded_hal::spi::MODE_3,
|
||||
spi::SlaveSelectConfig::AutoWithAutoStart,
|
||||
),
|
||||
(sck_pin, mosi_pin, miso_pin),
|
||||
ss_pin,
|
||||
(
|
||||
gpio_pins.mio.mio12,
|
||||
gpio_pins.mio.mio10,
|
||||
gpio_pins.mio.mio11,
|
||||
),
|
||||
gpio_pins.mio.mio13,
|
||||
)
|
||||
.unwrap();
|
||||
let mod_id = spi.regs().read_mod_id();
|
||||
@ -138,24 +136,25 @@ async fn main(spawner: Spawner) -> ! {
|
||||
.build(),
|
||||
);
|
||||
|
||||
let mio_led = gpio_pins.mio.mio7.into_output(PinState::Low).downgrade();
|
||||
let mut emio_leds: [EmioPin; 8] = [
|
||||
gpio_pins.emio.take(0).unwrap(),
|
||||
gpio_pins.emio.take(1).unwrap(),
|
||||
gpio_pins.emio.take(2).unwrap(),
|
||||
gpio_pins.emio.take(3).unwrap(),
|
||||
gpio_pins.emio.take(4).unwrap(),
|
||||
gpio_pins.emio.take(5).unwrap(),
|
||||
gpio_pins.emio.take(6).unwrap(),
|
||||
gpio_pins.emio.take(7).unwrap(),
|
||||
let mio_led = Output::new_for_mio(gpio_pins.mio.mio7, PinState::Low);
|
||||
let mut emio_leds: [Output; 8] = [
|
||||
Output::new_for_emio(gpio_pins.emio.take(0).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(1).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(2).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(3).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(4).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(5).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(6).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(7).unwrap(), PinState::Low),
|
||||
];
|
||||
for (idx, led) in emio_leds.iter_mut().enumerate() {
|
||||
if idx % 2 == 0 {
|
||||
led.into_output(PinState::High);
|
||||
led.set_high();
|
||||
} else {
|
||||
led.into_output(PinState::Low);
|
||||
led.set_low();
|
||||
}
|
||||
}
|
||||
|
||||
spawner.spawn(logger_task(uart)).unwrap();
|
||||
if BLOCKING {
|
||||
blocking_application(mio_led, emio_leds, spi).await;
|
||||
@ -178,8 +177,8 @@ pub async fn logger_task(uart: uart::Uart) {
|
||||
}
|
||||
|
||||
pub async fn blocking_application(
|
||||
mut mio_led: DynMioPin,
|
||||
mut emio_leds: [EmioPin; 8],
|
||||
mut mio_led: Output,
|
||||
mut emio_leds: [Output; 8],
|
||||
spi: spi::Spi,
|
||||
) -> ! {
|
||||
let mut delay = Delay;
|
||||
@ -207,8 +206,8 @@ pub async fn blocking_application(
|
||||
}
|
||||
|
||||
pub async fn non_blocking_application(
|
||||
mut mio_led: DynMioPin,
|
||||
mut emio_leds: [EmioPin; 8],
|
||||
mut mio_led: Output,
|
||||
mut emio_leds: [Output; 8],
|
||||
spi: spi::Spi,
|
||||
) -> ! {
|
||||
let mut delay = Delay;
|
||||
|
@ -17,7 +17,7 @@ use zynq7000_hal::{
|
||||
clocks::Clocks,
|
||||
configure_level_shifter,
|
||||
gic::{GicConfigurator, GicInterruptHelper, Interrupt},
|
||||
gpio::{EmioPin, GpioPins, PinState},
|
||||
gpio::{GpioPins, Output, PinState},
|
||||
gtc::Gtc,
|
||||
uart::{ClkConfigRaw, Uart, UartConfig},
|
||||
};
|
||||
@ -50,13 +50,13 @@ pub enum UartSel {
|
||||
}
|
||||
|
||||
pub struct UartMultiplexer {
|
||||
sel_pins: [EmioPin; 3],
|
||||
sel_pins: [Output; 3],
|
||||
}
|
||||
|
||||
impl UartMultiplexer {
|
||||
pub fn new(mut sel_pins: [EmioPin; 3]) -> Self {
|
||||
pub fn new(mut sel_pins: [Output; 3]) -> Self {
|
||||
for pin in sel_pins.iter_mut() {
|
||||
pin.into_output(PinState::Low);
|
||||
pin.set_low();
|
||||
}
|
||||
Self { sel_pins }
|
||||
}
|
||||
@ -65,34 +65,34 @@ impl UartMultiplexer {
|
||||
// TODO: A pin group switcher would be nice to do this in one go.
|
||||
match sel {
|
||||
UartSel::Uart0 => {
|
||||
self.sel_pins[2].set_low().unwrap();
|
||||
self.sel_pins[1].set_low().unwrap();
|
||||
self.sel_pins[0].set_low().unwrap();
|
||||
self.sel_pins[2].set_low();
|
||||
self.sel_pins[1].set_low();
|
||||
self.sel_pins[0].set_low();
|
||||
}
|
||||
UartSel::Uartlite => {
|
||||
self.sel_pins[2].set_low().unwrap();
|
||||
self.sel_pins[1].set_low().unwrap();
|
||||
self.sel_pins[0].set_high().unwrap();
|
||||
self.sel_pins[2].set_low();
|
||||
self.sel_pins[1].set_low();
|
||||
self.sel_pins[0].set_high();
|
||||
}
|
||||
UartSel::Uart16550 => {
|
||||
self.sel_pins[2].set_low().unwrap();
|
||||
self.sel_pins[1].set_high().unwrap();
|
||||
self.sel_pins[0].set_low().unwrap();
|
||||
self.sel_pins[2].set_low();
|
||||
self.sel_pins[1].set_high();
|
||||
self.sel_pins[0].set_low();
|
||||
}
|
||||
UartSel::Uart0ToUartlite => {
|
||||
self.sel_pins[2].set_low().unwrap();
|
||||
self.sel_pins[1].set_high().unwrap();
|
||||
self.sel_pins[0].set_high().unwrap();
|
||||
self.sel_pins[2].set_low();
|
||||
self.sel_pins[1].set_high();
|
||||
self.sel_pins[0].set_high();
|
||||
}
|
||||
UartSel::Uart0ToUart16550 => {
|
||||
self.sel_pins[2].set_high().unwrap();
|
||||
self.sel_pins[1].set_low().unwrap();
|
||||
self.sel_pins[0].set_low().unwrap();
|
||||
self.sel_pins[2].set_high();
|
||||
self.sel_pins[1].set_low();
|
||||
self.sel_pins[0].set_low();
|
||||
}
|
||||
UartSel::UartliteToUart16550 => {
|
||||
self.sel_pins[2].set_high().unwrap();
|
||||
self.sel_pins[1].set_low().unwrap();
|
||||
self.sel_pins[0].set_high().unwrap();
|
||||
self.sel_pins[2].set_high();
|
||||
self.sel_pins[1].set_low();
|
||||
self.sel_pins[0].set_high();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,12 +123,10 @@ async fn main(_spawner: Spawner) -> ! {
|
||||
let uart_clk_config = ClkConfigRaw::new_autocalc_with_error(clocks.io_clocks(), 115200)
|
||||
.unwrap()
|
||||
.0;
|
||||
let uart_tx = gpio_pins.mio.mio48.into_uart();
|
||||
let uart_rx = gpio_pins.mio.mio49.into_uart();
|
||||
let mut log_uart = Uart::new_with_mio(
|
||||
dp.uart_1,
|
||||
UartConfig::new_with_clk_config(uart_clk_config),
|
||||
(uart_tx, uart_rx),
|
||||
(gpio_pins.mio.mio48, gpio_pins.mio.mio49),
|
||||
)
|
||||
.unwrap();
|
||||
log_uart.write_all(INIT_STRING.as_bytes()).unwrap();
|
||||
@ -163,26 +161,23 @@ async fn main(_spawner: Spawner) -> ! {
|
||||
info!("Boot mode: {:?}", boot_mode);
|
||||
|
||||
let mut ticker = Ticker::every(Duration::from_millis(1000));
|
||||
let mut mio_led = gpio_pins.mio.mio7.into_output(PinState::Low);
|
||||
|
||||
let mut emio_leds: [EmioPin; 8] = [
|
||||
gpio_pins.emio.take(0).unwrap(),
|
||||
gpio_pins.emio.take(1).unwrap(),
|
||||
gpio_pins.emio.take(2).unwrap(),
|
||||
gpio_pins.emio.take(3).unwrap(),
|
||||
gpio_pins.emio.take(4).unwrap(),
|
||||
gpio_pins.emio.take(5).unwrap(),
|
||||
gpio_pins.emio.take(6).unwrap(),
|
||||
gpio_pins.emio.take(7).unwrap(),
|
||||
let mut mio_led = Output::new_for_mio(gpio_pins.mio.mio7, PinState::Low);
|
||||
let mut emio_leds: [Output; 8] = [
|
||||
Output::new_for_emio(gpio_pins.emio.take(0).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(1).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(2).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(3).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(4).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(5).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(6).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(7).unwrap(), PinState::Low),
|
||||
];
|
||||
for led in emio_leds.iter_mut() {
|
||||
led.into_output(PinState::Low);
|
||||
}
|
||||
|
||||
let mut uart_mux = UartMultiplexer::new([
|
||||
gpio_pins.emio.take(8).unwrap(),
|
||||
gpio_pins.emio.take(9).unwrap(),
|
||||
gpio_pins.emio.take(10).unwrap(),
|
||||
Output::new_for_emio(gpio_pins.emio.take(8).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(9).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(10).unwrap(), PinState::Low),
|
||||
]);
|
||||
let mut current_sel = UartSel::Uart0;
|
||||
uart_mux.select(current_sel);
|
||||
|
@ -43,7 +43,7 @@ use zynq7000_hal::{
|
||||
clocks::Clocks,
|
||||
configure_level_shifter,
|
||||
gic::{GicConfigurator, GicInterruptHelper, Interrupt},
|
||||
gpio::{EmioPin, GpioPins, Mio7, MioPin, Output, PinState},
|
||||
gpio::{GpioPins, Output, PinState},
|
||||
gtc::Gtc,
|
||||
time::Hertz,
|
||||
uart::{ClkConfigRaw, Uart, UartConfig},
|
||||
@ -114,13 +114,13 @@ pub enum UartSel {
|
||||
}
|
||||
|
||||
pub struct UartMultiplexer {
|
||||
sel_pins: [EmioPin; 3],
|
||||
sel_pins: [Output; 3],
|
||||
}
|
||||
|
||||
impl UartMultiplexer {
|
||||
pub fn new(mut sel_pins: [EmioPin; 3]) -> Self {
|
||||
pub fn new(mut sel_pins: [Output; 3]) -> Self {
|
||||
for pin in sel_pins.iter_mut() {
|
||||
pin.into_output(PinState::Low);
|
||||
pin.set_low();
|
||||
}
|
||||
Self { sel_pins }
|
||||
}
|
||||
@ -129,38 +129,39 @@ impl UartMultiplexer {
|
||||
// TODO: A pin group switcher would be nice to do this in one go.
|
||||
match sel {
|
||||
UartSel::Uart0 => {
|
||||
self.sel_pins[2].set_low().unwrap();
|
||||
self.sel_pins[1].set_low().unwrap();
|
||||
self.sel_pins[0].set_low().unwrap();
|
||||
self.sel_pins[2].set_low();
|
||||
self.sel_pins[1].set_low();
|
||||
self.sel_pins[0].set_low();
|
||||
}
|
||||
UartSel::Uartlite => {
|
||||
self.sel_pins[2].set_low().unwrap();
|
||||
self.sel_pins[1].set_low().unwrap();
|
||||
self.sel_pins[0].set_high().unwrap();
|
||||
self.sel_pins[2].set_low();
|
||||
self.sel_pins[1].set_low();
|
||||
self.sel_pins[0].set_high();
|
||||
}
|
||||
UartSel::Uart16550 => {
|
||||
self.sel_pins[2].set_low().unwrap();
|
||||
self.sel_pins[1].set_high().unwrap();
|
||||
self.sel_pins[0].set_low().unwrap();
|
||||
self.sel_pins[2].set_low();
|
||||
self.sel_pins[1].set_high();
|
||||
self.sel_pins[0].set_low();
|
||||
}
|
||||
UartSel::Uart0ToUartlite => {
|
||||
self.sel_pins[2].set_low().unwrap();
|
||||
self.sel_pins[1].set_high().unwrap();
|
||||
self.sel_pins[0].set_high().unwrap();
|
||||
self.sel_pins[2].set_low();
|
||||
self.sel_pins[1].set_high();
|
||||
self.sel_pins[0].set_high();
|
||||
}
|
||||
UartSel::Uart0ToUart16550 => {
|
||||
self.sel_pins[2].set_high().unwrap();
|
||||
self.sel_pins[1].set_low().unwrap();
|
||||
self.sel_pins[0].set_low().unwrap();
|
||||
self.sel_pins[2].set_high();
|
||||
self.sel_pins[1].set_low();
|
||||
self.sel_pins[0].set_low();
|
||||
}
|
||||
UartSel::UartliteToUart16550 => {
|
||||
self.sel_pins[2].set_high().unwrap();
|
||||
self.sel_pins[1].set_low().unwrap();
|
||||
self.sel_pins[0].set_high().unwrap();
|
||||
self.sel_pins[2].set_high();
|
||||
self.sel_pins[1].set_low();
|
||||
self.sel_pins[0].set_high();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[embassy_executor::main]
|
||||
#[unsafe(export_name = "main")]
|
||||
async fn main(spawner: Spawner) -> ! {
|
||||
@ -192,12 +193,10 @@ async fn main(spawner: Spawner) -> ! {
|
||||
let uart_clk_config = ClkConfigRaw::new_autocalc_with_error(clocks.io_clocks(), 115200)
|
||||
.unwrap()
|
||||
.0;
|
||||
let uart_tx = gpio_pins.mio.mio48.into_uart();
|
||||
let uart_rx = gpio_pins.mio.mio49.into_uart();
|
||||
let mut log_uart = Uart::new_with_mio(
|
||||
dp.uart_1,
|
||||
UartConfig::new_with_clk_config(uart_clk_config),
|
||||
(uart_tx, uart_rx),
|
||||
(gpio_pins.mio.mio48, gpio_pins.mio.mio49),
|
||||
)
|
||||
.unwrap();
|
||||
log_uart.write_all(INIT_STRING.as_bytes()).unwrap();
|
||||
@ -222,9 +221,9 @@ async fn main(spawner: Spawner) -> ! {
|
||||
|
||||
// Set up UART multiplexing before creating and configuring the UARTs.
|
||||
let mut uart_mux = UartMultiplexer::new([
|
||||
gpio_pins.emio.take(8).unwrap(),
|
||||
gpio_pins.emio.take(9).unwrap(),
|
||||
gpio_pins.emio.take(10).unwrap(),
|
||||
Output::new_for_emio(gpio_pins.emio.take(8).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(9).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(10).unwrap(), PinState::Low),
|
||||
]);
|
||||
match UART_MODE {
|
||||
UartMode::Uart0ToUartlite => uart_mux.select(UartSel::Uart0ToUartlite),
|
||||
@ -254,21 +253,17 @@ async fn main(spawner: Spawner) -> ! {
|
||||
let boot_mode = BootMode::new();
|
||||
info!("Boot mode: {:?}", boot_mode);
|
||||
|
||||
let mio_led = gpio_pins.mio.mio7.into_output(PinState::Low);
|
||||
|
||||
let mut emio_leds: [EmioPin; 8] = [
|
||||
gpio_pins.emio.take(0).unwrap(),
|
||||
gpio_pins.emio.take(1).unwrap(),
|
||||
gpio_pins.emio.take(2).unwrap(),
|
||||
gpio_pins.emio.take(3).unwrap(),
|
||||
gpio_pins.emio.take(4).unwrap(),
|
||||
gpio_pins.emio.take(5).unwrap(),
|
||||
gpio_pins.emio.take(6).unwrap(),
|
||||
gpio_pins.emio.take(7).unwrap(),
|
||||
let mio_led = Output::new_for_mio(gpio_pins.mio.mio7, PinState::Low);
|
||||
let emio_leds: [Output; 8] = [
|
||||
Output::new_for_emio(gpio_pins.emio.take(0).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(1).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(2).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(3).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(4).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(5).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(6).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(7).unwrap(), PinState::Low),
|
||||
];
|
||||
for led in emio_leds.iter_mut() {
|
||||
led.into_output(PinState::Low);
|
||||
}
|
||||
|
||||
let (uart_0_tx, mut uart_0_rx) = uart_0.split();
|
||||
let (uartlite_tx, _uartlite_rx) = uartlite.split();
|
||||
@ -353,7 +348,7 @@ fn build_print_string(prefix: &str, base_str: &str) -> alloc::string::String {
|
||||
}
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn led_task(mut mio_led: MioPin<Mio7, Output>, mut emio_leds: [EmioPin; 8]) {
|
||||
async fn led_task(mut mio_led: Output, mut emio_leds: [Output; 8]) {
|
||||
let mut ticker = Ticker::every(Duration::from_millis(1000));
|
||||
let mut led_idx = 0;
|
||||
loop {
|
||||
|
@ -14,7 +14,7 @@ use zynq7000_hal::{
|
||||
clocks::Clocks,
|
||||
configure_level_shifter,
|
||||
gic::{GicConfigurator, GicInterruptHelper, Interrupt},
|
||||
gpio::{EmioPin, GpioPins, PinState},
|
||||
gpio::{GpioPins, Output, PinState},
|
||||
gtc::Gtc,
|
||||
uart::{ClkConfigRaw, Uart, UartConfig},
|
||||
};
|
||||
@ -59,12 +59,10 @@ async fn main(_spawner: Spawner) -> ! {
|
||||
let uart_clk_config = ClkConfigRaw::new_autocalc_with_error(clocks.io_clocks(), 115200)
|
||||
.unwrap()
|
||||
.0;
|
||||
let uart_tx = gpio_pins.mio.mio48.into_uart();
|
||||
let uart_rx = gpio_pins.mio.mio49.into_uart();
|
||||
let mut uart = Uart::new_with_mio(
|
||||
dp.uart_1,
|
||||
UartConfig::new_with_clk_config(uart_clk_config),
|
||||
(uart_tx, uart_rx),
|
||||
(gpio_pins.mio.mio48, gpio_pins.mio.mio49),
|
||||
)
|
||||
.unwrap();
|
||||
uart.write_all(INIT_STRING.as_bytes()).unwrap();
|
||||
@ -81,21 +79,18 @@ async fn main(_spawner: Spawner) -> ! {
|
||||
info!("Boot mode: {:?}", boot_mode);
|
||||
|
||||
let mut ticker = Ticker::every(Duration::from_millis(200));
|
||||
let mut mio_led = gpio_pins.mio.mio7.into_output(PinState::Low);
|
||||
|
||||
let mut emio_leds: [EmioPin; 8] = [
|
||||
gpio_pins.emio.take(0).unwrap(),
|
||||
gpio_pins.emio.take(1).unwrap(),
|
||||
gpio_pins.emio.take(2).unwrap(),
|
||||
gpio_pins.emio.take(3).unwrap(),
|
||||
gpio_pins.emio.take(4).unwrap(),
|
||||
gpio_pins.emio.take(5).unwrap(),
|
||||
gpio_pins.emio.take(6).unwrap(),
|
||||
gpio_pins.emio.take(7).unwrap(),
|
||||
let mut mio_led = Output::new_for_mio(gpio_pins.mio.mio7, PinState::Low);
|
||||
let mut emio_leds: [Output; 8] = [
|
||||
Output::new_for_emio(gpio_pins.emio.take(0).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(1).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(2).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(3).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(4).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(5).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(6).unwrap(), PinState::Low),
|
||||
Output::new_for_emio(gpio_pins.emio.take(7).unwrap(), PinState::Low),
|
||||
];
|
||||
for led in emio_leds.iter_mut() {
|
||||
led.into_output(PinState::Low);
|
||||
}
|
||||
loop {
|
||||
mio_led.toggle().unwrap();
|
||||
|
||||
|
Reference in New Issue
Block a user