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:
- 2:7c190ac7f4d4
- Parent:
- 1:a46172536a3a
- Child:
- 3:9f3053336250
diff -r a46172536a3a -r 7c190ac7f4d4 lab7.cpp
--- a/lab7.cpp Tue Feb 27 00:38:48 2018 +0000
+++ b/lab7.cpp Tue Feb 27 15:49:35 2018 +0000
@@ -1,26 +1,51 @@
#include "mbed.h"
+#include <iostream>
#include <MPL3115.h>
// Interface pulled from MPL3115.cpp
// MPL3115::MPL3115(PinName sda, PinName scl) : MPL3115_i2c(sda,scl)
-MPL3115::MPL3115(PB_7, PB_6) : MPL3115_i2c(sda,scl);
+MPL3115 mpl3115(PB_7, PB_6);
int mpl3115_reg_print(int start, int length);
+void register_map(int i, int value);
int main() {
- mpl3115.config();
+ MPL3115 mpl3115_config();
printf("start\r\n");
- mpl3115_reg_print(0, 45);
+ mpl3115_reg_print(0, 0);
printf("finish\r\n");
-
+ return(0);
}
int mpl3115_reg_print(int start, int length) {
- return(0);
+ //if(mpl3115.read_reg(MPL3115::WHO_AM_I) != 0xC4) {
+ // printf("chip is not connected\r\n");
+ // return -1;
+ //}
+ printf("Success, chip is connected.\r\n");
+
+ int l = 0;
+ l = (length == 0? 46: length);
+
+ if(start < 0 || l > 46 || l < 0) {
+ printf("illegal input exception\r\n");
+ return -1;
+ }
+ /*
+ for(int i = start; i < l; i++) {
+ //printf();
+ register_map());
+ }*/
+
+ //printf("Reg Address %d: Register Name = %s", address, name)
+ return 0;
}
+
+
+
void register_map(int i, int value) {
//char* regi;
switch(i) {