Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
Masters/DS2480B/DS2480B.h@109:5c9180b4be25, 2016-08-05 (annotated)
- Committer:
- IanBenzMaxim
- Date:
- Fri Aug 05 15:06:47 2016 -0500
- Revision:
- 109:5c9180b4be25
- Parent:
- 92:aa40c49b8563
Begin cleanup of DS2480B. Removed receive buffer and some unused functionality.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
j3 | 3:644fc630f958 | 1 | /******************************************************************//** |
j3 | 3:644fc630f958 | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
j3 | 3:644fc630f958 | 3 | * |
j3 | 3:644fc630f958 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
j3 | 3:644fc630f958 | 5 | * copy of this software and associated documentation files (the "Software"), |
j3 | 3:644fc630f958 | 6 | * to deal in the Software without restriction, including without limitation |
j3 | 3:644fc630f958 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
j3 | 3:644fc630f958 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
j3 | 3:644fc630f958 | 9 | * Software is furnished to do so, subject to the following conditions: |
j3 | 3:644fc630f958 | 10 | * |
j3 | 3:644fc630f958 | 11 | * The above copyright notice and this permission notice shall be included |
j3 | 3:644fc630f958 | 12 | * in all copies or substantial portions of the Software. |
j3 | 3:644fc630f958 | 13 | * |
j3 | 3:644fc630f958 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
j3 | 3:644fc630f958 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
j3 | 3:644fc630f958 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
j3 | 3:644fc630f958 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
j3 | 3:644fc630f958 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
j3 | 3:644fc630f958 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
j3 | 3:644fc630f958 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
j3 | 3:644fc630f958 | 21 | * |
j3 | 3:644fc630f958 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
j3 | 3:644fc630f958 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
j3 | 3:644fc630f958 | 24 | * Products, Inc. Branding Policy. |
j3 | 3:644fc630f958 | 25 | * |
j3 | 3:644fc630f958 | 26 | * The mere transfer of this software does not imply any licenses |
j3 | 3:644fc630f958 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
j3 | 3:644fc630f958 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
j3 | 3:644fc630f958 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
j3 | 3:644fc630f958 | 30 | * ownership rights. |
j3 | 3:644fc630f958 | 31 | **********************************************************************/ |
j3 | 3:644fc630f958 | 32 | |
IanBenzMaxim | 73:2cecc1372acc | 33 | #ifndef OneWire_Masters_DS2480B |
IanBenzMaxim | 73:2cecc1372acc | 34 | #define OneWire_Masters_DS2480B |
j3 | 3:644fc630f958 | 35 | |
IanBenzMaxim | 109:5c9180b4be25 | 36 | #include "Serial.h" |
IanBenzMaxim | 73:2cecc1372acc | 37 | #include "Masters/OneWireMaster.h" |
j3 | 3:644fc630f958 | 38 | |
IanBenzMaxim | 73:2cecc1372acc | 39 | namespace OneWire |
j3 | 3:644fc630f958 | 40 | { |
IanBenzMaxim | 109:5c9180b4be25 | 41 | /// Serial to 1-Wire Line Driver |
IanBenzMaxim | 76:84e6c4994e29 | 42 | class DS2480B : public OneWireMaster |
j3 | 63:422be898443a | 43 | { |
IanBenzMaxim | 76:84e6c4994e29 | 44 | public: |
IanBenzMaxim | 109:5c9180b4be25 | 45 | /// Baud rates for DS2480B |
IanBenzMaxim | 109:5c9180b4be25 | 46 | enum BaudRate |
IanBenzMaxim | 73:2cecc1372acc | 47 | { |
IanBenzMaxim | 109:5c9180b4be25 | 48 | Baud9600bps = 0, ///< 9600 bps |
IanBenzMaxim | 109:5c9180b4be25 | 49 | Baud19200bps = 2, ///< 19200 bps |
IanBenzMaxim | 109:5c9180b4be25 | 50 | Baud57600bps = 4, ///< 57600 bps |
IanBenzMaxim | 109:5c9180b4be25 | 51 | Baud115200bps = 6 ///< 115200 bps |
IanBenzMaxim | 76:84e6c4994e29 | 52 | }; |
IanBenzMaxim | 74:23be10c32fa3 | 53 | |
IanBenzMaxim | 109:5c9180b4be25 | 54 | DS2480B(PinName tx, PinName rx); |
j3 | 3:644fc630f958 | 55 | |
IanBenzMaxim | 76:84e6c4994e29 | 56 | virtual OneWireMaster::CmdResult OWInitMaster(); |
IanBenzMaxim | 76:84e6c4994e29 | 57 | virtual OneWireMaster::CmdResult OWReset(); |
IanBenzMaxim | 76:84e6c4994e29 | 58 | virtual OneWireMaster::CmdResult OWTouchBitSetLevel(uint8_t & sendRecvBit, OWLevel afterLevel); |
IanBenzMaxim | 76:84e6c4994e29 | 59 | virtual OneWireMaster::CmdResult OWWriteByteSetLevel(uint8_t sendByte, OWLevel afterLevel); |
IanBenzMaxim | 76:84e6c4994e29 | 60 | virtual OneWireMaster::CmdResult OWReadByteSetLevel(uint8_t & recvByte, OWLevel afterLevel); |
IanBenzMaxim | 76:84e6c4994e29 | 61 | virtual OneWireMaster::CmdResult OWSetSpeed(OWSpeed newSpeed); |
IanBenzMaxim | 76:84e6c4994e29 | 62 | virtual OneWireMaster::CmdResult OWSetLevel(OWLevel newLevel); |
IanBenzMaxim | 109:5c9180b4be25 | 63 | |
IanBenzMaxim | 109:5c9180b4be25 | 64 | OneWireMaster::CmdResult detect(); |
IanBenzMaxim | 109:5c9180b4be25 | 65 | OneWireMaster::CmdResult changeBaud(BaudRate newBaud); |
IanBenzMaxim | 74:23be10c32fa3 | 66 | |
IanBenzMaxim | 76:84e6c4994e29 | 67 | private: |
IanBenzMaxim | 109:5c9180b4be25 | 68 | OneWireMaster::CmdResult writeCom(size_t outlen, uint8_t *outbuf); |
IanBenzMaxim | 109:5c9180b4be25 | 69 | OneWireMaster::CmdResult readCom(size_t inlen, uint8_t *inbuf); |
IanBenzMaxim | 109:5c9180b4be25 | 70 | void breakCom(); |
IanBenzMaxim | 109:5c9180b4be25 | 71 | void flushCom(); |
IanBenzMaxim | 109:5c9180b4be25 | 72 | void setComBaud(BaudRate new_baud); |
IanBenzMaxim | 74:23be10c32fa3 | 73 | |
IanBenzMaxim | 109:5c9180b4be25 | 74 | // COM interface |
IanBenzMaxim | 109:5c9180b4be25 | 75 | mbed::Serial serial; |
IanBenzMaxim | 74:23be10c32fa3 | 76 | |
IanBenzMaxim | 76:84e6c4994e29 | 77 | // DS2480B state |
IanBenzMaxim | 109:5c9180b4be25 | 78 | OWLevel level; // 1-Wire level |
IanBenzMaxim | 109:5c9180b4be25 | 79 | BaudRate baud; // baud rate |
IanBenzMaxim | 109:5c9180b4be25 | 80 | uint8_t mode; // command or data mode state |
IanBenzMaxim | 109:5c9180b4be25 | 81 | uint8_t speed; // 1-Wire communication speed |
IanBenzMaxim | 76:84e6c4994e29 | 82 | }; |
IanBenzMaxim | 73:2cecc1372acc | 83 | } |
j3 | 3:644fc630f958 | 84 | |
IanBenzMaxim | 74:23be10c32fa3 | 85 | #endif |
j3 | 3:644fc630f958 | 86 |