@@ -141,39 +141,33 @@ mod app {
141
141
}
142
142
143
143
#[ task( binds=DMA1_STR1 , shared = [ transfer, cs] , priority=2 ) ]
144
- fn dma_complete ( mut ctx : dma_complete:: Context ) {
144
+ fn dma_complete ( ctx : dma_complete:: Context ) {
145
145
// If desired, the transfer can scheduled again here to continue transmitting.
146
- let mut cs = ctx. shared . cs ;
147
- ctx. shared . transfer . lock ( |transfer| {
148
- cs. lock ( |cs| {
149
- transfer. clear_transfer_complete_interrupt ( ) ;
150
- transfer. pause ( |spi| {
151
- // At this point, the DMA transfer is done, but the data is still in the SPI output
152
- // FIFO. Wait for it to complete before disabling CS.
153
- while spi. inner ( ) . sr . read ( ) . txc ( ) . bit_is_clear ( ) { }
154
- cs. set_high ( ) . unwrap ( ) ;
155
- } ) ;
146
+ ( ctx. shared . transfer , ctx. shared . cs ) . lock ( |transfer, cs| {
147
+ transfer. clear_transfer_complete_interrupt ( ) ;
148
+ transfer. pause ( |spi| {
149
+ // At this point, the DMA transfer is done, but the data is still in the SPI output
150
+ // FIFO. Wait for it to complete before disabling CS.
151
+ while spi. inner ( ) . sr . read ( ) . txc ( ) . bit_is_clear ( ) { }
152
+ cs. set_high ( ) . unwrap ( ) ;
156
153
} ) ;
157
154
} ) ;
158
155
}
159
156
160
157
#[ idle( shared = [ transfer, cs] ) ]
161
- fn idle ( mut ctx : idle:: Context ) -> ! {
158
+ fn idle ( ctx : idle:: Context ) -> ! {
162
159
// Start the DMA transfer over SPI.
163
- let mut cs = ctx. shared . cs ;
164
- ctx. shared . transfer . lock ( |transfer| {
165
- cs. lock ( |cs| {
166
- transfer. start ( |spi| {
167
- // Set CS low for the transfer.
168
- cs. set_low ( ) . unwrap ( ) ;
169
-
170
- // Enable TX DMA support, enable the SPI peripheral, and start the transaction.
171
- spi. enable_dma_tx ( ) ;
172
- spi. inner_mut ( ) . cr1 . modify ( |_, w| w. spe ( ) . enabled ( ) ) ;
173
- spi. inner_mut ( ) . cr1 . modify ( |_, w| w. cstart ( ) . started ( ) ) ;
174
-
175
- // The transaction immediately begins as the TX FIFO is now being filled by DMA.
176
- } ) ;
160
+ ( ctx. shared . transfer , ctx. shared . cs ) . lock ( |transfer, cs| {
161
+ transfer. start ( |spi| {
162
+ // Set CS low for the transfer.
163
+ cs. set_low ( ) . unwrap ( ) ;
164
+
165
+ // Enable TX DMA support, enable the SPI peripheral, and start the transaction.
166
+ spi. enable_dma_tx ( ) ;
167
+ spi. inner_mut ( ) . cr1 . modify ( |_, w| w. spe ( ) . enabled ( ) ) ;
168
+ spi. inner_mut ( ) . cr1 . modify ( |_, w| w. cstart ( ) . started ( ) ) ;
169
+
170
+ // The transaction immediately begins as the TX FIFO is now being filled by DMA.
177
171
} ) ;
178
172
} ) ;
179
173
0 commit comments