Evironmental Shield API

Committer:
Deepti
Date:
Tue Aug 19 07:00:40 2014 +0000
Revision:
1:d37d15b70bc5
Parent:
0:9ac219c9a7df
Environment Shield API;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Deepti 0:9ac219c9a7df 1 /**
Deepti 0:9ac219c9a7df 2 ******************************************************************************
Deepti 0:9ac219c9a7df 3 * @file uvis3.h
Deepti 0:9ac219c9a7df 4 * @author AST Robotics Team
Deepti 0:9ac219c9a7df 5 * @version V0.0.1
Deepti 0:9ac219c9a7df 6 * @date 18-February-2014
Deepti 0:9ac219c9a7df 7 * @brief This file contains definitions uvis3.c
Deepti 0:9ac219c9a7df 8 * firmware driver.
Deepti 0:9ac219c9a7df 9 ******************************************************************************
Deepti 0:9ac219c9a7df 10 * @attention
Deepti 0:9ac219c9a7df 11 *
Deepti 0:9ac219c9a7df 12 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
Deepti 0:9ac219c9a7df 13 *
Deepti 0:9ac219c9a7df 14 * Redistribution and use in source and binary forms, with or without modification,
Deepti 0:9ac219c9a7df 15 * are permitted provided that the following conditions are met:
Deepti 0:9ac219c9a7df 16 * 1. Redistributions of source code must retain the above copyright notice,
Deepti 0:9ac219c9a7df 17 * this list of conditions and the following disclaimer.
Deepti 0:9ac219c9a7df 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
Deepti 0:9ac219c9a7df 19 * this list of conditions and the following disclaimer in the documentation
Deepti 0:9ac219c9a7df 20 * and/or other materials provided with the distribution.
Deepti 0:9ac219c9a7df 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Deepti 0:9ac219c9a7df 22 * may be used to endorse or promote products derived from this software
Deepti 0:9ac219c9a7df 23 * without specific prior written permission.
Deepti 0:9ac219c9a7df 24 *
Deepti 0:9ac219c9a7df 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Deepti 0:9ac219c9a7df 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Deepti 0:9ac219c9a7df 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Deepti 0:9ac219c9a7df 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Deepti 0:9ac219c9a7df 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Deepti 0:9ac219c9a7df 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Deepti 0:9ac219c9a7df 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Deepti 0:9ac219c9a7df 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Deepti 0:9ac219c9a7df 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Deepti 0:9ac219c9a7df 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Deepti 0:9ac219c9a7df 35 *
Deepti 0:9ac219c9a7df 36 ******************************************************************************
Deepti 0:9ac219c9a7df 37 */
Deepti 0:9ac219c9a7df 38
Deepti 0:9ac219c9a7df 39
Deepti 0:9ac219c9a7df 40 /* Define to prevent recursive inclusion -------------------------------------*/
Deepti 0:9ac219c9a7df 41 #ifndef __UVIS3_H
Deepti 0:9ac219c9a7df 42 #define __UVIS3_H
Deepti 0:9ac219c9a7df 43
Deepti 0:9ac219c9a7df 44 #ifdef __cplusplus
Deepti 0:9ac219c9a7df 45 extern "C" {
Deepti 0:9ac219c9a7df 46 #endif
Deepti 0:9ac219c9a7df 47
Deepti 0:9ac219c9a7df 48 /* Includes ------------------------------------------------------------------*/
Deepti 0:9ac219c9a7df 49 #include "../Common/uv.h"
Deepti 0:9ac219c9a7df 50
Deepti 0:9ac219c9a7df 51 /** @addtogroup BSP
Deepti 0:9ac219c9a7df 52 * @{
Deepti 0:9ac219c9a7df 53 */
Deepti 0:9ac219c9a7df 54
Deepti 0:9ac219c9a7df 55 /** @addtogroup UVIS3
Deepti 0:9ac219c9a7df 56 * @{
Deepti 0:9ac219c9a7df 57 */
Deepti 0:9ac219c9a7df 58
Deepti 0:9ac219c9a7df 59 /** @defgroup UVIS3_Exported_Constants
Deepti 0:9ac219c9a7df 60 * @{
Deepti 0:9ac219c9a7df 61 */
Deepti 0:9ac219c9a7df 62
Deepti 0:9ac219c9a7df 63 /******************************************************************************/
Deepti 0:9ac219c9a7df 64 /*************************** START REGISTER MAPPING **************************/
Deepti 0:9ac219c9a7df 65 /******************************************************************************/
Deepti 0:9ac219c9a7df 66 /**
Deepti 0:9ac219c9a7df 67 * @brief Device Address
Deepti 0:9ac219c9a7df 68 */
Deepti 0:9ac219c9a7df 69 #define UVIS3_ADDRESS 0x8E
Deepti 0:9ac219c9a7df 70
Deepti 0:9ac219c9a7df 71
Deepti 0:9ac219c9a7df 72 /**
Deepti 0:9ac219c9a7df 73 * @brief Device identifier register.
Deepti 0:9ac219c9a7df 74 * \code
Deepti 0:9ac219c9a7df 75 * Read
Deepti 0:9ac219c9a7df 76 * Default value: 0xBD
Deepti 0:9ac219c9a7df 77 * 7:0 This read-only register contains the device identifier that,
Deepti 0:9ac219c9a7df 78 for UVIS3, is set to 0xCA.
Deepti 0:9ac219c9a7df 79 * \endcode
Deepti 0:9ac219c9a7df 80 */
Deepti 0:9ac219c9a7df 81 #define UVIS3_WHO_AM_I_ADDR 0x0F
Deepti 0:9ac219c9a7df 82
Deepti 0:9ac219c9a7df 83
Deepti 0:9ac219c9a7df 84 /**
Deepti 0:9ac219c9a7df 85 * @brief UVIS3 control register 1
Deepti 0:9ac219c9a7df 86 * \code
Deepti 0:9ac219c9a7df 87 * Read/write
Deepti 0:9ac219c9a7df 88 * Default value: 0x80.
Deepti 0:9ac219c9a7df 89 * 7 PD: power down control. 1 - disable; 0 - enable.
Deepti 0:9ac219c9a7df 90 * 6:2 reserved.
Deepti 0:9ac219c9a7df 91 * 1 BDU: Block Data Update. 0 - continuous update; 1 -output registers not
Deepti 0:9ac219c9a7df 92 updated until MSB and LSB reading. //CHECK
Deepti 0:9ac219c9a7df 93 * 0 ODR: Output Data Rate. 0 - ODR disabled (one shot mode); 1 ODR at 1 Hz.
Deepti 0:9ac219c9a7df 94 * \endcode
Deepti 0:9ac219c9a7df 95 */
Deepti 0:9ac219c9a7df 96 #define UVIS3_CTRL_REG1_ADDR 0x20
Deepti 0:9ac219c9a7df 97
Deepti 0:9ac219c9a7df 98
Deepti 0:9ac219c9a7df 99 /**
Deepti 0:9ac219c9a7df 100 * @brief UVIS3 control register 2
Deepti 0:9ac219c9a7df 101 * \code
Deepti 0:9ac219c9a7df 102 * Read/write
Deepti 0:9ac219c9a7df 103 * Default value: 0x00.
Deepti 0:9ac219c9a7df 104 * 7 BOOT: reboot memory content. 1 - reload flash content; 0 - normal mode.
Deepti 0:9ac219c9a7df 105 * 6:5 reserved.
Deepti 0:9ac219c9a7df 106 * 4: I2C_DIS: Disable I2C interface. 0: enable; 1: disable.
Deepti 0:9ac219c9a7df 107 * 3 SIM: SPI Serial Interface Mode Selection. 0: 4 wires interface;
Deepti 0:9ac219c9a7df 108 1: 3 wires interface.
Deepti 0:9ac219c9a7df 109 * 2:1 Reserved
Deepti 0:9ac219c9a7df 110 * 0: One shot enable. 0: waiting for start of conversion;
Deepti 0:9ac219c9a7df 111 1: start for a new dataset.
Deepti 0:9ac219c9a7df 112 * \endcode
Deepti 0:9ac219c9a7df 113 */
Deepti 0:9ac219c9a7df 114 #define UVIS3_CTRL_REG2_ADDR 0x21
Deepti 0:9ac219c9a7df 115
Deepti 0:9ac219c9a7df 116
Deepti 0:9ac219c9a7df 117 /**
Deepti 0:9ac219c9a7df 118 * @brief UVIS3 control register 3
Deepti 0:9ac219c9a7df 119 * \code
Deepti 0:9ac219c9a7df 120 * Read/write
Deepti 0:9ac219c9a7df 121 * Default value: 0x00.
Deepti 0:9ac219c9a7df 122 * 7 INT_H_L: Interrupt active high, low. 0: active high; 1: active low.
Deepti 0:9ac219c9a7df 123 * 6 PP_OD: Push-pull/open drain selection on interrupt pads. 0: push-pull;
Deepti 0:9ac219c9a7df 124 1: open drain.
Deepti 0:9ac219c9a7df 125 * 5:2 Reserved
Deepti 0:9ac219c9a7df 126 * 1:0 INT1_S2, INT1_S1: data signal on INT1 pad control bits.
Deepti 0:9ac219c9a7df 127 Default value: 00.
Deepti 0:9ac219c9a7df 128 * | INT1_S2 | INT1_S1 | INT1 pin |
Deepti 0:9ac219c9a7df 129 * -------------------------------------------------
Deepti 0:9ac219c9a7df 130 * | 0 | 0 | Data ready |
Deepti 0:9ac219c9a7df 131 * | 0 | 1 | UV index High |
Deepti 0:9ac219c9a7df 132 * | 1 | 0 | UV index Low |
Deepti 0:9ac219c9a7df 133 * | 1 | 1 | UV index High or Low |
Deepti 0:9ac219c9a7df 134 * \endcode
Deepti 0:9ac219c9a7df 135 */
Deepti 0:9ac219c9a7df 136 #define UVIS3_CTRL_REG3_ADDR 0x22
Deepti 0:9ac219c9a7df 137
Deepti 0:9ac219c9a7df 138
Deepti 0:9ac219c9a7df 139 /**
Deepti 0:9ac219c9a7df 140 * @brief INT1 interrupt configuration
Deepti 0:9ac219c9a7df 141 * \code
Deepti 0:9ac219c9a7df 142 * Read/write
Deepti 0:9ac219c9a7df 143 * Default value: 0x00.
Deepti 0:9ac219c9a7df 144 * 7:4 Reserved.
Deepti 0:9ac219c9a7df 145 * 3: DIFF_EN: interrupt logical block enable. 0: interrupt logick block
Deepti 0:9ac219c9a7df 146 disable; 1: enable.
Deepti 0:9ac219c9a7df 147 * 2: LIR: Latch interrupt request into INT_SOURCE register with (24h), with
Deepti 0:9ac219c9a7df 148 the INT_SOURCE register cleared by reading INT_SOURCE reg (24h).
Deepti 0:9ac219c9a7df 149 0: interrupt request not latched;1: latched.
Deepti 0:9ac219c9a7df 150 * 1: UVLE: Enable interrupt generation on differential UV low event. 0: disable
Deepti 0:9ac219c9a7df 151 interrupt request;1: enable interrupt request
Deepti 0:9ac219c9a7df 152 * 0: UVHE: Enable interrupt generation on differential UV high event SIM;
Deepti 0:9ac219c9a7df 153 0: disable interrupt request;1: enable interrupt request
Deepti 0:9ac219c9a7df 154 * \endcode
Deepti 0:9ac219c9a7df 155 */
Deepti 0:9ac219c9a7df 156 #define UVIS3_INT_CFG_ADDR 0x23
Deepti 0:9ac219c9a7df 157
Deepti 0:9ac219c9a7df 158
Deepti 0:9ac219c9a7df 159
Deepti 0:9ac219c9a7df 160 /**
Deepti 0:9ac219c9a7df 161 * @brief Interrupt source configuration register
Deepti 0:9ac219c9a7df 162 * \code
Deepti 0:9ac219c9a7df 163 * Read/write
Deepti 0:9ac219c9a7df 164 * Default value: 0x00.
Deepti 0:9ac219c9a7df 165 * 7:3 Reserved.
Deepti 0:9ac219c9a7df 166 * 2: IA: Interrupt Active. 0: no interrupt has been generated;
Deepti 0:9ac219c9a7df 167 1: one or more interrupt events have been generated.
Deepti 0:9ac219c9a7df 168 * 1: UVL: Differential UV low. 0: no interrupt; 1: UVL event has occurred.
Deepti 0:9ac219c9a7df 169 * 0: UVH: Differential UV high. 0: no interrupt; 1: UVH event has occurred.
Deepti 0:9ac219c9a7df 170 * \endcode
Deepti 0:9ac219c9a7df 171 */
Deepti 0:9ac219c9a7df 172 #define UVIS3_INT_SRC_ADDR 0x24
Deepti 0:9ac219c9a7df 173
Deepti 0:9ac219c9a7df 174
Deepti 0:9ac219c9a7df 175
Deepti 0:9ac219c9a7df 176 /**
Deepti 0:9ac219c9a7df 177 * @brief Differential UV interrupt threshold
Deepti 0:9ac219c9a7df 178 * \code
Deepti 0:9ac219c9a7df 179 * Read/write
Deepti 0:9ac219c9a7df 180 * Default value: 0x00.
Deepti 0:9ac219c9a7df 181 * 7:0 Differential UV Interrupt Threshold values.
Deepti 0:9ac219c9a7df 182 * \endcode
Deepti 0:9ac219c9a7df 183 */
Deepti 0:9ac219c9a7df 184 #define UVIS3_DIFF_UV_TSH_ADDR 0x25
Deepti 0:9ac219c9a7df 185
Deepti 0:9ac219c9a7df 186
Deepti 0:9ac219c9a7df 187 /**
Deepti 0:9ac219c9a7df 188 * @brief Status register
Deepti 0:9ac219c9a7df 189 * \code
Deepti 0:9ac219c9a7df 190 * Read/write
Deepti 0:9ac219c9a7df 191 * Default value: 0x00.
Deepti 0:9ac219c9a7df 192 * 7:1 Reserved.
Deepti 0:9ac219c9a7df 193 * 0: UV_DA: UV data available. 0: UV data index not available; 1: UV data
Deepti 0:9ac219c9a7df 194 index available.
Deepti 0:9ac219c9a7df 195 * \endcode
Deepti 0:9ac219c9a7df 196 */
Deepti 0:9ac219c9a7df 197 #define UVIS3_STATUS_REG_ADDR 0x27
Deepti 0:9ac219c9a7df 198
Deepti 0:9ac219c9a7df 199
Deepti 0:9ac219c9a7df 200 /**
Deepti 0:9ac219c9a7df 201 * @brief UV index data
Deepti 0:9ac219c9a7df 202 * \code
Deepti 0:9ac219c9a7df 203 * Read/write
Deepti 0:9ac219c9a7df 204 * Default value: 0x00.
Deepti 0:9ac219c9a7df 205 * 7:0 UV index data output values.
Deepti 0:9ac219c9a7df 206 * \endcode
Deepti 0:9ac219c9a7df 207 */
Deepti 0:9ac219c9a7df 208 #define UVIS3_UVDATA_OUT_ADDR 0x28
Deepti 0:9ac219c9a7df 209
Deepti 0:9ac219c9a7df 210
Deepti 0:9ac219c9a7df 211 /******************************************************************************/
Deepti 0:9ac219c9a7df 212 /**************************** END REGISTER MAPPING ***************************/
Deepti 0:9ac219c9a7df 213 /******************************************************************************/
Deepti 0:9ac219c9a7df 214
Deepti 0:9ac219c9a7df 215 /**
Deepti 0:9ac219c9a7df 216 * @brief Device Identifier. Default value of the WHO_AM_I register.
Deepti 0:9ac219c9a7df 217 */
Deepti 0:9ac219c9a7df 218 #define I_AM_UVIS3 ((uint8_t)0xCA)
Deepti 0:9ac219c9a7df 219
Deepti 0:9ac219c9a7df 220 /** @defgroup Power_Mode_selection CTRL_REG1
Deepti 0:9ac219c9a7df 221 * @{
Deepti 0:9ac219c9a7df 222 */
Deepti 0:9ac219c9a7df 223 #define UVIS3_MODE_ACTIVE ((uint8_t)0x00)
Deepti 0:9ac219c9a7df 224 #define UVIS3_MODE_POWERDOWN ((uint8_t)0x80)
Deepti 0:9ac219c9a7df 225
Deepti 0:9ac219c9a7df 226 #define UVIS3_MODE_MASK ((uint8_t)0x80)
Deepti 0:9ac219c9a7df 227
Deepti 0:9ac219c9a7df 228 /**
Deepti 0:9ac219c9a7df 229 * @}
Deepti 0:9ac219c9a7df 230 */
Deepti 0:9ac219c9a7df 231
Deepti 0:9ac219c9a7df 232 /** @defgroup OutPut_DataRate_Selection CTRL_REG1
Deepti 0:9ac219c9a7df 233 * @{
Deepti 0:9ac219c9a7df 234 */
Deepti 0:9ac219c9a7df 235 #define UVIS3_ODR_ONE_SHOT ((uint8_t)0x00)
Deepti 0:9ac219c9a7df 236 #define UVIS3_ODR_1HZ ((uint8_t)0x01)
Deepti 0:9ac219c9a7df 237
Deepti 0:9ac219c9a7df 238 #define UVIS3_ODR_MASK ((uint8_t)0x01)
Deepti 0:9ac219c9a7df 239
Deepti 0:9ac219c9a7df 240 /**
Deepti 0:9ac219c9a7df 241 * @}
Deepti 0:9ac219c9a7df 242 */
Deepti 0:9ac219c9a7df 243
Deepti 0:9ac219c9a7df 244 /** @defgroup Boot_Mode_selection CTRL_REG2
Deepti 0:9ac219c9a7df 245 * @{
Deepti 0:9ac219c9a7df 246 */
Deepti 0:9ac219c9a7df 247 #define UVIS3_BOOT_NORMALMODE ((uint8_t)0x00)
Deepti 0:9ac219c9a7df 248 #define UVIS3_BOOT_REBOOTMEMORY ((uint8_t)0x80)
Deepti 0:9ac219c9a7df 249
Deepti 0:9ac219c9a7df 250 #define UVIS3_BOOT_MASK ((uint8_t)0x80)
Deepti 0:9ac219c9a7df 251
Deepti 0:9ac219c9a7df 252 /**
Deepti 0:9ac219c9a7df 253 * @}
Deepti 0:9ac219c9a7df 254 */
Deepti 0:9ac219c9a7df 255
Deepti 0:9ac219c9a7df 256
Deepti 0:9ac219c9a7df 257 /** @defgroup UVIS3_Exported_Functions
Deepti 0:9ac219c9a7df 258 * @{
Deepti 0:9ac219c9a7df 259 */
Deepti 0:9ac219c9a7df 260 /* Sensor Configuration Functions */
Deepti 0:9ac219c9a7df 261 void UVIS3_Init(UV_InitTypeDef *UVIS3_Init);
Deepti 0:9ac219c9a7df 262 uint8_t UVIS3_ReadID(void);
Deepti 0:9ac219c9a7df 263 void UVIS3_RebootCmd(void);
Deepti 0:9ac219c9a7df 264 void UVIS3_GetIndex(float* pfData);
Deepti 0:9ac219c9a7df 265
Deepti 0:9ac219c9a7df 266 /* Interrupt Configuration Functions */
Deepti 0:9ac219c9a7df 267 void UVIS3_INT1InterruptConfig(uint16_t Int1Config);
Deepti 0:9ac219c9a7df 268 void UVIS3_EnableIT(void);
Deepti 0:9ac219c9a7df 269 void UVIS3_DisableIT(void);
Deepti 0:9ac219c9a7df 270
Deepti 0:9ac219c9a7df 271 /* Uv sensor driver structure */
Deepti 0:9ac219c9a7df 272 extern UV_DrvTypeDef Uvis3Drv;
Deepti 0:9ac219c9a7df 273
Deepti 0:9ac219c9a7df 274 /* Uv sensor IO functions */
Deepti 0:9ac219c9a7df 275 void UV_IO_Init(void);
Deepti 0:9ac219c9a7df 276 void UV_IO_DeInit(void);
Deepti 0:9ac219c9a7df 277 void UV_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t WriteAddr, uint16_t NumByteToWrite);
Deepti 0:9ac219c9a7df 278 void UV_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead);
Deepti 0:9ac219c9a7df 279
Deepti 0:9ac219c9a7df 280 /**
Deepti 0:9ac219c9a7df 281 * @}
Deepti 0:9ac219c9a7df 282 */
Deepti 0:9ac219c9a7df 283
Deepti 0:9ac219c9a7df 284 /**
Deepti 0:9ac219c9a7df 285 * @}
Deepti 0:9ac219c9a7df 286 */
Deepti 0:9ac219c9a7df 287
Deepti 0:9ac219c9a7df 288 /**
Deepti 0:9ac219c9a7df 289 * @}
Deepti 0:9ac219c9a7df 290 */
Deepti 0:9ac219c9a7df 291
Deepti 0:9ac219c9a7df 292 #ifdef __cplusplus
Deepti 0:9ac219c9a7df 293 }
Deepti 0:9ac219c9a7df 294 #endif
Deepti 0:9ac219c9a7df 295
Deepti 0:9ac219c9a7df 296 #endif /* __UVIS3_H */
Deepti 0:9ac219c9a7df 297
Deepti 0:9ac219c9a7df 298
Deepti 0:9ac219c9a7df 299 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Deepti 0:9ac219c9a7df 300