DMA for Science thread
Dependencies: SimpleDMA mbed-rtos mbed
Fork of spiDMAtest by
Diff: dmaSPIslave.h
- Revision:
- 2:16545dbc88ae
- Parent:
- 1:3cceef118195
- Child:
- 3:e59d61aac1e1
diff -r 3cceef118195 -r 16545dbc88ae dmaSPIslave.h --- a/dmaSPIslave.h Thu Jul 16 05:19:02 2015 +0000 +++ b/dmaSPIslave.h Thu Jul 16 05:40:25 2015 +0000 @@ -1,6 +1,11 @@ #ifdef TARGET_KL46Z class dmaSPISlave : public SPISlave{ public: +/* +@brief: constructor : initialise the spi slave pins +@param: mosi, miso, sclk, ssel +@return: none +*/ dmaSPISlave(PinName mosi, PinName miso, PinName sclk, PinName ssel) : SPISlave(mosi, miso, sclk, ssel){ // trigger appropriate spi for dma if(_spi.spi == SPI0){ @@ -14,6 +19,13 @@ read_dma.source(&_spi.spi->DL, false); } +/* +@brief: initialise the dma buffer to store the recevied data +@param: read_data : pointer to the buffer + len : length in bytes to store in the buffer + fun : address of the function to attach to the dma interrupt, interrupt is called when the len num of bytes are written to the buffer +@return: none +*/ void bulkRead_init(uint8_t *read_data, int len, void (*fun)(void) ){ // acquire(); _spi.spi->C2 |= SPI_C2_RXDMAE_MASK; @@ -27,13 +39,27 @@ // attach interrupt function read_dma.attach(fun); -// _spi.spi->C2 &= ~(SPI_C2_RXDMAE_MASK); } +/* +@brief: start the dma read process : has to be done everytime the buffer gets filled, can be used repeatedly +@param: none +@return: none +*/ void bulkRead_start(){ // start the read_dma read_dma.start(length); } + +/* +@brief: end dma process and return back to normal spi mode +@param: none +@return: none +*/ + void bulkRead_end(){ +// turn off dma + _spi.spi->C2 &= ~(SPI_C2_RXDMAE_MASK); + } private: int length;