Skip to content

Commit 7ed3a7b

Browse files
authored
Merge pull request #52 from riscv-rust/svdup
Release v0.10.0
2 parents 94b6474 + 65fcbbb commit 7ed3a7b

File tree

8 files changed

+36
-158
lines changed

8 files changed

+36
-158
lines changed

CHANGELOG.md

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

88
## [Unreleased]
99

10-
- Refactored `e310x-hal::spi` module, splitting the abstraction into `SpiBus` and `SpiExclusiveDevice/SpiSharedDevice` to allow multiple devices on a single SPI bus to co-exist
10+
## [v0.10.0] - 2023-03-28
11+
12+
### Added
1113
- Added Pulse Width Modulation interface implementing `embedded_hal::Pwm`
12-
- Added `interrupt` module for vectored interrupt handlers.
13-
This module is only active if feature `virq` is selected.
14-
- Update `e310x` dependency to version 0.10
15-
- Update `riscv` dependency to version 0.8
14+
- Added `interrupt` module for vectored interrupt handlers. This module is only active if feature `virq` is selected.
15+
16+
### Changed
17+
- Refactored `e310x-hal::spi` module, splitting the abstraction into `SpiBus` and `SpiExclusiveDevice/SpiSharedDevice` to allow multiple devices on a single SPI bus to co-exist
18+
- Update `e310x` dependency to version 0.11
19+
- Update `riscv` dependency to version 0.10
20+
21+
### Removed
22+
- removed interrupt linking definitions, they are now provided by `e310x` via `svd2rust`
1623

1724
## [v0.9.4] - 2022-07-10
1825

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "e310x-hal"
3-
version = "0.10.0"
3+
version = "0.11.0"
44
authors = ["David Craven <david@craven.ch>"]
55
repository = "https://github.com/riscv-rust/e310x-hal"
66
categories = ["embedded", "hardware-support", "no-std"]
@@ -13,8 +13,8 @@ rust-version = "1.59"
1313
[dependencies]
1414
embedded-hal = { version = "0.2.6", features = ["unproven"] }
1515
nb = "1.0.0"
16-
riscv = "0.8.0"
17-
e310x = { version = "0.10.0", features = ["rt"] }
16+
riscv = { version = "0.10.1", features = ["critical-section-single-hart"] }
17+
e310x = { version = "0.11.0", features = ["rt", "critical-section"] }
1818

1919
[features]
2020
g002 = ["e310x/g002"]

build.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

fe310x-interrupt.x

Lines changed: 0 additions & 59 deletions
This file was deleted.

