Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
Diff: OneWire_Masters/DS2465/DS2465.hpp
- Revision:
- 27:d5aaefa252f1
- Parent:
- 26:a361e3f42ba5
- Child:
- 32:bce180b544ed
--- a/OneWire_Masters/DS2465/DS2465.hpp Wed Mar 23 15:25:40 2016 -0500 +++ b/OneWire_Masters/DS2465/DS2465.hpp Fri Mar 25 11:11:59 2016 -0500 @@ -1,10 +1,14 @@ #ifndef DS2465_H #define DS2465_H -#include "mbed.h" #include "OneWire_Masters/OneWireMaster.h" #include "OneWire_Masters/ISha256MacCoprocessor.hpp" +namespace mbed +{ + class I2C; +} + class DS2465 : public OneWireMaster, public ISha256MacCoprocessor { public: @@ -40,7 +44,7 @@ ADDR_USER_MEM_PAGE_1 = 0xA0 }; - DS2465(I2C & I2C_interface, std::uint8_t I2C_address); + DS2465(mbed::I2C & I2C_interface, std::uint8_t I2C_address); // Const member functions should not change the settings of the DS2465 or affect the state of the 1-Wire bus. // Read pointer, scratchpad, MAC output register, and command register on the DS2465 are considered mutable. @@ -50,7 +54,7 @@ OneWireMaster::CmdResult Reset(void); // Resets DS2465 (NOTE: This is NOT a 1-Wire Reset) // DS2465 Memory Commands - OneWireMaster::CmdResult ReadMemory(std::uint8_t addr, std::uint8_t * buf, size_t bufLen, bool skip_set_pointer = false) const; + OneWireMaster::CmdResult ReadMemory(std::uint8_t addr, std::uint8_t * buf, std::size_t bufLen, bool skip_set_pointer = false) const; OneWireMaster::CmdResult WriteMemory(std::uint8_t addr, const std::uint8_t * buf, std::size_t bufLen) { return CWriteMemory(addr, buf, bufLen); } OneWireMaster::CmdResult WriteScratchpad(const std::uint8_t * buf, std::size_t bufLen) const { return CWriteMemory(ADDR_SPAD, buf, bufLen); } OneWireMaster::CmdResult CopyScratchpad(bool dest_secret, unsigned int pageNum, bool notFull, unsigned int segmentNum); @@ -58,12 +62,12 @@ // 1-Wire Master Commands virtual OneWireMaster::CmdResult OWInitMaster(void); virtual OneWireMaster::CmdResult OWReset(void); // Issues a 1-Wire Reset Pulse - virtual OneWireMaster::CmdResult OWTouchBit(uint8_t & sendrecvbit, OW_LEVEL after_level); - virtual OneWireMaster::CmdResult OWReadByte(uint8_t & recvbyte, OW_LEVEL after_level); - virtual OneWireMaster::CmdResult OWWriteByte(uint8_t sendbyte, OW_LEVEL after_level); - virtual OneWireMaster::CmdResult OWReadBlock(uint8_t *rx_buf, uint8_t rx_len); - virtual OneWireMaster::CmdResult OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len); - OneWireMaster::CmdResult OWWriteBlock(bool tx_mac, const uint8_t *tran_buf, uint8_t tran_len); + virtual OneWireMaster::CmdResult OWTouchBit(std::uint8_t & sendrecvbit, OW_LEVEL after_level); + virtual OneWireMaster::CmdResult OWReadByte(std::uint8_t & recvbyte, OW_LEVEL after_level); + virtual OneWireMaster::CmdResult OWWriteByte(std::uint8_t sendbyte, OW_LEVEL after_level); + virtual OneWireMaster::CmdResult OWReadBlock(std::uint8_t *rx_buf, std::uint8_t rx_len); + virtual OneWireMaster::CmdResult OWWriteBlock(const std::uint8_t *tran_buf, std::uint8_t tran_len); + OneWireMaster::CmdResult OWWriteBlock(bool tx_mac, const std::uint8_t *tran_buf, std::uint8_t tran_len); virtual OneWireMaster::CmdResult OWSpeed(OW_SPEED new_speed); virtual OneWireMaster::CmdResult OWLevel(OW_LEVEL new_level); virtual OneWireMaster::CmdResult OWSearch(RomId & romId); @@ -71,7 +75,7 @@ OneWireMaster::CmdResult ConfigurePowerDown(bool pdn_enable); OneWireMaster::CmdResult ConfigureAPU(bool apu_enable); OneWireMaster::CmdResult ConfigureSPU(bool spu_enable); - OneWireMaster::CmdResult Triplet(Direction search_direction, uint8_t & status); + OneWireMaster::CmdResult Triplet(Direction search_direction, std::uint8_t & status); //DS2465 Coprocessor Commands OneWireMaster::CmdResult Compute_NextMasterSecret(bool swap, unsigned int pageNum, PageRegion region); @@ -98,13 +102,13 @@ Config() { reset(); } }; - I2C & m_I2C_interface; + mbed::I2C & m_I2C_interface; std::uint8_t m_I2C_address; Config m_curConfig; OneWireMaster::CmdResult CWriteMemory(std::uint8_t addr, const std::uint8_t * buf, std::size_t bufLen) const; OneWireMaster::CmdResult WriteConfig(const Config & config); - OneWireMaster::CmdResult PollBusy(uint8_t * pStatus = NULL); + OneWireMaster::CmdResult PollBusy(std::uint8_t * pStatus = NULL); }; #endif