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: main.cpp
- Revision:
- 29:a7dd81450b35
- Parent:
- 28:315604f4b374
- Child:
- 30:77a30ea425da
--- a/main.cpp Mon Oct 11 23:11:33 2021 +0000
+++ b/main.cpp Thu Feb 03 02:32:05 2022 +0000
@@ -51,9 +51,9 @@
/*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*/
// define one and only one of the following three platforms
-//#define MAXM86146_CFG 1 // tested on MAXM86146EVSYS_sensorBrd+MAXM86161_ADAPTER_REVB+MAX32630FTHR 33.13.12
+#define MAXM86146_CFG 1 // tested on MAXM86146EVSYS_sensorBrd+MAXM86161_ADAPTER_REVB+MAX32630FTHR 33.13.12
//#define MAXREFDES103_CFG // not tested
-#define MAXM86161_CFG 1 // tested on MAXM86161+MAX32630FTHR v32.9.22, 32.13.12
+//#define MAXM86161_CFG 1 // tested on MAXM86161+MAX32630FTHR v32.9.22, 32.13.12
/*****************************************************************************/
/*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*/
@@ -84,9 +84,9 @@
#endif
/*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*/
-//#define RAW // define this if you only AFE+accel data, no algo
-#define ALGO_ONLY 1 // define this if you only want algo data, comment out if you want raw sensor+algo data
-//#define EXTENDED_ALGO 1 // define this if you want the extended algo format
+//#define RAW // define this if you only wnatAFE+accel data, no algorithm
+//#define ALGO_ONLY 1 // define this if you only want algo data, comment out if you want raw sensor+algo data
+#define EXTENDED_ALGO 1 // define this if you want the extended algo format
//#define AGC 1 // define this for AGC, otherwise the default is AEC
#ifdef MAXREFDES103_CFG
@@ -249,6 +249,7 @@
ptr = sptr + SENSOR_SZ;
#endif
+
#ifndef RAW
#ifdef EXTENDED_ALGO
// pc.printf("ptr %d ttlsiz %d ", ptr, TTL_SZ);
@@ -660,7 +661,7 @@
// init_sh_raw
/*****************************************************************************/
void init_sh_raw(void) {
- char cmd[8];
+ char cmd[16];
char rsp[256];
// switch to application mode
rst = 0;
@@ -707,16 +708,16 @@
// raw1.3 enable sh accel
cmd[0] = 0x44; cmd[1] = 0x04; cmd[2] = 0x01; cmd[3] = 0x00;
sh_i2c.write(SH_ADDR, cmd, 4);
- mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
+ mfio = 1; thread_sleep_for(20); mfio = 0; wait_us(300);
sh_i2c.read(SH_ADDR, rsp, 1);
- mfio = 1; thread_sleep_for(20); mfio = 0; wait_us(300);
+ mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
pc.printf("raw1.3 Status: %x\n\r", rsp[0]);
// raw1.4 enable AFE
cmd[0] = 0x44; cmd[1] = 0x00; cmd[2] = 0x01; cmd[3] = 0x00;
- sh_i2c.write(SH_ADDR, cmd, 4);
+ sh_i2c.write(SH_ADDR, cmd, 3);
+ mfio = 1; thread_sleep_for(250); mfio = 0; wait_us(300);
+ sh_i2c.read(SH_ADDR, rsp, 1);
mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
- sh_i2c.read(SH_ADDR, rsp, 1);
- mfio = 1; thread_sleep_for(250); mfio = 0; wait_us(300);
pc.printf("raw1.4 Status: %x\n\r", rsp[0]);
// raw1.5 sample rate 100 Hz, ave 1
cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x12; cmd[3] = 0x18; // set AFE reg 0x12 to 100 Hz
@@ -727,7 +728,7 @@
mfio = 1; mfio = 0; wait_us(300);
pc.printf("raw1.5 Status: %x\n\r", rsp[0]);
// raw1.6 LED1 current
- cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x23; cmd[3] = 0x7F;
+ cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x23; cmd[3] = 0x3F;
sh_i2c.write(SH_ADDR, cmd, 4);
mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
sh_i2c.read(SH_ADDR, rsp, 1);
@@ -826,7 +827,11 @@
Timer tmr1;
while (1) {
tmr1.start();
+#if defined(RAW)
+ if (tmr1.read_ms() >= 10) {
+#else
if (tmr1.read_ms() >= 40) {
+#endif
tmr1.reset();
read_sh_fifo();
if ((ledcnt++ % 50) == 0)