Library for MAXREFDES131 OneWire GridEYE sensor interface

Dependents:   MAXREFDES131_Qt_Demo MAXREFDES130_131_Demo

Committer:
j3
Date:
Mon Sep 26 15:08:17 2016 -0700
Revision:
12:4b7ac3b21d91
Parent:
7:c936b48baaff
Fix include paths

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 1:9e457e35e2e3 1 /**********************************************************************
j3 1:9e457e35e2e3 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
j3 1:9e457e35e2e3 3 *
j3 1:9e457e35e2e3 4 * Permission is hereby granted, free of charge, to any person obtaining a
j3 1:9e457e35e2e3 5 * copy of this software and associated documentation files (the "Software"),
j3 1:9e457e35e2e3 6 * to deal in the Software without restriction, including without limitation
j3 1:9e457e35e2e3 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 1:9e457e35e2e3 8 * and/or sell copies of the Software, and to permit persons to whom the
j3 1:9e457e35e2e3 9 * Software is furnished to do so, subject to the following conditions:
j3 1:9e457e35e2e3 10 *
j3 1:9e457e35e2e3 11 * The above copyright notice and this permission notice shall be included
j3 1:9e457e35e2e3 12 * in all copies or substantial portions of the Software.
j3 1:9e457e35e2e3 13 *
j3 1:9e457e35e2e3 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 1:9e457e35e2e3 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 1:9e457e35e2e3 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 1:9e457e35e2e3 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 1:9e457e35e2e3 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 1:9e457e35e2e3 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 1:9e457e35e2e3 20 * OTHER DEALINGS IN THE SOFTWARE.
j3 1:9e457e35e2e3 21 *
j3 1:9e457e35e2e3 22 * Except as contained in this notice, the name of Maxim Integrated
j3 1:9e457e35e2e3 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 1:9e457e35e2e3 24 * Products, Inc. Branding Policy.
j3 1:9e457e35e2e3 25 *
j3 1:9e457e35e2e3 26 * The mere transfer of this software does not imply any licenses
j3 1:9e457e35e2e3 27 * of trade secrets, proprietary technology, copyrights, patents,
j3 1:9e457e35e2e3 28 * trademarks, maskwork rights, or any other form of intellectual
j3 1:9e457e35e2e3 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 1:9e457e35e2e3 30 * ownership rights.
j3 1:9e457e35e2e3 31 **********************************************************************/
j3 1:9e457e35e2e3 32
j3 1:9e457e35e2e3 33
j3 1:9e457e35e2e3 34 #ifndef OWGRIDEYE_H
j3 1:9e457e35e2e3 35 #define OWGRIDEYE_H
j3 1:9e457e35e2e3 36
j3 1:9e457e35e2e3 37
j3 1:9e457e35e2e3 38 #include "mbed.h"
j3 12:4b7ac3b21d91 39 #include "Slaves/Bridges/Bridges.h"
j3 12:4b7ac3b21d91 40 #include "Slaves/Switches/Switches.h"
j3 2:b10e7a2961ab 41
j3 2:b10e7a2961ab 42 using namespace OneWire;
j3 2:b10e7a2961ab 43
j3 12:4b7ac3b21d91 44 #include "API_Level_1/grideye_api_lv1.h"
j3 12:4b7ac3b21d91 45 #include "API_Level_2/grideye_api_lv2.h"
j3 12:4b7ac3b21d91 46 #include "API_Level_3/grideye_api_lv3.h"
j3 1:9e457e35e2e3 47
j3 1:9e457e35e2e3 48
j3 2:b10e7a2961ab 49 /**
j3 2:b10e7a2961ab 50 * @brief Object for interfacing to MAXREFDES131#
j3 2:b10e7a2961ab 51 *
j3 2:b10e7a2961ab 52 * @details MAXREFDES131# combines the DS28E17 1-wire to I2C bridge
j3 2:b10e7a2961ab 53 * with the Panasonic AMG8833 GridEye sensor. The reference design also
j3 2:b10e7a2961ab 54 * includes a DS2413 2ch open drain switch for controlling the MAX4717
j3 2:b10e7a2961ab 55 * dual SPDT analog switch. The DS28E17 and AMG8833 are connected to
j3 2:b10e7a2961ab 56 * the 1-wire bus via COM2 of the MAX4717 and COM1 is used for
j3 2:b10e7a2961ab 57 * daisy-chaining additional modules. Disconnecting the DS28E17/AMG8833
j3 2:b10e7a2961ab 58 * from the main 1-wire branch puts both devices to sleep and reduces current
j3 2:b10e7a2961ab 59 * consumption from 10mA to a couple hundred uA.
j3 2:b10e7a2961ab 60 */
j3 1:9e457e35e2e3 61 class OWGridEye
j3 1:9e457e35e2e3 62 {
j3 2:b10e7a2961ab 63 private:
j3 2:b10e7a2961ab 64 DS2413 m_switch;
j3 2:b10e7a2961ab 65 DS28E17 m_i2c_bridge;
j3 2:b10e7a2961ab 66
j3 2:b10e7a2961ab 67 static const uint8_t I2C_ADRS = 0x68;
j3 2:b10e7a2961ab 68
j3 1:9e457e35e2e3 69 public:
j3 1:9e457e35e2e3 70
j3 2:b10e7a2961ab 71 /**
j3 2:b10e7a2961ab 72 * @brief OWGridEye command results
j3 2:b10e7a2961ab 73 */
j3 1:9e457e35e2e3 74 enum CmdResult
j3 1:9e457e35e2e3 75 {
j3 1:9e457e35e2e3 76 Success,
j3 1:9e457e35e2e3 77 OpFailure
j3 1:9e457e35e2e3 78 };
j3 1:9e457e35e2e3 79
j3 2:b10e7a2961ab 80 /**
j3 2:b10e7a2961ab 81 * @brief AMG8833 register map
j3 2:b10e7a2961ab 82 */
j3 1:9e457e35e2e3 83 enum GridEyeRegister
j3 1:9e457e35e2e3 84 {
j3 1:9e457e35e2e3 85 POWER_CONTROL,
j3 1:9e457e35e2e3 86 RESET,
j3 1:9e457e35e2e3 87 FRAME_RATE,
j3 1:9e457e35e2e3 88 INT_CONTROL,
j3 1:9e457e35e2e3 89 STATUS,
j3 1:9e457e35e2e3 90 STATUS_CLEAR,
j3 1:9e457e35e2e3 91 AVERAGE = 7,
j3 1:9e457e35e2e3 92 INT_LEVEL_1,
j3 1:9e457e35e2e3 93 INT_LEVEL_2,
j3 1:9e457e35e2e3 94 INT_LEVEL_3,
j3 1:9e457e35e2e3 95 INT_LEVEL_4,
j3 1:9e457e35e2e3 96 INT_LEVEL_5,
j3 1:9e457e35e2e3 97 INT_LEVEL_6,
j3 1:9e457e35e2e3 98 THERMISTOR_LOW,
j3 1:9e457e35e2e3 99 THERMISTOR_HI,
j3 1:9e457e35e2e3 100 INT_1,
j3 1:9e457e35e2e3 101 INT_2,
j3 1:9e457e35e2e3 102 INT_3,
j3 1:9e457e35e2e3 103 INT_4,
j3 1:9e457e35e2e3 104 INT_5,
j3 1:9e457e35e2e3 105 INT_6,
j3 1:9e457e35e2e3 106 INT_7,
j3 3:5b025369ad96 107 INT_8,
j3 3:5b025369ad96 108 PIXEL_BASE_ADRS = 0x80
j3 1:9e457e35e2e3 109 };
j3 1:9e457e35e2e3 110
j3 3:5b025369ad96 111 static const uint8_t DS2413_FAMILY_CODE = 0x3A;
j3 3:5b025369ad96 112
j3 3:5b025369ad96 113 static const uint8_t DS28E17_FAMILY_CODE = 0x19;
j3 1:9e457e35e2e3 114
j3 2:b10e7a2961ab 115 /**
j3 2:b10e7a2961ab 116 * @brief OWGridEye Constructor
j3 2:b10e7a2961ab 117 *
j3 2:b10e7a2961ab 118 * @details setOWSwitchRomId() and setI2CBridgeRomId() must be
j3 2:b10e7a2961ab 119 * called before any other member fxs.
j3 2:b10e7a2961ab 120 *
j3 2:b10e7a2961ab 121 * @param[in] selector - MultidropRomIterator object that
j3 2:b10e7a2961ab 122 * encapsulates ROM fxs of 1-wire protocol
j3 2:b10e7a2961ab 123 */
j3 2:b10e7a2961ab 124 OWGridEye(RandomAccessRomIterator & selector);
j3 1:9e457e35e2e3 125
j3 1:9e457e35e2e3 126
j3 2:b10e7a2961ab 127 /**
j3 2:b10e7a2961ab 128 * @brief setOWSwitchRomId
j3 2:b10e7a2961ab 129 *
j3 2:b10e7a2961ab 130 * @details sets the RomId of the DS2413
j3 2:b10e7a2961ab 131 *
j3 2:b10e7a2961ab 132 * On Entry:
j3 2:b10e7a2961ab 133 * @param[in] romId - RomId of the DS2413 for this module
j3 2:b10e7a2961ab 134 *
j3 2:b10e7a2961ab 135 * @return none
j3 2:b10e7a2961ab 136 */
j3 2:b10e7a2961ab 137 void setOWSwitchRomId(const RomId & romId)
j3 2:b10e7a2961ab 138 {
j3 2:b10e7a2961ab 139 m_switch.setRomId(romId);
j3 2:b10e7a2961ab 140 };
j3 2:b10e7a2961ab 141
j3 1:9e457e35e2e3 142
j3 2:b10e7a2961ab 143 /**
j3 5:b313caf74975 144 * @brief getOWSwitchRomId
j3 5:b313caf74975 145 *
j3 5:b313caf74975 146 * @details Gets the RomId of the DS2413 for this sensor.
j3 5:b313caf74975 147 * The romId must have been set first.
j3 5:b313caf74975 148 *
j3 5:b313caf74975 149 * @return RomId of the DS2413 for this sensor
j3 5:b313caf74975 150 */
j3 5:b313caf74975 151 RomId getOWSwitchRomId(void)
j3 5:b313caf74975 152 {
j3 5:b313caf74975 153 return m_switch.romId();
j3 5:b313caf74975 154 };
j3 5:b313caf74975 155
j3 5:b313caf74975 156
j3 5:b313caf74975 157 /**
j3 2:b10e7a2961ab 158 * @brief setI2CBridgeRomId
j3 2:b10e7a2961ab 159 *
j3 2:b10e7a2961ab 160 * @details sets the RomId of the DS28E17
j3 2:b10e7a2961ab 161 *
j3 2:b10e7a2961ab 162 * On Entry:
j3 2:b10e7a2961ab 163 * @param[in] romId - RomId of the DS28E17 for this module
j3 2:b10e7a2961ab 164 *
j3 2:b10e7a2961ab 165 * @return none
j3 2:b10e7a2961ab 166 */
j3 2:b10e7a2961ab 167 void setI2CBridgeRomId(const RomId & romId)
j3 2:b10e7a2961ab 168 {
j3 2:b10e7a2961ab 169 m_i2c_bridge.setRomId(romId);
j3 2:b10e7a2961ab 170 };
j3 5:b313caf74975 171
j3 5:b313caf74975 172
j3 5:b313caf74975 173 /**
j3 5:b313caf74975 174 * @brief getI2CBridgeRomId
j3 5:b313caf74975 175 *
j3 5:b313caf74975 176 * @details Gets the RomId of the DS28E17 for this sensor.
j3 5:b313caf74975 177 * The romId must have been set first.
j3 5:b313caf74975 178 *
j3 5:b313caf74975 179 * @return RomId of the DS28E17 for this sensor
j3 5:b313caf74975 180 */
j3 5:b313caf74975 181 RomId getI2CBridgeRomId(void)
j3 5:b313caf74975 182 {
j3 5:b313caf74975 183 return m_i2c_bridge.romId();
j3 5:b313caf74975 184 };
j3 2:b10e7a2961ab 185
j3 2:b10e7a2961ab 186
j3 2:b10e7a2961ab 187 /**
j3 2:b10e7a2961ab 188 * @brief disconnectGridEye
j3 2:b10e7a2961ab 189 *
j3 2:b10e7a2961ab 190 * @details Disconnects the DS28E17 and AMG8833 sensor putting both
j3 2:b10e7a2961ab 191 * to sleep
j3 2:b10e7a2961ab 192 *
j3 2:b10e7a2961ab 193 * @return CmdResult - result of operation
j3 2:b10e7a2961ab 194 */
j3 1:9e457e35e2e3 195 CmdResult disconnectGridEye(void);
j3 1:9e457e35e2e3 196
j3 2:b10e7a2961ab 197
j3 2:b10e7a2961ab 198 /**
j3 2:b10e7a2961ab 199 * @brief connectGridEye
j3 2:b10e7a2961ab 200 *
j3 2:b10e7a2961ab 201 * @details Connects the DS28E17 and AMG883 to 1-wire bus
j3 2:b10e7a2961ab 202 *
j3 2:b10e7a2961ab 203 * @return CmdResult - result of operation
j3 2:b10e7a2961ab 204 */
j3 1:9e457e35e2e3 205 CmdResult connectGridEye(void);
j3 1:9e457e35e2e3 206
j3 2:b10e7a2961ab 207
j3 2:b10e7a2961ab 208 /**
j3 2:b10e7a2961ab 209 * @brief connectOWbus
j3 2:b10e7a2961ab 210 *
j3 2:b10e7a2961ab 211 * @details Connects down stream devices on 1-wire bus
j3 2:b10e7a2961ab 212 *
j3 2:b10e7a2961ab 213 * @return CmdResult - result of operation
j3 2:b10e7a2961ab 214 */
j3 1:9e457e35e2e3 215 CmdResult connectOWbus(void);
j3 1:9e457e35e2e3 216
j3 2:b10e7a2961ab 217
j3 2:b10e7a2961ab 218 /**
j3 2:b10e7a2961ab 219 * @brief disconnectOWbus
j3 2:b10e7a2961ab 220 *
j3 2:b10e7a2961ab 221 * @details Disconnects down stream devices on 1-wire bus
j3 2:b10e7a2961ab 222 *
j3 2:b10e7a2961ab 223 * @return CmdResult - result of operation
j3 2:b10e7a2961ab 224 */
j3 1:9e457e35e2e3 225 CmdResult disconnectOWbus(void);
j3 1:9e457e35e2e3 226
j3 2:b10e7a2961ab 227
j3 2:b10e7a2961ab 228 /**
j3 2:b10e7a2961ab 229 * @brief gridEyeAccess
j3 2:b10e7a2961ab 230 *
j3 2:b10e7a2961ab 231 * @details Provides read/write access to the AMG8833
j3 2:b10e7a2961ab 232 *
j3 2:b10e7a2961ab 233 * On Entry:
j3 2:b10e7a2961ab 234 * @param[in] readWrite - Boolean flag indicating desired access
j3 2:b10e7a2961ab 235 * @param[in] regAdrs - AMG8833 register to start reading/writting
j3 2:b10e7a2961ab 236 * from/to
j3 2:b10e7a2961ab 237 * @param[in] numBytes - Number of bytes to read/write
j3 2:b10e7a2961ab 238 * @param[in] dataBuf - Pointer to data buffer for storing data in
j3 2:b10e7a2961ab 239 * on read, or data to be written on write
j3 2:b10e7a2961ab 240 *
j3 2:b10e7a2961ab 241 * On Exit:
j3 2:b10e7a2961ab 242 * @param[out] dataBuf - Read data on read operation
j3 2:b10e7a2961ab 243 *
j3 2:b10e7a2961ab 244 * @return CmdResult - result of operation
j3 2:b10e7a2961ab 245 */
j3 1:9e457e35e2e3 246 CmdResult gridEyeAccess(bool readWrite, GridEyeRegister regAdrs, uint8_t numBytes, uint8_t * dataBuf);
j3 4:6be732966106 247
j3 4:6be732966106 248
j3 4:6be732966106 249 /**
j3 4:6be732966106 250 * @brief gridEyeGetThermistor
j3 4:6be732966106 251 *
j3 4:6be732966106 252 * @details Gets internal thermistor temperature
j3 4:6be732966106 253 *
j3 4:6be732966106 254 * On Entry:
j3 4:6be732966106 255 * @param[in] thermTemp - reference to int16_t var that will be overwritten
j3 4:6be732966106 256 * with thermistor data
j3 4:6be732966106 257 *
j3 4:6be732966106 258 * On Exit:
j3 4:6be732966106 259 * @param[out] thermTemp - thermistor data
j3 4:6be732966106 260 *
j3 4:6be732966106 261 * @return CmdResult - result of operation
j3 4:6be732966106 262 */
j3 4:6be732966106 263 CmdResult gridEyeGetThermistor(int16_t & thermTemp);
j3 4:6be732966106 264
j3 4:6be732966106 265
j3 4:6be732966106 266 /**
j3 4:6be732966106 267 * @brief gridEyeGetPixelTemperature
j3 4:6be732966106 268 *
j3 4:6be732966106 269 * @details Gets individual pixel temperature
j3 4:6be732966106 270 *
j3 4:6be732966106 271 * On Entry:
j3 4:6be732966106 272 * @param[in] pixelAdrs - address of pixel to read
j3 4:6be732966106 273 * @param[in] pixelTemp - reference to int16_t var that will be overwritten
j3 4:6be732966106 274 * with thermistor data
j3 4:6be732966106 275 *
j3 4:6be732966106 276 * On Exit:
j3 4:6be732966106 277 * @param[out] pixelTemp - pixel data
j3 4:6be732966106 278 *
j3 4:6be732966106 279 * @return CmdResult - result of operation
j3 4:6be732966106 280 */
j3 4:6be732966106 281 CmdResult gridEyeGetPixelTemperature(uint8_t pixelAdrs, int16_t & pixelTemp);
j3 4:6be732966106 282
j3 4:6be732966106 283
j3 4:6be732966106 284 /**
j3 4:6be732966106 285 * @brief gridEyeGetFrameTemperature
j3 4:6be732966106 286 *
j3 4:6be732966106 287 * @details Gets pixel frame(64 pixels) temperature
j3 4:6be732966106 288 *
j3 4:6be732966106 289 * On Entry:
j3 4:6be732966106 290 * @param[in] frameTemp - buffer to hold data
j3 4:6be732966106 291 *
j3 4:6be732966106 292 * On Exit:
j3 4:6be732966106 293 * @param[out] frameTemp - pixel data
j3 4:6be732966106 294 *
j3 4:6be732966106 295 * @return CmdResult - result of operation
j3 4:6be732966106 296 */
j3 4:6be732966106 297 CmdResult gridEyeGetFrameTemperature(int16_t * frameTemp);
j3 1:9e457e35e2e3 298 };
j3 1:9e457e35e2e3 299
j3 1:9e457e35e2e3 300
j3 2:b10e7a2961ab 301 #endif /*OWGridEye_H*/