Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
Diff: OneWire_Masters/OneWireMaster.h
- Revision:
- 27:d5aaefa252f1
- Parent:
- 26:a361e3f42ba5
- Child:
- 32:bce180b544ed
diff -r a361e3f42ba5 -r d5aaefa252f1 OneWire_Masters/OneWireMaster.h --- a/OneWire_Masters/OneWireMaster.h Wed Mar 23 15:25:40 2016 -0500 +++ b/OneWire_Masters/OneWireMaster.h Fri Mar 25 11:11:59 2016 -0500 @@ -34,13 +34,13 @@ #ifndef ONEWIREMASTER_H #define ONEWIREMASTER_H +#include <cstdint> +#include <cstddef> -#include "mbed.h" -#include "RomId.hpp" - +class RomId; class OneWireMaster -{ +{ public: enum OW_SPEED @@ -64,9 +64,9 @@ OperationFailure }; - static uint16_t calculateCRC16(uint16_t CRC16, uint16_t data); + static std::uint16_t calculateCRC16(std::uint16_t CRC16, std::uint16_t data); - static uint16_t calculateCRC16(const uint8_t * data, size_t data_offset, size_t data_len, uint16_t crc = 0); + static std::uint16_t calculateCRC16(const std::uint8_t * data, std::size_t data_offset, std::size_t data_len, std::uint16_t crc = 0); virtual ~OneWireMaster() { } @@ -118,7 +118,7 @@ * * @return CmdResult - zero on success, non-zero on failure **************************************************************/ - virtual CmdResult OWTouchBit(uint8_t & sendrecvbit, OW_LEVEL after_level) = 0; + virtual CmdResult OWTouchBit(std::uint8_t & sendrecvbit, OW_LEVEL after_level) = 0; /**********************************************************//** @@ -136,7 +136,7 @@ * * @return CmdResult - zero on success, non-zero on failure **************************************************************/ - virtual CmdResult OWWriteByte(uint8_t sendbyte, OW_LEVEL after_level) = 0; + virtual CmdResult OWWriteByte(std::uint8_t sendbyte, OW_LEVEL after_level) = 0; /**********************************************************//** @@ -151,7 +151,7 @@ * * @return CmdResult - zero on success, non-zero on failure **************************************************************/ - virtual CmdResult OWReadByte(uint8_t & recvbyte, OW_LEVEL after_level) = 0; + virtual CmdResult OWReadByte(std::uint8_t & recvbyte, OW_LEVEL after_level) = 0; /**********************************************************//** @@ -168,7 +168,7 @@ * * @return CmdResult - zero on success, non-zero on failure **************************************************************/ - virtual CmdResult OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len) = 0; + virtual CmdResult OWWriteBlock(const std::uint8_t *tran_buf, std::uint8_t tran_len) = 0; /**********************************************************//** @@ -185,7 +185,7 @@ * * @return CmdResult - zero on success, non-zero on failure **************************************************************/ - virtual CmdResult OWReadBlock(uint8_t *rx_buf, uint8_t rx_len) = 0; + virtual CmdResult OWReadBlock(std::uint8_t *rx_buf, std::uint8_t rx_len) = 0; /**********************************************************//** @@ -245,17 +245,17 @@ **************************************************************/ virtual CmdResult OWLevel(OW_LEVEL new_level) = 0; - CmdResult OWWriteBit(uint8_t sendbit, OW_LEVEL after_level) { return OWTouchBit(sendbit, after_level); } - CmdResult OWReadBit(uint8_t & recvbit, OW_LEVEL after_level) { recvbit = 0x01; return OWTouchBit(recvbit, after_level); } + CmdResult OWWriteBit(std::uint8_t sendbit, OW_LEVEL after_level) { return OWTouchBit(sendbit, after_level); } + CmdResult OWReadBit(std::uint8_t & recvbit, OW_LEVEL after_level) { recvbit = 0x01; return OWTouchBit(recvbit, after_level); } - CmdResult OWWriteBit(uint8_t sendbit) { return OWWriteBit(sendbit, LEVEL_NORMAL); } - CmdResult OWReadBit(uint8_t & recvbit) { return OWReadBit(recvbit, LEVEL_NORMAL); } - CmdResult OWWriteBitPower(uint8_t sendbit) { return OWWriteBit(sendbit, LEVEL_STRONG); } - CmdResult OWReadBitPower(uint8_t & recvbit) { return OWReadBit(recvbit, LEVEL_STRONG); } - CmdResult OWWriteByte(uint8_t sendbyte) { return OWWriteByte(sendbyte, LEVEL_NORMAL); } - CmdResult OWReadByte(uint8_t & recvbyte) { return OWReadByte(recvbyte, LEVEL_NORMAL); } - CmdResult OWWriteBytePower(uint8_t sendbyte) { return OWWriteByte(sendbyte, LEVEL_STRONG); } - CmdResult OWReadBytePower(uint8_t & recvbyte) { return OWReadByte(recvbyte, LEVEL_STRONG); } + CmdResult OWWriteBit(std::uint8_t sendbit) { return OWWriteBit(sendbit, LEVEL_NORMAL); } + CmdResult OWReadBit(std::uint8_t & recvbit) { return OWReadBit(recvbit, LEVEL_NORMAL); } + CmdResult OWWriteBitPower(std::uint8_t sendbit) { return OWWriteBit(sendbit, LEVEL_STRONG); } + CmdResult OWReadBitPower(std::uint8_t & recvbit) { return OWReadBit(recvbit, LEVEL_STRONG); } + CmdResult OWWriteByte(std::uint8_t sendbyte) { return OWWriteByte(sendbyte, LEVEL_NORMAL); } + CmdResult OWReadByte(std::uint8_t & recvbyte) { return OWReadByte(recvbyte, LEVEL_NORMAL); } + CmdResult OWWriteBytePower(std::uint8_t sendbyte) { return OWWriteByte(sendbyte, LEVEL_STRONG); } + CmdResult OWReadBytePower(std::uint8_t & recvbyte) { return OWReadByte(recvbyte, LEVEL_STRONG); } /**********************************************************//** @@ -438,17 +438,17 @@ }; // Search state - uint8_t _last_discrepancy; - uint8_t _last_family_discrepancy; + std::uint8_t _last_discrepancy; + std::uint8_t _last_family_discrepancy; bool _last_device_flag; private: - static const uint16_t _oddparity[16]; + static const std::uint16_t _oddparity[16]; }; -#endif /*ONEWIREMASTERSSHARED_H*/ \ No newline at end of file +#endif /*ONEWIREMASTER_H*/ \ No newline at end of file