fw: formatting
This commit is contained in:
parent
db1ff6761d
commit
800c6012f2
@ -1,7 +1,8 @@
|
||||
use smoltcp::socket::tcp::{Socket, State};
|
||||
|
||||
use crate::proto::{
|
||||
serialize_response_error, serialize_response_value, PacketParser, ResponsePacket, Settings, ErrorCodes
|
||||
serialize_response_error, serialize_response_value, ErrorCodes, PacketParser, ResponsePacket,
|
||||
Settings,
|
||||
};
|
||||
|
||||
pub struct CommandInterface {
|
||||
@ -70,7 +71,8 @@ impl CommandInterface {
|
||||
return (0, ());
|
||||
}
|
||||
|
||||
let response = serialize_response_error(packet.setting, ErrorCodes::InvalidSetting);
|
||||
let response =
|
||||
serialize_response_error(packet.setting, ErrorCodes::InvalidSetting);
|
||||
&tx_buf[0..8].copy_from_slice(&response);
|
||||
return (8, ());
|
||||
});
|
||||
@ -79,7 +81,12 @@ impl CommandInterface {
|
||||
}
|
||||
};
|
||||
|
||||
defmt::debug!("Valid packet: {:?}, is_write: {}, value: {}", packet.setting, packet.is_write, packet.value);
|
||||
defmt::debug!(
|
||||
"Valid packet: {:?}, is_write: {}, value: {}",
|
||||
packet.setting,
|
||||
packet.is_write,
|
||||
packet.value
|
||||
);
|
||||
|
||||
// TODO validate setting values
|
||||
|
||||
|
@ -69,7 +69,10 @@ impl LiteEthDevice {
|
||||
write_reg(csr_addr + ETHMAC_SRAM_WRITER_EV_ENABLE, 0u32);
|
||||
|
||||
// Return a new device
|
||||
Some(Self { csr_addr, ethmac_addr })
|
||||
Some(Self {
|
||||
csr_addr,
|
||||
ethmac_addr,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,13 +199,9 @@ impl smoltcp::phy::RxToken for LiteEthRxToken {
|
||||
F: FnOnce(&mut [u8]) -> R,
|
||||
{
|
||||
// Read the slot number
|
||||
let slot = unsafe {
|
||||
read_reg::<u32>(self.csr_addr + ETHMAC_SRAM_WRITER_SLOT)
|
||||
};
|
||||
let slot = unsafe { read_reg::<u32>(self.csr_addr + ETHMAC_SRAM_WRITER_SLOT) };
|
||||
// Read the available length
|
||||
let len = unsafe {
|
||||
read_reg::<u32>(self.csr_addr + ETHMAC_SRAM_WRITER_LENGTH)
|
||||
};
|
||||
let len = unsafe { read_reg::<u32>(self.csr_addr + ETHMAC_SRAM_WRITER_LENGTH) };
|
||||
|
||||
let rx_slot_addr: u32 = self.ethmac_addr + slot * SLOT_LEN;
|
||||
let rx_slot: &mut [u8] =
|
||||
|
@ -1,4 +1,4 @@
|
||||
use core::{fmt::Write, any::Any};
|
||||
use core::{any::Any, fmt::Write};
|
||||
|
||||
use defmt;
|
||||
|
||||
@ -29,7 +29,6 @@ unsafe impl defmt::Logger for DefmtLogger {
|
||||
UART = Some(LitexUart::new(0xf000_4000));
|
||||
}
|
||||
|
||||
|
||||
let mut dev = UART.unwrap();
|
||||
for byte in bytes {
|
||||
while let Err(_) = dev.try_put_char(*byte) {}
|
||||
|
@ -1,6 +1,5 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
// TODO remove
|
||||
#![allow(unused)]
|
||||
|
||||
@ -15,24 +14,24 @@ use core::{
|
||||
use embedded_hal::prelude::{_embedded_hal_blocking_i2c_Read, _embedded_hal_blocking_i2c_Write};
|
||||
use mcp4726::Status;
|
||||
use riscv_rt::entry;
|
||||
use smoltcp::socket::{Socket, self};
|
||||
use smoltcp::socket::{self, Socket};
|
||||
use smoltcp::time::Duration;
|
||||
use smoltcp::wire::{IpAddress, Ipv4Address};
|
||||
use smoltcp::{
|
||||
iface::{SocketSet, SocketStorage},
|
||||
time::Instant,
|
||||
wire::HardwareAddress,
|
||||
socket::tcp::Socket as TcpSocket,
|
||||
socket::tcp::SocketBuffer,
|
||||
time::Instant,
|
||||
wire::HardwareAddress,
|
||||
};
|
||||
|
||||
mod command_interface;
|
||||
mod eth;
|
||||
mod i2c;
|
||||
mod mcp4726;
|
||||
mod uart;
|
||||
mod logging;
|
||||
mod mcp4726;
|
||||
mod proto;
|
||||
mod command_interface;
|
||||
mod uart;
|
||||
|
||||
const MAC: [u8; 6] = [0xA0, 0xBB, 0xCC, 0xDD, 0xEE, 0xF0];
|
||||
|
||||
@ -94,16 +93,15 @@ fn main() -> ! {
|
||||
sock.set_timeout(Some(Duration::from_secs(10)))
|
||||
}
|
||||
|
||||
|
||||
let mut logger_tx_storage = [0u8; 128];
|
||||
let mut logger_rx_storage = [0u8; 16];
|
||||
let mut logger_tx_buf = SocketBuffer::new(&mut logger_tx_storage[..]);
|
||||
let mut logger_rx_buf = SocketBuffer::new(&mut logger_rx_storage[..]);
|
||||
let mut logger_socket = socket_set.add(TcpSocket::new(logger_tx_buf, logger_rx_buf));
|
||||
|
||||
unsafe { logging::set_logger_socket(Some(socket_set.get_mut::<TcpSocket>(logger_socket))); }
|
||||
|
||||
|
||||
unsafe {
|
||||
logging::set_logger_socket(Some(socket_set.get_mut::<TcpSocket>(logger_socket)));
|
||||
}
|
||||
|
||||
let mut last_blink: u32 = 0;
|
||||
let mut toggle = false;
|
||||
@ -206,7 +204,6 @@ fn handle_timer_event() {
|
||||
write_reg(0xf000_3818, 1u32);
|
||||
SECONDS += 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn busy_wait(ms: u32) {
|
||||
@ -218,7 +215,9 @@ fn busy_wait(ms: u32) {
|
||||
//}
|
||||
|
||||
for i in 0..ms * 20_000 {
|
||||
unsafe {asm!("nop");}
|
||||
unsafe {
|
||||
asm!("nop");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user