Skip to content

Commit 2523d1a

Browse files
committed
embedded-hal: 1.0.0-alpha.10 -> 1.0.0-alpha.11
1 parent 6cb008a commit 2523d1a

File tree

5 files changed

+33
-109
lines changed

5 files changed

+33
-109
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.16.0] - 2023-06-05
8+
### Changed
9+
- Updated the alpha release of `embedded-hal` from `1.0.0-alpha.10` to `1.0.0-alpha.11`.
10+
711
## [0.15.1] - 2023-05-13
812
### Fixed
913
- Changed the `Error` and `ErrorKind` types from private to public.
@@ -139,7 +143,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
139143
## [0.1.0] - 2020-09-12
140144
- Initial release
141145

142-
[Unreleased]: https://github.com/ftdi-rs/ftdi-embedded-hal/compare/v0.15.1...HEAD
146+
[Unreleased]: https://github.com/ftdi-rs/ftdi-embedded-hal/compare/v0.16.0...HEAD
147+
[0.16.0]: https://github.com/ftdi-rs/ftdi-embedded-hal/compare/v0.15.1...v0.16.0
143148
[0.15.1]: https://github.com/ftdi-rs/ftdi-embedded-hal/compare/v0.15.0...v0.15.1
144149
[0.15.0]: https://github.com/ftdi-rs/ftdi-embedded-hal/compare/v0.14.0...v0.15.0
145150
[0.14.0]: https://github.com/ftdi-rs/ftdi-embedded-hal/compare/v0.13.0...v0.14.0

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ftdi-embedded-hal"
3-
version = "0.15.1"
3+
version = "0.16.0"
44
authors = ["Alex Martens <alex@thinglab.org>"]
55
description = "embedded-hal implementation for FTDI USB devices."
66
keywords = ["ftdi", "usb", "io", "hal"]
@@ -17,8 +17,8 @@ default = []
1717

1818
[dependencies]
1919
eh0 = { package = "embedded-hal", version = "0.2.7", features = ["unproven"] }
20-
eh1 = { package = "embedded-hal", version = "=1.0.0-alpha.10" }
21-
ehnb1 = { package = "embedded-hal-nb", version = "=1.0.0-alpha.2" }
20+
eh1 = { package = "embedded-hal", version = "=1.0.0-alpha.11" }
21+
ehnb1 = { package = "embedded-hal-nb", version = "=1.0.0-alpha.3" }
2222
ftdi = { version = "0.1.3", optional = true }
2323
ftdi-mpsse = "0.1"
2424
libftd2xx = { version = "0.32", optional = true }

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ FTDI device into the [embedded-hal] traits.
2525

2626
```toml
2727
[dependencies.ftdi-embedded-hal]
28-
version = "0.15.1"
28+
version = "0.16.0"
2929
features = ["libftd2xx", "libftd2xx-static"]
3030
```
3131

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//!
1919
//! ```toml
2020
//! [dependencies.ftdi-embedded-hal]
21-
//! version = "0.15.1"
21+
//! version = "0.16.0"
2222
//! features = ["libftd2xx", "libftd2xx-static"]
2323
//! ```
2424
//!

src/spi.rs

Lines changed: 22 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -223,61 +223,40 @@ where
223223
type Error = Error<E>;
224224
}
225225

226-
impl<Device, E> eh1::spi::SpiBusFlush for Spi<Device>
227-
where
228-
Device: MpsseCmdExecutor<Error = E>,
229-
E: std::error::Error,
230-
Error<E>: From<E>,
231-
{
232-
fn flush(&mut self) -> Result<(), Self::Error> {
233-
Ok(())
234-
}
235-
}
236-
237-
impl<Device, E> eh1::spi::SpiBusWrite<u8> for Spi<Device>
226+
impl<Device, E> eh1::spi::SpiBus<u8> for Spi<Device>
238227
where
239228
Device: MpsseCmdExecutor<Error = E>,
240229
E: std::error::Error,
241230
Error<E>: From<E>,
242231
{
243-
fn write(&mut self, words: &[u8]) -> Result<(), Error<E>> {
232+
fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> {
233+
let data_out: Vec<u8> = vec![0; words.len()];
244234
let cmd: MpsseCmdBuilder = MpsseCmdBuilder::new()
245-
.clock_data_out(self.pol.clk_out, words)
235+
.clock_data(self.pol.clk, &data_out)
246236
.send_immediate();
247237

248238
let mut lock = self.mtx.lock().expect("Failed to aquire FTDI mutex");
249239
lock.ft.send(cmd.as_slice())?;
240+
lock.ft.recv(words)?;
250241

251242
Ok(())
252243
}
253-
}
254244

255-
impl<Device, E> eh1::spi::SpiBusRead<u8> for Spi<Device>
256-
where
257-
Device: MpsseCmdExecutor<Error = E>,
258-
E: std::error::Error,
259-
Error<E>: From<E>,
260-
{
261-
fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> {
262-
let data_out: Vec<u8> = vec![0; words.len()];
245+
fn write(&mut self, words: &[u8]) -> Result<(), Error<E>> {
263246
let cmd: MpsseCmdBuilder = MpsseCmdBuilder::new()
264-
.clock_data(self.pol.clk, &data_out)
247+
.clock_data_out(self.pol.clk_out, words)
265248
.send_immediate();
266249

267250
let mut lock = self.mtx.lock().expect("Failed to aquire FTDI mutex");
268251
lock.ft.send(cmd.as_slice())?;
269-
lock.ft.recv(words)?;
270252

271253
Ok(())
272254
}
273-
}
274255

275-
impl<Device, E> eh1::spi::SpiBus<u8> for Spi<Device>
276-
where
277-
Device: MpsseCmdExecutor<Error = E>,
278-
E: std::error::Error,
279-
Error<E>: From<E>,
280-
{
256+
fn flush(&mut self) -> Result<(), Self::Error> {
257+
Ok(())
258+
}
259+
281260
fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Error<E>> {
282261
let cmd: MpsseCmdBuilder = MpsseCmdBuilder::new()
283262
.clock_data(self.pol.clk, words)
@@ -350,18 +329,7 @@ where
350329
type Error = Error<E>;
351330
}
352331

353-
impl<'a, Device, E> eh1::spi::SpiBusFlush for SpiDeviceBus<'a, Device>
354-
where
355-
Device: MpsseCmdExecutor<Error = E>,
356-
E: std::error::Error,
357-
Error<E>: From<E>,
358-
{
359-
fn flush(&mut self) -> Result<(), Self::Error> {
360-
Ok(())
361-
}
362-
}
363-
364-
impl<'a, Device, E> eh1::spi::SpiBusRead<u8> for SpiDeviceBus<'a, Device>
332+
impl<'a, Device, E> eh1::spi::SpiBus<u8> for SpiDeviceBus<'a, Device>
365333
where
366334
Device: MpsseCmdExecutor<Error = E>,
367335
E: std::error::Error,
@@ -377,14 +345,7 @@ where
377345
)?;
378346
Ok(())
379347
}
380-
}
381348

