Skip to content

Commit 8d7208e

Browse files
committed
Update to embedded-hal 1.0.0-alpha.8
1 parent ef2384f commit 8d7208e

File tree

3 files changed

+13
-83
lines changed

3 files changed

+13
-83
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ version = "0.3"
5252
default-features = false
5353

5454
[dependencies.embedded-hal-one]
55-
version = "=1.0.0-alpha.7"
55+
version = "=1.0.0-alpha.8"
5656
package = "embedded-hal"
5757

5858
[dependencies.stm32_i2s_v12x]

src/adc.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ macro_rules! adc_pins {
3434
type ID = u8;
3535
fn channel() -> u8 { $chan }
3636
}
37-
38-
impl embedded_hal_one::adc::nb::Channel<pac::$adc> for $pin {
39-
type ID = u8;
40-
fn channel(&self) -> u8 { $chan }
41-
}
4237
)+
4338
};
4439
}
@@ -1075,17 +1070,6 @@ macro_rules! adc {
10751070
}
10761071
}
10771072

1078-
impl<PIN> embedded_hal_one::adc::nb::OneShot<pac::$adc_type, u16, PIN> for Adc<pac::$adc_type>
1079-
where
1080-
PIN: embedded_hal::adc::Channel<pac::$adc_type, ID=u8> + embedded_hal_one::adc::nb::Channel<pac::$adc_type, ID=u8>,
1081-
{
1082-
type Error = ();
1083-
1084-
fn read(&mut self, pin: &mut PIN) -> nb::Result<u16, Self::Error> {
1085-
self.read::<PIN>(pin)
1086-
}
1087-
}
1088-
10891073
unsafe impl PeriAddress for Adc<pac::$adc_type> {
10901074
#[inline(always)]
10911075
fn address(&self) -> u32 {

src/spi/hal_1.rs

Lines changed: 12 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -77,31 +77,24 @@ mod nb {
7777
mod blocking {
7878
use super::super::{Error, Instance, Spi, TransferModeBidi, TransferModeNormal};
7979
use embedded_hal_one::spi::{
80-
blocking::{Operation, Read, Transactional, Transfer, TransferInplace, Write, WriteIter},
80+
blocking::{SpiBus, SpiBusRead, SpiBusWrite, SpiBusFlush},
8181
nb::FullDuplex,
8282
};
8383

84-
impl<SPI, PINS, TRANSFER_MODE, W: Copy + 'static> TransferInplace<W>
85-
for Spi<SPI, PINS, TRANSFER_MODE>
84+
impl<SPI, PINS, TRANSFER_MODE, W: Copy + Default + 'static> SpiBus<W> for Spi<SPI, PINS, TRANSFER_MODE>
8685
where
87-
Self: FullDuplex<W, Error = Error>,
86+
Self: FullDuplex<W, Error = Error> + SpiBusWrite<W>,
8887
SPI: Instance,
8988
{
90-
fn transfer_inplace(&mut self, words: &mut [W]) -> Result<(), Self::Error> {
89+
fn transfer_in_place(&mut self, words: &mut [W]) -> Result<(), Self::Error> {
9190
for word in words.iter_mut() {
9291
nb::block!(<Self as FullDuplex<W>>::write(self, *word))?;
9392
*word = nb::block!(<Self as FullDuplex<W>>::read(self))?;
9493
}
9594

9695
Ok(())
9796
}
98-
}
9997

100-
impl<SPI, PINS, TRANSFER_MODE, W: Copy + 'static> Transfer<W> for Spi<SPI, PINS, TRANSFER_MODE>
101-
where
102-
Self: FullDuplex<W, Error = Error>,
103-
SPI: Instance,
104-
{
10598
fn transfer(&mut self, buff: &mut [W], data: &[W]) -> Result<(), Self::Error> {
10699
assert_eq!(data.len(), buff.len());
107100

@@ -114,71 +107,45 @@ mod blocking {
114107
}
115108
}
116109

117-
impl<SPI, PINS, W: Copy + 'static> Write<W> for Spi<SPI, PINS, TransferModeNormal>
110+
impl<SPI, PINS, TRANSFER_MODE> SpiBusFlush for Spi<SPI, PINS, TRANSFER_MODE>
118111
where
119-
Self: FullDuplex<W, Error = Error>,
120112
SPI: Instance,
121113
{
122-
fn write(&mut self, words: &[W]) -> Result<(), Self::Error> {
123-
for word in words {
124-
nb::block!(<Self as FullDuplex<W>>::write(self, *word))?;
125-
nb::block!(<Self as FullDuplex<W>>::read(self))?;
126-
}
127-
114+
fn flush(&mut self) -> Result<(), Self::Error> {
128115
Ok(())
129116
}
130117
}
131118

132-
impl<SPI, PINS, W: Copy + 'static> Write<W> for Spi<SPI, PINS, TransferModeBidi>
119+
impl<SPI, PINS, W: Copy + 'static> SpiBusWrite<W> for Spi<SPI, PINS, TransferModeNormal>
133120
where
134121
Self: FullDuplex<W, Error = Error>,
135122
SPI: Instance,
136123
{
137124
fn write(&mut self, words: &[W]) -> Result<(), Self::Error> {
138125
for word in words {
139126
nb::block!(<Self as FullDuplex<W>>::write(self, *word))?;
140-
}
141-
142-
Ok(())
143-
}
144-
}
145-
146-
impl<SPI, PINS, W: Copy + 'static> WriteIter<W> for Spi<SPI, PINS, TransferModeNormal>
147-
where
148-
Self: FullDuplex<W, Error = Error>,
149-
SPI: Instance,
150-
{
151-
fn write_iter<WI>(&mut self, words: WI) -> Result<(), Self::Error>
152-
where
153-
WI: IntoIterator<Item = W>,
154-
{
155-
for word in words.into_iter() {
156-
nb::block!(<Self as FullDuplex<W>>::write(self, word))?;
157127
nb::block!(<Self as FullDuplex<W>>::read(self))?;
158128
}
159129

160130
Ok(())
161131
}
162132
}
163133

164-
impl<SPI, PINS, W: Copy + 'static> WriteIter<W> for Spi<SPI, PINS, TransferModeBidi>
134+
impl<SPI, PINS, W: Copy + 'static> SpiBusWrite<W> for Spi<SPI, PINS, TransferModeBidi>
165135
where
166136
Self: FullDuplex<W, Error = Error>,
167137
SPI: Instance,
168138
{
169-
fn write_iter<WI>(&mut self, words: WI) -> Result<(), Self::Error>
170-
where
171-
WI: IntoIterator<Item = W>,
172-
{
173-
for word in words.into_iter() {
174-
nb::block!(<Self as FullDuplex<W>>::write(self, word))?;
139+
fn write(&mut self, words: &[W]) -> Result<(), Self::Error> {
140+
for word in words {
141+
nb::block!(<Self as FullDuplex<W>>::write(self, *word))?;
175142
}
176143

177144
Ok(())
178145
}
179146
}
180147

181-
impl<SPI, PINS, TRANSFER_MODE, W: Copy + Default + 'static> Read<W>
148+
impl<SPI, PINS, TRANSFER_MODE, W: Copy + Default + 'static> SpiBusRead<W>
182149
for Spi<SPI, PINS, TRANSFER_MODE>
183150
where
184151
Self: FullDuplex<W, Error = Error>,
@@ -193,25 +160,4 @@ mod blocking {
193160
Ok(())
194161
}
195162
}
196-
197-
impl<SPI, PINS, TRANSFER_MODE, W: Copy + 'static> Transactional<W> for Spi<SPI, PINS, TRANSFER_MODE>
198-
where
199-
Self: Write<W, Error = Error>
200-
+ Read<W, Error = Error>
201-
+ TransferInplace<W, Error = Error>
202-
+ Transfer<W, Error = Error>,
203-
{
204-
fn exec<'a>(&mut self, operations: &mut [Operation<'a, W>]) -> Result<(), Error> {
205-
for op in operations {
206-
match op {
207-
Operation::Write(w) => self.write(w)?,
208-
Operation::TransferInplace(t) => self.transfer_inplace(t)?,
209-
Operation::Read(r) => self.read(r)?,
210-
Operation::Transfer(w, r) => self.transfer(w, r)?,
211-
}
212-
}
213-
214-
Ok(())
215-
}
216-
}
217163
}

0 commit comments

Comments
 (0)