ME11B Sample Code in Maxim Integrated Team

Dependencies:   BMI160 max32630hsp3 MemoryLCD USBDevice

Fork of Host_Software_MAX32664GWEB_HR_EXTENDED by Seyhmus Cacina

Committer:
seyhmus.cacina
Date:
Mon Mar 18 10:21:53 2019 +0300
Revision:
0:ac4dea3e2894
ME11B Sample Code First Commit

Who changed what in which revision?

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