Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: USBDevice max32630fthr
Fork of MAXREFDES220# by
SensorComm.h
00001 /******************************************************************************* 00002 * Copyright (C) 2017 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 _SENSORCOMM_H_ 00035 #define _SENSORCOMM_H_ 00036 00037 #include "mbed.h" 00038 #include <stdint.h> 00039 #include "MaximSensor.h" 00040 00041 /** 00042 * @brief SensorComm is Maxim Sensor Studio GUI command handler base class. 00043 * @details SensorComm includes base functions and data structures for to 00044 * create new command handler classes. All command handler classes should 00045 * implement this class. 00046 */ 00047 class SensorComm 00048 { 00049 public: 00050 00051 const static uint8_t kMaxRegisterInOneStruct = 4; 00052 00053 /* PUBLIC FUNCTION DECLARATIONS */ 00054 /** 00055 * @brief SensorComm constructor. 00056 * 00057 * @param[in] sensorType Name of sensor (ie "ppg") 00058 * @param[in] visible Whether this sensor should be visible to users in DeviceStudio 00059 */ 00060 SensorComm(const char *type, bool visible); 00061 00062 /** 00063 * @brief SensorComm destructor. 00064 * 00065 */ 00066 virtual ~SensorComm(); 00067 00068 /** 00069 * @brief Initializer for SensorComm. 00070 * 00071 * @param[in] s MaximSensor instance to handle sensor commands. 00072 */ 00073 void comm_init(MaximSensor *s); 00074 00075 /** 00076 * @brief Get the type of the sensor 00077 * 00078 * @param[out] char* to name of type (ie "ppg") 00079 */ 00080 const char* get_type(); 00081 00082 /** 00083 * @brief Get the maxim part name of the sensor 00084 * 00085 * @param[out] char* to name (ie "max86140") 00086 */ 00087 virtual const char* get_part_name(); 00088 00089 /** 00090 * @brief Get the id and revision of the part 00091 * 00092 */ 00093 int get_part_info(uint8_t *part_id, uint8_t *part_rev); 00094 00095 /** 00096 * @brief Returns whether the sensor should be visible to users in DeviceStudio 00097 */ 00098 bool is_visible() { return vis; } 00099 00100 /** 00101 * @brief Get whether or not the sensor is enabled 00102 * 00103 * @param[out] true if the sensor is enabled 00104 */ 00105 bool is_enabled(); 00106 00107 /** 00108 * @brief Stop collecting data and disable sensor 00109 */ 00110 virtual void stop(); 00111 00112 /** 00113 * @brief Parses DeviceStudio commands. 00114 * @details Parses and executes commands. Prints return code to i/o device. 00115 * 00116 * @param[in] cmd - Command to parse 00117 * 00118 * @returns true if sensor acted upon the command, false if command was unknown 00119 */ 00120 virtual bool parse_command(const char* cmd); 00121 00122 /** 00123 * @brief Fill in buffer with sensor data 00124 * 00125 * @param[in] buf Buffer to fill data into 00126 * @param[in] size Maximum size of buffer 00127 * @param[out] Number of bytes written to buffer 00128 */ 00129 virtual int data_report_execute(char* buf, int size); 00130 00131 protected: 00132 00133 /* PROTECTED VARIABLES */ 00134 Mutex comm_mutex; 00135 MaximSensor *sensor; 00136 00137 int sensor_get_reg(char *ptr_ch, uint8_t *reg_addr, uint8_t *value); 00138 int sensor_set_reg(char *ptr_ch); 00139 00140 volatile uint8_t data_report_mode; 00141 volatile uint8_t console_interface_exists; 00142 00143 const char* sensor_type; 00144 bool vis; 00145 int sample_count; 00146 }; 00147 00148 #endif /* _SENSORCOMM_H_ */
Generated on Mon Jul 18 2022 23:37:28 by
