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 3:e59d61aac1e1, committed 2016-04-22
- Comitter:
- shreeshas95
- Date:
- Fri Apr 22 17:58:23 2016 +0000
- Parent:
- 2:16545dbc88ae
- Child:
- 4:33fc4fec3087
- Commit message:
- added new function restart
Changed in this revision
| dmaSPIslave.h | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/dmaSPIslave.h Thu Jul 16 05:40:25 2015 +0000
+++ b/dmaSPIslave.h Fri Apr 22 17:58:23 2016 +0000
@@ -38,7 +38,10 @@
// attach interrupt function
read_dma.attach(fun);
-
+ }
+
+ void bulkRead_restart(){
+ _spi.spi->C2 |= SPI_C2_RXDMAE_MASK;
}
/*
--- a/main.cpp Thu Jul 16 05:40:25 2015 +0000
+++ b/main.cpp Fri Apr 22 17:58:23 2016 +0000
@@ -2,23 +2,34 @@
#include "SimpleDMA.h"
#include "dmaSPIslave.h"
-#define PAYLOAD_LENGTH 1024
+#define PAYLOAD_LENGTH 6723
-dmaSPISlave spi(PTA16, PTA17, PTA15, PTA14);
+#define PAY_SPI_MOSI PTE18
+#define PAY_SPI_MISO PTE19
+#define PAY_SPI_CLK PTE17
+#define PAY_SPI_CS PTE16
+
+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;
void do_this(void){
flag = true;
}
+void do_this2(void){
+ flag = true;
+}
int main(){
- pc.baud(9600);
+// ledr = 1;
+// ledg = 1;
+ pc.baud(1200);
pc.printf("inside main\r\n");
spi.format(8,0);
- spi.frequency(10000000);
+ spi.frequency(1000000);
uint8_t buffer[PAYLOAD_LENGTH] = {0};
pc.printf("welcome to dma test, start sending data now\r\n");
@@ -27,19 +38,45 @@
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()){
+// buffer[i] = spi.read();
+// ++i;
+// }
+// }
+// ledr = !ledr;
+// for(int j = 0 ; j < PAYLOAD_LENGTH ; ++j){
+// printf("%02x ", buffer[j]);
+// }
+
+
if(flag){
+ count++;
flag = false;
- ledg = !ledg;
+// ledg = !ledg;
// for(int i = 0 ; i < PAYLOAD_LENGTH ; ++i){
// pc.printf("%02x ", buffer[i]);
// }
-// pc.printf("\r\n");
-
+ pc.printf("DATA RECEIVED\r\n");
+
// start dma again after handling the data
- spi.bulkRead_start();
+ 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();
+ }
}
}