Board library for MAX32630FTHR platform

Dependencies:   MAX14690

Dependents:   FTHR_OLED MAX32630FTHR_ADC_Example Test_TFT_RT MAX32630FTHR_RGB ... more

Fork of max32630fthr by Greg Steiert

Committer:
phonemacro
Date:
Thu Feb 14 09:20:32 2019 +0000
Revision:
14:8f6e6a800f2f
Parent:
11:e821831283e2
Move max31875 library back to correct spot.

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