test
Dependencies: SimpleDMA mbed-rtos mbed
Fork of spiDMAtest by
main.cpp
- Committer:
- shreeshas95
- Date:
- 2015-07-16
- Revision:
- 2:16545dbc88ae
- Parent:
- 1:3cceef118195
- Child:
- 3:972fa06ef0aa
File content as of revision 2:16545dbc88ae:
#include "mbed.h" #include "SimpleDMA.h" #include "dmaSPIslave.h" #define PAYLOAD_LENGTH 1024 dmaSPISlave spi(PTA16, PTA17, PTA15, PTA14); RawSerial pc(USBTX, USBRX); DigitalOut ledg(LED_GREEN); bool flag = false; void do_this(void){ flag = true; } int main(){ pc.baud(9600); pc.printf("inside main\r\n"); spi.format(8,0); spi.frequency(10000000); uint8_t buffer[PAYLOAD_LENGTH] = {0}; pc.printf("welcome to dma test, start sending data now\r\n"); // initialise the buffer for dma spi.bulkRead_init(buffer, PAYLOAD_LENGTH, &do_this); // start dma read spi.bulkRead_start(); while(true){ if(flag){ flag = false; ledg = !ledg; // for(int i = 0 ; i < PAYLOAD_LENGTH ; ++i){ // pc.printf("%02x ", buffer[i]); // } // pc.printf("\r\n"); // start dma again after handling the data spi.bulkRead_start(); } } }