TEST

Dependencies:   max32630fthr Adafruit_FeatherOLED USBDevice

Committer:
wwwarunraj
Date:
Sun Apr 19 11:19:57 2020 +0000
Revision:
4:291477e8690d
Parent:
1:f60eafbf009a
19/04

Who changed what in which revision?

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