ME11C Sample Code in Maxim Integrated Team

Dependencies:   BMI160 max32630hsp3 MemoryLCD USBDevice

Fork of Host_Software_MAX32664GWEC_SpO2_HR-_EXTE by Seyhmus Cacina

Committer:
seyhmus.cacina
Date:
Mon Mar 18 14:09:48 2019 +0300
Revision:
0:b259fd1a88f5
ME11C Sample Code First Commit

Who changed what in which revision?

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