Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
Diff: OneWire_Bridge/DS28E17/ds28e17.h
- Revision:
- 7:78a8857b3810
- Parent:
- 4:ca27db159b10
- Child:
- 8:7c7a0ea0c568
--- a/OneWire_Bridge/DS28E17/ds28e17.h Tue Feb 09 20:08:51 2016 +0000 +++ b/OneWire_Bridge/DS28E17/ds28e17.h Fri Feb 12 22:56:13 2016 +0000 @@ -55,6 +55,23 @@ { public: + enum DS28E17_CMDS + { + CMD_I2C_WRITE_W_STOP = 0x4B, + CMD_I2C_WRITE_NO_STOP = 0x5A, + CMD_I2C_WRITE_ONLY = 0x69, + CMD_I2C_WRITE_ONLY_W_STOP = 0x78, + CMD_I2C_READ_W_STOP = 0x87, + CMD_I2C_WRITE_READ_W_STOP = 0x2D, + CMD_WRITE_CONFIG_REG = 0xD2, + CMD_READ_CONFIG_REG = 0xE1, + CMD_DISABLE_OW_MODE = 0x96, + CMD_ENABLE_SLEEP_MODE = 0x1E, + CMD_READ_DEVICE_REV = 0xC3 + }; + + static const size_t POLL_LIMIT = 10000; + /**********************************************************//** * @brief Ds28e17 constructor * @@ -68,7 +85,7 @@ * On Exit: * @return **************************************************************/ - Ds28e17(OneWireInterface *p_owm); + Ds28e17(OneWireInterface &owm); /**********************************************************//** @@ -121,8 +138,8 @@ * false if failed device select **************************************************************/ bool I2C_WriteDataWithStop(uint8_t I2C_addr, uint8_t length, - uint8_t *data, uint8_t status, - uint8_t wr_status); + uint8_t *data, uint8_t &status, + uint8_t &wr_status); /**********************************************************//** * @brief Write to selected DS28E17's I2C No Stop. @@ -161,8 +178,8 @@ * false if failed device select **************************************************************/ bool I2C_WriteDataNoStop(uint8_t I2C_addr, uint8_t length, - uint8_t *data, uint8_t status, - uint8_t wr_status); + uint8_t *data, uint8_t &status, + uint8_t &wr_status); /**********************************************************//** @@ -197,7 +214,7 @@ * false if failed device select **************************************************************/ bool I2C_WriteDataOnly(uint8_t length, uint8_t *data, - uint8_t status, uint8_t wr_status); + uint8_t &status, uint8_t &wr_status); /**********************************************************//** @@ -232,7 +249,7 @@ * false if failed device select **************************************************************/ bool I2C_WriteDataOnlyWithStop(uint8_t length, uint8_t *data, - uint8_t status, uint8_t wr_status); + uint8_t &status, uint8_t &wr_status); /**********************************************************//** @@ -280,7 +297,7 @@ **************************************************************/ bool 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 &status, uint8_t &wr_status, uint8_t *read_data); @@ -309,10 +326,6 @@ * b1;0=No Err|1=Addr Err, * b0;0=Valid CRC16|1=Invalid CRC16 * - * @param[out] wr_status - * Indicates which write byte NACK’d. A value of 00h indicates all bytes were acknowledged by the slave. - * A non-zero value indicates the byte number that NACK’d. - * * @param[out] *read_data * Array of read data received from I2C. * @@ -321,7 +334,7 @@ * false if failed device select or timeout occurred or CRC16 error **************************************************************/ bool I2C_ReadDataWithStop(uint8_t I2C_addr, uint8_t nu_bytes_read, - uint8_t status, uint8_t *read_data); + uint8_t &status, uint8_t *read_data); /**********************************************************//** @@ -352,7 +365,7 @@ * On Exit: * * @return - * device selected and read correctly @n + * true if device selected and read correctly @n * false if failed device select **************************************************************/ uint8_t ReadConfigReg(void); @@ -415,41 +428,13 @@ private: OneWireInterface *_p_owm; + bool _owm_owner; uint16_t _crc16; uint8_t _i2c_speed; - static uint16_t _oddparity[16]; - /**********************************************************//** - * @brief Select the DS28E17 if rom number matches currently - * selected device - * - * @details - * - * On Entry: - * - * On Exit: - * - * @return - * true if device selected @n - * false if problem occurred - **************************************************************/ - bool DeviceSelect(void); + static const uint16_t _oddparity[16]; - - /**********************************************************//** - * @brief Calculate a new CRC16 from the input data shorteger. - * Return the current CRC16 and also update the global variable CRC16. - * - * @details - * - * On Entry: - * - * On Exit: - * - * @return - * CRC16 - **************************************************************/ uint16_t docrc16(uint16_t data); };