ch1 test1

Dependencies:   MAX14690

Committer:
switches
Date:
Sun Nov 20 23:31:36 2016 +0000
Revision:
1:15e34492fbf1
Parent:
0:8926602da648
Child:
3:09e3dbb49561
Created MAX32630FTHR class for board support functions

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