removed X-NUCLEO-COMMON and ST-INTERFACES

Dependents:   unh-hackathon-example unh-hackathon-example-raw

Fork of X_NUCLEO_IKS01A1 by ST

Committer:
Wolfgang Betz
Date:
Mon Jun 15 10:28:49 2015 +0200
Revision:
57:04563dd74269
Parent:
54:2a676c734b30
Child:
88:7b8d3316d753
Further fine-tuning of doxygen comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wolfgang Betz 6:8d2abd695c52 1 /**
Wolfgang Betz 6:8d2abd695c52 2 ******************************************************************************
Wolfgang Betz 6:8d2abd695c52 3 * @file lps25h_class.h
Wolfgang Betz 6:8d2abd695c52 4 * @author AST / EST
Wolfgang Betz 6:8d2abd695c52 5 * @version V0.0.1
Wolfgang Betz 6:8d2abd695c52 6 * @date 14-April-2015
Wolfgang Betz 6:8d2abd695c52 7 * @brief Header file for component LPS25H
Wolfgang Betz 6:8d2abd695c52 8 ******************************************************************************
Wolfgang Betz 6:8d2abd695c52 9 * @attention
Wolfgang Betz 6:8d2abd695c52 10 *
Wolfgang Betz 6:8d2abd695c52 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
Wolfgang Betz 6:8d2abd695c52 12 *
Wolfgang Betz 6:8d2abd695c52 13 * Redistribution and use in source and binary forms, with or without modification,
Wolfgang Betz 6:8d2abd695c52 14 * are permitted provided that the following conditions are met:
Wolfgang Betz 6:8d2abd695c52 15 * 1. Redistributions of source code must retain the above copyright notice,
Wolfgang Betz 6:8d2abd695c52 16 * this list of conditions and the following disclaimer.
Wolfgang Betz 6:8d2abd695c52 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Wolfgang Betz 6:8d2abd695c52 18 * this list of conditions and the following disclaimer in the documentation
Wolfgang Betz 6:8d2abd695c52 19 * and/or other materials provided with the distribution.
Wolfgang Betz 6:8d2abd695c52 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Wolfgang Betz 6:8d2abd695c52 21 * may be used to endorse or promote products derived from this software
Wolfgang Betz 6:8d2abd695c52 22 * without specific prior written permission.
Wolfgang Betz 6:8d2abd695c52 23 *
Wolfgang Betz 6:8d2abd695c52 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Wolfgang Betz 6:8d2abd695c52 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Wolfgang Betz 6:8d2abd695c52 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Wolfgang Betz 6:8d2abd695c52 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Wolfgang Betz 6:8d2abd695c52 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Wolfgang Betz 6:8d2abd695c52 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Wolfgang Betz 6:8d2abd695c52 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Wolfgang Betz 6:8d2abd695c52 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Wolfgang Betz 6:8d2abd695c52 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Wolfgang Betz 6:8d2abd695c52 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Wolfgang Betz 6:8d2abd695c52 34 *
Wolfgang Betz 6:8d2abd695c52 35 ******************************************************************************
Wolfgang Betz 6:8d2abd695c52 36 */
Wolfgang Betz 6:8d2abd695c52 37
Wolfgang Betz 6:8d2abd695c52 38 #ifndef __LPS25H_CLASS_H
Wolfgang Betz 6:8d2abd695c52 39 #define __LPS25H_CLASS_H
Wolfgang Betz 6:8d2abd695c52 40
Wolfgang Betz 6:8d2abd695c52 41 /* Includes ------------------------------------------------------------------*/
Wolfgang Betz 6:8d2abd695c52 42 #include "mbed.h"
Wolfgang Betz 6:8d2abd695c52 43 #include "DevI2C.h"
Wolfgang Betz 57:04563dd74269 44 #include "lps25h.h"
Wolfgang Betz 43:2544d064d528 45 #include "../Interfaces/PressureSensor.h"
Wolfgang Betz 43:2544d064d528 46 #include "../Interfaces/TempSensor.h"
Wolfgang Betz 6:8d2abd695c52 47
Wolfgang Betz 6:8d2abd695c52 48 /* Classes -------------------------------------------------------------------*/
Wolfgang Betz 6:8d2abd695c52 49 /** Class representing a LPS25H sensor component
Wolfgang Betz 6:8d2abd695c52 50 */
Wolfgang Betz 20:c20c8bd5be6b 51 class LPS25H : public PressureSensor, public TempSensor {
Wolfgang Betz 6:8d2abd695c52 52 public:
Wolfgang Betz 6:8d2abd695c52 53 /** Constructor
Wolfgang Betz 54:2a676c734b30 54 * @param[in] i2c device I2C to be used for communication
Wolfgang Betz 6:8d2abd695c52 55 */
Wolfgang Betz 20:c20c8bd5be6b 56 LPS25H(DevI2C &i2c) : PressureSensor(), TempSensor(), dev_i2c(i2c) {
Wolfgang Betz 6:8d2abd695c52 57 LPS25H_SlaveAddress = LPS25H_ADDRESS_HIGH;
Wolfgang Betz 6:8d2abd695c52 58 }
Wolfgang Betz 6:8d2abd695c52 59
Wolfgang Betz 44:d757094f6229 60 /** Destructor
Wolfgang Betz 44:d757094f6229 61 */
Wolfgang Betz 44:d757094f6229 62 virtual ~LPS25H() {}
Wolfgang Betz 44:d757094f6229 63
Wolfgang Betz 6:8d2abd695c52 64 /*** Interface Methods ***/
Wolfgang Betz 18:1cb4ae9d83e7 65 virtual int Init(void *init_struct) {
Wolfgang Betz 18:1cb4ae9d83e7 66 return LPS25H_Init((PRESSURE_InitTypeDef*)init_struct);
Wolfgang Betz 6:8d2abd695c52 67 }
Wolfgang Betz 6:8d2abd695c52 68
Wolfgang Betz 50:f507d4465c31 69 /**
Wolfgang Betz 50:f507d4465c31 70 * @brief Enter sensor shutdown mode
Wolfgang Betz 50:f507d4465c31 71 * @return 0 in case of success, an error code otherwise
Wolfgang Betz 50:f507d4465c31 72 */
Wolfgang Betz 18:1cb4ae9d83e7 73 virtual int PowerOff(void) {
Wolfgang Betz 6:8d2abd695c52 74 return LPS25H_PowerOff();
Wolfgang Betz 6:8d2abd695c52 75 }
Wolfgang Betz 6:8d2abd695c52 76
Wolfgang Betz 18:1cb4ae9d83e7 77 virtual int ReadID(uint8_t *p_id) {
Wolfgang Betz 6:8d2abd695c52 78 return LPS25H_ReadID(p_id);
Wolfgang Betz 6:8d2abd695c52 79 }
Wolfgang Betz 6:8d2abd695c52 80
Wolfgang Betz 50:f507d4465c31 81 /**
Wolfgang Betz 50:f507d4465c31 82 * @brief Reset sensor
Wolfgang Betz 50:f507d4465c31 83 * @return 0 in case of success, an error code otherwise
Wolfgang Betz 50:f507d4465c31 84 */
Wolfgang Betz 18:1cb4ae9d83e7 85 virtual int Reset(void) {
Wolfgang Betz 6:8d2abd695c52 86 return LPS25H_RebootCmd();
Wolfgang Betz 6:8d2abd695c52 87 }
Wolfgang Betz 6:8d2abd695c52 88
Wolfgang Betz 18:1cb4ae9d83e7 89 virtual int GetPressure(float *pfData) {
Wolfgang Betz 6:8d2abd695c52 90 return LPS25H_GetPressure(pfData);
Wolfgang Betz 6:8d2abd695c52 91 }
Wolfgang Betz 6:8d2abd695c52 92
Wolfgang Betz 18:1cb4ae9d83e7 93 virtual int GetTemperature(float *pfData) {
Wolfgang Betz 6:8d2abd695c52 94 return LPS25H_GetTemperature(pfData);
Wolfgang Betz 6:8d2abd695c52 95 }
Wolfgang Betz 6:8d2abd695c52 96
Wolfgang Betz 20:c20c8bd5be6b 97 void SlaveAddrRemap(uint8_t SA0_Bit_Status) {
Wolfgang Betz 6:8d2abd695c52 98 LPS25H_SlaveAddrRemap(SA0_Bit_Status);
Wolfgang Betz 6:8d2abd695c52 99 }
Wolfgang Betz 6:8d2abd695c52 100
Wolfgang Betz 6:8d2abd695c52 101 protected:
Wolfgang Betz 6:8d2abd695c52 102 /*** Methods ***/
Wolfgang Betz 6:8d2abd695c52 103 PRESSURE_StatusTypeDef LPS25H_Init(PRESSURE_InitTypeDef *LPS25H_Init);
Wolfgang Betz 6:8d2abd695c52 104 PRESSURE_StatusTypeDef LPS25H_ReadID(uint8_t *p_id);
Wolfgang Betz 6:8d2abd695c52 105 PRESSURE_StatusTypeDef LPS25H_RebootCmd(void);
Wolfgang Betz 6:8d2abd695c52 106 PRESSURE_StatusTypeDef LPS25H_GetPressure(float* pfData);
Wolfgang Betz 6:8d2abd695c52 107 PRESSURE_StatusTypeDef LPS25H_GetTemperature(float* pfData);
Wolfgang Betz 6:8d2abd695c52 108 PRESSURE_StatusTypeDef LPS25H_PowerOff(void);
Wolfgang Betz 6:8d2abd695c52 109 void LPS25H_SlaveAddrRemap(uint8_t SA0_Bit_Status);
Wolfgang Betz 6:8d2abd695c52 110
Wolfgang Betz 6:8d2abd695c52 111 PRESSURE_StatusTypeDef LPS25H_PowerOn(void);
Wolfgang Betz 24:92cc9c6e4b2b 112 PRESSURE_StatusTypeDef LPS25H_I2C_ReadRawPressure(int32_t *raw_press);
Wolfgang Betz 6:8d2abd695c52 113 PRESSURE_StatusTypeDef LPS25H_I2C_ReadRawTemperature(int16_t *raw_data);
Wolfgang Betz 6:8d2abd695c52 114
Wolfgang Betz 6:8d2abd695c52 115 /**
Wolfgang Betz 6:8d2abd695c52 116 * @brief Configures LPS25H interrupt lines for NUCLEO boards
Wolfgang Betz 6:8d2abd695c52 117 */
Wolfgang Betz 6:8d2abd695c52 118 void LPS25H_IO_ITConfig(void)
Wolfgang Betz 6:8d2abd695c52 119 {
Wolfgang Betz 6:8d2abd695c52 120 /* To be implemented */
Wolfgang Betz 6:8d2abd695c52 121 }
Wolfgang Betz 6:8d2abd695c52 122
Wolfgang Betz 6:8d2abd695c52 123 /**
Wolfgang Betz 6:8d2abd695c52 124 * @brief Configures LPS25H I2C interface
Wolfgang Betz 57:04563dd74269 125 * @return PRESSURE_OK in case of success, an error code otherwise
Wolfgang Betz 6:8d2abd695c52 126 */
Wolfgang Betz 6:8d2abd695c52 127 PRESSURE_StatusTypeDef LPS25H_IO_Init(void)
Wolfgang Betz 6:8d2abd695c52 128 {
Wolfgang Betz 6:8d2abd695c52 129 return PRESSURE_OK; /* done in constructor */
Wolfgang Betz 6:8d2abd695c52 130 }
Wolfgang Betz 6:8d2abd695c52 131
Wolfgang Betz 6:8d2abd695c52 132 /**
Wolfgang Betz 57:04563dd74269 133 * @brief Utility function to read data from LPS25H
Wolfgang Betz 57:04563dd74269 134 * @param[out] pBuffer pointer to the byte-array to read data in to
Wolfgang Betz 57:04563dd74269 135 * @param[in] RegisterAddr specifies internal address register to read from.
Wolfgang Betz 57:04563dd74269 136 * @param[in] NumByteToRead number of bytes to be read.
Wolfgang Betz 57:04563dd74269 137 * @retval PRESSURE_OK if ok,
Wolfgang Betz 57:04563dd74269 138 * @retval PRESSURE_ERROR if an I2C error has occured
Wolfgang Betz 6:8d2abd695c52 139 */
Wolfgang Betz 6:8d2abd695c52 140 PRESSURE_StatusTypeDef LPS25H_IO_Read(uint8_t* pBuffer,
Wolfgang Betz 6:8d2abd695c52 141 uint8_t RegisterAddr, uint16_t NumByteToRead)
Wolfgang Betz 6:8d2abd695c52 142 {
Wolfgang Betz 6:8d2abd695c52 143 int ret = dev_i2c.i2c_read(pBuffer,
Wolfgang Betz 6:8d2abd695c52 144 LPS25H_SlaveAddress,
Wolfgang Betz 6:8d2abd695c52 145 RegisterAddr,
Wolfgang Betz 6:8d2abd695c52 146 NumByteToRead);
Wolfgang Betz 6:8d2abd695c52 147 if(ret != 0) {
Wolfgang Betz 6:8d2abd695c52 148 return PRESSURE_ERROR;
Wolfgang Betz 6:8d2abd695c52 149 }
Wolfgang Betz 6:8d2abd695c52 150 return PRESSURE_OK;
Wolfgang Betz 6:8d2abd695c52 151 }
Wolfgang Betz 6:8d2abd695c52 152
Wolfgang Betz 6:8d2abd695c52 153 /**
Wolfgang Betz 57:04563dd74269 154 * @brief Utility function to write data to LPS25H
Wolfgang Betz 57:04563dd74269 155 * @param[in] pBuffer pointer to the byte-array data to send
Wolfgang Betz 57:04563dd74269 156 * @param[in] RegisterAddr specifies internal address register to read from.
Wolfgang Betz 57:04563dd74269 157 * @param[in] NumByteToWrite number of bytes to write.
Wolfgang Betz 57:04563dd74269 158 * @retval PRESSURE_OK if ok,
Wolfgang Betz 57:04563dd74269 159 * @retval PRESSURE_ERROR if an I2C error has occured
Wolfgang Betz 6:8d2abd695c52 160 */
Wolfgang Betz 6:8d2abd695c52 161 PRESSURE_StatusTypeDef LPS25H_IO_Write(uint8_t* pBuffer,
Wolfgang Betz 6:8d2abd695c52 162 uint8_t RegisterAddr, uint16_t NumByteToWrite)
Wolfgang Betz 6:8d2abd695c52 163 {
Wolfgang Betz 6:8d2abd695c52 164 int ret = dev_i2c.i2c_write(pBuffer,
Wolfgang Betz 6:8d2abd695c52 165 LPS25H_SlaveAddress,
Wolfgang Betz 6:8d2abd695c52 166 RegisterAddr,
Wolfgang Betz 6:8d2abd695c52 167 NumByteToWrite);
Wolfgang Betz 6:8d2abd695c52 168 if(ret != 0) {
Wolfgang Betz 6:8d2abd695c52 169 return PRESSURE_ERROR;
Wolfgang Betz 6:8d2abd695c52 170 }
Wolfgang Betz 6:8d2abd695c52 171 return PRESSURE_OK;
Wolfgang Betz 6:8d2abd695c52 172 }
Wolfgang Betz 6:8d2abd695c52 173
Wolfgang Betz 6:8d2abd695c52 174 /*** Instance Variables ***/
Wolfgang Betz 6:8d2abd695c52 175 /* IO Device */
Wolfgang Betz 6:8d2abd695c52 176 DevI2C &dev_i2c;
Wolfgang Betz 6:8d2abd695c52 177
Wolfgang Betz 6:8d2abd695c52 178 uint8_t LPS25H_SlaveAddress;
Wolfgang Betz 6:8d2abd695c52 179 };
Wolfgang Betz 6:8d2abd695c52 180
Wolfgang Betz 6:8d2abd695c52 181 #endif // __LPS25H_CLASS_H