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 Thread_Communication_V4_fortest by
Revision 4:93d6d13d4de3, committed 2017-12-14
- Comitter:
- GeorgeJourneaux
- Date:
- Thu Dec 14 20:02:48 2017 +0000
- Parent:
- 3:73497379c0cb
- Child:
- 5:ea3ec65cbf5f
- Commit message:
- Thread fix
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Dec 14 19:23:45 2017 +0000
+++ b/main.cpp Thu Dec 14 20:02:48 2017 +0000
@@ -1,6 +1,8 @@
#include "mbed.h"
#include "main.h"
+#define ENTER_KEY 1
+
LCD lcd(PD_15, PF_12, PF_13, PE_9, PF_14, PF_15);
BMP280 Sensor(D14, D15);
@@ -12,7 +14,6 @@
//Serial_CMD
volatile int rx_in=0;
char rx_line[80];
-int s_cmd = 0;
//Time date
time_t raw_time = time(NULL);
@@ -122,6 +123,7 @@
/*--------------------------------------------------------------------*/
/*------------------------------SERIAL_CMD----------------------------*/
+//Interrupt when recieving from serial port
void Rx_interrupt() {
while (pc.readable()) {
@@ -129,7 +131,7 @@
pc.putc(rx_line[rx_in]);
if(rx_line[rx_in] == 0xD){
- s_cmd = 1;
+ S_CMD.signal_set(ENTER_KEY);
}
else{
rx_in = (rx_in + 1);
@@ -137,10 +139,11 @@
}
}
+//Check what command what recieved and execute
void Serial_CMD(){
while(1){
- if(s_cmd == 1){
+ Thread::signal_wait(ENTER_KEY);
pc.attach(NULL, Serial::RxIrq);
struct tm * s_time;
@@ -219,9 +222,6 @@
rx_in = 0;
pc.attach(&Rx_interrupt, Serial::RxIrq);
- s_cmd = 0;
- }
- Thread::wait(5);
}
}
/*--------------------------------------------------------------------*/
\ No newline at end of file
