Skip to content

Commit b401085

Browse files
committed
simplfied UART error handling
1 parent c693530 commit b401085

File tree

4 files changed

+101
-151
lines changed

4 files changed

+101
-151
lines changed

va108xx-hal/CHANGELOG.md

+32-14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88

99
## [unreleased]
1010

11+
## [v0.11.0] 2025-03-07
12+
13+
## Changed
14+
15+
- Bugfix for I2C `TimingCfg::reg`
16+
- Simplified UART error handling. All APIs are now infallible because writing to a FIFO or
17+
reading from a FIFO never fails. Users can either poll errors using `Rx::poll_errors` or
18+
`Uart::poll_rx_errors` / `UartBase::poll_rx_errors`, or detect errors using the provided
19+
interrupt handlers.
20+
1121
## [v0.10.0] 2025-02-17
1222

1323
## Added
@@ -104,14 +114,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
104114
- Updated `embedded-hal` to v1
105115
- Added optional `defmt` v0.3 feature and support.
106116

107-
## [v0.5.2] 2024-06-16
117+
## v0.5.2 2024-06-16
108118

109119
## Fixed
110120

111121
- Replaced usage to `ptr::write_volatile` in UART module which is denied on more recent Rust
112122
compilers.
113123

114-
## [v0.5.1]
124+
## v0.5.1
115125

116126
### Changes
117127

@@ -120,7 +130,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
120130
- `once_cell` to 1.12.0
121131
- Other dependencies: Only revision has changed
122132

123-
## [v0.5.0]
133+
## v0.5.0
124134

125135
### Added
126136

@@ -133,14 +143,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
133143

134144
- Bugfix in UART code where RX and TX could not be enabled or disabled independently
135145

136-
## [v0.4.3]
146+
## v0.4.3
137147

138148
- Various smaller fixes for READMEs, update of links in documentation
139149
- Simplified CI for github, do not use `cross`
140150
- New `blinky-pac` example
141151
- Use HAL delay in `blinky` example
142152

143-
## [v0.4.2]
153+
## v0.4.2
144154

145155
### Added
146156

@@ -150,24 +160,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
150160

151161
- Clear TX and RX FIFO in SPI transfer function
152162

153-
## [v0.4.1]
163+
## v0.4.1
154164

155165
### Fixed
156166

157167
- Initial blockmode setting was not set in SPI constructor
158168

159-
## [v0.4.0]
169+
## v0.4.0
160170

161171
### Changed
162172

163173
- Replaced `Hertz` by `impl Into<Hertz>` completely and removed
164174
`+ Copy` where not necessary
165175

166-
## [v0.3.1]
176+
## v0.3.1
167177

168178
- Updated all links to point to new repository
169179

170-
## [v0.3.0]
180+
## v0.3.0
171181

172182
### Added
173183

@@ -179,7 +189,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
179189
- Primary repository now hosted on IRS external git: https://egit.irs.uni-stuttgart.de/rust/va108xx-hal
180190
- Relicensed as Apache-2.0
181191

182-
## [0.2.3]
192+
## v0.2.3
183193

184194
### Added
185195

@@ -191,7 +201,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
191201

192202
- Improved Timer API. It is now possible to simply use `new` on `CountDownTimer`
193203

194-
## [0.2.2]
204+
## v0.2.2
195205

196206
### Added
197207

@@ -203,7 +213,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
203213

204214
- API which expects values in Hertz now uses `impl Into<Hertz>` as input parameter
205215

206-
## [0.2.1]
216+
## v0.2.1
207217

208218
### Added
209219

@@ -217,7 +227,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
217227
- Moved the `FilterClkSel` struct to the `clock` module, re-exporting in `gpio`
218228
- Clearing output state at initialization of Output pins
219229

220-
## [0.2.0]
230+
## v0.2.0
221231

222232
### Changed
223233

@@ -232,7 +242,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
232242
- Some bugfixes for GPIO implementation
233243
- Rust edition updated to 2021
234244

235-
## [0.1.0]
245+
## v0.1.0
236246

237247
### Added
238248

@@ -241,3 +251,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
241251
- RTT example application
242252
- Added basic test binary in form of an example
243253
- README with basic instructions how to set up own binary crate
254+
255+
[unreleased]: https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/compare/va108xx-hal-v0.11.0...HEAD
256+
[v0.11.0]: https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/compare/va108xx-hal-v0.10.0...va108xx-hal-v0.11.0
257+
[v0.10.0]: https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/compare/va108xx-hal-v0.9.0...va108xx-hal-v0.10.0
258+
[v0.9.0]: https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/compare/va108xx-hal-v0.8.0...va108xx-hal-v0.9.0
259+
[v0.8.0]: https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/compare/va108xx-hal-v0.7.0...va108xx-hal-v0.8.0
260+
[v0.7.0]: https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/compare/va108xx-hal-v0.6.0...va108xx-hal-v0.7.0
261+
[v0.6.0]: https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/src/tag/va108xx-hal-v0.6.0

va108xx-hal/src/i2c.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,13 @@ impl TimingCfg {
198198
}
199199

200200
pub fn reg(&self) -> u32 {
201-
(self.tbuf as u32) << 28
202-
| (self.thd_sta as u32) << 24
203-
| (self.tsu_sta as u32) << 20
204-
| (self.tsu_sto as u32) << 16
205-
| (self.tlow as u32) << 12
206-
| (self.thigh as u32) << 8
207-
| (self.tf as u32) << 4
201+
((self.tbuf as u32) << 28)
202+
| ((self.thd_sta as u32) << 24)
203+
| ((self.tsu_sta as u32) << 20)
204+
| ((self.tsu_sto as u32) << 16)
205+
| ((self.tlow as u32) << 12)
206+
| ((self.thigh as u32) << 8)
207+
| ((self.tf as u32) << 4)
208208
| (self.tr as u32)
209209
}
210210
}
@@ -376,7 +376,7 @@ impl<I2c: Instance> I2cBase<I2c> {
376376
if let Some(max_words) = max_words {
377377
self.i2c
378378
.s0_maxwords()
379-
.write(|w| unsafe { w.bits(1 << 31 | max_words as u32) });
379+
.write(|w| unsafe { w.bits((1 << 31) | max_words as u32) });
380380
}
381381
let (addr, addr_mode_mask) = Self::unwrap_addr(sl_cfg.addr);
382382
// The first bit is the read/write value. Normally, both read and write are matched
@@ -437,7 +437,7 @@ impl<I2c: Instance> I2cBase<I2c> {
437437
let clk_div = self.calc_clk_div(speed_mode)?;
438438
self.i2c
439439
.clkscale()
440-
.write(|w| unsafe { w.bits((speed_mode as u32) << 31 | clk_div as u32) });
440+
.write(|w| unsafe { w.bits(((speed_mode as u32) << 31) | clk_div as u32) });
441441
Ok(())
442442
}
443443

0 commit comments

Comments
 (0)