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