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: lab7.cpp
- Revision:
- 7:f2c4408367f7
- Parent:
- 6:2568b22678fc
- Child:
- 8:ac1e388d4d1b
--- a/lab7.cpp Fri Mar 02 18:29:34 2018 +0000
+++ b/lab7.cpp Fri Mar 02 20:12:03 2018 +0000
@@ -30,12 +30,16 @@
int main() {
printf("\n\rMPL3115A2 test\n\r");
- mpl3115_reg_print(26, 2);
+ mpl3115_reg_print(0x26, 1);
// set control register 1 bit 7 to 1 (sets the pressure sensor to altimeter mode)
- uint8_t d;
- pressure_sensor.readRegs(0x26, &d, 1);
- d = d | 0b10000001;
- pressure_sensor.writeRegs(&d, 1);
+ uint8_t d[1];
+ //pressure_sensor.readRegs(0x26, d, 1);//0x26
+ //printf("d: %d\n\r",d[0]);
+ //d[0] = d[0] & 0b10000001;
+ //printf("d: %d\n\r",d[0]);
+ pressure_sensor.readRegs(0x26, d, 1);
+ d[0] = 0b10101001;
+ pressure_sensor.writeRegs(d, 1);
/* while(1) {
// don't overflow buffer
@@ -55,7 +59,7 @@
*/
printf("start\r\n");
- mpl3115_reg_print(0, 0);
+ mpl3115_reg_print(38, 5);
printf("finish\r\n");
return(0);
@@ -83,7 +87,7 @@
uint8_t data[1];
// print reg, name, val
- for(int i = start; i < l; i++) {
+ for(int i = start; i < (start + l); i++) {
// reading (1 byte its bit oriented)8-bits from each register
pressure_sensor.readRegs(i, data, 1);
//printf("0x%x\tregister: 0x%.2x\r\n", i, data[0]);