File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
5
5
and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
6
6
7
+ ## [ Unreleased]
8
+ ### Fixed
9
+ - Fixed undefined behaviour in SPI full duplex RX DMA transfers.
10
+
7
11
## [ 0.6.0] - 2022-07-04
8
12
### Added
9
13
- Added ` rcc::Lsco ` to use the low-speed oscillator output.
Original file line number Diff line number Diff line change @@ -148,9 +148,12 @@ const fn cpol_from_polarity(polarity: Polarity) -> bool {
148
148
}
149
149
}
150
150
151
+ // a space for the RX DMA to transfer into when TX'ing in full-duplex
152
+ static mut GARBAGE : [ u8 ; 1 ] = [ 0 ] ;
153
+
151
154
use sealed:: SpiRegs ;
152
155
pub ( crate ) mod sealed {
153
- use super :: Error ;
156
+ use super :: { Error , GARBAGE } ;
154
157
use crate :: {
155
158
dma:: { self , DmaCh } ,
156
159
pac,
@@ -261,9 +264,7 @@ pub(crate) mod sealed {
261
264
. set_mem_inc ( true )
262
265
. set_enable ( true ) ;
263
266
264
- let garbage: [ u8 ; 1 ] = [ 0 ] ;
265
-
266
- rx_dma. set_mem_addr ( garbage. as_ptr ( ) as u32 ) ;
267
+ rx_dma. set_mem_addr ( unsafe { GARBAGE . as_mut_ptr ( ) } as u32 ) ;
267
268
tx_dma. set_mem_addr ( words. as_ptr ( ) as u32 ) ;
268
269
269
270
let ndt: u32 = words. len ( ) as u32 ;
You can’t perform that action at this time.
0 commit comments