Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Committer:
IanBenzMaxim
Date:
Thu May 12 14:38:16 2016 -0500
Revision:
73:2cecc1372acc
Parent:
OneWire_Switches/DS2413/ds2413.h@54:08985bf69691
Child:
74:23be10c32fa3
Added namespaces. Renamed files and directories for consistency. Use <stdint.h> instead of <cstdint> since it is not supported by C++98.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j3 19:6d4c039a2d8e 1 /******************************************************************//**
j3 19:6d4c039a2d8e 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
j3 19:6d4c039a2d8e 3 *
j3 19:6d4c039a2d8e 4 * Permission is hereby granted, free of charge, to any person obtaining a
j3 19:6d4c039a2d8e 5 * copy of this software and associated documentation files (the "Software"),
j3 19:6d4c039a2d8e 6 * to deal in the Software without restriction, including without limitation
j3 19:6d4c039a2d8e 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
j3 19:6d4c039a2d8e 8 * and/or sell copies of the Software, and to permit persons to whom the
j3 19:6d4c039a2d8e 9 * Software is furnished to do so, subject to the following conditions:
j3 19:6d4c039a2d8e 10 *
j3 19:6d4c039a2d8e 11 * The above copyright notice and this permission notice shall be included
j3 19:6d4c039a2d8e 12 * in all copies or substantial portions of the Software.
j3 19:6d4c039a2d8e 13 *
j3 19:6d4c039a2d8e 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
j3 19:6d4c039a2d8e 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
j3 19:6d4c039a2d8e 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
j3 19:6d4c039a2d8e 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
j3 19:6d4c039a2d8e 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
j3 19:6d4c039a2d8e 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
j3 19:6d4c039a2d8e 20 * OTHER DEALINGS IN THE SOFTWARE.
j3 19:6d4c039a2d8e 21 *
j3 19:6d4c039a2d8e 22 * Except as contained in this notice, the name of Maxim Integrated
j3 19:6d4c039a2d8e 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
j3 19:6d4c039a2d8e 24 * Products, Inc. Branding Policy.
j3 19:6d4c039a2d8e 25 *
j3 19:6d4c039a2d8e 26 * The mere transfer of this software does not imply any licenses
j3 19:6d4c039a2d8e 27 * of trade secrets, proprietary technology, copyrights, patents,
j3 19:6d4c039a2d8e 28 * trademarks, maskwork rights, or any other form of intellectual
j3 19:6d4c039a2d8e 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
j3 19:6d4c039a2d8e 30 * ownership rights.
j3 19:6d4c039a2d8e 31 **********************************************************************/
j3 19:6d4c039a2d8e 32
IanBenzMaxim 73:2cecc1372acc 33 #ifndef OneWire_Switches_DS2413
IanBenzMaxim 73:2cecc1372acc 34 #define OneWire_Switches_DS2413
j3 19:6d4c039a2d8e 35
IanBenzMaxim 73:2cecc1372acc 36 #include <stdint.h>
IanBenzMaxim 73:2cecc1372acc 37 #include "OneWireSlave.h"
IanBenzMaxim 73:2cecc1372acc 38
IanBenzMaxim 73:2cecc1372acc 39 namespace OneWire
IanBenzMaxim 73:2cecc1372acc 40 {
IanBenzMaxim 73:2cecc1372acc 41 namespace Masters { class OneWireMaster; }
j3 19:6d4c039a2d8e 42
IanBenzMaxim 73:2cecc1372acc 43 namespace Switches
IanBenzMaxim 73:2cecc1372acc 44 {
IanBenzMaxim 73:2cecc1372acc 45 class DS2413 : public OneWireSlave
IanBenzMaxim 73:2cecc1372acc 46 {
IanBenzMaxim 73:2cecc1372acc 47 public:
IanBenzMaxim 73:2cecc1372acc 48
IanBenzMaxim 73:2cecc1372acc 49 enum DS2413_CMDS
IanBenzMaxim 73:2cecc1372acc 50 {
IanBenzMaxim 73:2cecc1372acc 51 PIO_ACCESS_READ = 0xF5,
IanBenzMaxim 73:2cecc1372acc 52 PIO_ACCESS_WRITE = 0x5A
IanBenzMaxim 73:2cecc1372acc 53 };
IanBenzMaxim 73:2cecc1372acc 54
IanBenzMaxim 73:2cecc1372acc 55 enum DS2413_PIO
IanBenzMaxim 73:2cecc1372acc 56 {
IanBenzMaxim 73:2cecc1372acc 57 PIOA,
IanBenzMaxim 73:2cecc1372acc 58 PIOB,
IanBenzMaxim 73:2cecc1372acc 59 PIOAB
IanBenzMaxim 73:2cecc1372acc 60 };
IanBenzMaxim 73:2cecc1372acc 61
IanBenzMaxim 73:2cecc1372acc 62 enum CmdResult
IanBenzMaxim 73:2cecc1372acc 63 {
IanBenzMaxim 73:2cecc1372acc 64 Success,
IanBenzMaxim 73:2cecc1372acc 65 CommsReadError,
IanBenzMaxim 73:2cecc1372acc 66 CommsWriteError,
IanBenzMaxim 73:2cecc1372acc 67 OpFailure
IanBenzMaxim 73:2cecc1372acc 68 };
IanBenzMaxim 73:2cecc1372acc 69
IanBenzMaxim 73:2cecc1372acc 70 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 71 * @brief DS2413 constructor
IanBenzMaxim 73:2cecc1372acc 72 *
IanBenzMaxim 73:2cecc1372acc 73 * @details
IanBenzMaxim 73:2cecc1372acc 74 *
IanBenzMaxim 73:2cecc1372acc 75 * On Entry:
IanBenzMaxim 73:2cecc1372acc 76 * @param[in] owm - reference to 1-wire master
IanBenzMaxim 73:2cecc1372acc 77 *
IanBenzMaxim 73:2cecc1372acc 78 * On Exit:
IanBenzMaxim 73:2cecc1372acc 79 *
IanBenzMaxim 73:2cecc1372acc 80 * @return
IanBenzMaxim 73:2cecc1372acc 81 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 82 DS2413(Masters::OneWireMaster &owm);
IanBenzMaxim 73:2cecc1372acc 83
j3 19:6d4c039a2d8e 84
IanBenzMaxim 73:2cecc1372acc 85 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 86 * @brief pio_access_read_chA()
IanBenzMaxim 73:2cecc1372acc 87 *
IanBenzMaxim 73:2cecc1372acc 88 * @details reads state of pio
IanBenzMaxim 73:2cecc1372acc 89 *
IanBenzMaxim 73:2cecc1372acc 90 * On Entry:
IanBenzMaxim 73:2cecc1372acc 91 * @param[in] romId - refernce to ROM # of switch
IanBenzMaxim 73:2cecc1372acc 92 *
IanBenzMaxim 73:2cecc1372acc 93 * On Exit:
IanBenzMaxim 73:2cecc1372acc 94 * @param[out] val - lsb represents the state of the pio
IanBenzMaxim 73:2cecc1372acc 95 *
IanBenzMaxim 73:2cecc1372acc 96 * @return CmdResult - result of operation
IanBenzMaxim 73:2cecc1372acc 97 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 98 CmdResult pio_access_read_chA(uint8_t & val);
IanBenzMaxim 73:2cecc1372acc 99
IanBenzMaxim 73:2cecc1372acc 100
IanBenzMaxim 73:2cecc1372acc 101 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 102 * @brief pio_access_read_chB()
IanBenzMaxim 73:2cecc1372acc 103 *
IanBenzMaxim 73:2cecc1372acc 104 * @details reads state of pio
IanBenzMaxim 73:2cecc1372acc 105 *
IanBenzMaxim 73:2cecc1372acc 106 * On Entry:
IanBenzMaxim 73:2cecc1372acc 107 * @param[in] romId - refernce to ROM # of switch
IanBenzMaxim 73:2cecc1372acc 108 *
IanBenzMaxim 73:2cecc1372acc 109 * On Exit:
IanBenzMaxim 73:2cecc1372acc 110 * @param[out] val - lsb represents the state of the pio
IanBenzMaxim 73:2cecc1372acc 111 *
IanBenzMaxim 73:2cecc1372acc 112 * @return CmdResult - result of operation
IanBenzMaxim 73:2cecc1372acc 113 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 114 CmdResult pio_access_read_chB(uint8_t & val);
IanBenzMaxim 73:2cecc1372acc 115
IanBenzMaxim 73:2cecc1372acc 116
IanBenzMaxim 73:2cecc1372acc 117 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 118 * @brief pio_acess_write_chA()
IanBenzMaxim 73:2cecc1372acc 119 *
IanBenzMaxim 73:2cecc1372acc 120 * @details writes to pio
IanBenzMaxim 73:2cecc1372acc 121 *
IanBenzMaxim 73:2cecc1372acc 122 * On Entry:
IanBenzMaxim 73:2cecc1372acc 123 * @param[in] romId - refernce to ROM # of switch
IanBenzMaxim 73:2cecc1372acc 124 * @param[in] val - lsb sets state of pio
IanBenzMaxim 73:2cecc1372acc 125 *
IanBenzMaxim 73:2cecc1372acc 126 * On Exit:
IanBenzMaxim 73:2cecc1372acc 127 *
IanBenzMaxim 73:2cecc1372acc 128 * @return CmdResult - result of operation
IanBenzMaxim 73:2cecc1372acc 129 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 130 CmdResult pio_access_write_chA(uint8_t val);
IanBenzMaxim 73:2cecc1372acc 131
IanBenzMaxim 73:2cecc1372acc 132
IanBenzMaxim 73:2cecc1372acc 133 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 134 * @brief pio_acess_write_chB()
IanBenzMaxim 73:2cecc1372acc 135 *
IanBenzMaxim 73:2cecc1372acc 136 * @details writes to pio
IanBenzMaxim 73:2cecc1372acc 137 *
IanBenzMaxim 73:2cecc1372acc 138 * On Entry:
IanBenzMaxim 73:2cecc1372acc 139 * @param[in] romId - refernce to ROM # of switch
IanBenzMaxim 73:2cecc1372acc 140 * @param[in] val - lsb sets state of pio
IanBenzMaxim 73:2cecc1372acc 141 *
IanBenzMaxim 73:2cecc1372acc 142 * On Exit:
IanBenzMaxim 73:2cecc1372acc 143 *
IanBenzMaxim 73:2cecc1372acc 144 * @return CmdResult - result of operation
IanBenzMaxim 73:2cecc1372acc 145 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 146 CmdResult pio_access_write_chB(uint8_t val);
IanBenzMaxim 73:2cecc1372acc 147
IanBenzMaxim 73:2cecc1372acc 148
IanBenzMaxim 73:2cecc1372acc 149 /**********************************************************//**
IanBenzMaxim 73:2cecc1372acc 150 * @brief pio_acess_write_chAB()
IanBenzMaxim 73:2cecc1372acc 151 *
IanBenzMaxim 73:2cecc1372acc 152 * @details writes to pio
IanBenzMaxim 73:2cecc1372acc 153 *
IanBenzMaxim 73:2cecc1372acc 154 * On Entry:
IanBenzMaxim 73:2cecc1372acc 155 * @param[in] romId - refernce to ROM # of switch
IanBenzMaxim 73:2cecc1372acc 156 * @param[in] val - Bits 1:0 set PIOB and PIOB respectively
IanBenzMaxim 73:2cecc1372acc 157 *
IanBenzMaxim 73:2cecc1372acc 158 * On Exit:
IanBenzMaxim 73:2cecc1372acc 159 *
IanBenzMaxim 73:2cecc1372acc 160 * @return CmdResult - result of operation
IanBenzMaxim 73:2cecc1372acc 161 **************************************************************/
IanBenzMaxim 73:2cecc1372acc 162 CmdResult pio_access_write_chAB(uint8_t val);
IanBenzMaxim 73:2cecc1372acc 163
j3 19:6d4c039a2d8e 164
IanBenzMaxim 73:2cecc1372acc 165 private:
IanBenzMaxim 73:2cecc1372acc 166
IanBenzMaxim 73:2cecc1372acc 167 CmdResult pio_access_read(uint8_t & val);
IanBenzMaxim 73:2cecc1372acc 168
IanBenzMaxim 73:2cecc1372acc 169 CmdResult pio_access_write(uint8_t val);
IanBenzMaxim 73:2cecc1372acc 170
IanBenzMaxim 73:2cecc1372acc 171 Masters::OneWireMaster &_owm;
IanBenzMaxim 73:2cecc1372acc 172
IanBenzMaxim 73:2cecc1372acc 173 };
IanBenzMaxim 73:2cecc1372acc 174 }
IanBenzMaxim 73:2cecc1372acc 175 }
IanBenzMaxim 73:2cecc1372acc 176
IanBenzMaxim 73:2cecc1372acc 177 #endif /*DS2413_H*/