test
Dependencies: SimpleDMA mbed-rtos mbed
Fork of spiDMAtest by
main.cpp@0:f0f5102ed9ca, 2015-07-15 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
shreeshas95 | 0:f0f5102ed9ca | 1 | #include "mbed.h" |
shreeshas95 | 0:f0f5102ed9ca | 2 | #include "rtos.h" |
shreeshas95 | 0:f0f5102ed9ca | 3 | #include "SimpleDMA.h" |
shreeshas95 | 0:f0f5102ed9ca | 4 | #include "dmaSPIslave.h" |
shreeshas95 | 0:f0f5102ed9ca | 5 | |
shreeshas95 | 0:f0f5102ed9ca | 6 | dmaSPISlave spi(PTA16, PTA17, PTA15, PTA14); |
shreeshas95 | 0:f0f5102ed9ca | 7 | RawSerial pc(USBTX, USBRX); |
shreeshas95 | 0:f0f5102ed9ca | 8 | DigitalOut ledg(LED_GREEN); |
shreeshas95 | 0:f0f5102ed9ca | 9 | |
shreeshas95 | 0:f0f5102ed9ca | 10 | int main(){ |
shreeshas95 | 0:f0f5102ed9ca | 11 | pc.baud(9600); |
shreeshas95 | 0:f0f5102ed9ca | 12 | pc.printf("inside main\r\n"); |
shreeshas95 | 0:f0f5102ed9ca | 13 | spi.format(8,3); |
shreeshas95 | 0:f0f5102ed9ca | 14 | spi.frequency(1000000); |
shreeshas95 | 0:f0f5102ed9ca | 15 | |
shreeshas95 | 0:f0f5102ed9ca | 16 | uint8_t buffer[100] = {0}; |
shreeshas95 | 0:f0f5102ed9ca | 17 | pc.printf("welcome to dma test, start sending data now\r\n"); |
shreeshas95 | 0:f0f5102ed9ca | 18 | |
shreeshas95 | 0:f0f5102ed9ca | 19 | // int i = 0; |
shreeshas95 | 0:f0f5102ed9ca | 20 | // while(i < 100){ |
shreeshas95 | 0:f0f5102ed9ca | 21 | // if(spi.receive()){ |
shreeshas95 | 0:f0f5102ed9ca | 22 | // buffer[i] = spi.read(); |
shreeshas95 | 0:f0f5102ed9ca | 23 | // ++i; |
shreeshas95 | 0:f0f5102ed9ca | 24 | // ledg = !ledg; |
shreeshas95 | 0:f0f5102ed9ca | 25 | // } |
shreeshas95 | 0:f0f5102ed9ca | 26 | // } |
shreeshas95 | 0:f0f5102ed9ca | 27 | spi.bulkRead(buffer, 100); |
shreeshas95 | 0:f0f5102ed9ca | 28 | |
shreeshas95 | 0:f0f5102ed9ca | 29 | for(int i = 0 ; i < 100 ; ++i){ |
shreeshas95 | 0:f0f5102ed9ca | 30 | pc.printf("%02x ", buffer[i]); |
shreeshas95 | 0:f0f5102ed9ca | 31 | } |
shreeshas95 | 0:f0f5102ed9ca | 32 | pc.printf("\r\n"); |
shreeshas95 | 0:f0f5102ed9ca | 33 | |
shreeshas95 | 0:f0f5102ed9ca | 34 | return 0; |
shreeshas95 | 0:f0f5102ed9ca | 35 | } |