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.
Diff: Main.cpp
- Revision:
- 4:12dfd9a8ee76
- Parent:
- 3:1ba96949e2fd
- Child:
- 5:7cabc36d4352
--- a/Main.cpp Sat Aug 05 06:59:15 2017 +0000
+++ b/Main.cpp Mon Aug 07 23:36:40 2017 +0000
@@ -7,6 +7,19 @@
#include "mbed.h"
#include "stdlib.h"
+#define VERSION "1.2"
+
+
+#ifdef MDOT
+#define
+#define
+#define
+#define
+#endif
+
+#ifdef FREEDOM
+#endif
+
#define TRACE_MODE
//Turn on trace logging to the PC USB port
@@ -52,7 +65,7 @@
//Use second UART to communicate witb the Honneywell sensor
//Default UART setting are 8,N,1
-Serial sensor(PA_2, PA_3 , 9600);
+Serial sensor(D1, D0, 9600);
Timer t;
@@ -73,7 +86,7 @@
logTrace(*pointer);
counter--;
}
- if(count == 0) {
+ if(counter == 0) {
return;
}
}
@@ -92,13 +105,13 @@
sensor.putc(*pointer++);
counter--;
}
- if(count == 0) {
+ if(counter == 0) {
return;
}
}
}
-//Va;idate the received mesurements checksum
+//Validate the received mesurements checksum
bool checkValue(uint8_t *thebuf, uint8_t leng)
{
@@ -149,6 +162,8 @@
uint16_t PM01Value=0; //define PM1.0 value of the air detector module
uint16_t PM2_5Value=0; //define PM2.5 value of the air detector module
uint16_t PM10Value=0; //define PM10 value of the air detector module
+
+ pc.printf("Starting Honeywell Dust Sesor App version %s", VERSION);
//Send start command to the sensor
writeBuffer(measureCommand, 4);
@@ -169,15 +184,16 @@
return -2;
}
t.start();
-
+
//Start continous loop
- while(1)
+ uint32_t count = 0;
+ while(count++ < 4)
{
if(sensor.getc() == 0x42){ //start to read when detect 0x42
readBuffer(dataBuffer,MESSAGE_LEN -1);
if(dataBuffer[0] == 0x4d){
- if(checkValue(dataBuffer,MESSAGE_LEN)){
+ if(checkValue(dataBuffer,MESSAGE_LEN-1)){
PM01Value=transmitPM01(dataBuffer); //count PM1.0 value of the air detector module
PM2_5Value=transmitPM2_5(dataBuffer);//count PM2.5 value of the air detector module
PM10Value=transmitPM10(dataBuffer); //count PM10 value of the air detector module
@@ -213,4 +229,5 @@
}
}
+ pc.printf("Honeywell Dust Sensor exiting");
}
\ No newline at end of file