Compare commits

..

60 Commits

Author SHA1 Message Date
da5d577215 boot: update ed25519-dalek in dev-dependencies. 2023-12-19 22:56:25 +01:00
7591a6abc5 cargo fmt 2023-12-19 22:56:25 +01:00
a5ce77cfb2 fix: update ed25519-dalek to new version 2023-12-19 22:56:25 +01:00
1211db46d5 fix: build warnings 2023-12-19 22:56:25 +01:00
6caf261a62 fix: update salty to released version 2023-12-19 22:56:25 +01:00
351eb33148 stm32: doc everything else. 2023-12-19 22:56:25 +01:00
322606b5b9 stm32/timer: docs. 2023-12-19 22:56:25 +01:00
b1c7c3f728 docs: document usb-logger and usb-dfu 2023-12-19 22:56:25 +01:00
7c8eebe287 Reset .vscode/settings.json (doh) 2023-12-19 22:56:25 +01:00
5d696f6d0d Documented usart public API 2023-12-19 22:56:25 +01:00
f058698c25 stm32: document hrtim, qspi, sdmmc, spi. 2023-12-19 22:56:25 +01:00
2c2783d795 update metapac dep 2023-12-19 22:56:25 +01:00
81f7569a52 match up with metapac change 2023-12-19 22:56:25 +01:00
1df1f8e742 docs: document public apis for cyw43 driver 2023-12-19 22:56:25 +01:00
e65d6fa698 docs: document all embassy-rp public apis
Enable missing doc warnings.
2023-12-19 22:56:25 +01:00
a7429a7f46 docs: document spi, rtc and rest of uart for embassy-rp 2023-12-19 22:56:25 +01:00
5151bac60c docs: embassy-rp rustdoc and refactoring 2023-12-19 22:56:25 +01:00
f993344b19 stm32: i2c: Clean up conditional code a bit
By moving conditional code inside the functions, we can
reduce duplication and in one case we can even eliminate one...
2023-12-19 22:56:25 +01:00
565ed78f91 stm32/sai: fix typo. 2023-12-19 22:56:25 +01:00
d3f3c425a2 stm32: more docs. 2023-12-19 22:56:25 +01:00
f4fb0a2467 stm32/sai: docs, remove unused enums. 2023-12-19 22:56:25 +01:00
3ee90e8d30 stm32/sai: remove unused Word trait. 2023-12-19 22:56:25 +01:00
8da11edca5 stm32/sai: deduplicate code for subblocks A/B. 2023-12-19 22:56:25 +01:00
49ba2036d6 stm32/sai: remove unimplemented SetConfig. 2023-12-19 22:56:25 +01:00
fd48b8fa84 Fix nb on rp uart 2023-12-19 22:56:25 +01:00
7f5526a9b1 stm32: more docs. 2023-12-19 22:56:25 +01:00
b06e4a6ab4 stm32/can: docs. 2023-12-19 22:56:25 +01:00
d709aa231b stm32/can: cleanup interrupt traits. 2023-12-19 22:56:25 +01:00
91e107ea07 stm32/i2c: remove _timeout public API, share more code between v1/v2. 2023-12-19 22:56:25 +01:00
42f5c8109b feat: support multiwrite flash traits if configured 2023-12-19 22:56:25 +01:00
0c2274a0e3 stm32: add some docs. 2023-12-19 22:56:25 +01:00
44cc1954a9 STM32: Fix race in alarm setting, which impacted scheduling.
Detect potential race condition (should be rare) and return false back
to caller, allowing them to handle the possibility that either the
alarm was never set because it was in the past (old meaning of false),
or that in fact the alarm was set and may have fired within the race
window (new meaning of false). In either case, the caller needs to
make sure the callback got called.
2023-12-19 22:56:25 +01:00
c4d9feb36e remove suspendable field from embassy_usb::builder::Config 2023-12-19 22:56:25 +01:00
6181646314 Update usb.rs
- add check of `dev_resume_from_host` interrupt register to catch wake event
2023-12-19 22:56:25 +01:00
fa6039c92b add susependable field to embassy_usb::builder::Config
- allow for optional override of `Suspend` event for a UsbDevice
2023-12-19 22:56:25 +01:00
0f98fcdb19 STM32: Enable flash support for STM32G4 2023-12-19 22:56:25 +01:00
992a9565a8 STM32 QSPI: Fix flash selection. 2023-12-19 22:56:25 +01:00
287f57b704 unify channel assign 2023-12-19 22:56:25 +01:00
bee0edb3f8 cargo fmt 2023-12-19 22:56:25 +01:00
d928228237 add ws2812 example for stm32f4 with PWM and DMA 2023-12-19 22:56:25 +01:00
abbc2d73c3 STM32H7: adjust flash latency and programming delay for series in RM0468 2023-12-19 22:56:25 +01:00
ac28d39b95 STM32H7: limit max frequency to 520MHz until cpu frequency boost option is implemented 2023-12-19 22:56:25 +01:00
51a70307f0 STM32H7: adjust frequency limits for series in RM0468 2023-12-19 22:56:25 +01:00
2cc9fea6d3 STM32H7: Allow PLL1 DIVP of 1 for certain series 2023-12-19 22:56:25 +01:00
958b3c6de1 use released embedded-hal-mock. 2023-12-19 22:56:25 +01:00
11157ddd15 Rename bootloader feature to dfu 2023-12-19 22:56:25 +01:00
1c56523341 Abstract chip reset logic, add Reset impls for cortex-m and esp32c3 2023-12-19 22:56:25 +01:00
39ac7e574f Adjust stm32wb-dfu example memory maps to fix linker errors 2023-12-19 22:56:25 +01:00
7a5d090810 Adjust toml files, fix application example 2023-12-19 22:56:25 +01:00
ccf4d854f8 Add examples to ci.sh 2023-12-19 22:56:25 +01:00
beb587ca22 SCB::sys_reset has a DSB internally, no need to replicate 2023-12-19 22:56:25 +01:00
b3e74ebc34 fmt 2023-12-19 22:56:25 +01:00
29114c849d fmt 2023-12-19 22:56:25 +01:00
4757257ac0 Address reviews 2023-12-19 22:56:25 +01:00
686ee2cb14 Last fmt hopefully 2023-12-19 22:56:25 +01:00
ea21052fde Formatting fixes, add example using stm32wb55 2023-12-19 22:56:25 +01:00
6513d03fdf fmt 2023-12-19 22:56:25 +01:00
0b26b2d360 Add embassy-usb-dfu 2023-12-19 22:56:25 +01:00
08203d4c04 ci: fix test job not caching anything. 2023-12-19 22:56:25 +01:00
9d8dbd67fe Update embedded-hal to 1.0.0-rc.3 2023-12-19 22:56:25 +01:00
2 changed files with 3 additions and 59 deletions

