Arun Raj / Mbed OS MAXREFDES101_SOURCE

Dependencies:   max32630fthr Adafruit_FeatherOLED USBDevice

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_INACTIVE = 0,
00099         BUTTONSTATUS_RELEASED,
00100         BUTTONSTATUS_PRESSED,
00101         BUTTONSTATUS_PRESSED_WAITING,
00102         BUTTONSTATUS_LONG_PRESS,
00103         BUTTONSTATUS_LONG_PRESS_WAITING,
00104         BUTTONSTATUS_LONG_PRESS_WAITING_RED,
00105     } ;
00106 
00107     /**
00108         * MAX32630HSP constructor.
00109         *
00110         */
00111     MAX32630HSP();
00112 
00113     /**
00114         * MAX32630HSP constructor.
00115         *
00116         */
00117     MAX32630HSP(vio_t vio);
00118 
00119     /**
00120         * MAX32630HSP constructor.
00121         *
00122         */
00123     MAX32630HSP(vio_t vio, InterruptIn *max32630hsp3_powerButtonInterrupt);
00124 
00125     /**
00126         * MAX32630HSP destructor.
00127         */
00128     ~MAX32630HSP();
00129 
00130     //InterruptIn _interruptIn_PowerButton;
00131 
00132     /**
00133      * @brief   Initialize MAX32630HSP board
00134      * @details Initializes PMIC and I/O on MAX32630HSP board.
00135      *  Configures PMIC to enable LDO2 and LDO3 at 3.3V.
00136      *  Disables resisitive pulldown on MON(AIN_0)
00137      *  Sets default I/O voltages to 3V3 for micro SD card.
00138      *  Sets I/O voltage for header pins to hdrVio specified.
00139      * @param hdrVio I/O voltage for header pins
00140      * @returns 0 if no errors, -1 if error.
00141     */
00142     int init(vio_t hdrVio);
00143 
00144     /**
00145      * @brief   Sets I/O Voltage
00146      * @details Sets the voltage rail to be used for a given pin.
00147      *  VIO_1V8 selects VDDIO which is supplied by Buck2, which is set at 1.8V,
00148      *  VIO_3V3 selects VDDIOH which is supplied by LDO2, which is typically 3.3V/
00149      * @param   pin Pin whose voltage supply is being assigned.
00150      * @param   vio Voltage rail to be used for specified pin.
00151      * @returns 0 if no errors, -1 if error.
00152     */
00153     int vddioh(PinName pin, vio_t vio);
00154 
00155     /**Interrupt Hander for Power Button Press**/
00156 
00157     //InterruptIn _interruptIn_UpButton(PIN_UPBUTTON);
00158     //InterruptIn _interruptIn_DownButton(PIN_DOWNBUTTON);
00159 
00160     /* Set vddio for Sharp LS013B7DH03 Display */
00161     void enableDisplay(void);
00162 
00163     void Max32630HSP_CheckInterrupt_Status(void);
00164 
00165     /// Local I2C bus for configuring PMIC and accessing BMI160 IMU.
00166     I2C i2c;
00167 
00168     /// MAX20303 PMIC Instance
00169     MAX20303 max20303;
00170 
00171 
00172     InterruptIn *m_max32630hsp3_powerButtonInterrupt;
00173     Timeout button_timeout;
00174 
00175     volatile ButtonStatus status_powerButton;
00176     ButtonStatus status_upButton;
00177     ButtonStatus status_downButton;
00178     void event_powerButtonPressed(void);
00179     void event_powerButtonReleased(void);
00180     void event_longpresscheck(void);
00181 };
00182 
00183 #endif /* _MAX32630HSP_H_ */