Skip to content

Commit 645254c

Browse files
committed
migration...
1 parent d0a011f commit 645254c

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

src/dma.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub use transfer::{Transfer, TransferExt};
2828

2929
/// Errors.
3030
#[derive(PartialEq, Debug, Copy, Clone)]
31+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
3132
pub enum DMAError {
3233
/// DMA not ready to change buffers.
3334
NotReady,
@@ -39,6 +40,7 @@ pub enum DMAError {
3940

4041
/// Possible DMA's directions.
4142
#[derive(Debug, Clone, Copy, PartialEq)]
43+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
4244
pub enum DmaDirection {
4345
/// Memory to Memory transfer.
4446
MemoryToMemory,
@@ -50,6 +52,7 @@ pub enum DmaDirection {
5052

5153
/// DMA from a peripheral to a memory location.
5254
#[derive(Debug, Clone, Copy)]
55+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
5356
pub struct PeripheralToMemory;
5457

5558
impl PeripheralToMemory {
@@ -73,6 +76,7 @@ impl Direction for PeripheralToMemory {
7376

7477
/// DMA from one memory location to another memory location.
7578
#[derive(Debug, Clone, Copy)]
79+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7680
pub struct MemoryToMemory<T>
7781
where
7882
T: Into<u32>,
@@ -101,6 +105,7 @@ where
101105

102106
/// DMA from a memory location to a peripheral.
103107
#[derive(Debug, Clone, Copy)]
108+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
104109
pub struct MemoryToPeripheral;
105110

106111
impl MemoryToPeripheral {

src/dma/transfer.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ use core::{
1212
use embedded_dma::{StaticReadBuffer, StaticWriteBuffer};
1313

1414
/// Marker type for a transfer with a mutable source and backed by a
15+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
1516
pub struct MutTransfer;
1617
/// Marker type for a transfer with a constant source and backed by a
18+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
1719
pub struct ConstTransfer;
1820

1921
/// DMA Transfer.
22+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
2023
pub struct Transfer<CHANNEL, PERIPHERAL, DIR, BUF, TXFRT>
2124
where
2225
CHANNEL: Channel,

src/gpio.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,43 @@ pub trait GpioExt {
1818
}
1919

2020
/// Input mode (type state)
21+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
2122
pub struct Input<MODE> {
2223
_mode: PhantomData<MODE>,
2324
}
2425

2526
/// Floating input (type state)
27+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
2628
pub struct Floating;
2729

2830
/// Pulled down input (type state)
31+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
2932
pub struct PullDown;
3033

3134
/// Pulled up input (type state)
35+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
3236
pub struct PullUp;
3337

3438
/// Open drain input or output (type state)
39+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
3540
pub struct OpenDrain;
3641

3742
/// Analog mode (type state)
43+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
3844
pub struct Analog;
3945

4046
/// Output mode (type state)
47+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
4148
pub struct Output<MODE> {
4249
_mode: PhantomData<MODE>,
4350
}
4451

4552
/// Push pull output (type state)
53+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
4654
pub struct PushPull;
4755

4856
/// GPIO Pin speed selection
57+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
4958
pub enum Speed {
5059
Low = 0,
5160
Medium = 1,
@@ -54,14 +63,17 @@ pub enum Speed {
5463
}
5564

5665
/// Trigger edgw
66+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
5767
pub enum SignalEdge {
5868
Rising,
5969
Falling,
6070
RisingFalling,
6171
}
6272

6373
/// Altername Mode (type state)
74+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
6475
pub struct Alternate<const A: u8>;
76+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
6577
pub struct AlternateOD<const A: u8>;
6678

6779
pub const AF0: u8 = 0;
@@ -267,6 +279,7 @@ macro_rules! gpio {
267279
}
268280

269281
/// Partially erased pin
282+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
270283
pub struct $PXx<MODE> {
271284
i: u8,
272285
_mode: PhantomData<MODE>,
@@ -338,6 +351,7 @@ macro_rules! gpio {
338351
exti_erased!($PXx<Input<MODE>>, $Pxn);
339352

340353
$(
354+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
341355
pub struct $PXi<MODE> {
342356
_mode: PhantomData<MODE>,
343357
}

src/serial/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ impl FullConfig {
232232
}
233233

234234
#[derive(Debug)]
235+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
235236
pub struct InvalidConfig;
236237

237238
impl Default for LowPowerConfig {

src/serial/usart.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use nb::block;
1616
use crate::serial::config::*;
1717
/// Serial error
1818
#[derive(Debug)]
19+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
1920
pub enum Error {
2021
/// Framing error
2122
Framing,
@@ -28,6 +29,7 @@ pub enum Error {
2829
}
2930

3031
/// Interrupt event
32+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
3133
pub enum Event {
3234
/// TXFIFO reaches the threshold
3335
TXFT = 1 << 27,
@@ -74,20 +76,23 @@ impl Event {
7476
}
7577

7678
/// Serial receiver
79+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7780
pub struct Rx<USART, Pin, Dma> {
7881
pin: Pin,
7982
_usart: PhantomData<USART>,
8083
_dma: PhantomData<Dma>,
8184
}
8285

8386
/// Serial transmitter
87+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
8488
pub struct Tx<USART, Pin, Dma> {
8589
pin: Pin,
8690
usart: USART,
8791
_dma: PhantomData<Dma>,
8892
}
8993

9094
/// Serial abstraction
95+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9196
pub struct Serial<USART, TXPin, RXPin> {
9297
tx: Tx<USART, TXPin, NoDMA>,
9398
rx: Rx<USART, RXPin, NoDMA>,
@@ -99,15 +104,18 @@ pub trait TxPin<USART> {}
99104
/// Serial RX pin
100105
pub trait RxPin<USART> {}
101106

107+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
102108
pub struct NoTx;
103109

104110
impl<USART> TxPin<USART> for NoTx {}
105111

106112
/// Type state for Tx/Rx, indicating operation without DMA
107113
#[derive(Debug)]
114+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
108115
pub struct NoDMA;
109116
/// Type state for Tx/Rx, indicating configuration for DMA
110117
#[derive(Debug)]
118+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
111119
pub struct DMA;
112120

113121
pub trait SerialExt<USART, Config> {

0 commit comments

Comments
 (0)