View File

@ -1,6 +1,5 @@
#![no_std]
#![doc = include_str!("../README.md")]
#![warn(missing_docs)]
// must go first!
mod fmt;
@ -16,9 +15,6 @@ use embassy_sync::blocking_mutex::Mutex;
use embassy_sync::waitqueue::WakerRegistration;
use embassy_sync::zerocopy_channel;
/// Channel state.
///
/// Holds a buffer of packets with size MTU, for both TX and RX.
pub struct State<const MTU: usize, const N_RX: usize, const N_TX: usize> {
rx: [PacketBuf<MTU>; N_RX],
tx: [PacketBuf<MTU>; N_TX],
@ -28,7 +24,6 @@ pub struct State<const MTU: usize, const N_RX: usize, const N_TX: usize> {
impl<const MTU: usize, const N_RX: usize, const N_TX: usize> State<MTU, N_RX, N_TX> {
const NEW_PACKET: PacketBuf<MTU> = PacketBuf::new();
/// Create a new channel state.
pub const fn new() -> Self {
Self {
rx: [Self::NEW_PACKET; N_RX],
@ -44,45 +39,33 @@ struct StateInner<'d, const MTU: usize> {
shared: Mutex<NoopRawMutex, RefCell<Shared>>,
}
/// State of the LinkState
struct Shared {
link_state: LinkState,
waker: WakerRegistration,
hardware_address: driver::HardwareAddress,
}
/// Channel runner.
///
/// Holds the shared state and the lower end of channels for inbound and outbound packets.
pub struct Runner<'d, const MTU: usize> {
tx_chan: zerocopy_channel::Receiver<'d, NoopRawMutex, PacketBuf<MTU>>,
rx_chan: zerocopy_channel::Sender<'d, NoopRawMutex, PacketBuf<MTU>>,
shared: &'d Mutex<NoopRawMutex, RefCell<Shared>>,
}
/// State runner.
///
/// Holds the shared state of the channel such as link state.
#[derive(Clone, Copy)]
pub struct StateRunner<'d> {
shared: &'d Mutex<NoopRawMutex, RefCell<Shared>>,
}
/// RX runner.
///
/// Holds the lower end of the channel for passing inbound packets up the stack.
pub struct RxRunner<'d, const MTU: usize> {
rx_chan: zerocopy_channel::Sender<'d, NoopRawMutex, PacketBuf<MTU>>,
}
/// TX runner.
///
/// Holds the lower end of the channel for passing outbound packets down the stack.
pub struct TxRunner<'d, const MTU: usize> {
tx_chan: zerocopy_channel::Receiver<'d, NoopRawMutex, PacketBuf<MTU>>,
}
impl<'d, const MTU: usize> Runner<'d, MTU> {
/// Split the runner into separate runners for controlling state, rx and tx.
pub fn split(self) -> (StateRunner<'d>, RxRunner<'d, MTU>, TxRunner<'d, MTU>) {
(
StateRunner { shared: self.shared },
@ -91,7 +74,6 @@ impl<'d, const MTU: usize> Runner<'d, MTU> {
)
}
/// Split the runner into separate runners for controlling state, rx and tx borrowing the underlying state.
pub fn borrow_split(&mut self) -> (StateRunner<'_>, RxRunner<'_, MTU>, TxRunner<'_, MTU>) {
(
StateRunner { shared: self.shared },
@ -104,12 +86,10 @@ impl<'d, const MTU: usize> Runner<'d, MTU> {
)
}
/// Create a state runner sharing the state channel.
pub fn state_runner(&self) -> StateRunner<'d> {
StateRunner { shared: self.shared }
}
/// Set the link state.
pub fn set_link_state(&mut self, state: LinkState) {
self.shared.lock(|s| {
let s = &mut *s.borrow_mut();
@ -118,7 +98,6 @@ impl<'d, const MTU: usize> Runner<'d, MTU> {
});
}
/// Set the hardware address.
pub fn set_hardware_address(&mut self, address: driver::HardwareAddress) {
self.shared.lock(|s| {
let s = &mut *s.borrow_mut();
@ -127,19 +106,16 @@ impl<'d, const MTU: usize> Runner<'d, MTU> {
});
}
/// Wait until there is space for more inbound packets and return a slice they can be copied into.
pub async fn rx_buf(&mut self) -> &mut [u8] {
let p = self.rx_chan.send().await;
&mut p.buf
}
/// Check if there is space for more inbound packets right now.
pub fn try_rx_buf(&mut self) -> Option<&mut [u8]> {
let p = self.rx_chan.try_send()?;
Some(&mut p.buf)
}
/// Polling the inbound channel if there is space for packets.
pub fn poll_rx_buf(&mut self, cx: &mut Context) -> Poll<&mut [u8]> {
match self.rx_chan.poll_send(cx) {
Poll::Ready(p) => Poll::Ready(&mut p.buf),
@ -147,26 +123,22 @@ impl<'d, const MTU: usize> Runner<'d, MTU> {
}
}
/// Mark packet of len bytes as pushed to the inbound channel.
pub fn rx_done(&mut self, len: usize) {
let p = self.rx_chan.try_send().unwrap();
p.len = len;
self.rx_chan.send_done();
}
/// Wait until there is space for more outbound packets and return a slice they can be copied into.
pub async fn tx_buf(&mut self) -> &mut [u8] {
let p = self.tx_chan.receive().await;
&mut p.buf[..p.len]
}
/// Check if there is space for more outbound packets right now.
pub fn try_tx_buf(&mut self) -> Option<&mut [u8]> {
let p = self.tx_chan.try_receive()?;
Some(&mut p.buf[..p.len])
}
/// Polling the outbound channel if there is space for packets.
pub fn poll_tx_buf(&mut self, cx: &mut Context) -> Poll<&mut [u8]> {
match self.tx_chan.poll_receive(cx) {
Poll::Ready(p) => Poll::Ready(&mut p.buf[..p.len]),
@ -174,14 +146,12 @@ impl<'d, const MTU: usize> Runner<'d, MTU> {
}
}
/// Mark outbound packet as copied.
pub fn tx_done(&mut self) {
self.tx_chan.receive_done();
}
}
impl<'d> StateRunner<'d> {
/// Set link state.
pub fn set_link_state(&self, state: LinkState) {
self.shared.lock(|s| {
let s = &mut *s.borrow_mut();
@ -190,7 +160,6 @@ impl<'d> StateRunner<'d> {
});
}
/// Set the hardware address.
pub fn set_hardware_address(&self, address: driver::HardwareAddress) {
self.shared.lock(|s| {
let s = &mut *s.borrow_mut();
@ -201,19 +170,16 @@ impl<'d> StateRunner<'d> {
}
impl<'d, const MTU: usize> RxRunner<'d, MTU> {
/// Wait until there is space for more inbound packets and return a slice they can be copied into.
pub async fn rx_buf(&mut self) -> &mut [u8] {
let p = self.rx_chan.send().await;
&mut p.buf
}
/// Check if there is space for more inbound packets right now.
pub fn try_rx_buf(&mut self) -> Option<&mut [u8]> {
let p = self.rx_chan.try_send()?;
Some(&mut p.buf)
}
/// Polling the inbound channel if there is space for packets.
pub fn poll_rx_buf(&mut self, cx: &mut Context) -> Poll<&mut [u8]> {
match self.rx_chan.poll_send(cx) {
Poll::Ready(p) => Poll::Ready(&mut p.buf),
@ -221,7 +187,6 @@ impl<'d, const MTU: usize> RxRunner<'d, MTU> {
}
}
/// Mark packet of len bytes as pushed to the inbound channel.
pub fn rx_done(&mut self, len: usize) {
let p = self.rx_chan.try_send().unwrap();
p.len = len;
@ -230,19 +195,16 @@ impl<'d, const MTU: usize> RxRunner<'d, MTU> {
}
impl<'d, const MTU: usize> TxRunner<'d, MTU> {
/// Wait until there is space for more outbound packets and return a slice they can be copied into.
pub async fn tx_buf(&mut self) -> &mut [u8] {
let p = self.tx_chan.receive().await;
&mut p.buf[..p.len]
}
/// Check if there is space for more outbound packets right now.
pub fn try_tx_buf(&mut self) -> Option<&mut [u8]> {
let p = self.tx_chan.try_receive()?;
Some(&mut p.buf[..p.len])
}
/// Polling the outbound channel if there is space for packets.
pub fn poll_tx_buf(&mut self, cx: &mut Context) -> Poll<&mut [u8]> {
match self.tx_chan.poll_receive(cx) {
Poll::Ready(p) => Poll::Ready(&mut p.buf[..p.len]),
@ -250,18 +212,11 @@ impl<'d, const MTU: usize> TxRunner<'d, MTU> {
}
}
/// Mark outbound packet as copied.
pub fn tx_done(&mut self) {
self.tx_chan.receive_done();
}
}
/// Create a channel.
///
/// Returns a pair of handles for interfacing with the peripheral and the networking stack.
///
/// The runner is interfacing with the peripheral at the lower part of the stack.
/// The device is interfacing with the networking stack on the layer above.
pub fn new<'d, const MTU: usize, const N_RX: usize, const N_TX: usize>(
state: &'d mut State<MTU, N_RX, N_TX>,
hardware_address: driver::HardwareAddress,
@ -302,22 +257,17 @@ pub fn new<'d, const MTU: usize, const N_RX: usize, const N_TX: usize>(
)
}
/// Represents a packet of size MTU.
pub struct PacketBuf<const MTU: usize> {
len: usize,
buf: [u8; MTU],
}
impl<const MTU: usize> PacketBuf<MTU> {
/// Create a new packet buffer.
pub const fn new() -> Self {
Self { len: 0, buf: [0; MTU] }
}
}
/// Channel device.
///
/// Holds the shared state and upper end of channels for inbound and outbound packets.
pub struct Device<'d, const MTU: usize> {
rx: zerocopy_channel::Receiver<'d, NoopRawMutex, PacketBuf<MTU>>,
tx: zerocopy_channel::Sender<'d, NoopRawMutex, PacketBuf<MTU>>,
@ -364,9 +314,6 @@ impl<'d, const MTU: usize> embassy_net_driver::Driver for Device<'d, MTU> {
}
}
/// A rx token.
///
/// Holds inbound receive channel and interfaces with embassy-net-driver.
pub struct RxToken<'a, const MTU: usize> {
rx: zerocopy_channel::Receiver<'a, NoopRawMutex, PacketBuf<MTU>>,
}
@ -384,9 +331,6 @@ impl<'a, const MTU: usize> embassy_net_driver::RxToken for RxToken<'a, MTU> {
}
}
/// A tx token.
///
/// Holds outbound transmit channel and interfaces with embassy-net-driver.
pub struct TxToken<'a, const MTU: usize> {
tx: zerocopy_channel::Sender<'a, NoopRawMutex, PacketBuf<MTU>>,
}

View File

@ -130,7 +130,7 @@ impl RtcTimeProvider {
let weekday = day_of_week_from_u8(dr.wdu()).map_err(RtcError::InvalidDateTime)?;
let day = bcd2_to_byte((dr.dt(), dr.du()));
let month = bcd2_to_byte((dr.mt() as u8, dr.mu()));
let year = bcd2_to_byte((dr.yt(), dr.yu())) as u16 + 2000_u16;
let year = bcd2_to_byte((dr.yt(), dr.yu())) as u16 + 1970_u16;
DateTime::from(year, month, day, weekday, hour, minute, second).map_err(RtcError::InvalidDateTime)
})
@ -261,7 +261,7 @@ impl Rtc {
let (dt, du) = byte_to_bcd2(t.day() as u8);
let (mt, mu) = byte_to_bcd2(t.month() as u8);
let yr = t.year() as u16;
let yr_offset = (yr - 2000_u16) as u8;
let yr_offset = (yr - 1970_u16) as u8;
let (yt, yu) = byte_to_bcd2(yr_offset);
use crate::pac::rtc::vals::Ampm;