Fork of MAX32630FTHR utilities library
Dependents: MAX32630FTHR_BALANCE_BOT MAX32630FTHR_iButton_uSD_Logger MAX32630FTHR_DS18B20_uSD_Logger MAX32630FTHR_BALANCE_BOT
Fork of max32630fthr by
max32630fthr.h@6:92b485e70885, 2016-12-08 (annotated)
- Committer:
- j3
- Date:
- Thu Dec 08 03:33:50 2016 +0000
- Revision:
- 6:92b485e70885
- Parent:
- 3:b735212d2fe5
- Child:
- 7:9157b152011b
Added getVoltage member functions for pmic outputs.
Who changed what in which revision?
User | Revision | Line number | New 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 | 6:92b485e70885 | 97 | MAX32630FTHR(IoVoltage vio); |
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 | 6:92b485e70885 | 126 | int32_t init(); |
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 | 6:92b485e70885 | 155 | int32_t getSysVoltage(float *sysVolts); |
j3 | 6:92b485e70885 | 156 | |
j3 | 6:92b485e70885 | 157 | int32_t getBuck1Voltage(float *buckVolts); |
j3 | 6:92b485e70885 | 158 | |
j3 | 6:92b485e70885 | 159 | int32_t getBuck2Voltage(float *buckVolts); |
j3 | 6:92b485e70885 | 160 | |
j3 | 6:92b485e70885 | 161 | int32_t getLDO1Voltage(float *ldoVolts); |
j3 | 6:92b485e70885 | 162 | |
j3 | 6:92b485e70885 | 163 | int32_t getLDO2Voltage(float *ldoVolts); |
j3 | 6:92b485e70885 | 164 | |
j3 | 6:92b485e70885 | 165 | int32_t getLDO3Voltage(float *ldoVolts); |
j3 | 6:92b485e70885 | 166 | |
j3 | 6:92b485e70885 | 167 | |
j3 | 6:92b485e70885 | 168 | private: |
j3 | 3:b735212d2fe5 | 169 | |
j3 | 6:92b485e70885 | 170 | /// I2C bus for configuring PMIC |
j3 | 6:92b485e70885 | 171 | I2C m_i2c; |
switches | 1:15e34492fbf1 | 172 | |
switches | 1:15e34492fbf1 | 173 | /// MAX14690 PMIC Instance |
j3 | 6:92b485e70885 | 174 | MAX14690 m_max14690; |
j3 | 6:92b485e70885 | 175 | |
switches | 1:15e34492fbf1 | 176 | /// The default I/O voltage to be used for header pins. |
j3 | 6:92b485e70885 | 177 | IoVoltage m_hdrVio; |
j3 | 6:92b485e70885 | 178 | |
j3 | 6:92b485e70885 | 179 | int32_t readMonVoltage(MAX14690::monCfg_t monCfg, float *volts); |
switches | 1:15e34492fbf1 | 180 | }; |
switches | 1:15e34492fbf1 | 181 | |
switches | 1:15e34492fbf1 | 182 | #endif /* _MAX32630FTHR_H_ */ |
j3 | 6:92b485e70885 | 183 | |
j3 | 6:92b485e70885 | 184 | ///@brief fx documentation template.\n |
j3 | 6:92b485e70885 | 185 | /// |
j3 | 6:92b485e70885 | 186 | ///On Entry: |
j3 | 6:92b485e70885 | 187 | ///@param[in] none |
j3 | 6:92b485e70885 | 188 | /// |
j3 | 6:92b485e70885 | 189 | ///On Exit: |
j3 | 6:92b485e70885 | 190 | ///@param[out] none |
j3 | 6:92b485e70885 | 191 | /// |
j3 | 6:92b485e70885 | 192 | ///@returns none |
j3 | 6:92b485e70885 | 193 |