test

Dependencies:   SimpleDMA mbed-rtos mbed

Fork of spiDMAtest by Siva ram

Committer:
shreeshas95
Date:
Wed Jul 15 11:16:13 2015 +0000
Revision:
0:f0f5102ed9ca
Child:
1:3cceef118195
working dma without interrupt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shreeshas95 0:f0f5102ed9ca 1 #ifdef TARGET_KL46Z
shreeshas95 0:f0f5102ed9ca 2 class dmaSPISlave : public SPISlave{
shreeshas95 0:f0f5102ed9ca 3 public:
shreeshas95 0:f0f5102ed9ca 4 dmaSPISlave(PinName mosi, PinName miso, PinName sclk, PinName ssel) : SPISlave(mosi, miso, sclk, ssel){
shreeshas95 0:f0f5102ed9ca 5 // trigger appropriate spi for dma
shreeshas95 0:f0f5102ed9ca 6 if(_spi.spi == SPI0){
shreeshas95 0:f0f5102ed9ca 7 read_dma.trigger(Trigger_SPI0_RX);
shreeshas95 0:f0f5102ed9ca 8 }
shreeshas95 0:f0f5102ed9ca 9 else{
shreeshas95 0:f0f5102ed9ca 10 read_dma.trigger(Trigger_SPI1_RX);
shreeshas95 0:f0f5102ed9ca 11 }
shreeshas95 0:f0f5102ed9ca 12
shreeshas95 0:f0f5102ed9ca 13 // set source for spi slave dma : mosi
shreeshas95 0:f0f5102ed9ca 14 read_dma.source(&_spi.spi->DL, false);
shreeshas95 0:f0f5102ed9ca 15 }
shreeshas95 0:f0f5102ed9ca 16
shreeshas95 0:f0f5102ed9ca 17 void bulkRead(uint8_t *read_data, int length){
shreeshas95 0:f0f5102ed9ca 18 // acquire();
shreeshas95 0:f0f5102ed9ca 19 _spi.spi->C2 |= SPI_C2_RXDMAE_MASK;
shreeshas95 0:f0f5102ed9ca 20
shreeshas95 0:f0f5102ed9ca 21 // auto increment is true
shreeshas95 0:f0f5102ed9ca 22 read_dma.destination(read_data, true);
shreeshas95 0:f0f5102ed9ca 23
shreeshas95 0:f0f5102ed9ca 24 // start the read_dma
shreeshas95 0:f0f5102ed9ca 25 read_dma.start(length);
shreeshas95 0:f0f5102ed9ca 26
shreeshas95 0:f0f5102ed9ca 27 while(read_dma.isBusy());
shreeshas95 0:f0f5102ed9ca 28
shreeshas95 0:f0f5102ed9ca 29 _spi.spi->C2 &= ~(SPI_C2_RXDMAE_MASK);
shreeshas95 0:f0f5102ed9ca 30 }
shreeshas95 0:f0f5102ed9ca 31 private:
shreeshas95 0:f0f5102ed9ca 32 SimpleDMA read_dma;
shreeshas95 0:f0f5102ed9ca 33 };
shreeshas95 0:f0f5102ed9ca 34 #endif