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.
Fork of DecaWave by
Diff: main.cpp
- Revision:
- 17:8afa5f9122da
- Parent:
- 16:96879e1c99f2
- Child:
- 18:bbc7ca7d3a95
--- a/main.cpp Mon Nov 24 12:48:40 2014 +0000
+++ b/main.cpp Mon Nov 24 14:09:49 2014 +0000
@@ -7,9 +7,7 @@
const float timeunit = 1/(128*499.2e6);
int i=0;
-bool starter = 1;
-bool ping = 0;
-char message[1024] = "";
+char message[1200] = "";
uint64_t timestamp_old = 0;
//#define PINGPONG
@@ -31,7 +29,6 @@
} else
pc.printf("Received! %d ", framelength);
-# ifdef PINGPONG
uint64_t status;
dw.readRegister(DW1000_SYS_STATUS, 0, (uint8_t*)&status, 5);
status &= 0xFFFFFFFFFF; // only 40-Bit
@@ -44,19 +41,8 @@
timestamp_old = timestamp;
//pc.printf("Timestamp: %lld\r\n", difference);
pc.printf("Timestamp: %fs", difference*timeunit); // TODO: gives some wrong values because of timer overflow
-
- starter = 0;
- wait(1); // TODO: ugly, never wait in interrupthandler!
- if (ping) {
- sprintf((char*)message, "PING! %d", i);
- dw.sendString(message);
- } else {
- sprintf((char*)message, "PONG! %d", i);
- dw.sendString(message);
- }
-#endif
pc.printf("\r\n");
- dw.receiveFrame();
+ dw.startRX();
}
int main() {
@@ -76,44 +62,26 @@
// Receiver initialisation
uint8_t dataframereadyinterrupt = 0x40; // only good frame 0x40 all frames 0x20
dw.writeRegister(DW1000_SYS_MASK, 1, &dataframereadyinterrupt, 1);
-
- dw.receiveFrame();
-# ifdef PINGPONG
- wait(3);
-# endif
+ dw.startRX();
while(1) {
-# ifndef PINGPONG
- message[i] = 48+ (i%10);
- message[i+1] = '\0';
-
- pc.printf("%d Message: \"%s\" %d\r\n", i, message, strlen(message)+1);
+#if 1
+ if(i < 1200) {
+ message[i] = 48+ (i%10);
+ message[i+1] = '\0';
+ }
//wait(0.1);
- char messagecheck[1024];
+ char messagecheck[1200];
dw.sendString(message);
- wait(0.1);
+ wait_us(10000);
dw.readRegister(DW1000_TX_BUFFER, 0, (uint8_t*)messagecheck, strlen(message)+1);
- pc.printf("%d nBuffer: \"%s\" %d\r\n\r\n", i, messagecheck, strlen(messagecheck)+1);
- //wait(0.1);
+ if (i < 200)
+ pc.printf("%d Sent: \"%s\" %d\r\n", i, messagecheck, strlen(message)+1);
+ else
+ pc.printf("%d Sent! %d\r\n", i, strlen(message)+1);
- //return 0;
- /*for(int i=0; i<10; i++) { // to control Voltage
- pc.printf("%d Voltage: %f\r\n", i, dw.getVoltage());
- wait(0.2);
- }*/
-#else
- if (starter) {
- ping = 1;
- while (starter) {
- sprintf((char*)message, "PING! %d", i);
- dw.sendString(message);
- wait(1);
- }
- }
-
- wait(1);
-# endif
+#endif
#if 0
pc.printf("%d Waiting... ", i);
uint64_t status;
