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:
- 9:df0c4e8a3097
- Parent:
- 8:efab0e415826
- Child:
- 10:db20118b7d32
--- a/peer_to_peer_example.cpp Tue Dec 05 23:33:16 2017 +0000
+++ b/peer_to_peer_example.cpp Wed Dec 06 00:04:04 2017 +0000
@@ -94,11 +94,13 @@
"2: Read converted values from Temperature ADT7410\n\r"
"3: Read raw values from Accelerometer ADXL372\n\r"
"4: Read raw values from Temperature ADT7410\n\r"
- "5: Initialize Accelerometer\n\r"
+ "5: Initialize Accelerometer with I2C\n\r"
"6: Reset Accelerometer\n\r"
"7: Send Temperature data\n\r"
"8: SPI Read values from Accelerometer ADXL372\n\r"
- "9: SPI reset for ADXL372\n\r");
+ "9: SPI reset for ADXL372\n\r"
+ "a: Initialize Accelerometer with SPI\n\r"
+ "b: Check data in status register with SPI\n\r");
}
@@ -382,6 +384,34 @@
BitBangSPIWrite(0x41, 0x52);
pc.printf("Done \n\r");
break;
+ case 97: // a: Initialize Accelerometer with SPI
+ BitBangSPIWrite(0x24, 0x01); // Turn on X
+ BitBangSPIWrite(0x26, 0x01); // Turn on Y
+ BitBangSPIWrite(0x28, 0x01); // Turn on Z
+ pc.printf("Done\n\r");
+ break;
+ case 98: // b: Check status with SPI
+ uint8_t statusData = BitBangSPIRead(0x04);
+
+ pc.printf("0x%x in status\n\r", statusData);
+ break;
+ case 99: // c: Perform self-test
+ uint8_t testResult;
+ BitBangSPIWrite(0x3F, 0x03); // put to fullbandwidth measurement mode and lpf enaled(0)
+
+ BitBangSPIWrite(0x40, 0x01); // start self test
+ testResult = BitBangSPIRead(0x40);
+ while(!(BitBangSPIRead(0x40) & 0x02)){}
+ wait(0.4);
+
+ testResult = BitBangSPIRead(0x40);
+
+ if(testResult & 0x04)
+ {
+ pc.printf("It passed \n\r");
+ }
+ pc.printf("0x%x\n\r", testResult);
+ break;
default:
printMenu();
break;
