local changes to increase sample rate

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON_Local

Fork of X_NUCLEO_IKS01A1 by ST

Committer:
Wolfgang Betz
Date:
Wed Apr 15 13:45:30 2015 +0200
Revision:
6:8d2abd695c52
Child:
18:1cb4ae9d83e7
Added component LPS25H

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 6:8d2abd695c52 44 #include "../Common/Pressure.h"
Wolfgang Betz 6:8d2abd695c52 45 #include "lps25h.h"
Wolfgang Betz 6:8d2abd695c52 46
Wolfgang Betz 6:8d2abd695c52 47 /* Classes -------------------------------------------------------------------*/
Wolfgang Betz 6:8d2abd695c52 48 /** Class representing a LPS25H sensor component
Wolfgang Betz 6:8d2abd695c52 49 */
Wolfgang Betz 6:8d2abd695c52 50 class LPS25H : public Pressure {
Wolfgang Betz 6:8d2abd695c52 51 public:
Wolfgang Betz 6:8d2abd695c52 52 /** Constructor
Wolfgang Betz 6:8d2abd695c52 53 * @param i2c device I2C to be used for communication
Wolfgang Betz 6:8d2abd695c52 54 */
Wolfgang Betz 6:8d2abd695c52 55 LPS25H(DevI2C &i2c) : Pressure(), dev_i2c(i2c) {
Wolfgang Betz 6:8d2abd695c52 56 LPS25H_SlaveAddress = LPS25H_ADDRESS_HIGH;
Wolfgang Betz 6:8d2abd695c52 57 }
Wolfgang Betz 6:8d2abd695c52 58
Wolfgang Betz 6:8d2abd695c52 59 /*** Interface Methods ***/
Wolfgang Betz 6:8d2abd695c52 60 virtual PRESSURE_StatusTypeDef Init(PRESSURE_InitTypeDef *init_struct) {
Wolfgang Betz 6:8d2abd695c52 61 return LPS25H_Init(init_struct);
Wolfgang Betz 6:8d2abd695c52 62 }
Wolfgang Betz 6:8d2abd695c52 63
Wolfgang Betz 6:8d2abd695c52 64 virtual PRESSURE_StatusTypeDef PowerOff(void) {
Wolfgang Betz 6:8d2abd695c52 65 return LPS25H_PowerOff();
Wolfgang Betz 6:8d2abd695c52 66 }
Wolfgang Betz 6:8d2abd695c52 67
Wolfgang Betz 6:8d2abd695c52 68 virtual PRESSURE_StatusTypeDef ReadID(uint8_t *p_id) {
Wolfgang Betz 6:8d2abd695c52 69 return LPS25H_ReadID(p_id);
Wolfgang Betz 6:8d2abd695c52 70 }
Wolfgang Betz 6:8d2abd695c52 71
Wolfgang Betz 6:8d2abd695c52 72 virtual PRESSURE_StatusTypeDef Reset(void) {
Wolfgang Betz 6:8d2abd695c52 73 return LPS25H_RebootCmd();
Wolfgang Betz 6:8d2abd695c52 74 }
Wolfgang Betz 6:8d2abd695c52 75
Wolfgang Betz 6:8d2abd695c52 76 virtual void ConfigIT(uint16_t) { /* not yet implemented */ }
Wolfgang Betz 6:8d2abd695c52 77 virtual void EnableIT(uint8_t) { /* not yet implemented */ }
Wolfgang Betz 6:8d2abd695c52 78 virtual void DisableIT(uint8_t) { /* not yet implemented */ }
Wolfgang Betz 6:8d2abd695c52 79 virtual uint8_t ITStatus(uint16_t, uint16_t) { /* not yet implemented */ return 0; }
Wolfgang Betz 6:8d2abd695c52 80 virtual void ClearIT(uint16_t, uint16_t) { /* not yet implemented */ }
Wolfgang Betz 6:8d2abd695c52 81
Wolfgang Betz 6:8d2abd695c52 82 virtual PRESSURE_StatusTypeDef GetPressure(float *pfData) {
Wolfgang Betz 6:8d2abd695c52 83 return LPS25H_GetPressure(pfData);
Wolfgang Betz 6:8d2abd695c52 84 }
Wolfgang Betz 6:8d2abd695c52 85
Wolfgang Betz 6:8d2abd695c52 86 virtual PRESSURE_StatusTypeDef GetTemperature(float *pfData) {
Wolfgang Betz 6:8d2abd695c52 87 return LPS25H_GetTemperature(pfData);
Wolfgang Betz 6:8d2abd695c52 88 }
Wolfgang Betz 6:8d2abd695c52 89
Wolfgang Betz 6:8d2abd695c52 90 virtual void SlaveAddrRemap(uint8_t SA0_Bit_Status) {
Wolfgang Betz 6:8d2abd695c52 91 LPS25H_SlaveAddrRemap(SA0_Bit_Status);
Wolfgang Betz 6:8d2abd695c52 92 }
Wolfgang Betz 6:8d2abd695c52 93
Wolfgang Betz 6:8d2abd695c52 94 virtual void AttachIT(void (*fptr)(void)) { /* not yet implemented */ }
Wolfgang Betz 6:8d2abd695c52 95
Wolfgang Betz 6:8d2abd695c52 96 protected:
Wolfgang Betz 6:8d2abd695c52 97 /*** Methods ***/
Wolfgang Betz 6:8d2abd695c52 98 PRESSURE_StatusTypeDef LPS25H_Init(PRESSURE_InitTypeDef *LPS25H_Init);
Wolfgang Betz 6:8d2abd695c52 99 PRESSURE_StatusTypeDef LPS25H_ReadID(uint8_t *p_id);
Wolfgang Betz 6:8d2abd695c52 100 PRESSURE_StatusTypeDef LPS25H_RebootCmd(void);
Wolfgang Betz 6:8d2abd695c52 101 PRESSURE_StatusTypeDef LPS25H_GetPressure(float* pfData);
Wolfgang Betz 6:8d2abd695c52 102 PRESSURE_StatusTypeDef LPS25H_GetTemperature(float* pfData);
Wolfgang Betz 6:8d2abd695c52 103 PRESSURE_StatusTypeDef LPS25H_PowerOff(void);
Wolfgang Betz 6:8d2abd695c52 104 void LPS25H_SlaveAddrRemap(uint8_t SA0_Bit_Status);
Wolfgang Betz 6:8d2abd695c52 105
Wolfgang Betz 6:8d2abd695c52 106 PRESSURE_StatusTypeDef LPS25H_PowerOn(void);
Wolfgang Betz 6:8d2abd695c52 107 PRESSURE_StatusTypeDef LPS25H_I2C_ReadRawPressure(uint32_t *raw_press);
Wolfgang Betz 6:8d2abd695c52 108 PRESSURE_StatusTypeDef LPS25H_I2C_ReadRawTemperature(int16_t *raw_data);
Wolfgang Betz 6:8d2abd695c52 109
Wolfgang Betz 6:8d2abd695c52 110 /**
Wolfgang Betz 6:8d2abd695c52 111 * @brief Configures LPS25H interrupt lines for NUCLEO boards
Wolfgang Betz 6:8d2abd695c52 112 * @param None
Wolfgang Betz 6:8d2abd695c52 113 * @retval None
Wolfgang Betz 6:8d2abd695c52 114 */
Wolfgang Betz 6:8d2abd695c52 115 void LPS25H_IO_ITConfig(void)
Wolfgang Betz 6:8d2abd695c52 116 {
Wolfgang Betz 6:8d2abd695c52 117 /* To be implemented */
Wolfgang Betz 6:8d2abd695c52 118 }
Wolfgang Betz 6:8d2abd695c52 119
Wolfgang Betz 6:8d2abd695c52 120 /**
Wolfgang Betz 6:8d2abd695c52 121 * @brief Configures LPS25H I2C interface
Wolfgang Betz 6:8d2abd695c52 122 * @param None
Wolfgang Betz 6:8d2abd695c52 123 * @retval PRESSURE_OK in case of success, an error code otherwise
Wolfgang Betz 6:8d2abd695c52 124 */
Wolfgang Betz 6:8d2abd695c52 125 PRESSURE_StatusTypeDef LPS25H_IO_Init(void)
Wolfgang Betz 6:8d2abd695c52 126 {
Wolfgang Betz 6:8d2abd695c52 127 return PRESSURE_OK; /* done in constructor */
Wolfgang Betz 6:8d2abd695c52 128 }
Wolfgang Betz 6:8d2abd695c52 129
Wolfgang Betz 6:8d2abd695c52 130 /**
Wolfgang Betz 6:8d2abd695c52 131 * @brief utility function to read data from STC3115
Wolfgang Betz 6:8d2abd695c52 132 * @param pBuffer: pointer to data to be read.
Wolfgang Betz 6:8d2abd695c52 133 * @param RegisterAddr: specifies internal address register to read from.
Wolfgang Betz 6:8d2abd695c52 134 * @param NumByteToRead: number of bytes to be read.
Wolfgang Betz 6:8d2abd695c52 135 * @retval PRESSURE_OK if ok, PRESSURE_ERROR if an I2C error has occured
Wolfgang Betz 6:8d2abd695c52 136 */
Wolfgang Betz 6:8d2abd695c52 137 PRESSURE_StatusTypeDef LPS25H_IO_Read(uint8_t* pBuffer,
Wolfgang Betz 6:8d2abd695c52 138 uint8_t RegisterAddr, uint16_t NumByteToRead)
Wolfgang Betz 6:8d2abd695c52 139 {
Wolfgang Betz 6:8d2abd695c52 140 int ret = dev_i2c.i2c_read(pBuffer,
Wolfgang Betz 6:8d2abd695c52 141 LPS25H_SlaveAddress,
Wolfgang Betz 6:8d2abd695c52 142 RegisterAddr,
Wolfgang Betz 6:8d2abd695c52 143 NumByteToRead);
Wolfgang Betz 6:8d2abd695c52 144 if(ret != 0) {
Wolfgang Betz 6:8d2abd695c52 145 return PRESSURE_ERROR;
Wolfgang Betz 6:8d2abd695c52 146 }
Wolfgang Betz 6:8d2abd695c52 147 return PRESSURE_OK;
Wolfgang Betz 6:8d2abd695c52 148 }
Wolfgang Betz 6:8d2abd695c52 149
Wolfgang Betz 6:8d2abd695c52 150 /**
Wolfgang Betz 6:8d2abd695c52 151 * @brief utility function to write data to STC3115
Wolfgang Betz 6:8d2abd695c52 152 * @param pBuffer: pointer to buffer to be filled.
Wolfgang Betz 6:8d2abd695c52 153 * @param RegisterAddr: specifies internal address register to read from.
Wolfgang Betz 6:8d2abd695c52 154 * @param NumByteToWrite: number of bytes to write.
Wolfgang Betz 6:8d2abd695c52 155 * @retval 0 if ok, -1 if an I2C error has occured
Wolfgang Betz 6:8d2abd695c52 156 */
Wolfgang Betz 6:8d2abd695c52 157 PRESSURE_StatusTypeDef LPS25H_IO_Write(uint8_t* pBuffer,
Wolfgang Betz 6:8d2abd695c52 158 uint8_t RegisterAddr, uint16_t NumByteToWrite)
Wolfgang Betz 6:8d2abd695c52 159 {
Wolfgang Betz 6:8d2abd695c52 160 int ret = dev_i2c.i2c_write(pBuffer,
Wolfgang Betz 6:8d2abd695c52 161 LPS25H_SlaveAddress,
Wolfgang Betz 6:8d2abd695c52 162 RegisterAddr,
Wolfgang Betz 6:8d2abd695c52 163 NumByteToWrite);
Wolfgang Betz 6:8d2abd695c52 164 if(ret != 0) {
Wolfgang Betz 6:8d2abd695c52 165 return PRESSURE_ERROR;
Wolfgang Betz 6:8d2abd695c52 166 }
Wolfgang Betz 6:8d2abd695c52 167 return PRESSURE_OK;
Wolfgang Betz 6:8d2abd695c52 168 }
Wolfgang Betz 6:8d2abd695c52 169
Wolfgang Betz 6:8d2abd695c52 170 /*** Instance Variables ***/
Wolfgang Betz 6:8d2abd695c52 171 /* IO Device */
Wolfgang Betz 6:8d2abd695c52 172 DevI2C &dev_i2c;
Wolfgang Betz 6:8d2abd695c52 173
Wolfgang Betz 6:8d2abd695c52 174 uint8_t LPS25H_SlaveAddress;
Wolfgang Betz 6:8d2abd695c52 175 };
Wolfgang Betz 6:8d2abd695c52 176
Wolfgang Betz 6:8d2abd695c52 177 #endif // __LPS25H_CLASS_H