max32630 icarus board support library

Committer:
gmehmet
Date:
Mon Dec 17 10:40:37 2018 +0000
Revision:
2:5da03fb73b5b
Parent:
0:0921c8ac8608
lib removed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gmehmet 0:0921c8ac8608 1 /*******************************************************************************
gmehmet 0:0921c8ac8608 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
gmehmet 0:0921c8ac8608 3 *
gmehmet 0:0921c8ac8608 4 * Permission is hereby granted, free of charge, to any person obtaining a
gmehmet 0:0921c8ac8608 5 * copy of this software and associated documentation files (the "Software"),
gmehmet 0:0921c8ac8608 6 * to deal in the Software without restriction, including without limitation
gmehmet 0:0921c8ac8608 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
gmehmet 0:0921c8ac8608 8 * and/or sell copies of the Software, and to permit persons to whom the
gmehmet 0:0921c8ac8608 9 * Software is furnished to do so, subject to the following conditions:
gmehmet 0:0921c8ac8608 10 *
gmehmet 0:0921c8ac8608 11 * The above copyright notice and this permission notice shall be included
gmehmet 0:0921c8ac8608 12 * in all copies or substantial portions of the Software.
gmehmet 0:0921c8ac8608 13 *
gmehmet 0:0921c8ac8608 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
gmehmet 0:0921c8ac8608 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
gmehmet 0:0921c8ac8608 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
gmehmet 0:0921c8ac8608 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
gmehmet 0:0921c8ac8608 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
gmehmet 0:0921c8ac8608 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
gmehmet 0:0921c8ac8608 20 * OTHER DEALINGS IN THE SOFTWARE.
gmehmet 0:0921c8ac8608 21 *
gmehmet 0:0921c8ac8608 22 * Except as contained in this notice, the name of Maxim Integrated
gmehmet 0:0921c8ac8608 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
gmehmet 0:0921c8ac8608 24 * Products, Inc. Branding Policy.
gmehmet 0:0921c8ac8608 25 *
gmehmet 0:0921c8ac8608 26 * The mere transfer of this software does not imply any licenses
gmehmet 0:0921c8ac8608 27 * of trade secrets, proprietary technology, copyrights, patents,
gmehmet 0:0921c8ac8608 28 * trademarks, maskwork rights, or any other form of intellectual
gmehmet 0:0921c8ac8608 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
gmehmet 0:0921c8ac8608 30 * ownership rights.
gmehmet 0:0921c8ac8608 31 *******************************************************************************
gmehmet 0:0921c8ac8608 32 */
gmehmet 0:0921c8ac8608 33
gmehmet 0:0921c8ac8608 34 #ifndef _MAX32630HSP_H_
gmehmet 0:0921c8ac8608 35 #define _MAX32630HSP_H_
gmehmet 0:0921c8ac8608 36
gmehmet 0:0921c8ac8608 37 #include "mbed.h"
gmehmet 0:0921c8ac8608 38 #include "MAX20303.h"
gmehmet 0:0921c8ac8608 39
gmehmet 0:0921c8ac8608 40
gmehmet 0:0921c8ac8608 41 /**
gmehmet 0:0921c8ac8608 42 * @brief MAX32630HSP Board Support Library
gmehmet 0:0921c8ac8608 43 *
gmehmet 0:0921c8ac8608 44 * @details The MAX32630HSP is a rapid development application board for
gmehmet 0:0921c8ac8608 45 * ultra low power wearable applications. It includes common peripherals and
gmehmet 0:0921c8ac8608 46 * expansion connectors all power optimized for getting the longest life from
gmehmet 0:0921c8ac8608 47 * the battery. This library configures the power and I/O for the board.
gmehmet 0:0921c8ac8608 48 * <br>https://www.maximintegrated.com/max32630hsp
gmehmet 0:0921c8ac8608 49 *
gmehmet 0:0921c8ac8608 50 * @code
gmehmet 0:0921c8ac8608 51 * #include "mbed.h"
gmehmet 0:0921c8ac8608 52 * #include "max32630hsp.h"
gmehmet 0:0921c8ac8608 53 *
gmehmet 0:0921c8ac8608 54 * DigitalOut led1(LED1);
gmehmet 0:0921c8ac8608 55 * MAX32630HSP icarus(MAX32630HSP::VIO_3V3);
gmehmet 0:0921c8ac8608 56 *
gmehmet 0:0921c8ac8608 57 * // main() runs in its own thread in the OS
gmehmet 0:0921c8ac8608 58 * // (note the calls to Thread::wait below for delays)
gmehmet 0:0921c8ac8608 59 * int main()
gmehmet 0:0921c8ac8608 60 * {
gmehmet 0:0921c8ac8608 61 * // initialize power and I/O on MAX32630HSP board
gmehmet 0:0921c8ac8608 62 * icarus.init();
gmehmet 0:0921c8ac8608 63 *
gmehmet 0:0921c8ac8608 64 * while (true) {
gmehmet 0:0921c8ac8608 65 * led1 = !led1;
gmehmet 0:0921c8ac8608 66 * Thread::wait(500);
gmehmet 0:0921c8ac8608 67 * }
gmehmet 0:0921c8ac8608 68 * }
gmehmet 0:0921c8ac8608 69 * @endcode
gmehmet 0:0921c8ac8608 70 */
gmehmet 0:0921c8ac8608 71
gmehmet 0:0921c8ac8608 72 // Sharp LS013B7DH03 Memory Display
gmehmet 0:0921c8ac8608 73 #define SCK_PIN P6_1
gmehmet 0:0921c8ac8608 74 #define MOSI_PIN P6_2
gmehmet 0:0921c8ac8608 75 #define CS_PIN P6_5
gmehmet 0:0921c8ac8608 76 #define EXTCOM_PIN P6_4
gmehmet 0:0921c8ac8608 77 #define DISP_PIN P6_6
gmehmet 0:0921c8ac8608 78 #define DISPSEL_PIN NC
gmehmet 0:0921c8ac8608 79 #define PIN_POWERBUTTON P7_6
gmehmet 0:0921c8ac8608 80 #define PIN_UPBUTTON P2_3
gmehmet 0:0921c8ac8608 81 #define PIN_DOWNBUTTON P6_5
gmehmet 0:0921c8ac8608 82
gmehmet 0:0921c8ac8608 83 class MAX32630HSP
gmehmet 0:0921c8ac8608 84 {
gmehmet 0:0921c8ac8608 85 public:
gmehmet 0:0921c8ac8608 86 // max32630hsp configuration utilities
gmehmet 0:0921c8ac8608 87
gmehmet 0:0921c8ac8608 88 /**
gmehmet 0:0921c8ac8608 89 * @brief IO Voltage
gmehmet 0:0921c8ac8608 90 * @details Enumerated options for operating voltage
gmehmet 0:0921c8ac8608 91 */
gmehmet 0:0921c8ac8608 92 typedef enum {
gmehmet 0:0921c8ac8608 93 VIO_1V8 = 0x00, ///< 1.8V IO voltage at headers (from BUCK2)
gmehmet 0:0921c8ac8608 94 VIO_3V3 = 0x01, ///< 3.3V IO voltage at headers (from LDO2)
gmehmet 0:0921c8ac8608 95 } vio_t;
gmehmet 0:0921c8ac8608 96
gmehmet 0:0921c8ac8608 97 enum ButtonStatus {
gmehmet 0:0921c8ac8608 98 BUTTONSTATUS_RELEASED = 1,
gmehmet 0:0921c8ac8608 99 BUTTONSTATUS_PRESSED
gmehmet 0:0921c8ac8608 100 } ;
gmehmet 0:0921c8ac8608 101
gmehmet 0:0921c8ac8608 102 /**
gmehmet 0:0921c8ac8608 103 * MAX32630HSP constructor.
gmehmet 0:0921c8ac8608 104 *
gmehmet 0:0921c8ac8608 105 */
gmehmet 0:0921c8ac8608 106 MAX32630HSP();
gmehmet 0:0921c8ac8608 107
gmehmet 0:0921c8ac8608 108 /**
gmehmet 0:0921c8ac8608 109 * MAX32630HSP constructor.
gmehmet 0:0921c8ac8608 110 *
gmehmet 0:0921c8ac8608 111 */
gmehmet 0:0921c8ac8608 112 MAX32630HSP(vio_t vio);
gmehmet 0:0921c8ac8608 113
gmehmet 0:0921c8ac8608 114 /**
gmehmet 0:0921c8ac8608 115 * MAX32630HSP constructor.
gmehmet 0:0921c8ac8608 116 *
gmehmet 0:0921c8ac8608 117 */
gmehmet 0:0921c8ac8608 118 MAX32630HSP(vio_t vio, InterruptIn *max32630hsp3_powerButtonInterrupt);
gmehmet 0:0921c8ac8608 119
gmehmet 0:0921c8ac8608 120 /**
gmehmet 0:0921c8ac8608 121 * MAX32630HSP destructor.
gmehmet 0:0921c8ac8608 122 */
gmehmet 0:0921c8ac8608 123 ~MAX32630HSP();
gmehmet 0:0921c8ac8608 124
gmehmet 0:0921c8ac8608 125 //InterruptIn _interruptIn_PowerButton;
gmehmet 0:0921c8ac8608 126
gmehmet 0:0921c8ac8608 127 /**
gmehmet 0:0921c8ac8608 128 * @brief Initialize MAX32630HSP board
gmehmet 0:0921c8ac8608 129 * @details Initializes PMIC and I/O on MAX32630HSP board.
gmehmet 0:0921c8ac8608 130 * Configures PMIC to enable LDO2 and LDO3 at 3.3V.
gmehmet 0:0921c8ac8608 131 * Disables resisitive pulldown on MON(AIN_0)
gmehmet 0:0921c8ac8608 132 * Sets default I/O voltages to 3V3 for micro SD card.
gmehmet 0:0921c8ac8608 133 * Sets I/O voltage for header pins to hdrVio specified.
gmehmet 0:0921c8ac8608 134 * @param hdrVio I/O voltage for header pins
gmehmet 0:0921c8ac8608 135 * @returns 0 if no errors, -1 if error.
gmehmet 0:0921c8ac8608 136 */
gmehmet 0:0921c8ac8608 137 int init(vio_t hdrVio);
gmehmet 0:0921c8ac8608 138
gmehmet 0:0921c8ac8608 139 /**
gmehmet 0:0921c8ac8608 140 * @brief Sets I/O Voltage
gmehmet 0:0921c8ac8608 141 * @details Sets the voltage rail to be used for a given pin.
gmehmet 0:0921c8ac8608 142 * VIO_1V8 selects VDDIO which is supplied by Buck2, which is set at 1.8V,
gmehmet 0:0921c8ac8608 143 * VIO_3V3 selects VDDIOH which is supplied by LDO2, which is typically 3.3V/
gmehmet 0:0921c8ac8608 144 * @param pin Pin whose voltage supply is being assigned.
gmehmet 0:0921c8ac8608 145 * @param vio Voltage rail to be used for specified pin.
gmehmet 0:0921c8ac8608 146 * @returns 0 if no errors, -1 if error.
gmehmet 0:0921c8ac8608 147 */
gmehmet 0:0921c8ac8608 148 int vddioh(PinName pin, vio_t vio);
gmehmet 0:0921c8ac8608 149
gmehmet 0:0921c8ac8608 150 /**Interrupt Hander for Power Button Press**/
gmehmet 0:0921c8ac8608 151
gmehmet 0:0921c8ac8608 152 //InterruptIn _interruptIn_UpButton(PIN_UPBUTTON);
gmehmet 0:0921c8ac8608 153 //InterruptIn _interruptIn_DownButton(PIN_DOWNBUTTON);
gmehmet 0:0921c8ac8608 154
gmehmet 0:0921c8ac8608 155 /* Set vddio for Sharp LS013B7DH03 Display */
gmehmet 0:0921c8ac8608 156 void enableDisplay(void);
gmehmet 0:0921c8ac8608 157
gmehmet 0:0921c8ac8608 158 /// Local I2C bus for configuring PMIC and accessing BMI160 IMU.
gmehmet 0:0921c8ac8608 159 I2C i2c;
gmehmet 0:0921c8ac8608 160
gmehmet 0:0921c8ac8608 161 /// MAX20303 PMIC Instance
gmehmet 0:0921c8ac8608 162 MAX20303 max20303;
gmehmet 0:0921c8ac8608 163
gmehmet 0:0921c8ac8608 164
gmehmet 0:0921c8ac8608 165 InterruptIn *m_max32630hsp3_powerButtonInterrupt;
gmehmet 0:0921c8ac8608 166 bool button_status;
gmehmet 0:0921c8ac8608 167 bool button_longpressdetected;
gmehmet 0:0921c8ac8608 168 Timeout button_timeout;
gmehmet 0:0921c8ac8608 169
gmehmet 0:0921c8ac8608 170 ButtonStatus status_powerButton;
gmehmet 0:0921c8ac8608 171 ButtonStatus status_upButton;
gmehmet 0:0921c8ac8608 172 ButtonStatus status_downButton;
gmehmet 0:0921c8ac8608 173 void event_powerButtonPressed(void);
gmehmet 0:0921c8ac8608 174 void event_powerButtonReleased(void);
gmehmet 0:0921c8ac8608 175 void event_longpresscheck(void);
gmehmet 0:0921c8ac8608 176 };
gmehmet 0:0921c8ac8608 177
gmehmet 0:0921c8ac8608 178 #endif /* _MAX32630HSP_H_ */