Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SimpleDMA mbed-rtos mbed
Revision 4:33fc4fec3087, committed 2016-09-27
- Comitter:
- shreeshas95
- Date:
- Tue Sep 27 10:39:48 2016 +0000
- Parent:
- 3:e59d61aac1e1
- Commit message:
- Simple test program for spi-DMA
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r e59d61aac1e1 -r 33fc4fec3087 main.cpp
--- a/main.cpp Fri Apr 22 17:58:23 2016 +0000
+++ b/main.cpp Tue Sep 27 10:39:48 2016 +0000
@@ -11,7 +11,7 @@
dmaSPISlave spi(PAY_SPI_MOSI, PAY_SPI_MISO, PAY_SPI_CLK, PAY_SPI_CS);
RawSerial pc(USBTX, USBRX);
-//DigitalOut ledg(LED_GREEN);
+DigitalOut ledg(LED_GREEN);
//DigitalOut ledr(LED_RED);
bool flag = false;
@@ -19,9 +19,6 @@
void do_this(void){
flag = true;
}
-void do_this2(void){
- flag = true;
-}
int main(){
// ledr = 1;
@@ -38,9 +35,9 @@
spi.bulkRead_init(buffer, PAYLOAD_LENGTH, &do_this);
// start dma read
spi.bulkRead_start();
- int count = 0;
while(true){
+
// int i = 0;
// while(i < PAYLOAD_LENGTH){
// if(spi.receive()){
@@ -55,29 +52,11 @@
if(flag){
- count++;
flag = false;
-// ledg = !ledg;
-
-// for(int i = 0 ; i < PAYLOAD_LENGTH ; ++i){
-// pc.printf("%02x ", buffer[i]);
-// }
- pc.printf("DATA RECEIVED\r\n");
// start dma again after handling the data
- if(count == 3){
- count = 0;
- spi.bulkRead_end();
- pc.printf("tried END\r\n");
- wait(1);
- pc.printf("restarting the procedure\r\n");
- spi.bulkRead_restart();
- spi.bulkRead_start();
- }
- else{
- spi.bulkRead_start();
- }
+ spi.bulkRead_start();
+ ledg = !ledg;
}
- }
-
+ }
}
\ No newline at end of file