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: BME280 SI1145 mbed
Revision 3:07fd499e96b4, committed 2017-07-18
- Comitter:
- jonathanyost
- Date:
- Tue Jul 18 22:26:52 2017 +0000
- Parent:
- 2:dd4d53687372
- Child:
- 4:7335cd74f3bc
- Commit message:
- reading on an interrupt;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jul 18 20:34:59 2017 +0000
+++ b/main.cpp Tue Jul 18 22:26:52 2017 +0000
@@ -23,6 +23,9 @@
Timer t;
const char nodeID = '1';
+uint8_t rx_buffer[64];
+bool rx_flag = false;
+
// I/O Delarations
I2C i2c(I2C_SDA, I2C_SCL); // D4, D5
@@ -77,10 +80,17 @@
pc.baud(115200);
}
+void rx_read_callback(){
+ rx_flag = true;
+ pc.printf("%c", xb.getc());
+}
+
int main() {
initialize_serial_connections();
+ memset(rx_buffer, '\0', 64);
+ pc.printf("\n\rMic test 1-2, 1-2\n\r");
- pc.printf("\n\rMic test 1-2, 1-2\n\r");
+ xb.attach(&rx_read_callback, Serial::RxIrq);
// Attach the PIR function to interrupt
PIR_sensor.rise(&PIR);
@@ -101,6 +111,8 @@
int wait_times[32];
bool send_enable = false;
+
+ char read_char;
while(true){
//pc.printf("top of loop \r\n");
@@ -112,23 +124,19 @@
if(xb.writeable()){xb.printf("%c", pc_data);}
}
- // First Message: "id:1,____"
- // char test_char;
- // "123456789"
- // "12345 78 "
- /*
- while(true){
- //test_char = xb.getc();
+ if(rx_flag){
+ pc.printf("hello");
- //pc.printf("%c,%d\r\n", test_char, test_char);
- pc.printf("%c\r\n", xb.getc());
+ if(xb.readable()){
+ pc.printf("%c",xb.getc());
+ }
+ pc.printf("goodbye");
+ rx_flag = false;
}
- */
-
-
+ /*
if(xb.readable()){
pc.printf("=========================================\r\n");
@@ -185,6 +193,7 @@
pc.printf("*****************************************\r\n");
}
+ */
// Take in new measurements
// Read in values from the BME280 board