test
Dependencies: SimpleDMA mbed-rtos mbed
Fork of spiDMAtest by
Diff: dmaSPIslave.h
- Revision:
- 0:f0f5102ed9ca
- Child:
- 1:3cceef118195
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dmaSPIslave.h Wed Jul 15 11:16:13 2015 +0000 @@ -0,0 +1,34 @@ +#ifdef TARGET_KL46Z +class dmaSPISlave : public SPISlave{ + public: + dmaSPISlave(PinName mosi, PinName miso, PinName sclk, PinName ssel) : SPISlave(mosi, miso, sclk, ssel){ +// trigger appropriate spi for dma + if(_spi.spi == SPI0){ + read_dma.trigger(Trigger_SPI0_RX); + } + else{ + read_dma.trigger(Trigger_SPI1_RX); + } + +// set source for spi slave dma : mosi + read_dma.source(&_spi.spi->DL, false); + } + + void bulkRead(uint8_t *read_data, int length){ +// acquire(); + _spi.spi->C2 |= SPI_C2_RXDMAE_MASK; + +// auto increment is true + read_dma.destination(read_data, true); + +// start the read_dma + read_dma.start(length); + + while(read_dma.isBusy()); + + _spi.spi->C2 &= ~(SPI_C2_RXDMAE_MASK); + } + private: + SimpleDMA read_dma; +}; +#endif \ No newline at end of file