mbed library for STMicroelectronics' X-NUCLEO-IKA01A1 expansion board.
Dependents: HelloWorld_IKA01A1
Fork of X_NUCLEO_IKA01A1 by
TSZ124.h
00001 /** 00002 ****************************************************************************** 00003 * @file TSZ124.h 00004 * @author Central Labs 00005 * @version 1.0.0 00006 * @date 11-February-2016 00007 * @brief Portable architecture for TSZ124 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 00038 00039 /* Generated with STM32CubeTOO -----------------------------------------------*/ 00040 00041 00042 /* Revision ------------------------------------------------------------------*/ 00043 /* 00044 Repository: http://svn.x-nucleodev.codex.cro.st.com/svnroot/X-NucleoDev 00045 Branch/Trunk/Tag: trunk 00046 Based on: X-CUBE-IKA01A1/trunk/Drivers/BSP/Components/tsz124/tsz124.h 00047 Revision: 402 00048 */ 00049 00050 00051 /* Define to prevent recursive inclusion -------------------------------------*/ 00052 00053 #ifndef __TSZ124_CLASS_H 00054 #define __TSZ124_CLASS_H 00055 00056 00057 /* Includes ------------------------------------------------------------------*/ 00058 00059 /* ACTION 1 ------------------------------------------------------------------* 00060 * Include here platform specific header files. * 00061 *----------------------------------------------------------------------------*/ 00062 #include "mbed.h" 00063 /* ACTION 2 ------------------------------------------------------------------* 00064 * Include here component specific header files. * 00065 *----------------------------------------------------------------------------*/ 00066 #include "TSZ124_def.h" 00067 /* ACTION 3 ------------------------------------------------------------------* 00068 * Include here interface specific header files. * 00069 * * 00070 * Example: * 00071 * #include "HumiditySensor.h" * 00072 * #include "TemperatureSensor.h" * 00073 *----------------------------------------------------------------------------*/ 00074 #include "../Interfaces/InstrumentationAmp.h" 00075 #include "x_nucleo_ika01a1_config.h" 00076 00077 00078 /* Classes -------------------------------------------------------------------*/ 00079 00080 /** 00081 * @brief Class representing a TSZ124 operational amplifier component. 00082 */ 00083 class TSZ124 : public InstrumentationAmp 00084 { 00085 public: 00086 00087 /*** Constructor and Destructor Methods ***/ 00088 00089 /** 00090 * @brief Constructor. 00091 */ 00092 TSZ124(PinName instrumentAmpPin, PinName currentSensorPin) : InstrumentationAmp() 00093 { 00094 instrAmpPin = instrumentAmpPin; 00095 currentSensPin = currentSensorPin; 00096 } 00097 00098 /** 00099 * @brief Destructor. 00100 */ 00101 virtual ~TSZ124(void) {} 00102 00103 00104 /*** Public Component Related Methods ***/ 00105 00106 /* ACTION 5 --------------------------------------------------------------* 00107 * Implement here the component's public methods, as wrappers of the C * 00108 * component's functions. * 00109 * They should be: * 00110 * + Methods with the same name of the C component's virtual table's * 00111 * functions (1); * 00112 * + Methods with the same name of the C component's extended virtual * 00113 * table's functions, if any (2). * 00114 * * 00115 * Example: * 00116 * virtual int get_value(float *p_data) //(1) * 00117 * { * 00118 * return COMPONENT_get_value(float *pf_data); * 00119 * } * 00120 * * 00121 * virtual int enable_feature(void) //(2) * 00122 * { * 00123 * return COMPONENT_enable_feature(); * 00124 * } * 00125 *------------------------------------------------------------------------*/ 00126 00127 /** 00128 * @brief Public functions inherited from the Component Class 00129 */ 00130 00131 /** 00132 * @brief initialize class for TSZ124 operational amplifier component 00133 * @retval COMPONENT_OK if initialization is successfull 00134 * @retval suitable error code otherwise 00135 */ 00136 virtual int init(void *init = NULL) 00137 { 00138 return (int) TSZ124_Init((void *) init); 00139 } 00140 00141 /** 00142 * @brief obtain component ID for TSZ124 perational amplifier 00143 * @retval component ID for TSZ124 operational amplifier 00144 */ 00145 virtual int read_id(uint8_t *id = NULL) 00146 { 00147 return (int) TSZ124_ReadID((uint8_t *) id); 00148 } 00149 00150 /** 00151 * @brief Public functions inherited from the InstrumentationAmp Class 00152 */ 00153 00154 /** 00155 * @brief obtain the amplified differential voltage in instrumentation Amplifier configuration 00156 * @retval amplified differential voltage in instrumentation Amplifier configuration 00157 */ 00158 virtual unsigned int get_voltage(void) 00159 { 00160 const unsigned int ADC_RANGE_12_BIT = 0xFFF; 00161 AnalogIn ain(instrAmpPin); 00162 return ((double)ain.read())*805.0*ADC_RANGE_12_BIT/1000.0; 00163 } 00164 00165 /** 00166 * @brief obtain the current consumed by the application in Current sensing configuration 00167 * @retval current consumed by the application in Current sensing configuration 00168 */ 00169 virtual unsigned int get_current(void) 00170 { 00171 const unsigned int ADC_RANGE_12_BIT = 0xFFF; 00172 AnalogIn ain(currentSensPin); 00173 return ((double)ain.read())*1000.0*805.0*ADC_RANGE_12_BIT/1000.0/1586.0; 00174 } 00175 00176 00177 /*** Public Interrupt Related Methods ***/ 00178 00179 /* ACTION 6 --------------------------------------------------------------* 00180 * Implement here interrupt related methods, if any. * 00181 * Note that interrupt handling is platform dependent, e.g.: * 00182 * + mbed: * 00183 * InterruptIn feature_irq(pin); //Interrupt object. * 00184 * feature_irq.fall(callback); //Attach a callback. * 00185 * feature_irq.mode(PullNone); //Set interrupt mode. * 00186 * feature_irq.enable_irq(); //Enable interrupt. * 00187 * feature_irq.disable_irq(); //Disable interrupt. * 00188 * + Arduino: * 00189 * attachInterrupt(pin, callback, RISING); //Attach a callback. * 00190 * detachInterrupt(pin); //Detach a callback. * 00191 * * 00192 * Example (mbed): * 00193 * void attach_feature_irq(void (*fptr) (void)) * 00194 * { * 00195 * feature_irq.rise(fptr); * 00196 * } * 00197 * * 00198 * void enable_feature_irq(void) * 00199 * { * 00200 * feature_irq.enable_irq(); * 00201 * } * 00202 * * 00203 * void disable_feature_irq(void) * 00204 * { * 00205 * feature_irq.disable_irq(); * 00206 * } * 00207 *------------------------------------------------------------------------*/ 00208 00209 00210 protected: 00211 00212 /*** Protected Component Related Methods ***/ 00213 00214 /* ACTION 7 --------------------------------------------------------------* 00215 * Declare here the component's specific methods. * 00216 * They should be: * 00217 * + Methods with the same name of the C component's virtual table's * 00218 * functions (1); * 00219 * + Methods with the same name of the C component's extended virtual * 00220 * table's functions, if any (2); * 00221 * + Helper methods, if any, like functions declared in the component's * 00222 * source files but not pointed by the component's virtual table (3). * 00223 * * 00224 * Example: * 00225 * status_t COMPONENT_get_value(float *f); //(1) * 00226 * status_t COMPONENT_enable_feature(void); //(2) * 00227 * status_t COMPONENT_compute_average(void); //(3) * 00228 *------------------------------------------------------------------------*/ 00229 /* TSZ124's generic functions. */ 00230 status_t TSZ124_Init(void *init); 00231 unsigned int TSZ124_ReadID(void *id); 00232 PinName instrAmpPin; 00233 PinName currentSensPin; 00234 00235 00236 /*** Component's Instance Variables ***/ 00237 00238 /* ACTION 9 --------------------------------------------------------------* 00239 * Declare here interrupt related variables, if needed. * 00240 * Note that interrupt handling is platform dependent, see * 00241 * "Interrupt Related Methods" above. * 00242 * * 00243 * Example: * 00244 * + mbed: * 00245 * InterruptIn feature_irq; * 00246 *------------------------------------------------------------------------*/ 00247 00248 /* ACTION 10 -------------------------------------------------------------* 00249 * Declare here other pin related variables, if needed. * 00250 * * 00251 * Example: * 00252 * + mbed: * 00253 * DigitalOut standby_reset; * 00254 *------------------------------------------------------------------------*/ 00255 00256 /* ACTION 11 -------------------------------------------------------------* 00257 * Declare here communication related variables, if needed. * 00258 * * 00259 * Example: * 00260 * + mbed: * 00261 * DigitalOut address; * 00262 * DevI2C &dev_i2c; * 00263 *------------------------------------------------------------------------*/ 00264 00265 /* ACTION 12 -------------------------------------------------------------* 00266 * Declare here identity related variables, if needed. * 00267 * Note that there should be only a unique identifier for each component, * 00268 * which should be the "who_am_i" parameter. * 00269 *------------------------------------------------------------------------*/ 00270 /* Identity */ 00271 uint8_t who_am_i; 00272 00273 /* ACTION 13 -------------------------------------------------------------* 00274 * Declare here the component's static and non-static data, one variable * 00275 * per line. * 00276 * * 00277 * Example: * 00278 * float measure; * 00279 * int instance_id; * 00280 * static int number_of_instances; * 00281 *------------------------------------------------------------------------*/ 00282 }; 00283 00284 #endif /* __TSZ124_CLASS_H */ 00285 00286 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 17:01:48 by 1.7.2