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

Dependencies:   USBDevice max32630fthr

Committer:
phonemacro
Date:
Wed May 30 23:34:01 2018 +0000
Revision:
0:76206161b30f
Example host software for the Maxim Integrated MAX14690 I2C wearable PMIC, power/charge management IC. Hosted on the MAX32630FTHR.

Who changed what in which revision?

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