Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
Diff: OneWire_Bridge/DS28E17/ds28e17.h
- Revision:
- 17:b646b1e3970b
- Parent:
- 13:d1bdb03703de
- Child:
- 21:00c94aeb533e
diff -r 883becbd85f8 -r b646b1e3970b OneWire_Bridge/DS28E17/ds28e17.h --- a/OneWire_Bridge/DS28E17/ds28e17.h Wed Mar 16 19:10:19 2016 +0000 +++ b/OneWire_Bridge/DS28E17/ds28e17.h Fri Mar 18 20:21:05 2016 +0000 @@ -1,16 +1,4 @@ /******************************************************************//** -* @file ds28e17.h -* -* @author Justin Jordan -* -* @version 0.0.0 -* -* Started: 31JAN16 -* -* Updated: -* -* @brief Header file for DS28E17 1-wire to I2C bridge -*********************************************************************** * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -70,6 +58,19 @@ CMD_READ_DEVICE_REV = 0xC3 }; + enum CmdResult + { + Success, + CommsReadBitError, + CommsWriteBitError, + CommsReadByteError, + CommsWriteByteError, + CommsReadBlockError, + CommsWriteBlockError, + TimeoutError, + OperationFailure + }; + static const size_t POLL_LIMIT = 10000; /**********************************************************//** @@ -87,6 +88,32 @@ **************************************************************/ Ds28e17(OneWireInterface &owm); + /**********************************************************//** + * @brief + * + * @details + * + * On Entry: + * @param[in] romId - reference to RomId type + * + * On Exit: + * + * @return + **************************************************************/ + void set_rom_id(const RomId & romId); + + /**********************************************************//** + * @brief + * + * @details + * + * On Entry: + * + * On Exit: + * + * @return current RomId held by this object + **************************************************************/ + RomId get_rom_id(void); /**********************************************************//** * @brief Write to selected DS28E17's I2C with Stop. @@ -124,7 +151,7 @@ * true if device selected and written @n * false if failed device select **************************************************************/ - bool I2C_WriteDataWithStop(uint8_t I2C_addr, uint8_t length, + CmdResult I2C_WriteDataWithStop(uint8_t I2C_addr, uint8_t length, uint8_t *data, uint8_t &status, uint8_t &wr_status); @@ -164,7 +191,7 @@ * true if device selected and written @n * false if failed device select **************************************************************/ - bool I2C_WriteDataNoStop(uint8_t I2C_addr, uint8_t length, + CmdResult I2C_WriteDataNoStop(uint8_t I2C_addr, uint8_t length, uint8_t *data, uint8_t &status, uint8_t &wr_status); @@ -200,7 +227,7 @@ * true if device selected and written @n * false if failed device select **************************************************************/ - bool I2C_WriteDataOnly(uint8_t length, uint8_t *data, + CmdResult I2C_WriteDataOnly(uint8_t length, uint8_t *data, uint8_t &status, uint8_t &wr_status); @@ -235,7 +262,7 @@ * true if device selected and written @n * false if failed device select **************************************************************/ - bool I2C_WriteDataOnlyWithStop(uint8_t length, uint8_t *data, + CmdResult I2C_WriteDataOnlyWithStop(uint8_t length, uint8_t *data, uint8_t &status, uint8_t &wr_status); @@ -282,7 +309,7 @@ * true if device selected, written and read @n * false if failed device select or timeout occurred or CRC16 error **************************************************************/ - bool I2C_WriteReadDataWithStop(uint8_t I2C_addr, uint8_t length, + CmdResult I2C_WriteReadDataWithStop(uint8_t I2C_addr, uint8_t length, uint8_t *data, uint8_t nu_bytes_read, uint8_t &status, uint8_t &wr_status, uint8_t *read_data); @@ -320,7 +347,7 @@ * true if device selected, written and read @n * false if failed device select or timeout occurred or CRC16 error **************************************************************/ - bool I2C_ReadDataWithStop(uint8_t I2C_addr, uint8_t nu_bytes_read, + CmdResult I2C_ReadDataWithStop(uint8_t I2C_addr, uint8_t nu_bytes_read, uint8_t &status, uint8_t *read_data); @@ -339,7 +366,7 @@ * true if device selected and written @n * false if failed device select **************************************************************/ - bool WriteConfigReg(uint8_t data); + CmdResult WriteConfigReg(uint8_t data); /**********************************************************//** @@ -355,7 +382,7 @@ * true if device selected and read correctly @n * false if failed device select **************************************************************/ - uint8_t ReadConfigReg(void); + CmdResult ReadConfigReg(uint8_t & config); /**********************************************************//** @@ -373,7 +400,7 @@ * true if device selected and written @n * false if failed device select **************************************************************/ - bool DisableOWMode(); + CmdResult DisableOWMode(); /**********************************************************//** @@ -392,7 +419,7 @@ * true if device selected and written @n * false if failed device select* **************************************************************/ - bool EnableSleepMode(); + CmdResult EnableSleepMode(); /**********************************************************//** @@ -410,11 +437,19 @@ * revision value if device selected and read correctly @n * false if failed device select (i.e. 00h) **************************************************************/ - uint8_t ReadDeviceRevision(void); + CmdResult ReadDeviceRevision(uint8_t & rev); private: - OneWireInterface &_p_owm; + CmdResult send_packet(const uint8_t * data, uint8_t data_length, + uint8_t & status, uint8_t & wr_status); + + //overloaded function for I2C read only command + CmdResult send_packet(const uint8_t * data, uint8_t data_length, + uint8_t & status); + + OneWireInterface &_owm; + RomId _romId; uint16_t _crc16; uint8_t _i2c_speed; @@ -424,4 +459,5 @@ uint16_t docrc16(uint16_t data); }; -#endif /*DS28E17_H*/ \ No newline at end of file +#endif /*DS28E17_H*/ +