MAX32620HSP (MAXREFDES100) RPC Example for Graphical User Interface

Dependencies:   USBDevice

Fork of HSP_Release by Jerry Bradshaw

This is an example program for the MAX32620HSP (MAXREFDES100 Health Sensor Platform). It demonstrates all the features of the platform and works with a companion graphical user interface (GUI) to help evaluate/configure/monitor the board. Go to the MAXREFDES100 product page and click on "design resources" to download the companion software. The GUI connects to the board through an RPC interface on a virtual serial port over the USB interface.

The RPC interface provides access to all the features of the board and is available to interface with other development environments such Matlab. This firmware provides realtime data streaming through the RPC interface over USB, and also provides the ability to log the data to flash for untethered battery operation. The data logging settings are configured through the GUI, and the GUI also provides the interface to download logged data.

Details on the RPC interface can be found here: HSP RPC Interface Documentation

Windows

With this program loaded, the MAX32620HSP will appear on your computer as a serial port. On Mac and Linux, this will happen by default. For Windows, you need to install a driver: HSP serial port windows driver

For more details about this platform and how to use it, see the MAXREFDES100 product page.

Committer:
jbradshaw
Date:
Fri Apr 21 12:12:30 2017 -0500
Revision:
1:9490836294ea
Parent:
0:e4a10ed6eb92
Child:
3:8e9b9f5818aa
Flash device is now fully utilized for datalog of sensor data

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jbradshaw 0:e4a10ed6eb92 1 /*******************************************************************************
jbradshaw 0:e4a10ed6eb92 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
jbradshaw 0:e4a10ed6eb92 3 *
jbradshaw 0:e4a10ed6eb92 4 * Permission is hereby granted, free of charge, to any person obtaining a
jbradshaw 0:e4a10ed6eb92 5 * copy of this software and associated documentation files (the "Software"),
jbradshaw 0:e4a10ed6eb92 6 * to deal in the Software without restriction, including without limitation
jbradshaw 0:e4a10ed6eb92 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
jbradshaw 0:e4a10ed6eb92 8 * and/or sell copies of the Software, and to permit persons to whom the
jbradshaw 0:e4a10ed6eb92 9 * Software is furnished to do so, subject to the following conditions:
jbradshaw 0:e4a10ed6eb92 10 *
jbradshaw 0:e4a10ed6eb92 11 * The above copyright notice and this permission notice shall be included
jbradshaw 0:e4a10ed6eb92 12 * in all copies or substantial portions of the Software.
jbradshaw 0:e4a10ed6eb92 13 *
jbradshaw 0:e4a10ed6eb92 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
jbradshaw 0:e4a10ed6eb92 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
jbradshaw 0:e4a10ed6eb92 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
jbradshaw 0:e4a10ed6eb92 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
jbradshaw 0:e4a10ed6eb92 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
jbradshaw 0:e4a10ed6eb92 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
jbradshaw 0:e4a10ed6eb92 20 * OTHER DEALINGS IN THE SOFTWARE.
jbradshaw 0:e4a10ed6eb92 21 *
jbradshaw 0:e4a10ed6eb92 22 * Except as contained in this notice, the name of Maxim Integrated
jbradshaw 0:e4a10ed6eb92 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
jbradshaw 0:e4a10ed6eb92 24 * Products, Inc. Branding Policy.
jbradshaw 0:e4a10ed6eb92 25 *
jbradshaw 0:e4a10ed6eb92 26 * The mere transfer of this software does not imply any licenses
jbradshaw 0:e4a10ed6eb92 27 * of trade secrets, proprietary technology, copyrights, patents,
jbradshaw 0:e4a10ed6eb92 28 * trademarks, maskwork rights, or any other form of intellectual
jbradshaw 0:e4a10ed6eb92 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
jbradshaw 0:e4a10ed6eb92 30 * ownership rights.
jbradshaw 0:e4a10ed6eb92 31 *******************************************************************************
jbradshaw 0:e4a10ed6eb92 32 */
jbradshaw 0:e4a10ed6eb92 33 #include "mbed.h"
jbradshaw 0:e4a10ed6eb92 34 #include "MAX14720.h"
jbradshaw 0:e4a10ed6eb92 35 #include "MAX30101.h"
jbradshaw 0:e4a10ed6eb92 36 #include "MAX30205.h"
jbradshaw 0:e4a10ed6eb92 37 #include "LIS2DH.h"
jbradshaw 0:e4a10ed6eb92 38 #include "USBSerial.h"
jbradshaw 0:e4a10ed6eb92 39 #include "RpcServer.h"
jbradshaw 0:e4a10ed6eb92 40 #include "StringInOut.h"
jbradshaw 0:e4a10ed6eb92 41 #include "Peripherals.h"
jbradshaw 0:e4a10ed6eb92 42 #include "BMP280.h"
jbradshaw 0:e4a10ed6eb92 43 #include "MAX30001.h"
jbradshaw 0:e4a10ed6eb92 44 #include "DataLoggingService.h"
jbradshaw 0:e4a10ed6eb92 45 #include "MAX30101_helper.h"
jbradshaw 0:e4a10ed6eb92 46 #include "S25FS512.h"
jbradshaw 0:e4a10ed6eb92 47 #include "QuadSpiInterface.h"
jbradshaw 0:e4a10ed6eb92 48 #include "PushButton.h"
jbradshaw 0:e4a10ed6eb92 49 #include "BLE.h"
jbradshaw 0:e4a10ed6eb92 50 #include "HspBLE.h"
jbradshaw 0:e4a10ed6eb92 51 #include "USBSerial.h"
jbradshaw 0:e4a10ed6eb92 52 #include "Streaming.h"
jbradshaw 0:e4a10ed6eb92 53
jbradshaw 0:e4a10ed6eb92 54 /// define the HVOUT Boost Voltage default for the MAX14720 PMIC
jbradshaw 0:e4a10ed6eb92 55 #define HVOUT_VOLTAGE 4500 // set to 4500 mV
jbradshaw 0:e4a10ed6eb92 56
jbradshaw 0:e4a10ed6eb92 57 /// define all I2C addresses
jbradshaw 0:e4a10ed6eb92 58 #define MAX30205_I2C_SLAVE_ADDR_TOP (0x92)
jbradshaw 0:e4a10ed6eb92 59 #define MAX30205_I2C_SLAVE_ADDR_BOTTOM (0x90)
jbradshaw 0:e4a10ed6eb92 60 #define MAX14720_I2C_SLAVE_ADDR (0x54)
jbradshaw 0:e4a10ed6eb92 61 #define BMP280_I2C_SLAVE_ADDR (0xEC)
jbradshaw 0:e4a10ed6eb92 62 #define MAX30101_I2C_SLAVE_ADDR (0xAE)
jbradshaw 0:e4a10ed6eb92 63 #define LIS2DH_I2C_SLAVE_ADDR (0x32)
jbradshaw 0:e4a10ed6eb92 64
jbradshaw 0:e4a10ed6eb92 65 ///
jbradshaw 0:e4a10ed6eb92 66 /// wire Interfaces
jbradshaw 0:e4a10ed6eb92 67 ///
jbradshaw 0:e4a10ed6eb92 68 /// Define with Maxim VID and a Maxim assigned PID, set to version 0x0001 and non-blocking
jbradshaw 0:e4a10ed6eb92 69 USBSerial usbSerial(0x0b6a, 0x0100, 0x0001, false);
jbradshaw 0:e4a10ed6eb92 70 /// I2C Master 1
jbradshaw 0:e4a10ed6eb92 71 I2C i2c1(I2C1_SDA, I2C1_SCL); // used by MAX30205 (1), MAX30205 (2), BMP280
jbradshaw 0:e4a10ed6eb92 72 /// I2C Master 2
jbradshaw 0:e4a10ed6eb92 73 I2C i2c2(I2C2_SDA, I2C2_SCL); // used by MAX14720, MAX30101, LIS2DH
jbradshaw 0:e4a10ed6eb92 74 /// SPI Master 0 with SPI0_SS for use with MAX30001
jbradshaw 0:e4a10ed6eb92 75 SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK, SPI0_SS); // used by MAX30001
jbradshaw 0:e4a10ed6eb92 76 /// SPI Master 1
jbradshaw 0:e4a10ed6eb92 77 QuadSpiInterface quadSpiInterface(SPI1_MOSI, SPI1_MISO, SPI1_SCK,
jbradshaw 0:e4a10ed6eb92 78 SPI1_SS); // used by S25FS512
jbradshaw 0:e4a10ed6eb92 79
jbradshaw 0:e4a10ed6eb92 80 ///
jbradshaw 0:e4a10ed6eb92 81 /// Devices
jbradshaw 0:e4a10ed6eb92 82 ///
jbradshaw 0:e4a10ed6eb92 83 /// Pressure Sensor
jbradshaw 0:e4a10ed6eb92 84 BMP280 bmp280(&i2c1, BMP280_I2C_SLAVE_ADDR);
jbradshaw 0:e4a10ed6eb92 85 /// Top Local Temperature Sensor
jbradshaw 0:e4a10ed6eb92 86 MAX30205 MAX30205_top(&i2c1, MAX30205_I2C_SLAVE_ADDR_TOP);
jbradshaw 0:e4a10ed6eb92 87 /// Bottom Local Temperature Sensor
jbradshaw 0:e4a10ed6eb92 88 MAX30205 MAX30205_bottom(&i2c1, MAX30205_I2C_SLAVE_ADDR_BOTTOM);
jbradshaw 0:e4a10ed6eb92 89 /// Accelerometer
jbradshaw 0:e4a10ed6eb92 90 LIS2DH lis2dh(&i2c2, LIS2DH_I2C_SLAVE_ADDR);
jbradshaw 0:e4a10ed6eb92 91 InterruptIn lis2dh_Interrupt(P4_7);
jbradshaw 0:e4a10ed6eb92 92 /// PMIC
jbradshaw 0:e4a10ed6eb92 93 MAX14720 max14720(&i2c2, MAX14720_I2C_SLAVE_ADDR);
jbradshaw 0:e4a10ed6eb92 94 /// Optical Oximeter
jbradshaw 0:e4a10ed6eb92 95 MAX30101 max30101(&i2c2, MAX30101_I2C_SLAVE_ADDR);
jbradshaw 0:e4a10ed6eb92 96 InterruptIn max30101_Interrupt(P4_0);
jbradshaw 0:e4a10ed6eb92 97 /// External Flash
jbradshaw 0:e4a10ed6eb92 98 S25FS512 s25fs512(&quadSpiInterface);
jbradshaw 0:e4a10ed6eb92 99 /// ECG device
jbradshaw 0:e4a10ed6eb92 100 MAX30001 max30001(&spi);
jbradshaw 0:e4a10ed6eb92 101 InterruptIn max30001_InterruptB(P3_6);
jbradshaw 0:e4a10ed6eb92 102 InterruptIn max30001_Interrupt2B(P4_5);
jbradshaw 0:e4a10ed6eb92 103 /// PWM used as fclk for the MAX30001
jbradshaw 0:e4a10ed6eb92 104 PwmOut pwmout(P1_7);
jbradshaw 0:e4a10ed6eb92 105 /// HSP platform LED
jbradshaw 0:e4a10ed6eb92 106 HspLed hspLed(LED_RED);
jbradshaw 0:e4a10ed6eb92 107 /// Packet TimeStamp Timer, set for 1uS
jbradshaw 0:e4a10ed6eb92 108 Timer timestampTimer;
jbradshaw 0:e4a10ed6eb92 109 /// HSP Platform push button
jbradshaw 0:e4a10ed6eb92 110 PushButton pushButton(SW1);
jbradshaw 0:e4a10ed6eb92 111
jbradshaw 0:e4a10ed6eb92 112 /// BLE instance
jbradshaw 0:e4a10ed6eb92 113 static BLE ble;
jbradshaw 0:e4a10ed6eb92 114
jbradshaw 0:e4a10ed6eb92 115 /// HSP BluetoothLE specific functions
jbradshaw 0:e4a10ed6eb92 116 HspBLE hspBLE(&ble);
jbradshaw 1:9490836294ea 117 USBSerial *usbSerialPtr;
jbradshaw 0:e4a10ed6eb92 118
jbradshaw 0:e4a10ed6eb92 119 int main() {
jbradshaw 0:e4a10ed6eb92 120 // hold results for returning funtcoins
jbradshaw 0:e4a10ed6eb92 121 int result;
jbradshaw 0:e4a10ed6eb92 122 // local input state of the RPC
jbradshaw 0:e4a10ed6eb92 123 int inputState;
jbradshaw 0:e4a10ed6eb92 124 // RPC request buffer
jbradshaw 0:e4a10ed6eb92 125 char request[128];
jbradshaw 0:e4a10ed6eb92 126 // RPC reply buffer
jbradshaw 0:e4a10ed6eb92 127 char reply[128];
jbradshaw 0:e4a10ed6eb92 128
jbradshaw 0:e4a10ed6eb92 129 // display start banner
jbradshaw 0:e4a10ed6eb92 130 printf("Maxim Integrated mbed hSensor 3.0.0 10/14/16\n");
jbradshaw 0:e4a10ed6eb92 131 fflush(stdout);
jbradshaw 0:e4a10ed6eb92 132
jbradshaw 0:e4a10ed6eb92 133 // initialize HVOUT on the MAX14720 PMIC
jbradshaw 0:e4a10ed6eb92 134 printf("Init MAX14720...\n");
jbradshaw 0:e4a10ed6eb92 135 fflush(stdout);
jbradshaw 0:e4a10ed6eb92 136 result = max14720.init();
jbradshaw 0:e4a10ed6eb92 137 if (result == MAX14720_ERROR)
jbradshaw 0:e4a10ed6eb92 138 printf("Error initializing MAX14720");
jbradshaw 0:e4a10ed6eb92 139 max14720.boostEn = MAX14720::BOOST_ENABLED;
jbradshaw 0:e4a10ed6eb92 140 max14720.boostSetVoltage(HVOUT_VOLTAGE);
jbradshaw 0:e4a10ed6eb92 141
jbradshaw 0:e4a10ed6eb92 142 // turn on red led
jbradshaw 0:e4a10ed6eb92 143 printf("Init HSPLED...\n");
jbradshaw 0:e4a10ed6eb92 144 fflush(stdout);
jbradshaw 0:e4a10ed6eb92 145 hspLed.on();
jbradshaw 0:e4a10ed6eb92 146
jbradshaw 0:e4a10ed6eb92 147 // set NVIC priorities for GPIO to prevent priority inversion
jbradshaw 0:e4a10ed6eb92 148 printf("Init NVIC Priorities...\n");
jbradshaw 0:e4a10ed6eb92 149 fflush(stdout);
jbradshaw 0:e4a10ed6eb92 150 NVIC_SetPriority(GPIO_P0_IRQn, 5);
jbradshaw 0:e4a10ed6eb92 151 NVIC_SetPriority(GPIO_P1_IRQn, 5);
jbradshaw 0:e4a10ed6eb92 152 NVIC_SetPriority(GPIO_P2_IRQn, 5);
jbradshaw 0:e4a10ed6eb92 153 NVIC_SetPriority(GPIO_P3_IRQn, 5);
jbradshaw 0:e4a10ed6eb92 154 NVIC_SetPriority(GPIO_P4_IRQn, 5);
jbradshaw 0:e4a10ed6eb92 155 NVIC_SetPriority(GPIO_P5_IRQn, 5);
jbradshaw 0:e4a10ed6eb92 156 NVIC_SetPriority(GPIO_P6_IRQn, 5);
jbradshaw 0:e4a10ed6eb92 157 // used by the MAX30001
jbradshaw 0:e4a10ed6eb92 158 NVIC_SetPriority(SPI1_IRQn, 0);
jbradshaw 0:e4a10ed6eb92 159
jbradshaw 0:e4a10ed6eb92 160 // Be able to statically reference these devices anywhere in the application
jbradshaw 0:e4a10ed6eb92 161 Peripherals::setS25FS512(&s25fs512);
jbradshaw 0:e4a10ed6eb92 162 Peripherals::setMAX30205_top(&MAX30205_top);
jbradshaw 0:e4a10ed6eb92 163 Peripherals::setMAX30205_bottom(&MAX30205_bottom);
jbradshaw 0:e4a10ed6eb92 164 Peripherals::setBMP280(&bmp280);
jbradshaw 0:e4a10ed6eb92 165 Peripherals::setLIS2DH(&lis2dh);
jbradshaw 1:9490836294ea 166 //Peripherals::setUSBSerial(&usbSerial);
jbradshaw 0:e4a10ed6eb92 167 Peripherals::setTimestampTimer(&timestampTimer);
jbradshaw 0:e4a10ed6eb92 168 Peripherals::setHspLed(&hspLed);
jbradshaw 0:e4a10ed6eb92 169 Peripherals::setMAX30101(&max30101);
jbradshaw 0:e4a10ed6eb92 170 Peripherals::setI2c1(&i2c1);
jbradshaw 0:e4a10ed6eb92 171 Peripherals::setI2c2(&i2c2);
jbradshaw 0:e4a10ed6eb92 172 Peripherals::setPushButton(&pushButton);
jbradshaw 0:e4a10ed6eb92 173 Peripherals::setBLE(&ble);
jbradshaw 0:e4a10ed6eb92 174 Peripherals::setMAX14720(&max14720);
jbradshaw 0:e4a10ed6eb92 175 Peripherals::setMAX30001(&max30001);
jbradshaw 0:e4a10ed6eb92 176 Peripherals::setHspBLE(&hspBLE);
jbradshaw 1:9490836294ea 177 usbSerialPtr = &usbSerial;
jbradshaw 0:e4a10ed6eb92 178
jbradshaw 0:e4a10ed6eb92 179 // init the S25FS256 external flash device
jbradshaw 0:e4a10ed6eb92 180 printf("Init S25FS512...\n");
jbradshaw 0:e4a10ed6eb92 181 fflush(stdout);
jbradshaw 0:e4a10ed6eb92 182 s25fs512.init();
jbradshaw 0:e4a10ed6eb92 183
jbradshaw 0:e4a10ed6eb92 184 // init the BMP280
jbradshaw 0:e4a10ed6eb92 185 printf("Init BMP280...\n");
jbradshaw 0:e4a10ed6eb92 186 fflush(stdout);
jbradshaw 0:e4a10ed6eb92 187 bmp280.init(BMP280::OVERSAMPLING_X2_P, BMP280::OVERSAMPLING_X1_T,
jbradshaw 0:e4a10ed6eb92 188 BMP280::FILT_OFF, BMP280::NORMAL_MODE, BMP280::T_62_5);
jbradshaw 0:e4a10ed6eb92 189
jbradshaw 0:e4a10ed6eb92 190 // Initialize BLE base layer
jbradshaw 0:e4a10ed6eb92 191 printf("Init HSPBLE...\n");
jbradshaw 0:e4a10ed6eb92 192 fflush(stdout);
jbradshaw 0:e4a10ed6eb92 193 hspBLE.init();
jbradshaw 0:e4a10ed6eb92 194
jbradshaw 0:e4a10ed6eb92 195 // start blinking led1
jbradshaw 0:e4a10ed6eb92 196 printf("Init HSPLED Blink...\n");
jbradshaw 0:e4a10ed6eb92 197 fflush(stdout);
jbradshaw 0:e4a10ed6eb92 198 hspLed.blink(1000);
jbradshaw 0:e4a10ed6eb92 199
jbradshaw 0:e4a10ed6eb92 200 // MAX30101 initialize interrupt
jbradshaw 0:e4a10ed6eb92 201 printf("Init MAX30101 callbacks, interrupt...\n");
jbradshaw 0:e4a10ed6eb92 202 fflush(stdout);
jbradshaw 0:e4a10ed6eb92 203 max30101.onInterrupt(&MAX30101_OnInterrupt);
jbradshaw 0:e4a10ed6eb92 204 max30101.onDataAvailable(&StreamPacketUint32);
jbradshaw 1:9490836294ea 205 max30101_Interrupt.fall(&MAX30101::MidIntHandler);
jbradshaw 0:e4a10ed6eb92 206
jbradshaw 0:e4a10ed6eb92 207 //
jbradshaw 0:e4a10ed6eb92 208 // MAX30001
jbradshaw 0:e4a10ed6eb92 209 //
jbradshaw 0:e4a10ed6eb92 210 printf("Init MAX30001 callbacks, interrupts...\n");
jbradshaw 0:e4a10ed6eb92 211 fflush(stdout);
jbradshaw 0:e4a10ed6eb92 212 max30001_InterruptB.disable_irq();
jbradshaw 0:e4a10ed6eb92 213 max30001_Interrupt2B.disable_irq();
jbradshaw 0:e4a10ed6eb92 214 max30001_InterruptB.mode(PullUp);
jbradshaw 1:9490836294ea 215 max30001_InterruptB.fall(&MAX30001::Mid_IntB_Handler);
jbradshaw 0:e4a10ed6eb92 216 max30001_Interrupt2B.mode(PullUp);
jbradshaw 1:9490836294ea 217 max30001_Interrupt2B.fall(&MAX30001::Mid_Int2B_Handler);
jbradshaw 0:e4a10ed6eb92 218 max30001_InterruptB.enable_irq();
jbradshaw 0:e4a10ed6eb92 219 max30001_Interrupt2B.enable_irq();
jbradshaw 1:9490836294ea 220 max30001.AllowInterrupts(1);
jbradshaw 0:e4a10ed6eb92 221 // Configuring the FCLK for the ECG, set to 32.768KHZ
jbradshaw 0:e4a10ed6eb92 222 printf("Init MAX30001 PWM...\n");
jbradshaw 0:e4a10ed6eb92 223 fflush(stdout);
jbradshaw 1:9490836294ea 224 //pwmout.period_us(31);
jbradshaw 1:9490836294ea 225 //pwmout.write(0.5); // 0-1 is 0-100%, 0.5 = 50% duty cycle.
jbradshaw 1:9490836294ea 226 max30001.FCLK_MaximOnly(); // mbed does not provide the resolution necessary, so for now we have a specific solution...
jbradshaw 1:9490836294ea 227 max30001.sw_rst(); // Do a software reset of the MAX30001
jbradshaw 1:9490836294ea 228 max30001.INT_assignment(MAX30001::MAX30001_INT_B, MAX30001::MAX30001_NO_INT, MAX30001::MAX30001_NO_INT, // en_enint_loc, en_eovf_loc, en_fstint_loc,
jbradshaw 0:e4a10ed6eb92 229 MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_NO_INT, // en_dcloffint_loc, en_bint_loc, en_bovf_loc,
jbradshaw 0:e4a10ed6eb92 230 MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_NO_INT, // en_bover_loc, en_bundr_loc, en_bcgmon_loc,
jbradshaw 0:e4a10ed6eb92 231 MAX30001::MAX30001_INT_B, MAX30001::MAX30001_NO_INT, MAX30001::MAX30001_NO_INT, // en_pint_loc, en_povf_loc, en_pedge_loc,
jbradshaw 0:e4a10ed6eb92 232 MAX30001::MAX30001_INT_2B, MAX30001::MAX30001_INT_B, MAX30001::MAX30001_NO_INT, // en_lonint_loc, en_rrint_loc, en_samp_loc,
jbradshaw 0:e4a10ed6eb92 233 MAX30001::MAX30001_INT_ODNR, MAX30001::MAX30001_INT_ODNR); // intb_Type, int2b_Type)
jbradshaw 0:e4a10ed6eb92 234 max30001.onDataAvailable(&StreamPacketUint32);
jbradshaw 0:e4a10ed6eb92 235
jbradshaw 0:e4a10ed6eb92 236 // initialize the LIS2DH accelerometer and interrupts
jbradshaw 0:e4a10ed6eb92 237 printf("Init LIS2DH interrupt...\n");
jbradshaw 0:e4a10ed6eb92 238 fflush(stdout);
jbradshaw 0:e4a10ed6eb92 239 lis2dh.init();
jbradshaw 0:e4a10ed6eb92 240 lis2dh_Interrupt.fall(&LIS2DHIntHandler);
jbradshaw 0:e4a10ed6eb92 241 lis2dh_Interrupt.mode(PullUp);
jbradshaw 0:e4a10ed6eb92 242 // initialize the RPC server
jbradshaw 0:e4a10ed6eb92 243 printf("Init RPC Server...\n");
jbradshaw 0:e4a10ed6eb92 244 fflush(stdout);
jbradshaw 0:e4a10ed6eb92 245 RPC_init();
jbradshaw 0:e4a10ed6eb92 246 // initialize the logging service
jbradshaw 0:e4a10ed6eb92 247 printf("Init LoggingService...\n");
jbradshaw 0:e4a10ed6eb92 248 fflush(stdout);
jbradshaw 0:e4a10ed6eb92 249 LoggingService_Init();
jbradshaw 0:e4a10ed6eb92 250
jbradshaw 0:e4a10ed6eb92 251 // start main loop
jbradshaw 0:e4a10ed6eb92 252 printf("Start main loop...\n");
jbradshaw 0:e4a10ed6eb92 253 fflush(stdout);
jbradshaw 0:e4a10ed6eb92 254 while (1) {
jbradshaw 0:e4a10ed6eb92 255 // get a RPC string if one is available
jbradshaw 0:e4a10ed6eb92 256 inputState = getLine(request, sizeof(request));
jbradshaw 0:e4a10ed6eb92 257 // if a string has been captured, process string
jbradshaw 0:e4a10ed6eb92 258 if (inputState == GETLINE_DONE) {
jbradshaw 0:e4a10ed6eb92 259 // process the RPC string
jbradshaw 0:e4a10ed6eb92 260 RPC_call(request, reply);
jbradshaw 0:e4a10ed6eb92 261 // output the reply
jbradshaw 0:e4a10ed6eb92 262 putStr(reply);
jbradshaw 0:e4a10ed6eb92 263 }
jbradshaw 0:e4a10ed6eb92 264 // process any logging or streaming requests
jbradshaw 0:e4a10ed6eb92 265 LoggingService_ServiceRoutine();
jbradshaw 0:e4a10ed6eb92 266 // allow for ble processing
jbradshaw 0:e4a10ed6eb92 267 ble.waitForEvent();
jbradshaw 0:e4a10ed6eb92 268 }
jbradshaw 0:e4a10ed6eb92 269 }