FitGroup: Network of Hexiwear Fitness Watches for Group of Friends/Family
Dependencies: FXOS8700 Hexi_KW40Z Hexi_OLED_SSD1351 MAX30101
Fork of FINAL_FINAL_FINAL by
Revision 0:33686dd26bf9, committed 2018-05-30
- Comitter:
- xihan94
- Date:
- Wed May 30 10:40:47 2018 +0000
- Child:
- 1:ad1b075585bc
- Commit message:
- dev
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Wed May 30 10:40:47 2018 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MAX30101.lib Wed May 30 10:40:47 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/MaximIntegrated/code/MAX30101/#a450e384f57a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Wed May 30 10:40:47 2018 +0000 @@ -0,0 +1,57 @@ +# Getting started with Blinky on mbed OS + +This guide reviews the steps required to get Blinky working on an mbed OS platform. + +Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). + +## Import the example application + +From the command-line, import the example: + +``` +mbed import mbed-os-example-blinky +cd mbed-os-example-blinky +``` + +### Now compile + +Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5: + +``` +mbed compile -m K64F -t ARM +``` + +Your PC may take a few minutes to compile your code. At the end, you see the following result: + +``` +[snip] ++----------------------------+-------+-------+------+ +| Module | .text | .data | .bss | ++----------------------------+-------+-------+------+ +| Misc | 13939 | 24 | 1372 | +| core/hal | 16993 | 96 | 296 | +| core/rtos | 7384 | 92 | 4204 | +| features/FEATURE_IPV4 | 80 | 0 | 176 | +| frameworks/greentea-client | 1830 | 60 | 44 | +| frameworks/utest | 2392 | 512 | 292 | +| Subtotals | 42618 | 784 | 6384 | ++----------------------------+-------+-------+------+ +Allocated Heap: unknown +Allocated Stack: unknown +Total Static RAM memory (data + bss): 7168 bytes +Total RAM memory (data + bss + heap + stack): 7168 bytes +Total Flash memory (text + data + misc): 43402 bytes +Image: .\.build\K64F\ARM\mbed-os-example-blinky.bin +``` + +### Program your board + +1. Connect your mbed device to the computer over USB. +1. Copy the binary file to the mbed device. +1. Press the reset button to start the program. + +The LED on your platform turns on and off. + +## Troubleshooting + +If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed May 30 10:40:47 2018 +0000 @@ -0,0 +1,119 @@ +#include "mbed.h" +#include "mbed_events.h" +#include "MAX30101.h" + +#define FIFO_DATA_MAX 288 + +DigitalOut pwr1v8(PTA29); +DigitalOut pwr3v3b(PTB12); +I2C i2c0(PTB1, PTB0); +InterruptIn maximInterrupt(PTB18); +Serial pc(USBTX, USBRX); + +EventQueue evqueue(32 * EVENTS_EVENT_SIZE); +Thread t; + +MAX30101 hr(i2c0); + +void interruptHandlerQueued() { + + MAX30101::InterruptBitField_u interruptStatus; + hr.getInterruptStatus(interruptStatus); + printf("Interrupt Status: 0x%02x\r\n", interruptStatus.all); + + if (interruptStatus.bits.pwr_rdy == 0x1) { + printf("Powered on\r\n"); + + // Configure FIFO + MAX30101::FIFO_Configuration_u fifoConf; + hr.getFIFOConfiguration(fifoConf); + pc.printf("FIFO Configuration: 0x%02x\r\n", fifoConf.all); + + // Set LED power + hr.setLEDPulseAmplitude(MAX30101::LED1_PA, 0xFF); + pc.printf("LED set\r\n"); + + MAX30101::SpO2Configuration_u spo2Conf; + hr.getSpO2Configuration(spo2Conf); + pc.printf("SpO2 Configuration: 0x%02x\r\n", spo2Conf.all); + + // Enable HR mode + MAX30101::ModeConfiguration_u modeConf; + modeConf.all = 0; + modeConf.bits.mode = MAX30101::HeartRateMode; + hr.setModeConfiguration(modeConf); + printf("Mode set\r\n"); + } + + if (interruptStatus.bits.ppg_rdy == 0x1) { + printf("PPG Ready.\r\n"); + maximInterrupt.disable_irq(); + while (true) { + hr.getInterruptStatus(interruptStatus); + printf("Interrupt Status: 0x%02x\r\n", interruptStatus.all); + if (interruptStatus.bits.ppg_rdy == 0x1) { + uint8_t byte; + hr.readRegister(MAX30101::FIFO_DataRegister, byte); + printf("Read byte: %hhu\r\n", byte); + hr.readRegister(MAX30101::FIFO_DataRegister, byte); + printf("Read byte: %hhu\r\n", byte); + hr.readRegister(MAX30101::FIFO_DataRegister, byte); + printf("Read byte: %hhu\r\n", byte); + } + } + } + + if (interruptStatus.bits.a_full == 0x1) { + printf("FIFO Almost Full.\r\n"); +// uint8_t data[FIFO_DATA_MAX]; +// uint16_t readBytes = 0; +// hr.readFIFO(MAX30101::OneLedChannel, data, readBytes); +// printf("FIFO has %hu bytes of data\r\n", readBytes); +// +// for (uint16_t i = 0; i < readBytes; i += 3) { +// uint8_t sample[4] = {0}; +// memcpy(sample, data + i, 3); +// printf("Read data: %u\r\n", *(uint32_t *) sample); +// } + } + + interruptStatus.all = 0xFF; + hr.enableInterrupts(interruptStatus); +} + +void interruptHandler() { + evqueue.call(interruptHandlerQueued); +} + +// main() runs in its own thread in the OS +int main() { + printf("Hello world.\r\n"); + + t.start(callback(&evqueue, &EventQueue::dispatch_forever)); + + pwr1v8 = 1; + pwr3v3b = 1; + + maximInterrupt.fall(interruptHandler); + maximInterrupt.enable_irq(); + + MAX30101::InterruptBitField_u interruptStatus; + interruptStatus.all = 0xFF; + hr.enableInterrupts(interruptStatus); + +// MAX30101::FIFO_Configuration_u fifoConf; +// hr.getFIFOConfiguration(fifoConf); +// pc.printf("FIFO Configuration: 0x%02x\r\n", fifoConf.all); +// +// MAX30101::ModeConfiguration_u modeConf; +// hr.getModeConfiguration(modeConf); +// pc.printf("Mode Configuration: 0x%02x\r\n", modeConf.all); +// + +// while (true) { +// wait(1); +// printf("%d\r\n", maximInterrupt.read()); +// } + return 0; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Wed May 30 10:40:47 2018 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#367dbdf5145f4d6aa3e483c147fe7bda1ce23a36