DMA for Science thread
Dependencies: SimpleDMA mbed-rtos mbed
Fork of spiDMAtest by
main.cpp
- Committer:
- shreeshas95
- Date:
- 2015-07-16
- Revision:
- 1:3cceef118195
- Parent:
- 0:f0f5102ed9ca
- Child:
- 2:16545dbc88ae
File content as of revision 1:3cceef118195:
#include "mbed.h" #include "rtos.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(16000000); uint8_t buffer[PAYLOAD_LENGTH] = {0}; pc.printf("welcome to dma test, start sending data now\r\n"); // while(true){ // int i = 0; // while(i < PAYLOAD_LENGTH){ // if(spi.receive()){ // buffer[i] = spi.read(); // ++i; // ledg = !ledg; // } // } // for(int i = 0 ; i < PAYLOAD_LENGTH ; ++i){ // pc.printf("%02x ", buffer[i]); // } // pc.printf("\r\n"); // // } spi.bulkRead_init(buffer, PAYLOAD_LENGTH, &do_this); 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"); spi.bulkRead_start(); } } }