Example host software for the Maxim Integrated MAX20303 I2C wearable PMIC, power management IC. Hosted on the MAX32630FTHR.

Dependencies:   USBDevice max20303 max32630fthr

Fork of MAX20303_Wearable_PMIC_Activity_Tracker by David Jung

Committer:
phonemacro
Date:
Wed May 30 03:00:33 2018 +0000
Revision:
1:d9eb07545205
Parent:
0:9216b8a5fd16
Updated for documentation.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phonemacro 0:9216b8a5fd16 1 /*******************************************************************************
phonemacro 0:9216b8a5fd16 2 * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved.
phonemacro 0:9216b8a5fd16 3 *
phonemacro 0:9216b8a5fd16 4 * Permission is hereby granted, free of charge, to any person obtaining a
phonemacro 0:9216b8a5fd16 5 * copy of this software and associated documentation files (the "Software"),
phonemacro 0:9216b8a5fd16 6 * to deal in the Software without restriction, including without limitation
phonemacro 0:9216b8a5fd16 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
phonemacro 0:9216b8a5fd16 8 * and/or sell copies of the Software, and to permit persons to whom the
phonemacro 0:9216b8a5fd16 9 * Software is furnished to do so, subject to the following conditions:
phonemacro 0:9216b8a5fd16 10 *
phonemacro 0:9216b8a5fd16 11 * The above copyright notice and this permission notice shall be included
phonemacro 0:9216b8a5fd16 12 * in all copies or substantial portions of the Software.
phonemacro 0:9216b8a5fd16 13 *
phonemacro 0:9216b8a5fd16 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
phonemacro 0:9216b8a5fd16 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
phonemacro 0:9216b8a5fd16 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
phonemacro 0:9216b8a5fd16 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
phonemacro 0:9216b8a5fd16 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
phonemacro 0:9216b8a5fd16 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
phonemacro 0:9216b8a5fd16 20 * OTHER DEALINGS IN THE SOFTWARE.
phonemacro 0:9216b8a5fd16 21 *
phonemacro 0:9216b8a5fd16 22 * Except as contained in this notice, the name of Maxim Integrated
phonemacro 0:9216b8a5fd16 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
phonemacro 0:9216b8a5fd16 24 * Products, Inc. Branding Policy.
phonemacro 0:9216b8a5fd16 25 *
phonemacro 0:9216b8a5fd16 26 * The mere transfer of this software does not imply any licenses
phonemacro 0:9216b8a5fd16 27 * of trade secrets, proprietary technology, copyrights, patents,
phonemacro 0:9216b8a5fd16 28 * trademarks, maskwork rights, or any other form of intellectual
phonemacro 0:9216b8a5fd16 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
phonemacro 0:9216b8a5fd16 30 * ownership rights.
phonemacro 0:9216b8a5fd16 31 *******************************************************************************
phonemacro 0:9216b8a5fd16 32 */
phonemacro 0:9216b8a5fd16 33
phonemacro 0:9216b8a5fd16 34 #include "mbed.h"
phonemacro 0:9216b8a5fd16 35 #include "max32630fthr.h"
phonemacro 0:9216b8a5fd16 36 #include "MAX20303.h"
phonemacro 0:9216b8a5fd16 37
phonemacro 0:9216b8a5fd16 38 #include "USBSerial.h"
phonemacro 0:9216b8a5fd16 39
phonemacro 0:9216b8a5fd16 40 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
phonemacro 0:9216b8a5fd16 41
phonemacro 0:9216b8a5fd16 42 DigitalOut rLED(LED1);
phonemacro 0:9216b8a5fd16 43 DigitalOut gLED(LED2);
phonemacro 0:9216b8a5fd16 44 DigitalOut bLED(LED3);
phonemacro 0:9216b8a5fd16 45
phonemacro 0:9216b8a5fd16 46 I2C i2cBus(P3_4, P3_5);
phonemacro 0:9216b8a5fd16 47
phonemacro 0:9216b8a5fd16 48 MAX20303 max20303_pmic(&i2cBus);
phonemacro 0:9216b8a5fd16 49
phonemacro 0:9216b8a5fd16 50 // main() runs in its own thread in the OS
phonemacro 0:9216b8a5fd16 51 // (note the calls to Thread::wait below for delays)
phonemacro 1:d9eb07545205 52 /**
phonemacro 1:d9eb07545205 53 * @brief Sample main program for MAX30303
phonemacro 1:d9eb07545205 54 * @version 1.0000.0
phonemacro 1:d9eb07545205 55 *
phonemacro 1:d9eb07545205 56 * @details Sample main program for MAX30303
phonemacro 1:d9eb07545205 57 * The prints are sent to the terminal window (9600, 8n1).
phonemacro 1:d9eb07545205 58 * The program initializeds the LED to blue-green.
phonemacro 1:d9eb07545205 59 * If the program is successful at reading the hardware ID
phonemacro 1:d9eb07545205 60 * then it prints out a successful message, and if not, then
phonemacro 1:d9eb07545205 61 * it turns on the red LED.
phonemacro 1:d9eb07545205 62 * To run the program, drag and drop the .bin file into the
phonemacro 1:d9eb07545205 63 * DAPLINK folder. After it finishes flashing, cycle the power or
phonemacro 1:d9eb07545205 64 * reset the Pegasus after flashing by pressing the button on
phonemacro 1:d9eb07545205 65 * the Pegasus next to the battery connector or the button
phonemacro 1:d9eb07545205 66 * on the MAXREFDES100HDK.
phonemacro 1:d9eb07545205 67 */
phonemacro 0:9216b8a5fd16 68 int main()
phonemacro 0:9216b8a5fd16 69 {
phonemacro 0:9216b8a5fd16 70 char hwIdOk;
phonemacro 0:9216b8a5fd16 71
phonemacro 0:9216b8a5fd16 72 DigitalOut rLED(LED1, LED_OFF);
phonemacro 0:9216b8a5fd16 73 DigitalOut gLED(LED2, LED_OFF);
phonemacro 0:9216b8a5fd16 74 DigitalOut bLED(LED3, LED_OFF);
phonemacro 0:9216b8a5fd16 75
phonemacro 0:9216b8a5fd16 76 bLED = LED_ON;
phonemacro 0:9216b8a5fd16 77 gLED = LED_ON;
phonemacro 0:9216b8a5fd16 78
phonemacro 0:9216b8a5fd16 79 i2cBus.frequency(400000);
phonemacro 0:9216b8a5fd16 80
phonemacro 0:9216b8a5fd16 81 hwIdOk = max20303_pmic.CheckPMICHWID();
phonemacro 0:9216b8a5fd16 82 if (hwIdOk)
phonemacro 1:d9eb07545205 83 printf("Reading of the hardware ID is successful.\r\n");
phonemacro 0:9216b8a5fd16 84 else {
phonemacro 0:9216b8a5fd16 85 bLED = LED_OFF;
phonemacro 0:9216b8a5fd16 86 gLED = LED_OFF;
phonemacro 0:9216b8a5fd16 87 rLED = LED_ON;
phonemacro 1:d9eb07545205 88 }
phonemacro 0:9216b8a5fd16 89 }
phonemacro 0:9216b8a5fd16 90