Utility library for HSP SPo2 HR demo including user interface, board support adn accelerometer.

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers max32630hsp.h Source File

max32630hsp.h

00001 /*******************************************************************************
00002  * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a
00005  * copy of this software and associated documentation files (the "Software"),
00006  * to deal in the Software without restriction, including without limitation
00007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008  * and/or sell copies of the Software, and to permit persons to whom the
00009  * Software is furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included
00012  * in all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00015  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00016  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00017  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
00018  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00020  * OTHER DEALINGS IN THE SOFTWARE.
00021  *
00022  * Except as contained in this notice, the name of Maxim Integrated
00023  * Products, Inc. shall not be used except as stated in the Maxim Integrated
00024  * Products, Inc. Branding Policy.
00025  *
00026  * The mere transfer of this software does not imply any licenses
00027  * of trade secrets, proprietary technology, copyrights, patents,
00028  * trademarks, maskwork rights, or any other form of intellectual
00029  * property whatsoever. Maxim Integrated Products, Inc. retains all
00030  * ownership rights.
00031  *******************************************************************************
00032  */
00033 
00034 #ifndef _MAX32630HSP_H_
00035 #define _MAX32630HSP_H_
00036 
00037 #include "mbed.h"
00038 #include "MAX20303.h"
00039 
00040 
00041 /**
00042  * @brief MAX32630HSP Board Support Library
00043  *
00044  * @details The MAX32630HSP is a rapid development application board for
00045  * ultra low power wearable applications.  It includes common peripherals and
00046  * expansion connectors all power optimized for getting the longest life from
00047  * the battery.  This library configures the power and I/O for the board.
00048  * <br>https://www.maximintegrated.com/max32630hsp
00049  *
00050  * @code
00051  * #include "mbed.h"
00052  * #include "max32630hsp.h"
00053  *
00054  * DigitalOut led1(LED1);
00055  * MAX32630HSP icarus(MAX32630HSP::VIO_3V3);
00056  *
00057  * // main() runs in its own thread in the OS
00058  * // (note the calls to Thread::wait below for delays)
00059  * int main()
00060  * {
00061  *     // initialize power and I/O on MAX32630HSP board
00062  *     icarus.init();
00063  *
00064  *     while (true) {
00065  *         led1 = !led1;
00066  *         Thread::wait(500);
00067  *     }
00068  * }
00069  * @endcode
00070  */
00071 
00072 // Sharp LS013B7DH03 Memory Display
00073 #define SCK_PIN             P6_1
00074 #define MOSI_PIN            P6_2
00075 #define CS_PIN              P6_5
00076 #define EXTCOM_PIN          P6_4
00077 #define DISP_PIN            P6_6
00078 #define DISPSEL_PIN         NC
00079 #define PIN_POWERBUTTON     P7_6
00080 #define PIN_UPBUTTON        P2_3
00081 #define PIN_DOWNBUTTON      P6_5
00082 
00083 class MAX32630HSP
00084 {
00085 public:
00086 // max32630hsp configuration utilities
00087 
00088     /**
00089       * @brief   IO Voltage
00090       * @details Enumerated options for operating voltage
00091       */
00092     typedef enum {
00093         VIO_1V8 = 0x00,    ///< 1.8V IO voltage at headers (from BUCK2)
00094         VIO_3V3 = 0x01,    ///< 3.3V IO voltage at headers (from LDO2)
00095     } vio_t;
00096 
00097     enum ButtonStatus {
00098         BUTTONSTATUS_RELEASED = 1,
00099         BUTTONSTATUS_PRESSED
00100     } ;
00101 
00102     /**
00103         * MAX32630HSP constructor.
00104         *
00105         */
00106     MAX32630HSP();
00107 
00108     /**
00109         * MAX32630HSP constructor.
00110         *
00111         */
00112     MAX32630HSP(vio_t vio);
00113 
00114     /**
00115         * MAX32630HSP constructor.
00116         *
00117         */
00118     MAX32630HSP(vio_t vio, InterruptIn *max32630hsp3_powerButtonInterrupt);
00119 
00120     /**
00121         * MAX32630HSP destructor.
00122         */
00123     ~MAX32630HSP();
00124 
00125     //InterruptIn _interruptIn_PowerButton;
00126 
00127     /**
00128      * @brief   Initialize MAX32630HSP board
00129      * @details Initializes PMIC and I/O on MAX32630HSP board.
00130      *  Configures PMIC to enable LDO2 and LDO3 at 3.3V.
00131      *  Disables resisitive pulldown on MON(AIN_0)
00132      *  Sets default I/O voltages to 3V3 for micro SD card.
00133      *  Sets I/O voltage for header pins to hdrVio specified.
00134      * @param hdrVio I/O voltage for header pins
00135      * @returns 0 if no errors, -1 if error.
00136     */
00137     int init(vio_t hdrVio);
00138 
00139     /**
00140      * @brief   Sets I/O Voltage
00141      * @details Sets the voltage rail to be used for a given pin.
00142      *  VIO_1V8 selects VDDIO which is supplied by Buck2, which is set at 1.8V,
00143      *  VIO_3V3 selects VDDIOH which is supplied by LDO2, which is typically 3.3V/
00144      * @param   pin Pin whose voltage supply is being assigned.
00145      * @param   vio Voltage rail to be used for specified pin.
00146      * @returns 0 if no errors, -1 if error.
00147     */
00148     int vddioh(PinName pin, vio_t vio);
00149 
00150     /**Interrupt Hander for Power Button Press**/
00151 
00152     //InterruptIn _interruptIn_UpButton(PIN_UPBUTTON);
00153     //InterruptIn _interruptIn_DownButton(PIN_DOWNBUTTON);
00154 
00155     /* Set vddio for Sharp LS013B7DH03 Display */
00156     void enableDisplay(void);
00157 
00158     /// Local I2C bus for configuring PMIC and accessing BMI160 IMU.
00159     I2C i2c;
00160 
00161     /// MAX20303 PMIC Instance
00162     MAX20303 max20303;
00163 
00164 
00165     InterruptIn *m_max32630hsp3_powerButtonInterrupt;
00166     bool    button_status;
00167     bool    button_longpressdetected;
00168     Timeout button_timeout;
00169 
00170     ButtonStatus status_powerButton;
00171     ButtonStatus status_upButton;
00172     ButtonStatus status_downButton;
00173     void event_powerButtonPressed(void);
00174     void event_powerButtonReleased(void);
00175     void event_longpresscheck(void);
00176 };
00177 
00178 #endif /* _MAX32630HSP_H_ */