382-
impl<'a, Device, E> eh1::spi::SpiBusWrite<u8> for SpiDeviceBus<'a, Device>
383-
where
384-
Device: MpsseCmdExecutor<Error = E>,
385-
E: std::error::Error,
386-
Error<E>: From<E>,
387-
{
388349
fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> {
389350
self.lock.ft.send(
390351
MpsseCmdBuilder::new()
@@ -394,14 +355,11 @@ where
394355
)?;
395356
Ok(())
396357
}
397-
}
398358

399-
impl<'a, Device, E> eh1::spi::SpiBus<u8> for SpiDeviceBus<'a, Device>
400-
where
401-
Device: MpsseCmdExecutor<Error = E>,
402-
E: std::error::Error,
403-
Error<E>: From<E>,
404-
{
359+
fn flush(&mut self) -> Result<(), Self::Error> {
360+
Ok(())
361+
}
362+
405363
fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> {
406364
self.lock.ft.xfer(
407365
MpsseCmdBuilder::new()
@@ -519,48 +477,6 @@ where
519477
type Error = Error<E>;
520478
}
521479

522-
impl<'a, Device, E> eh1::spi::SpiDeviceRead for &'a SpiDevice<Device>
523-
where
524-
Device: MpsseCmdExecutor<Error = E>,
525-
E: std::error::Error,
526-
Error<E>: From<E>,
527-
{
528-
fn read_transaction(&mut self, operations: &mut [&mut [u8]]) -> Result<(), Self::Error> {
529-
// lock the bus
530-
let lock: MutexGuard<FtInner<Device>> =
531-
self.mtx.lock().expect("Failed to aquire FTDI mutex");
532-
let mut bus: SpiDeviceBus<'a, Device> = SpiDeviceBus {
533-
lock,
534-
pol: self.pol,
535-
};
536-
for op in operations {
537-
eh1::spi::SpiBusRead::read(&mut bus, op)?;
538-
}
539-
Ok(())
540-
}
541-
}
542-
543-
impl<'a, Device, E> eh1::spi::SpiDeviceWrite for &'a SpiDevice<Device>
544-
where
545-
Device: MpsseCmdExecutor<Error = E>,
546-
E: std::error::Error,
547-
Error<E>: From<E>,
548-
{
549-
fn write_transaction(&mut self, operations: &[&[u8]]) -> Result<(), Self::Error> {
550-
// lock the bus
551-
let lock: MutexGuard<FtInner<Device>> =
552-
self.mtx.lock().expect("Failed to aquire FTDI mutex");
553-
let mut bus: SpiDeviceBus<'a, Device> = SpiDeviceBus {
554-
lock,
555-
pol: self.pol,
556-
};
557-
for op in operations {
558-
eh1::spi::SpiBusWrite::write(&mut bus, op)?;
559-
}
560-
Ok(())
561-
}
562-
}
563-
564480
impl<'a, Device, E> eh1::spi::SpiDevice for &'a SpiDevice<Device>
565481
where
566482
Device: MpsseCmdExecutor<Error = E>,
@@ -593,23 +509,26 @@ where
593509
for op in operations {
594510
match op {
595511
eh1::spi::Operation::Read(buffer) => {
596-
eh1::spi::SpiBusRead::read(&mut bus, buffer)?;
512+
eh1::spi::SpiBus::read(&mut bus, buffer)?;
597513
}
598514
eh1::spi::Operation::Write(buffer) => {
599-
eh1::spi::SpiBusWrite::write(&mut bus, buffer)?;
515+
eh1::spi::SpiBus::write(&mut bus, buffer)?;
600516
}
601517
eh1::spi::Operation::Transfer(read, write) => {
602518
eh1::spi::SpiBus::transfer(&mut bus, read, write)?;
603519
}
604520
eh1::spi::Operation::TransferInPlace(buffer) => {
605521
eh1::spi::SpiBus::transfer_in_place(&mut bus, buffer)?;
606522
}
523+
eh1::spi::Operation::DelayUs(micros) => {
524+
std::thread::sleep(std::time::Duration::from_micros((*micros).into()));
525+
}
607526
}
608527
}
609528

610529
// flush the bus
611530
{
612-
use eh1::spi::SpiBusFlush;
531+
use eh1::spi::SpiBus;
613532
bus.flush()?;
614533
}
615534

0 commit comments

Comments
 (0)