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 00:12:14 2018 +0000
Revision:
0:9216b8a5fd16
Child:
1:d9eb07545205
Initial commit for MAX20303 Wearable PMIC

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 0:9216b8a5fd16 52 int main()
phonemacro 0:9216b8a5fd16 53 {
phonemacro 0:9216b8a5fd16 54 int32_t value = 0;
phonemacro 0:9216b8a5fd16 55 int ret, i;
phonemacro 0:9216b8a5fd16 56 char hwIdOk;
phonemacro 0:9216b8a5fd16 57
phonemacro 0:9216b8a5fd16 58 DigitalOut rLED(LED1, LED_OFF);
phonemacro 0:9216b8a5fd16 59 DigitalOut gLED(LED2, LED_OFF);
phonemacro 0:9216b8a5fd16 60 DigitalOut bLED(LED3, LED_OFF);
phonemacro 0:9216b8a5fd16 61
phonemacro 0:9216b8a5fd16 62
phonemacro 0:9216b8a5fd16 63 bLED = LED_ON;
phonemacro 0:9216b8a5fd16 64 gLED = LED_ON;
phonemacro 0:9216b8a5fd16 65
phonemacro 0:9216b8a5fd16 66 i2cBus.frequency(400000);
phonemacro 0:9216b8a5fd16 67
phonemacro 0:9216b8a5fd16 68 hwIdOk = max20303_pmic.CheckPMICHWID();
phonemacro 0:9216b8a5fd16 69 if (hwIdOk)
phonemacro 0:9216b8a5fd16 70 printf("Reading of the hardware ID is okay.\r\n");
phonemacro 0:9216b8a5fd16 71 else {
phonemacro 0:9216b8a5fd16 72 bLED = LED_OFF;
phonemacro 0:9216b8a5fd16 73 gLED = LED_OFF;
phonemacro 0:9216b8a5fd16 74 rLED = LED_ON;
phonemacro 0:9216b8a5fd16 75 }
phonemacro 0:9216b8a5fd16 76
phonemacro 0:9216b8a5fd16 77 }
phonemacro 0:9216b8a5fd16 78