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: ADXL362 mbed MPL3115A2
Revision 21:b85d1a4f0373, committed 2018-02-27
- Comitter:
- htdoughe
- Date:
- Tue Feb 27 14:35:58 2018 +0000
- Parent:
- 20:8d93acd1f8cd
- Child:
- 22:1cd3cb77ec07
- Commit message:
- maybe ok? computer will die and i forgot my charger so i'm pushing anyway
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Feb 23 17:46:12 2018 +0000
+++ b/main.cpp Tue Feb 27 14:35:58 2018 +0000
@@ -82,7 +82,7 @@
}
//map of register values and names for the adxl
-int mregids[34];
+char mregids[34];
char* mregnames[34];
//populating the map
void initmap() {
@@ -217,11 +217,11 @@
int in = s;
while(in < stop){
//get register name
- char * name = regnames[in]; //GET NAME
- ADXL362::ADXL362_register_t reg = (ADXL362::ADXL362_register_t) regids[in];
+ char * name = aregnames[in]; //GET NAME
+ ADXL362::ADXL362_register_t reg = (ADXL362::ADXL362_register_t) aregids[in];
uint8_t val = adxl362.read_reg(reg); //GET REG VAL
//print val
- printf("0x%01x: %s=0x%01x\r\n", regids[in], name, val);
+ printf("0x%01x: %s=0x%01x\r\n", aregids[in], name, val);
in++;
}
}
@@ -268,12 +268,32 @@
return -1;
}else{
//else do stuff
- if(WHOAMI IS NOT 0xC4){
- //return error
- printf("error: WHO_AM_I is not 0xC4; exiting\n\r");
+ char whoami = mpl115A2.read_reg(MPL3115A2::WHO_AM_I);
+ if(whoami != 0xC4){
+ printf("error: WHO_AM_I is not 0xC4; exiting\n");
return -1;
}else{
- //else do stuff again
+ //now do stuff
+ //if length == 0, send everything from s to end of registers
+ //else print from s to l
+ // formula : range = end - start - length
+ // area = start + range
+ int stop = 0;
+ if(l == 0){
+ stop = 34;
+ }else{
+ stop = s + l;
+ }
+ int in = s;
+ while(in < stop){
+ //get register name
+ char * name = mregnames[in]; //GET NAME
+ char reg = mregids[in];
+ char val = MPL3115A2::i2cRead(reg); //GET REG VAL
+ //print val
+ printf("0x%01x: %s=0x%01x\r\n", mregids[in], name, val);
+ in++;
+ }
}
}
}