Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

u8 as default SPI Word #321

Merged
merged 2 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Changed

- Use `u8` as default SPI as Serial Word type

### Added
- Added `Can` Controller Area Network traits.
- `Error` traits for SPI, I2C and Serial traits. The error types used in those must
Expand Down
2 changes: 1 addition & 1 deletion src/serial/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! Implementing that marker trait will opt in your type into a blanket implementation.

/// Write half of a serial interface (blocking variant)
pub trait Write<Word> {
pub trait Write<Word = u8> {
/// The type of error that can occur when writing
type Error: crate::serial::Error;

Expand Down
4 changes: 2 additions & 2 deletions src/serial/nb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
///
/// Some serial interfaces support different data sizes (8 bits, 9 bits, etc.);
/// This can be encoded in this trait via the `Word` type parameter.
pub trait Read<Word> {
pub trait Read<Word = u8> {
/// Read error
type Error: crate::serial::Error;

Expand All @@ -21,7 +21,7 @@ impl<T: Read<Word>, Word> Read<Word> for &mut T {
}

/// Write half of a serial interface
pub trait Write<Word> {
pub trait Write<Word = u8> {
/// Write error
type Error: crate::serial::Error;

Expand Down
10 changes: 5 additions & 5 deletions src/spi/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! Implementing that marker trait will opt in your type into a blanket implementation.

/// Blocking transfer
pub trait Transfer<W> {
pub trait Transfer<W = u8> {
/// Error type
type Error: crate::spi::Error;

Expand All @@ -24,7 +24,7 @@ impl<T: Transfer<W>, W> Transfer<W> for &mut T {
}

/// Blocking write
pub trait Write<W> {
pub trait Write<W = u8> {
/// Error type
type Error: crate::spi::Error;

Expand All @@ -41,7 +41,7 @@ impl<T: Write<W>, W> Write<W> for &mut T {
}

/// Blocking write (iterator version)
pub trait WriteIter<W> {
pub trait WriteIter<W = u8> {
/// Error type
type Error: crate::spi::Error;

Expand All @@ -66,7 +66,7 @@ impl<T: WriteIter<W>, W> WriteIter<W> for &mut T {
///
/// This allows composition of SPI operations into a single bus transaction
#[derive(Debug, PartialEq)]
pub enum Operation<'a, W: 'static> {
pub enum Operation<'a, W: 'static = u8> {
/// Write data from the provided buffer, discarding read data
Write(&'a [W]),
/// Write data out while reading data into the provided buffer
Expand All @@ -75,7 +75,7 @@ pub enum Operation<'a, W: 'static> {

/// Transactional trait allows multiple actions to be executed
/// as part of a single SPI transaction
pub trait Transactional<W: 'static> {
pub trait Transactional<W: 'static = u8> {
/// Associated error type
type Error: crate::spi::Error;

Expand Down
2 changes: 1 addition & 1 deletion src/spi/nb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
///
/// - Some SPIs can work with 8-bit *and* 16-bit words. You can overload this trait with different
/// `Word` types to allow operation in both modes.
pub trait FullDuplex<Word> {
pub trait FullDuplex<Word = u8> {
/// An enumeration of SPI errors
type Error: crate::spi::Error;

Expand Down