Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Committer:
j3
Date:
Tue Feb 02 21:34:27 2016 +0000
Revision:
4:ca27db159b10
Parent:
3:644fc630f958
Child:
7:78a8857b3810
publishing privately for collaboration with other team members

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 4:ca27db159b10 1 /******************************************************************//**
j3 4:ca27db159b10 2 * @file ds28e17.cpp
j3 4:ca27db159b10 3 *
j3 4:ca27db159b10 4 * @author Justin Jordan
j3 4:ca27db159b10 5 *
j3 4:ca27db159b10 6 * @version 0.0.0
j3 4:ca27db159b10 7 *
j3 4:ca27db159b10 8 * Started: 31JAN16
j3 4:ca27db159b10 9 *
j3 4:ca27db159b10 10 * Updated:
j3 4:ca27db159b10 11 *
j3 4:ca27db159b10 12 * @brief Source file for DS28E17 1-wire to I2C bridge
j3 4:ca27db159b10 13 ***********************************************************************
j3 4:ca27db159b10 14 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
j3 4:ca27db159b10 15 *
j3 4:ca27db159b10 16 * Permission is hereby granted, free of charge, to any person obtaining a
j3 4:ca27db159b10 17 * copy of this software and associated documentation files (the "Software"),
j3 4:ca27db159b10 18 * to deal in the Software without restriction, including without limitation
j3 4:ca27db159b10 19 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 4:ca27db159b10 20 * and/or sell copies of the Software, and to permit persons to whom the
j3 4:ca27db159b10 21 * Software is furnished to do so, subject to the following conditions:
j3 4:ca27db159b10 22 *
j3 4:ca27db159b10 23 * The above copyright notice and this permission notice shall be included
j3 4:ca27db159b10 24 * in all copies or substantial portions of the Software.
j3 4:ca27db159b10 25 *
j3 4:ca27db159b10 26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 4:ca27db159b10 27 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 4:ca27db159b10 28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 4:ca27db159b10 29 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 4:ca27db159b10 30 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 4:ca27db159b10 31 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 4:ca27db159b10 32 * OTHER DEALINGS IN THE SOFTWARE.
j3 4:ca27db159b10 33 *
j3 4:ca27db159b10 34 * Except as contained in this notice, the name of Maxim Integrated
j3 4:ca27db159b10 35 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 4:ca27db159b10 36 * Products, Inc. Branding Policy.
j3 4:ca27db159b10 37 *
j3 4:ca27db159b10 38 * The mere transfer of this software does not imply any licenses
j3 4:ca27db159b10 39 * of trade secrets, proprietary technology, copyrights, patents,
j3 4:ca27db159b10 40 * trademarks, maskwork rights, or any other form of intellectual
j3 4:ca27db159b10 41 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 4:ca27db159b10 42 * ownership rights.
j3 4:ca27db159b10 43 **********************************************************************/
j3 4:ca27db159b10 44
j3 4:ca27db159b10 45
j3 4:ca27db159b10 46 #include "ds28e17.h"
j3 4:ca27db159b10 47
j3 4:ca27db159b10 48
j3 4:ca27db159b10 49 #define OW_ENABLE_DELAY 3
j3 4:ca27db159b10 50 #define CMD_I2C_WRITE_W_STOP 0x4B
j3 4:ca27db159b10 51 #define CMD_I2C_WRITE_NO_STOP 0x5A
j3 4:ca27db159b10 52 #define CMD_I2C_WRITE_ONLY 0x69
j3 4:ca27db159b10 53 #define CMD_I2C_WRITE_ONLY_W_STOP 0x78
j3 4:ca27db159b10 54 #define CMD_I2C_READ_W_STOP 0x87
j3 4:ca27db159b10 55 #define CMD_I2C_WRITE_READ_W_STOP 0x2D
j3 4:ca27db159b10 56 #define CMD_WRITE_CONFIG_REG 0xD2
j3 4:ca27db159b10 57 #define CMD_READ_CONFIG_REG 0xE1
j3 4:ca27db159b10 58 #define CMD_DISABLE_OW_MODE 0x96
j3 4:ca27db159b10 59 #define CMD_ENABLE_SLEEP_MODE 0x1E
j3 4:ca27db159b10 60 #define CMD_READ_DEVICE_REV 0xC3
j3 4:ca27db159b10 61 #define POLL_LIMIT 10000
j3 4:ca27db159b10 62
j3 4:ca27db159b10 63
j3 4:ca27db159b10 64 uint16_t Ds28e17::_oddparity[] = { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 };
j3 4:ca27db159b10 65
j3 4:ca27db159b10 66
j3 4:ca27db159b10 67 //*********************************************************************
j3 4:ca27db159b10 68 Ds28e17::Ds28e17(OneWireInterface *p_owm)
j3 4:ca27db159b10 69 {
j3 4:ca27db159b10 70 _p_owm = p_owm;
j3 4:ca27db159b10 71 _owm_owner = false;
j3 4:ca27db159b10 72 }
j3 4:ca27db159b10 73
j3 4:ca27db159b10 74
j3 4:ca27db159b10 75 //*********************************************************************
j3 4:ca27db159b10 76 Ds28e17::~Ds28e17()
j3 4:ca27db159b10 77 {
j3 4:ca27db159b10 78 if(_owm_owner)
j3 4:ca27db159b10 79 {
j3 4:ca27db159b10 80 delete _p_owm;
j3 4:ca27db159b10 81 }
j3 4:ca27db159b10 82 }
j3 4:ca27db159b10 83
j3 4:ca27db159b10 84
j3 4:ca27db159b10 85 //*********************************************************************
j3 4:ca27db159b10 86 bool Ds28e17::I2C_WriteDataWithStop(uint8_t I2C_addr, uint8_t length,
j3 4:ca27db159b10 87 uint8_t *data, uint8_t status,
j3 4:ca27db159b10 88 uint8_t wr_status)
j3 4:ca27db159b10 89 {
j3 4:ca27db159b10 90 bool rtn_val = false;
j3 4:ca27db159b10 91
j3 4:ca27db159b10 92 /*uint8_t send_cnt = 0;
j3 4:ca27db159b10 93 uint8_t i;
j3 4:ca27db159b10 94 uint16_t poll_count = 0;
j3 4:ca27db159b10 95 uint8_t send_block[0xFF];*/
j3 4:ca27db159b10 96
j3 4:ca27db159b10 97 return(rtn_val);
j3 4:ca27db159b10 98 }
j3 4:ca27db159b10 99
j3 4:ca27db159b10 100
j3 4:ca27db159b10 101 //*********************************************************************
j3 4:ca27db159b10 102 bool Ds28e17::I2C_WriteDataNoStop(uint8_t I2C_addr, uint8_t length,
j3 4:ca27db159b10 103 uint8_t *data, uint8_t status,
j3 4:ca27db159b10 104 uint8_t wr_status)
j3 4:ca27db159b10 105 {
j3 4:ca27db159b10 106 bool rtn_val = false;
j3 4:ca27db159b10 107
j3 4:ca27db159b10 108 return(rtn_val);
j3 4:ca27db159b10 109 }
j3 4:ca27db159b10 110
j3 4:ca27db159b10 111
j3 4:ca27db159b10 112 //*********************************************************************
j3 4:ca27db159b10 113 bool Ds28e17::I2C_WriteDataOnly(uint8_t length, uint8_t *data,
j3 4:ca27db159b10 114 uint8_t status, uint8_t wr_status)
j3 4:ca27db159b10 115 {
j3 4:ca27db159b10 116 bool rtn_val = false;
j3 4:ca27db159b10 117
j3 4:ca27db159b10 118 return(rtn_val);
j3 4:ca27db159b10 119 }
j3 4:ca27db159b10 120
j3 4:ca27db159b10 121
j3 4:ca27db159b10 122 //*********************************************************************
j3 4:ca27db159b10 123 bool Ds28e17::I2C_WriteDataOnlyWithStop(uint8_t length, uint8_t *data,
j3 4:ca27db159b10 124 uint8_t status, uint8_t wr_status)
j3 4:ca27db159b10 125 {
j3 4:ca27db159b10 126 bool rtn_val = false;
j3 4:ca27db159b10 127
j3 4:ca27db159b10 128 return(rtn_val);
j3 4:ca27db159b10 129 }
j3 4:ca27db159b10 130
j3 4:ca27db159b10 131
j3 4:ca27db159b10 132 //*********************************************************************
j3 4:ca27db159b10 133 bool Ds28e17::I2C_WriteReadDataWithStop(uint8_t I2C_addr, uint8_t length,
j3 4:ca27db159b10 134 uint8_t *data, uint8_t nu_bytes_read,
j3 4:ca27db159b10 135 uint8_t status, uint8_t wr_status,
j3 4:ca27db159b10 136 uint8_t *read_data)
j3 4:ca27db159b10 137 {
j3 4:ca27db159b10 138 bool rtn_val = false;
j3 4:ca27db159b10 139
j3 4:ca27db159b10 140 return(rtn_val);
j3 4:ca27db159b10 141 }
j3 4:ca27db159b10 142
j3 4:ca27db159b10 143
j3 4:ca27db159b10 144 //*********************************************************************
j3 4:ca27db159b10 145 bool Ds28e17::I2C_ReadDataWithStop(uint8_t I2C_addr, uint8_t nu_bytes_read,
j3 4:ca27db159b10 146 uint8_t status, uint8_t *read_data)
j3 4:ca27db159b10 147 {
j3 4:ca27db159b10 148 bool rtn_val = false;
j3 4:ca27db159b10 149
j3 4:ca27db159b10 150 return(rtn_val);
j3 4:ca27db159b10 151 }
j3 4:ca27db159b10 152
j3 4:ca27db159b10 153
j3 4:ca27db159b10 154 //*********************************************************************