Skip to content

Commit b07a488

Browse files
authored
Merge pull request #19 from david-sawatzke/send_sync
Add Send & Sync impls for Pin
2 parents 1a01001 + 0c4a1db commit b07a488

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Added Sync & Send ability to Pin
13+
1014
## [v0.10.0] - 2018-12-23
1115

1216
### Added

src/gpio.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ pub struct Pin<MODE> {
6565
_mode: PhantomData<MODE>,
6666
}
6767

68+
// NOTE(unsafe) The only write acess is to BSRR, which is thread safe
69+
unsafe impl<MODE> Sync for Pin<MODE> {}
70+
// NOTE(unsafe) this only enables read access to the same pin from multiple
71+
// threads
72+
unsafe impl<MODE> Send for Pin<MODE> {}
73+
6874
impl<MODE> StatefulOutputPin for Pin<Output<MODE>> {
6975
fn is_set_high(&self) -> bool {
7076
!self.is_set_low()

0 commit comments

Comments
 (0)