interrupts.x

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/clock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ impl Clocks {
386386
/// Measure the coreclk frequency by counting the number of aonclk ticks.
387387
fn _measure_coreclk(&self, min_ticks: u64) -> Hertz {
388388
let mtime = MTIME;
389-
interrupt::free(|_| {
389+
interrupt::free(|| {
390390
// Don't start measuring until we see an mtime tick
391391
while mtime.mtime() == mtime.mtime() {}
392392

src/spi/shared_bus.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@ use core::cell::RefCell;
22
use core::ops::Deref;
33
pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3};
44
use riscv::interrupt;
5-
use riscv::interrupt::Mutex;
65

76
use super::{PinCS, PinsNoCS, SpiBus, SpiConfig, SpiSharedDevice, SpiX};
87

98
/// Newtype for RefCell<Spi> locked behind a Mutex.
109
/// Used to hold the [SpiBus] instance so it can be used for multiple [SpiSharedDevice] instances.
11-
pub struct SharedBus<SPI, PINS>(Mutex<RefCell<SpiBus<SPI, PINS>>>);
10+
pub struct SharedBus<SPI, PINS>(RefCell<SpiBus<SPI, PINS>>);
1211

1312
impl<SPI, PINS> SharedBus<SPI, PINS>
1413
where
1514
SPI: SpiX,
1615
PINS: PinsNoCS<SPI>,
1716
{
1817
pub(crate) fn new(bus: SpiBus<SPI, PINS>) -> Self {
19-
Self(Mutex::new(RefCell::new(bus)))
18+
Self(RefCell::new(bus))
2019
}
2120

2221
/// Create a new shared device on this SPI bus.
@@ -39,30 +38,30 @@ where
3938
{
4039
/// Set HOLD CS mode to per-frame operation, unless CSMODE is set to OFF
4140
pub fn start_frame(&mut self) {
42-
interrupt::free(|cs| {
43-
let mut bus = self.0.borrow(*cs).borrow_mut();
41+
interrupt::free(|| {
42+
let mut bus = self.0.borrow_mut();
4443
bus.start_frame();
4544
});
4645
}
4746

4847
/// Finishes transfer by deasserting CS (only for hardware-controlled CS)
4948
pub fn end_frame(&mut self) {
50-
interrupt::free(|cs| {
51-
let mut bus = self.0.borrow(*cs).borrow_mut();
49+
interrupt::free(|| {
50+
let mut bus = self.0.borrow_mut();
5251
bus.end_frame();
5352
});
5453
}
5554

5655
/// Releases the SPI peripheral and associated pins
5756
pub fn release(self) -> (SPI, PINS) {
58-
let bus = self.0.into_inner().into_inner();
57+
let bus = self.0.into_inner();
5958

6059
(bus.spi, bus.pins)
6160
}
6261
}
6362

6463
impl<SPI, PINS> Deref for SharedBus<SPI, PINS> {
65-
type Target = Mutex<RefCell<SpiBus<SPI, PINS>>>;
64+
type Target = RefCell<SpiBus<SPI, PINS>>;
6665

6766
fn deref(&self) -> &Self::Target {
6867
&self.0

src/spi/shared_device.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ where
4949
type Error = Infallible;
5050

5151
fn read(&mut self) -> nb::Result<u8, Infallible> {
52-
interrupt::free(|cs| {
53-
let mut bus = self.bus.borrow(*cs).borrow_mut();
52+
interrupt::free(|| {
53+
let mut bus = self.bus.borrow_mut();
5454

5555
bus.configure(&self.config, Some(CS::CS_INDEX));
5656

@@ -59,8 +59,8 @@ where
5959
}
6060

6161
fn send(&mut self, byte: u8) -> nb::Result<(), Infallible> {
62-
interrupt::free(|cs| {
63-
let mut bus = self.bus.borrow(*cs).borrow_mut();
62+
interrupt::free(|| {
63+
let mut bus = self.bus.borrow_mut();
6464

6565
bus.configure(&self.config, Some(CS::CS_INDEX));
6666

@@ -78,8 +78,8 @@ where
7878
type Error = Infallible;
7979

8080
fn transfer<'w>(&mut self, words: &'w mut [u8]) -> Result<&'w [u8], Self::Error> {
81-
interrupt::free(move |cs| {
82-
let mut bus = self.bus.borrow(*cs).borrow_mut();
81+
interrupt::free(move || {
82+
let mut bus = self.bus.borrow_mut();
8383

8484
bus.configure(&self.config, Some(CS::CS_INDEX));
8585

@@ -101,8 +101,8 @@ where
101101
type Error = Infallible;
102102

103103
fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> {
104-
interrupt::free(|cs| {
105-
let mut bus = self.bus.borrow(*cs).borrow_mut();
104+
interrupt::free(|| {
105+
let mut bus = self.bus.borrow_mut();
106106

107107
bus.configure(&self.config, Some(CS::CS_INDEX));
108108

@@ -127,8 +127,8 @@ where
127127
where
128128
WI: IntoIterator<Item = u8>,
129129
{
130-
interrupt::free(|cs| {
131-
let mut bus = self.bus.borrow(*cs).borrow_mut();
130+
interrupt::free(|| {
131+
let mut bus = self.bus.borrow_mut();
132132

133133
bus.configure(&self.config, Some(CS::CS_INDEX));
134134

@@ -150,8 +150,8 @@ where
150150
type Error = Infallible;
151151

152152
fn exec<'op>(&mut self, operations: &mut [Operation<'op, u8>]) -> Result<(), Infallible> {
153-
interrupt::free(|cs| {
154-
let mut bus = self.bus.borrow(*cs).borrow_mut();
153+
interrupt::free(|| {
154+
let mut bus = self.bus.borrow_mut();
155155

156156
bus.configure(&self.config, Some(CS::CS_INDEX));
157157

0 commit comments

Comments
 (0)