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: max32630fthr Adafruit_FeatherOLED USBDevice
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 //Flag to check if ascii is enabled 00052 static bool AsciiEn; 00053 00054 const static uint8_t kMaxRegisterInOneStruct = 4; 00055 00056 // size of that struct is 20 bytes(checked) 00057 typedef struct{ 00058 uint8_t reg_adresses[4]; 00059 uint32_t reg_values[4]; 00060 }Reg_Val_BLE; 00061 00062 /* PUBLIC FUNCTION DECLARATIONS */ 00063 /** 00064 * @brief SensorComm constructor. 00065 * 00066 * @param[in] sensorType Name of sensor (ie "ppg") 00067 * @param[in] visible Whether this sensor should be visible to users in DeviceStudio 00068 */ 00069 SensorComm(const char *type, bool visible); 00070 00071 /** 00072 * @brief SensorComm destructor. 00073 * 00074 */ 00075 virtual ~SensorComm(); 00076 00077 /** 00078 * @brief Initializer for SensorComm. 00079 * 00080 * @param[in] s MaximSensor instance to handle sensor commands. 00081 */ 00082 void comm_init(MaximSensor *s); 00083 00084 /** 00085 * @brief Get the type of the sensor 00086 * 00087 * @param[out] char* to name of type (ie "ppg") 00088 */ 00089 const char* get_type(); 00090 00091 /** 00092 * @brief Get the maxim part name of the sensor 00093 * 00094 * @param[out] char* to name (ie "max86140") 00095 */ 00096 virtual const char* get_part_name(); 00097 00098 /** 00099 * @brief Get the maxim algorithm version of the sensor 00100 * 00101 * @param[out] char* to name (ie "max86140") 00102 */ 00103 virtual const char* get_algo_ver(); 00104 00105 /** 00106 * @brief Get the id and revision of the part 00107 * 00108 */ 00109 int get_part_info(uint8_t *part_id, uint8_t *part_rev); 00110 00111 /** 00112 * @brief Returns whether the sensor should be visible to users in DeviceStudio 00113 */ 00114 bool is_visible() { return vis; } 00115 00116 /** 00117 * @brief Get whether or not the sensor is enabled 00118 * 00119 * @param[out] true if the sensor is enabled 00120 */ 00121 bool is_enabled(); 00122 00123 /** 00124 * @brief Get data report mode of the sensor 00125 * 00126 * @param[out] data report mode 00127 */ 00128 uint8_t get_data_report_mode(); 00129 00130 00131 00132 /** 00133 * @brief Stop collecting data and disable sensor 00134 */ 00135 virtual void stop(); 00136 00137 /** 00138 * @brief Parses DeviceStudio commands. 00139 * @details Parses and executes commands. Prints return code to i/o device. 00140 * 00141 * @param[in] cmd - Command to parse 00142 * 00143 * @returns true if sensor acted upon the command, false if command was unknown 00144 */ 00145 virtual bool parse_command(const char* cmd); 00146 00147 /** 00148 * @brief Fill in buffer with sensor data 00149 * 00150 * @param[in] buf Buffer to fill data into 00151 * @param[in] size Maximum size of buffer 00152 * @param[out] Number of bytes written to buffer 00153 */ 00154 virtual int data_report_execute(char* buf, int size); 00155 00156 /** 00157 * 00158 * @param status 00159 */ 00160 void SensorComm_Set_Ble_Status (bool status); 00161 00162 void SensorComm_Set_Flash_Status(bool status); 00163 00164 int InsertRegValuesIntoBleQeueu(addr_val_pair *reg_values, uint8_t reg_count); 00165 00166 virtual unsigned char get_sensor_id(); 00167 00168 protected: 00169 00170 /* PROTECTED VARIABLES */ 00171 Mutex comm_mutex; 00172 00173 MaximSensor *sensor; 00174 00175 int sensor_get_reg(char *ptr_ch, uint8_t *reg_addr, uint8_t *value); 00176 int sensor_set_reg(char *ptr_ch); 00177 00178 volatile uint8_t data_report_mode; 00179 volatile uint8_t console_interface_exists; 00180 volatile bool m_sensorcomm_ble_interface_exists_; 00181 volatile bool m_sensorcomm_flash_rec_started_; 00182 00183 const char* sensor_type; 00184 bool vis; 00185 int sample_count; 00186 }; 00187 00188 #endif /* _SENSORCOMM_H_ */
Generated on Tue Jul 12 2022 20:09:29 by
