Fork of MAX32630FTHR utilities library

Dependencies:   MAX14690

Dependents:   MAX32630FTHR_BALANCE_BOT MAX32630FTHR_iButton_uSD_Logger MAX32630FTHR_DS18B20_uSD_Logger MAX32630FTHR_BALANCE_BOT

Fork of max32630fthr by Greg Steiert

Committer:
j3
Date:
Wed Dec 14 23:51:19 2016 +0000
Revision:
11:54d31920a9b5
Parent:
8:69740ee6903a
removed IMU lib

Who changed what in which revision?

UserRevisionLine numberNew contents of line
switches 1:15e34492fbf1 1 /*******************************************************************************
switches 1:15e34492fbf1 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
switches 1:15e34492fbf1 3 *
switches 1:15e34492fbf1 4 * Permission is hereby granted, free of charge, to any person obtaining a
switches 1:15e34492fbf1 5 * copy of this software and associated documentation files (the "Software"),
switches 1:15e34492fbf1 6 * to deal in the Software without restriction, including without limitation
switches 1:15e34492fbf1 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
switches 1:15e34492fbf1 8 * and/or sell copies of the Software, and to permit persons to whom the
switches 1:15e34492fbf1 9 * Software is furnished to do so, subject to the following conditions:
switches 1:15e34492fbf1 10 *
switches 1:15e34492fbf1 11 * The above copyright notice and this permission notice shall be included
switches 1:15e34492fbf1 12 * in all copies or substantial portions of the Software.
switches 1:15e34492fbf1 13 *
switches 1:15e34492fbf1 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
switches 1:15e34492fbf1 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
switches 1:15e34492fbf1 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
switches 1:15e34492fbf1 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
switches 1:15e34492fbf1 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
switches 1:15e34492fbf1 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
switches 1:15e34492fbf1 20 * OTHER DEALINGS IN THE SOFTWARE.
switches 1:15e34492fbf1 21 *
switches 1:15e34492fbf1 22 * Except as contained in this notice, the name of Maxim Integrated
switches 1:15e34492fbf1 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
switches 1:15e34492fbf1 24 * Products, Inc. Branding Policy.
switches 1:15e34492fbf1 25 *
switches 1:15e34492fbf1 26 * The mere transfer of this software does not imply any licenses
switches 1:15e34492fbf1 27 * of trade secrets, proprietary technology, copyrights, patents,
switches 1:15e34492fbf1 28 * trademarks, maskwork rights, or any other form of intellectual
switches 1:15e34492fbf1 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
switches 1:15e34492fbf1 30 * ownership rights.
switches 1:15e34492fbf1 31 *******************************************************************************
switches 1:15e34492fbf1 32 */
j3 6:92b485e70885 33
switches 1:15e34492fbf1 34
switches 1:15e34492fbf1 35 #ifndef _MAX32630FTHR_H_
switches 1:15e34492fbf1 36 #define _MAX32630FTHR_H_
switches 1:15e34492fbf1 37
j3 6:92b485e70885 38
switches 1:15e34492fbf1 39 #include "mbed.h"
switches 1:15e34492fbf1 40 #include "MAX14690.h"
switches 1:15e34492fbf1 41
j3 6:92b485e70885 42
switches 2:7a1d7d6d520e 43 /**
switches 2:7a1d7d6d520e 44 * @brief MAX32630FTHR Board Support Library
switches 2:7a1d7d6d520e 45 *
switches 2:7a1d7d6d520e 46 * @details The MAX32630FTHR is a rapid development application board for
j3 3:b735212d2fe5 47 * ultra low power wearable applications. It includes common peripherals and
j3 3:b735212d2fe5 48 * expansion connectors all power optimized for getting the longest life from
switches 2:7a1d7d6d520e 49 * the battery. This library configures the power and I/O for the board.
switches 2:7a1d7d6d520e 50 * <br>https://www.maximintegrated.com/max32630fthr
switches 2:7a1d7d6d520e 51 *
switches 2:7a1d7d6d520e 52 * @code
switches 2:7a1d7d6d520e 53 * #include "mbed.h"
switches 2:7a1d7d6d520e 54 * #include "max32630fthr.h"
j3 3:b735212d2fe5 55 *
switches 2:7a1d7d6d520e 56 * DigitalOut led1(LED1);
switches 2:7a1d7d6d520e 57 * MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
j3 3:b735212d2fe5 58 *
switches 2:7a1d7d6d520e 59 * // main() runs in its own thread in the OS
switches 2:7a1d7d6d520e 60 * // (note the calls to Thread::wait below for delays)
switches 2:7a1d7d6d520e 61 * int main()
switches 2:7a1d7d6d520e 62 * {
switches 2:7a1d7d6d520e 63 * // initialize power and I/O on MAX32630FTHR board
switches 2:7a1d7d6d520e 64 * pegasus.init();
j3 3:b735212d2fe5 65 *
switches 2:7a1d7d6d520e 66 * while (true) {
switches 2:7a1d7d6d520e 67 * led1 = !led1;
switches 2:7a1d7d6d520e 68 * Thread::wait(500);
switches 2:7a1d7d6d520e 69 * }
switches 2:7a1d7d6d520e 70 * }
switches 2:7a1d7d6d520e 71 * @endcode
switches 2:7a1d7d6d520e 72 */
switches 1:15e34492fbf1 73 class MAX32630FTHR
switches 1:15e34492fbf1 74 {
switches 1:15e34492fbf1 75 public:
switches 0:8926602da648 76
j3 6:92b485e70885 77 // max32630fthr configuration utilities
j3 6:92b485e70885 78
j3 6:92b485e70885 79 ///@brief IoVoltage
j3 6:92b485e70885 80 ///@details Enumerated options for operating voltage
j3 6:92b485e70885 81 enum IoVoltage
j3 6:92b485e70885 82 {
switches 1:15e34492fbf1 83 VIO_1V8 = 0x00, ///< 1.8V IO voltage at headers (from BUCK2)
j3 6:92b485e70885 84 VIO_3V3 = 0x01 ///< 3.3V IO voltage at headers (from LDO2)
j3 6:92b485e70885 85 };
j3 6:92b485e70885 86
switches 1:15e34492fbf1 87
j3 6:92b485e70885 88 ///@brief MAX32630FTHR constructor..\n
j3 6:92b485e70885 89 ///
j3 6:92b485e70885 90 ///On Entry:
j3 6:92b485e70885 91 ///@param[in] vio - I/O voltage for header pins
j3 6:92b485e70885 92 ///
j3 6:92b485e70885 93 ///On Exit:
j3 6:92b485e70885 94 ///@param[out] none
j3 6:92b485e70885 95 ///
j3 6:92b485e70885 96 ///@returns none
j3 8:69740ee6903a 97 MAX32630FTHR();
j3 6:92b485e70885 98
j3 6:92b485e70885 99
j3 6:92b485e70885 100 ///@brief MAX32630FTHR destructor..\n
j3 6:92b485e70885 101 ///
j3 6:92b485e70885 102 ///On Entry:
j3 6:92b485e70885 103 ///@param[in] none
j3 6:92b485e70885 104 ///
j3 6:92b485e70885 105 ///On Exit:
j3 6:92b485e70885 106 ///@param[out] none
j3 6:92b485e70885 107 ///
j3 6:92b485e70885 108 ///@returns none
j3 6:92b485e70885 109 ~MAX32630FTHR(){ };
switches 0:8926602da648 110
j3 6:92b485e70885 111
j3 6:92b485e70885 112 ///@brief Initialize MAX32630FTHR board.\n
j3 6:92b485e70885 113 ///@details Initializes PMIC and I/O on MAX32630FTHR board.\n
j3 6:92b485e70885 114 ///Configures PMIC to enable LDO2 and LDO3 at 3.3V.
j3 6:92b485e70885 115 ///Disables resisitive pulldown on MON(AIN_0).\n
j3 6:92b485e70885 116 ///Sets default I/O voltages to 3V3 for micro SD card.\n
j3 6:92b485e70885 117 ///Sets I/O voltage for header pins to hdrVio specified.\n
j3 6:92b485e70885 118 ///
j3 6:92b485e70885 119 ///On Entry:
j3 6:92b485e70885 120 ///@param[in] none
j3 6:92b485e70885 121 ///
j3 6:92b485e70885 122 ///On Exit:
j3 6:92b485e70885 123 ///@param[out] none
j3 6:92b485e70885 124 ///
j3 6:92b485e70885 125 ///@returns 0 if no errors, -1 if error.
j3 8:69740ee6903a 126 int32_t init(IoVoltage vio);
j3 6:92b485e70885 127
switches 1:15e34492fbf1 128
j3 6:92b485e70885 129 ///@brief Sets I/O Voltage.\n
j3 6:92b485e70885 130 ///@details Sets the voltage rail to be used for a given pin.\n
j3 6:92b485e70885 131 ///VIO_1V8 selects VDDIO which is supplied by Buck2, which is set at 1.8V,\n
j3 6:92b485e70885 132 ///VIO_3V3 selects VDDIOH which is supplied by LDO2, which is typically 3.3V.
j3 6:92b485e70885 133 ///On Entry:
j3 6:92b485e70885 134 ///@param[in] pin - Pin whose voltage supply is being assigned.
j3 6:92b485e70885 135 ///@param[in] vio - Voltage rail to be used for specified pin.
j3 6:92b485e70885 136 ///
j3 6:92b485e70885 137 ///On Exit:
j3 6:92b485e70885 138 ///@param[out] none
j3 6:92b485e70885 139 ///
j3 6:92b485e70885 140 ///@returns 0 if no errors, -1 if error.
j3 6:92b485e70885 141 int32_t vddioh(PinName pin, IoVoltage vio);
j3 6:92b485e70885 142
j3 6:92b485e70885 143
j3 6:92b485e70885 144 ///@brief Gets battery voltage as float.\n
j3 6:92b485e70885 145 ///
j3 6:92b485e70885 146 ///On Entry:
j3 6:92b485e70885 147 ///@param[in] battVolts - pointer to float for storing battery voltage
j3 6:92b485e70885 148 ///
j3 6:92b485e70885 149 ///On Exit:
j3 6:92b485e70885 150 ///@param[out] battVolts - holds battery voltage on success
j3 6:92b485e70885 151 ///
j3 6:92b485e70885 152 ///@returns 0 if no errors, -1 if error.
j3 6:92b485e70885 153 int32_t getBatteryVoltage(float *battVolts);
j3 6:92b485e70885 154
j3 7:9157b152011b 155
j3 7:9157b152011b 156 ///@brief Gets system voltage voltage as float.\n
j3 7:9157b152011b 157 ///
j3 7:9157b152011b 158 ///On Entry:
j3 7:9157b152011b 159 ///@param[in] sysVolts - pointer to float for storing system voltage
j3 7:9157b152011b 160 ///
j3 7:9157b152011b 161 ///On Exit:
j3 7:9157b152011b 162 ///@param[out] sysVolts - holds system voltage on success
j3 7:9157b152011b 163 ///
j3 7:9157b152011b 164 ///@returns 0 if no errors, -1 if error.
j3 6:92b485e70885 165 int32_t getSysVoltage(float *sysVolts);
j3 6:92b485e70885 166
j3 7:9157b152011b 167
j3 7:9157b152011b 168 ///@brief Gets buck 1 voltage as float.\n
j3 7:9157b152011b 169 ///
j3 7:9157b152011b 170 ///On Entry:
j3 7:9157b152011b 171 ///@param[in] buckVolts - pointer to float for storing buck 1 voltage
j3 7:9157b152011b 172 ///
j3 7:9157b152011b 173 ///On Exit:
j3 7:9157b152011b 174 ///@param[out] buckVolts - holds buck 1 voltage on success
j3 7:9157b152011b 175 ///
j3 7:9157b152011b 176 ///@returns 0 if no errors, -1 if error.
j3 6:92b485e70885 177 int32_t getBuck1Voltage(float *buckVolts);
j3 6:92b485e70885 178
j3 7:9157b152011b 179
j3 7:9157b152011b 180 ///@brief Gets buck 2 voltage as float.\n
j3 7:9157b152011b 181 ///
j3 7:9157b152011b 182 ///On Entry:
j3 7:9157b152011b 183 ///@param[in] buckVolts - pointer to float for storing buck 2 voltage
j3 7:9157b152011b 184 ///
j3 7:9157b152011b 185 ///On Exit:
j3 7:9157b152011b 186 ///@param[out] buckVolts - holds buck 2 voltage on success
j3 7:9157b152011b 187 ///
j3 7:9157b152011b 188 ///@returns 0 if no errors, -1 if error.
j3 6:92b485e70885 189 int32_t getBuck2Voltage(float *buckVolts);
j3 6:92b485e70885 190
j3 7:9157b152011b 191
j3 7:9157b152011b 192 ///@brief Gets LDO1 voltage as float.\n
j3 7:9157b152011b 193 ///
j3 7:9157b152011b 194 ///On Entry:
j3 7:9157b152011b 195 ///@param[in] ldoVolts - pointer to float for storing LDO1 voltage
j3 7:9157b152011b 196 ///
j3 7:9157b152011b 197 ///On Exit:
j3 7:9157b152011b 198 ///@param[out] ldoVolts - holds LDO1 voltage on success
j3 7:9157b152011b 199 ///
j3 7:9157b152011b 200 ///@returns 0 if no errors, -1 if error.
j3 6:92b485e70885 201 int32_t getLDO1Voltage(float *ldoVolts);
j3 6:92b485e70885 202
j3 7:9157b152011b 203
j3 7:9157b152011b 204 ///@brief Gets LDO2 voltage as float.\n
j3 7:9157b152011b 205 ///
j3 7:9157b152011b 206 ///On Entry:
j3 7:9157b152011b 207 ///@param[in] ldoVolts - pointer to float for storing LDO2 voltage
j3 7:9157b152011b 208 ///
j3 7:9157b152011b 209 ///On Exit:
j3 7:9157b152011b 210 ///@param[out] ldoVolts - holds LDO2 voltage on success
j3 7:9157b152011b 211 ///
j3 7:9157b152011b 212 ///@returns 0 if no errors, -1 if error.
j3 6:92b485e70885 213 int32_t getLDO2Voltage(float *ldoVolts);
j3 6:92b485e70885 214
j3 7:9157b152011b 215
j3 7:9157b152011b 216 ///@brief Gets LDO3 voltage as float.\n
j3 7:9157b152011b 217 ///
j3 7:9157b152011b 218 ///On Entry:
j3 7:9157b152011b 219 ///@param[in] ldoVolts - pointer to float for storing LDO3 voltage
j3 7:9157b152011b 220 ///
j3 7:9157b152011b 221 ///On Exit:
j3 7:9157b152011b 222 ///@param[out] ldoVolts - holds LDO3 voltage on success
j3 7:9157b152011b 223 ///
j3 7:9157b152011b 224 ///@returns 0 if no errors, -1 if error.
j3 6:92b485e70885 225 int32_t getLDO3Voltage(float *ldoVolts);
j3 6:92b485e70885 226
j3 6:92b485e70885 227
j3 6:92b485e70885 228 private:
j3 3:b735212d2fe5 229
j3 6:92b485e70885 230 /// I2C bus for configuring PMIC
j3 6:92b485e70885 231 I2C m_i2c;
switches 1:15e34492fbf1 232
switches 1:15e34492fbf1 233 /// MAX14690 PMIC Instance
j3 6:92b485e70885 234 MAX14690 m_max14690;
j3 6:92b485e70885 235
switches 1:15e34492fbf1 236 /// The default I/O voltage to be used for header pins.
j3 6:92b485e70885 237 IoVoltage m_hdrVio;
j3 6:92b485e70885 238
j3 6:92b485e70885 239 int32_t readMonVoltage(MAX14690::monCfg_t monCfg, float *volts);
switches 1:15e34492fbf1 240 };
switches 1:15e34492fbf1 241
switches 1:15e34492fbf1 242 #endif /* _MAX32630FTHR_H_ */
j3 6:92b485e70885 243
j3 6:92b485e70885 244 ///@brief fx documentation template.\n
j3 6:92b485e70885 245 ///
j3 6:92b485e70885 246 ///On Entry:
j3 6:92b485e70885 247 ///@param[in] none
j3 6:92b485e70885 248 ///
j3 6:92b485e70885 249 ///On Exit:
j3 6:92b485e70885 250 ///@param[out] none
j3 6:92b485e70885 251 ///
j3 6:92b485e70885 252 ///@returns none
j3 6:92b485e70885 253