ch1 test1
Dependencies: MAX14690
max32630fthr.cpp@3:09e3dbb49561, 2016-12-13 (annotated)
- Committer:
- switches
- Date:
- Tue Dec 13 21:28:57 2016 +0000
- Revision:
- 3:09e3dbb49561
- Parent:
- 1:15e34492fbf1
- Child:
- 5:8e424775234a
Moved hdrVio parameter to init function so that it is more clear when this setting gets applied.
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 | */ |
switches | 1:15e34492fbf1 | 33 | |
switches | 0:8926602da648 | 34 | #include "mbed.h" |
switches | 0:8926602da648 | 35 | #include "max3263x.h" |
switches | 0:8926602da648 | 36 | #include "ioman_regs.h" |
switches | 0:8926602da648 | 37 | #include "PinNames.h" |
switches | 0:8926602da648 | 38 | #include "max32630fthr.h" |
switches | 0:8926602da648 | 39 | |
switches | 1:15e34492fbf1 | 40 | //****************************************************************************** |
switches | 3:09e3dbb49561 | 41 | MAX32630FTHR::MAX32630FTHR() : i2c(P5_7, P6_0), max14690(&i2c) |
switches | 1:15e34492fbf1 | 42 | { |
switches | 1:15e34492fbf1 | 43 | } |
switches | 0:8926602da648 | 44 | |
switches | 1:15e34492fbf1 | 45 | //****************************************************************************** |
switches | 1:15e34492fbf1 | 46 | MAX32630FTHR::~MAX32630FTHR() |
switches | 1:15e34492fbf1 | 47 | { |
switches | 1:15e34492fbf1 | 48 | } |
switches | 0:8926602da648 | 49 | |
switches | 1:15e34492fbf1 | 50 | //****************************************************************************** |
switches | 3:09e3dbb49561 | 51 | int MAX32630FTHR::init(vio_t hdrVio) |
switches | 0:8926602da648 | 52 | { |
switches | 1:15e34492fbf1 | 53 | // Override the default values |
switches | 1:15e34492fbf1 | 54 | max14690.ldo2Millivolts = 3300; |
switches | 1:15e34492fbf1 | 55 | max14690.ldo3Millivolts = 3300; |
switches | 1:15e34492fbf1 | 56 | max14690.ldo2Mode = MAX14690::LDO_ENABLED; |
switches | 1:15e34492fbf1 | 57 | max14690.ldo3Mode = MAX14690::LDO_ENABLED; |
switches | 1:15e34492fbf1 | 58 | max14690.monCfg = MAX14690::MON_HI_Z; |
switches | 1:15e34492fbf1 | 59 | // Note that writing the local value does directly affect the part |
switches | 1:15e34492fbf1 | 60 | // The buck-boost regulator will remain off until init is called |
switches | 1:15e34492fbf1 | 61 | |
switches | 1:15e34492fbf1 | 62 | // Call init to apply all settings to the PMIC |
switches | 1:15e34492fbf1 | 63 | if (max14690.init() == MAX14690_ERROR) { |
switches | 1:15e34492fbf1 | 64 | printf("Error initializing MAX14690"); |
switches | 1:15e34492fbf1 | 65 | } |
switches | 1:15e34492fbf1 | 66 | |
switches | 1:15e34492fbf1 | 67 | // Set micro SD card pins to 3.3V |
switches | 1:15e34492fbf1 | 68 | vddioh(P0_4, VIO_3V3); |
switches | 1:15e34492fbf1 | 69 | vddioh(P0_5, VIO_3V3); |
switches | 1:15e34492fbf1 | 70 | vddioh(P0_6, VIO_3V3); |
switches | 1:15e34492fbf1 | 71 | vddioh(P0_7, VIO_3V3); |
switches | 1:15e34492fbf1 | 72 | // Set LED pins to 3.3V |
switches | 1:15e34492fbf1 | 73 | vddioh(P2_4, VIO_3V3); |
switches | 1:15e34492fbf1 | 74 | vddioh(P2_5, VIO_3V3); |
switches | 1:15e34492fbf1 | 75 | vddioh(P2_6, VIO_3V3); |
switches | 1:15e34492fbf1 | 76 | // Set header pins to hdrVio |
switches | 1:15e34492fbf1 | 77 | vddioh(P3_0, hdrVio); |
switches | 1:15e34492fbf1 | 78 | vddioh(P3_1, hdrVio); |
switches | 1:15e34492fbf1 | 79 | vddioh(P3_2, hdrVio); |
switches | 1:15e34492fbf1 | 80 | vddioh(P3_3, hdrVio); |
switches | 1:15e34492fbf1 | 81 | vddioh(P3_4, hdrVio); |
switches | 1:15e34492fbf1 | 82 | vddioh(P3_5, hdrVio); |
switches | 1:15e34492fbf1 | 83 | vddioh(P4_0, hdrVio); |
switches | 1:15e34492fbf1 | 84 | vddioh(P4_1, hdrVio); |
switches | 1:15e34492fbf1 | 85 | vddioh(P4_2, hdrVio); |
switches | 1:15e34492fbf1 | 86 | vddioh(P4_3, hdrVio); |
switches | 1:15e34492fbf1 | 87 | vddioh(P4_4, hdrVio); |
switches | 1:15e34492fbf1 | 88 | vddioh(P4_5, hdrVio); |
switches | 1:15e34492fbf1 | 89 | vddioh(P4_6, hdrVio); |
switches | 1:15e34492fbf1 | 90 | vddioh(P4_7, hdrVio); |
switches | 1:15e34492fbf1 | 91 | vddioh(P5_0, hdrVio); |
switches | 1:15e34492fbf1 | 92 | vddioh(P5_1, hdrVio); |
switches | 1:15e34492fbf1 | 93 | vddioh(P5_2, hdrVio); |
switches | 1:15e34492fbf1 | 94 | vddioh(P5_3, hdrVio); |
switches | 1:15e34492fbf1 | 95 | vddioh(P5_4, hdrVio); |
switches | 1:15e34492fbf1 | 96 | vddioh(P5_5, hdrVio); |
switches | 1:15e34492fbf1 | 97 | vddioh(P5_6, hdrVio); |
switches | 1:15e34492fbf1 | 98 | |
switches | 0:8926602da648 | 99 | return 0; |
switches | 0:8926602da648 | 100 | } |
switches | 0:8926602da648 | 101 | |
switches | 1:15e34492fbf1 | 102 | //****************************************************************************** |
switches | 1:15e34492fbf1 | 103 | int MAX32630FTHR::vddioh(PinName pin, vio_t vio) |
switches | 0:8926602da648 | 104 | { |
switches | 0:8926602da648 | 105 | __IO uint32_t *use_vddioh = &((mxc_ioman_regs_t *)MXC_IOMAN)->use_vddioh_0; |
switches | 0:8926602da648 | 106 | |
switches | 0:8926602da648 | 107 | if (pin == NOT_CONNECTED) { |
switches | 0:8926602da648 | 108 | return -1; |
switches | 0:8926602da648 | 109 | } |
switches | 0:8926602da648 | 110 | |
switches | 0:8926602da648 | 111 | use_vddioh += PINNAME_TO_PORT(pin) >> 2; |
switches | 1:15e34492fbf1 | 112 | if (vio) { |
switches | 0:8926602da648 | 113 | *use_vddioh |= (1 << (PINNAME_TO_PIN(pin) + ((PINNAME_TO_PORT(pin) & 0x3) << 3))); |
switches | 0:8926602da648 | 114 | } else { |
switches | 0:8926602da648 | 115 | *use_vddioh &= ~(1 << (PINNAME_TO_PIN(pin) + ((PINNAME_TO_PORT(pin) & 0x3) << 3))); |
switches | 0:8926602da648 | 116 | } |
switches | 0:8926602da648 | 117 | |
switches | 0:8926602da648 | 118 | return 0; |
switches | 0:8926602da648 | 119 | } |