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: libmDot-dev-mbed5-deprecated ISL29011
Fork of mdot-examples by
Diff: peer_to_peer_example.cpp
- Revision:
- 19:0799d6348449
- Parent:
- 18:0185bc4b9935
diff -r 0185bc4b9935 -r 0799d6348449 peer_to_peer_example.cpp
--- a/peer_to_peer_example.cpp Sun Dec 10 20:23:12 2017 +0000
+++ b/peer_to_peer_example.cpp Sun Dec 10 21:03:22 2017 +0000
@@ -70,8 +70,14 @@
const int DS7505s_Address_7bit = 0x48; // A0 set LOR, A1 set LOW, A2 set LOW
const int DS7505s_Address_8bit = DS7505s_Address_7bit << 1; // Same
+char * rawTempValues; // Could change to uint8_t, same for other char pointers
+uint16_t convertedTempValue; // Data values must be uint16_t for conversion and send prep
+int regAddress;
+
+uint16_t temperatureBuffer[20];
int counter = 0;
+bool takeTemperature = false;
//-------------------All prototype functions-----------------------//
void ADXL372Initialize(void);
@@ -142,10 +148,8 @@
}
////////////////////////////////////////////////////////////////////////////////
-void CriticalTemperatureInterrupt(void){
-
- pc.printf("HELLOOOO\n\r");
- counter++;
+void CriticalTemperatureInterrupt(void){
+ takeTemperature = true; // Take temperature because something happened
}
@@ -168,7 +172,7 @@
uint8_t frequency_band;
// Points to the returned char pointer from called functions
- char * rawTempValues; // Could change to uint8_t, same for other char pointers
+ //char * rawTempValues; // Could change to uint8_t, same for other char pointers
char Xmsb;
char Xlsb;
char Ymsb;
@@ -177,12 +181,13 @@
char Zlsb;
// Save converted values here
- uint16_t convertedTempValue; // Data values must be uint16_t for conversion and send prep
+ //uint16_t convertedTempValue; // Data values must be uint16_t for conversion and send prep
char *accelValues;
uint16_t XData;
uint16_t YData;
uint16_t ZData;
- int regAddress;
+
+ //int regAddress;
// Change baud rate in serial terminal to this value
pc.baud(115200);
@@ -314,6 +319,21 @@
char userInput = pc.getc();
while(1){
+
+ if(takeTemperature) // Interrupt will trigger this
+ {
+ for(int i = 0; i < sizeof(temperatureBuffer); ++i)
+ {
+ regAddress = 0x00;
+ rawTempValues = ADT7410Read(regAddress);
+ convertedTempValue = ((*(rawTempValues + 0) << 8) | *(rawTempValues + 1)) >> 3; // Combine the two bytes into
+ // a short int variable(16 bits), remove last 3 bits
+ temperatureBuffer[i] = convertedTempValue;
+ }
+ takeTemperature = !takeTemperature; // Flip back to false so it doesn't trigger again
+ }
+
+
// Create a vector of uint8_t elements to be sent later
std::vector<uint8_t> tx_data;
@@ -537,6 +557,10 @@
break;
case 104: // h: get count value
pc.printf("Count Value: %d\n\r", counter);
+ for(int i = 0; i < sizeof(temperatureBuffer); ++i)
+ {
+ pc.printf("0x%x \n\r", temperatureBuffer[i]);
+ }
break;
default:
printMenu();
