DMA changes; still not working
This commit is contained in:
parent
8790a7ce04
commit
86691868ea
|
@ -54,10 +54,9 @@ const HIGH: u16 = 25000;
|
||||||
/// if your board has a different frequency
|
/// if your board has a different frequency
|
||||||
const XTAL_FREQ_HZ: u32 = 12_000_000u32;
|
const XTAL_FREQ_HZ: u32 = 12_000_000u32;
|
||||||
|
|
||||||
fn get_adc_channel_blocking<S, D, const DS: u8, E>(dma: &hal::dma::Channels, spi: &mut rp2040_hal::Spi<S, D, DS>, cs_pin: &dyn embedded_hal::digital::v2::OutputPin<Error = E>) -> u16
|
fn get_adc_channel_blocking<BIDI, WORD, E>(dma: &hal::dma::Channels, spi: &mut BIDI, cs_pin: &dyn embedded_hal::digital::v2::OutputPin<Error = E>) -> u16
|
||||||
where
|
where
|
||||||
S: hal::spi::State,
|
BIDI: hal::dma::ReadTarget<ReceivedWord = WORD> + hal::dma::WriteTarget<TransmittedWord = WORD>,
|
||||||
D: hal::spi::SpiDevice,
|
|
||||||
E: core::fmt::Debug
|
E: core::fmt::Debug
|
||||||
{
|
{
|
||||||
let mut tx_buf: [u8; 3] = [0x06, 0x40, 0x00];
|
let mut tx_buf: [u8; 3] = [0x06, 0x40, 0x00];
|
||||||
|
@ -67,7 +66,7 @@ where
|
||||||
cs_pin.set_low().unwrap();
|
cs_pin.set_low().unwrap();
|
||||||
|
|
||||||
// Use BidirectionalConfig to simultaneously write to spi from tx_buf and read into rx_buf
|
// Use BidirectionalConfig to simultaneously write to spi from tx_buf and read into rx_buf
|
||||||
let transfer = bidirectional::Config::new((dma.ch0, dma.ch1), &tx_buf, spi, &rx_buf).start();
|
let transfer = bidirectional::Config::new((dma.ch0, dma.ch1), &tx_buf, spi, &mut rx_buf).start();
|
||||||
// Wait for both DMA channels to finish
|
// Wait for both DMA channels to finish
|
||||||
let ((_ch0, _ch1), tx_buf, _spi, rx_buf) = transfer.wait();
|
let ((_ch0, _ch1), tx_buf, _spi, rx_buf) = transfer.wait();
|
||||||
cs_pin.set_high().unwrap();
|
cs_pin.set_high().unwrap();
|
||||||
|
|
Loading…
Reference in a new issue