Creating a project about VL6180XA1 for TT_Mxx

Committer:
ThunderSoft
Date:
Fri Apr 26 09:34:53 2019 +0000
Revision:
3:7a97a01bad5e
Parent:
0:293917667c17
"update the mbed-os code to support TT_M4G9"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ThunderSoft 0:293917667c17 1 /**
ThunderSoft 0:293917667c17 2 ******************************************************************************
ThunderSoft 0:293917667c17 3 * @file Switch.h
ThunderSoft 0:293917667c17 4 * @author AST / EST
ThunderSoft 0:293917667c17 5 * @version V0.0.1
ThunderSoft 0:293917667c17 6 * @date 14-April-2015
ThunderSoft 0:293917667c17 7 * @brief Header file for red switch
ThunderSoft 0:293917667c17 8 ******************************************************************************
ThunderSoft 0:293917667c17 9 * @attention
ThunderSoft 0:293917667c17 10 *
ThunderSoft 0:293917667c17 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
ThunderSoft 0:293917667c17 12 *
ThunderSoft 0:293917667c17 13 * Redistribution and use in source and binary forms, with or without modification,
ThunderSoft 0:293917667c17 14 * are permitted provided that the following conditions are met:
ThunderSoft 0:293917667c17 15 * 1. Redistributions of source code must retain the above copyright notice,
ThunderSoft 0:293917667c17 16 * this list of conditions and the following disclaimer.
ThunderSoft 0:293917667c17 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
ThunderSoft 0:293917667c17 18 * this list of conditions and the following disclaimer in the documentation
ThunderSoft 0:293917667c17 19 * and/or other materials provided with the distribution.
ThunderSoft 0:293917667c17 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
ThunderSoft 0:293917667c17 21 * may be used to endorse or promote products derived from this software
ThunderSoft 0:293917667c17 22 * without specific prior written permission.
ThunderSoft 0:293917667c17 23 *
ThunderSoft 0:293917667c17 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
ThunderSoft 0:293917667c17 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
ThunderSoft 0:293917667c17 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
ThunderSoft 0:293917667c17 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
ThunderSoft 0:293917667c17 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
ThunderSoft 0:293917667c17 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
ThunderSoft 0:293917667c17 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
ThunderSoft 0:293917667c17 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
ThunderSoft 0:293917667c17 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
ThunderSoft 0:293917667c17 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ThunderSoft 0:293917667c17 34 *
ThunderSoft 0:293917667c17 35 ******************************************************************************
ThunderSoft 0:293917667c17 36 */
ThunderSoft 0:293917667c17 37
ThunderSoft 0:293917667c17 38
ThunderSoft 0:293917667c17 39 #ifndef __SWITCH_H
ThunderSoft 0:293917667c17 40 #define __SWITCH_H
ThunderSoft 0:293917667c17 41
ThunderSoft 0:293917667c17 42
ThunderSoft 0:293917667c17 43 /* Includes ------------------------------------------------------------------*/
ThunderSoft 0:293917667c17 44
ThunderSoft 0:293917667c17 45 #include "mbed.h"
ThunderSoft 0:293917667c17 46 #include "STMPE1600.h"
ThunderSoft 0:293917667c17 47
ThunderSoft 0:293917667c17 48 #ifdef __cplusplus
ThunderSoft 0:293917667c17 49 extern "C" {
ThunderSoft 0:293917667c17 50 #endif
ThunderSoft 0:293917667c17 51
ThunderSoft 0:293917667c17 52 typedef enum {
ThunderSoft 0:293917667c17 53 RANGE = 0,
ThunderSoft 0:293917667c17 54 ALS
ThunderSoft 0:293917667c17 55 } SwitchState;
ThunderSoft 0:293917667c17 56
ThunderSoft 0:293917667c17 57
ThunderSoft 0:293917667c17 58 /* Classes -------------------------------------------------------------------*/
ThunderSoft 0:293917667c17 59
ThunderSoft 0:293917667c17 60 /**
ThunderSoft 0:293917667c17 61 * Class representing Red Switch
ThunderSoft 0:293917667c17 62 */
ThunderSoft 0:293917667c17 63
ThunderSoft 0:293917667c17 64 class Switch
ThunderSoft 0:293917667c17 65 {
ThunderSoft 0:293917667c17 66 public:
ThunderSoft 0:293917667c17 67 Switch(STMPE1600 &stmpe_1600, exp_gpio_pin_name Pin_Name=GPIO_11) : stmpe1600(stmpe_1600), PinName(Pin_Name) {
ThunderSoft 0:293917667c17 68 stmpe1600.set_gpio_dir(PinName, INPUT);
ThunderSoft 0:293917667c17 69 }
ThunderSoft 0:293917667c17 70
ThunderSoft 0:293917667c17 71 bool rd_switch () {
ThunderSoft 0:293917667c17 72 return stmpe1600.rd_gpio(PinName);
ThunderSoft 0:293917667c17 73 }
ThunderSoft 0:293917667c17 74
ThunderSoft 0:293917667c17 75 operator int() {
ThunderSoft 0:293917667c17 76 return rd_switch();
ThunderSoft 0:293917667c17 77 }
ThunderSoft 0:293917667c17 78
ThunderSoft 0:293917667c17 79 private:
ThunderSoft 0:293917667c17 80 STMPE1600 &stmpe1600;
ThunderSoft 0:293917667c17 81 exp_gpio_pin_name PinName;
ThunderSoft 0:293917667c17 82 };
ThunderSoft 0:293917667c17 83
ThunderSoft 0:293917667c17 84 #ifdef __cplusplus
ThunderSoft 0:293917667c17 85 }
ThunderSoft 0:293917667c17 86 #endif
ThunderSoft 0:293917667c17 87 #endif // __SWITCH_H
ThunderSoft 0:293917667c17 88