max4146x_comp

Dependencies:   MAX14690

Committer:
sdivarci
Date:
Sun Oct 25 20:10:02 2020 +0000
Revision:
0:0061165683ee
sdivarci

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sdivarci 0:0061165683ee 1 /*******************************************************************************
sdivarci 0:0061165683ee 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
sdivarci 0:0061165683ee 3 *
sdivarci 0:0061165683ee 4 * Permission is hereby granted, free of charge, to any person obtaining a
sdivarci 0:0061165683ee 5 * copy of this software and associated documentation files (the "Software"),
sdivarci 0:0061165683ee 6 * to deal in the Software without restriction, including without limitation
sdivarci 0:0061165683ee 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
sdivarci 0:0061165683ee 8 * and/or sell copies of the Software, and to permit persons to whom the
sdivarci 0:0061165683ee 9 * Software is furnished to do so, subject to the following conditions:
sdivarci 0:0061165683ee 10 *
sdivarci 0:0061165683ee 11 * The above copyright notice and this permission notice shall be included
sdivarci 0:0061165683ee 12 * in all copies or substantial portions of the Software.
sdivarci 0:0061165683ee 13 *
sdivarci 0:0061165683ee 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
sdivarci 0:0061165683ee 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
sdivarci 0:0061165683ee 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
sdivarci 0:0061165683ee 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
sdivarci 0:0061165683ee 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
sdivarci 0:0061165683ee 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
sdivarci 0:0061165683ee 20 * OTHER DEALINGS IN THE SOFTWARE.
sdivarci 0:0061165683ee 21 *
sdivarci 0:0061165683ee 22 * Except as contained in this notice, the name of Maxim Integrated
sdivarci 0:0061165683ee 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
sdivarci 0:0061165683ee 24 * Products, Inc. Branding Policy.
sdivarci 0:0061165683ee 25 *
sdivarci 0:0061165683ee 26 * The mere transfer of this software does not imply any licenses
sdivarci 0:0061165683ee 27 * of trade secrets, proprietary technology, copyrights, patents,
sdivarci 0:0061165683ee 28 * trademarks, maskwork rights, or any other form of intellectual
sdivarci 0:0061165683ee 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
sdivarci 0:0061165683ee 30 * ownership rights.
sdivarci 0:0061165683ee 31 *******************************************************************************
sdivarci 0:0061165683ee 32 */
sdivarci 0:0061165683ee 33
sdivarci 0:0061165683ee 34 #include "mbed.h"
sdivarci 0:0061165683ee 35 #include "max3263x.h"
sdivarci 0:0061165683ee 36 #include "ioman_regs.h"
sdivarci 0:0061165683ee 37 #include "PinNames.h"
sdivarci 0:0061165683ee 38 #include "max32630fthr.h"
sdivarci 0:0061165683ee 39
sdivarci 0:0061165683ee 40 //******************************************************************************
sdivarci 0:0061165683ee 41 MAX32630FTHR::MAX32630FTHR() : i2c(P5_7, P6_0), max14690(&i2c)
sdivarci 0:0061165683ee 42 {
sdivarci 0:0061165683ee 43 }
sdivarci 0:0061165683ee 44
sdivarci 0:0061165683ee 45 //******************************************************************************
sdivarci 0:0061165683ee 46 MAX32630FTHR::MAX32630FTHR(vio_t vio) : i2c(P5_7, P6_0), max14690(&i2c)
sdivarci 0:0061165683ee 47 {
sdivarci 0:0061165683ee 48 init(vio);
sdivarci 0:0061165683ee 49 }
sdivarci 0:0061165683ee 50
sdivarci 0:0061165683ee 51 //******************************************************************************
sdivarci 0:0061165683ee 52 MAX32630FTHR::~MAX32630FTHR()
sdivarci 0:0061165683ee 53 {
sdivarci 0:0061165683ee 54 }
sdivarci 0:0061165683ee 55
sdivarci 0:0061165683ee 56 //******************************************************************************
sdivarci 0:0061165683ee 57 int MAX32630FTHR::init(vio_t hdrVio)
sdivarci 0:0061165683ee 58 {
sdivarci 0:0061165683ee 59 // Override the default values
sdivarci 0:0061165683ee 60 max14690.ldo2Millivolts = 3300;
sdivarci 0:0061165683ee 61 max14690.ldo3Millivolts = 3300;
sdivarci 0:0061165683ee 62 max14690.ldo2Mode = MAX14690::LDO_ENABLED;
sdivarci 0:0061165683ee 63 max14690.ldo3Mode = MAX14690::LDO_ENABLED;
sdivarci 0:0061165683ee 64 max14690.monCfg = MAX14690::MON_HI_Z;
sdivarci 0:0061165683ee 65 // Note that writing the local value does directly affect the part
sdivarci 0:0061165683ee 66 // The buck-boost regulator will remain off until init is called
sdivarci 0:0061165683ee 67
sdivarci 0:0061165683ee 68 // Call init to apply all settings to the PMIC
sdivarci 0:0061165683ee 69 if (max14690.init() == MAX14690_ERROR) {
sdivarci 0:0061165683ee 70 printf("Error initializing MAX14690");
sdivarci 0:0061165683ee 71 }
sdivarci 0:0061165683ee 72
sdivarci 0:0061165683ee 73 // Set micro SD card pins to 3.3V
sdivarci 0:0061165683ee 74 vddioh(P0_4, VIO_3V3);
sdivarci 0:0061165683ee 75 vddioh(P0_5, VIO_3V3);
sdivarci 0:0061165683ee 76 vddioh(P0_6, VIO_3V3);
sdivarci 0:0061165683ee 77 vddioh(P0_7, VIO_3V3);
sdivarci 0:0061165683ee 78 // Set LED pins to 3.3V
sdivarci 0:0061165683ee 79 vddioh(P2_4, VIO_3V3);
sdivarci 0:0061165683ee 80 vddioh(P2_5, VIO_3V3);
sdivarci 0:0061165683ee 81 vddioh(P2_6, VIO_3V3);
sdivarci 0:0061165683ee 82 // Set header pins to hdrVio
sdivarci 0:0061165683ee 83 vddioh(P3_0, hdrVio);
sdivarci 0:0061165683ee 84 vddioh(P3_1, hdrVio);
sdivarci 0:0061165683ee 85 vddioh(P3_2, hdrVio);
sdivarci 0:0061165683ee 86 vddioh(P3_3, hdrVio);
sdivarci 0:0061165683ee 87 vddioh(P3_4, hdrVio);
sdivarci 0:0061165683ee 88 vddioh(P3_5, hdrVio);
sdivarci 0:0061165683ee 89 vddioh(P4_0, hdrVio);
sdivarci 0:0061165683ee 90 vddioh(P4_1, hdrVio);
sdivarci 0:0061165683ee 91 vddioh(P4_2, hdrVio);
sdivarci 0:0061165683ee 92 vddioh(P4_3, hdrVio);
sdivarci 0:0061165683ee 93 vddioh(P4_4, hdrVio);
sdivarci 0:0061165683ee 94 vddioh(P4_5, hdrVio);
sdivarci 0:0061165683ee 95 vddioh(P4_6, hdrVio);
sdivarci 0:0061165683ee 96 vddioh(P4_7, hdrVio);
sdivarci 0:0061165683ee 97 vddioh(P5_0, hdrVio);
sdivarci 0:0061165683ee 98 vddioh(P5_1, hdrVio);
sdivarci 0:0061165683ee 99 vddioh(P5_2, hdrVio);
sdivarci 0:0061165683ee 100 vddioh(P5_3, hdrVio);
sdivarci 0:0061165683ee 101 vddioh(P5_4, hdrVio);
sdivarci 0:0061165683ee 102 vddioh(P5_5, hdrVio);
sdivarci 0:0061165683ee 103 vddioh(P5_6, hdrVio);
sdivarci 0:0061165683ee 104
sdivarci 0:0061165683ee 105 return 0;
sdivarci 0:0061165683ee 106 }
sdivarci 0:0061165683ee 107
sdivarci 0:0061165683ee 108 //******************************************************************************
sdivarci 0:0061165683ee 109 int MAX32630FTHR::vddioh(PinName pin, vio_t vio)
sdivarci 0:0061165683ee 110 {
sdivarci 0:0061165683ee 111 __IO uint32_t *use_vddioh = &((mxc_ioman_regs_t *)MXC_IOMAN)->use_vddioh_0;
sdivarci 0:0061165683ee 112
sdivarci 0:0061165683ee 113 if (pin == NOT_CONNECTED) {
sdivarci 0:0061165683ee 114 return -1;
sdivarci 0:0061165683ee 115 }
sdivarci 0:0061165683ee 116
sdivarci 0:0061165683ee 117 use_vddioh += PINNAME_TO_PORT(pin) >> 2;
sdivarci 0:0061165683ee 118 if (vio) {
sdivarci 0:0061165683ee 119 *use_vddioh |= (1 << (PINNAME_TO_PIN(pin) + ((PINNAME_TO_PORT(pin) & 0x3) << 3)));
sdivarci 0:0061165683ee 120 } else {
sdivarci 0:0061165683ee 121 *use_vddioh &= ~(1 << (PINNAME_TO_PIN(pin) + ((PINNAME_TO_PORT(pin) & 0x3) << 3)));
sdivarci 0:0061165683ee 122 }
sdivarci 0:0061165683ee 123
sdivarci 0:0061165683ee 124 return 0;
sdivarci 0:0061165683ee 125 }