Skip to content

Commit 6cd069b

Browse files
Merge #510
510: Update to embedded-hal 1.0.0-alpha.8 r=burrbull a=quentinmit Co-authored-by: Quentin Smith <quentin@mit.edu>
2 parents ef2384f + bec11bd commit 6cd069b

File tree

4 files changed

+14
-82
lines changed

4 files changed

+14
-82
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2121
- `i2s-audio-out` example updated and now use pcm5102 dac module instead one from discovery board.
2222
- extend visibility of gpio/marker to crate since i2s module require it.
2323
- Bump `synopsys-usb-otg` to `0.3.0`
24+
- Bump `embedded-hal` to `1.0.0-alpha.8`
2425

2526
### Added
2627
- example of using i2s in out with rtic and interrupt.

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 & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -77,31 +77,25 @@ 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, SpiBusFlush, SpiBusRead, SpiBusWrite},
8181
nb::FullDuplex,
8282
};
8383

84-
impl<SPI, PINS, TRANSFER_MODE, W: Copy + 'static> TransferInplace<W>
84+
impl<SPI, PINS, TRANSFER_MODE, W: Copy + Default + 'static> SpiBus<W>
8585
for Spi<SPI, PINS, TRANSFER_MODE>
8686
where
87-
Self: FullDuplex<W, Error = Error>,
87+
Self: FullDuplex<W, Error = Error> + SpiBusWrite<W>,
8888
SPI: Instance,
8989
{
90-
fn transfer_inplace(&mut self, words: &mut [W]) -> Result<(), Self::Error> {
90+
fn transfer_in_place(&mut self, words: &mut [W]) -> Result<(), Self::Error> {
9191
for word in words.iter_mut() {
9292
nb::block!(<Self as FullDuplex<W>>::write(self, *word))?;
9393
*word = nb::block!(<Self as FullDuplex<W>>::read(self))?;
9494
}
9595

9696
Ok(())
9797
}
98-
}
9998

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-
{
10599
fn transfer(&mut self, buff: &mut [W], data: &[W]) -> Result<(), Self::Error> {
106100
assert_eq!(data.len(), buff.len());
107101

@@ -114,71 +108,45 @@ mod blocking {
114108
}
115109
}
116110

117-
impl<SPI, PINS, W: Copy + 'static> Write<W> for Spi<SPI, PINS, TransferModeNormal>
111+
impl<SPI, PINS, TRANSFER_MODE> SpiBusFlush for Spi<SPI, PINS, TRANSFER_MODE>
118112
where
119-
Self: FullDuplex<W, Error = Error>,
120113
SPI: Instance,
121114
{
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-
115+
fn flush(&mut self) -> Result<(), Self::Error> {
128116
Ok(())
129117
}
130118
}
131119

132-
impl<SPI, PINS, W: Copy + 'static> Write<W> for Spi<SPI, PINS, TransferModeBidi>
120+
impl<SPI, PINS, W: Copy + 'static> SpiBusWrite<W> for Spi<SPI, PINS, TransferModeNormal>
133121
where
134122
Self: FullDuplex<W, Error = Error>,
135123
SPI: Instance,
136124
{
137125
fn write(&mut self, words: &[W]) -> Result<(), Self::Error> {
138126
for word in words {
139127
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))?;
157128
nb::block!(<Self as FullDuplex<W>>::read(self))?;
158129
}
159130

160131
Ok(())
161132
}
162133
}
163134

164-
impl<SPI, PINS, W: Copy + 'static> WriteIter<W> for Spi<SPI, PINS, TransferModeBidi>
135+
impl<SPI, PINS, W: Copy + 'static> SpiBusWrite<W> for Spi<SPI, PINS, TransferModeBidi>
165136
where
166137
Self: FullDuplex<W, Error = Error>,
167138
SPI: Instance,
168139
{
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))?;
140+
fn write(&mut self, words: &[W]) -> Result<(), Self::Error> {
141+
for word in words {
142+
nb::block!(<Self as FullDuplex<W>>::write(self, *word))?;
175143
}
176144

177145
Ok(())
178146
}
179147
}
180148

181-
impl<SPI, PINS, TRANSFER_MODE, W: Copy + Default + 'static> Read<W>
149+
impl<SPI, PINS, TRANSFER_MODE, W: Copy + Default + 'static> SpiBusRead<W>
182150
for Spi<SPI, PINS, TRANSFER_MODE>
183151
where
184152
Self: FullDuplex<W, Error = Error>,
@@ -193,25 +161,4 @@ mod blocking {
193161
Ok(())
194162
}
195163
}
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-
}
217164
}

0 commit comments

Comments
 (0)