Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
Diff: OneWire_Masters/DS248x/ds248x.h
- Revision:
- 17:b646b1e3970b
- Parent:
- 15:f6cb0d906fb6
- Child:
- 21:00c94aeb533e
--- a/OneWire_Masters/DS248x/ds248x.h Wed Mar 16 19:10:19 2016 +0000 +++ b/OneWire_Masters/DS248x/ds248x.h Fri Mar 18 20:21:05 2016 +0000 @@ -1,16 +1,4 @@ /******************************************************************//** -* @file ds248x.h -* -* @author Justin Jordan -* -* @version 0.0.0 -* -* Started: 30JAN16 -* -* Updated: -* -* @brief Header file for Ds248x I2C to 1-wire master -*********************************************************************** * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -113,9 +101,19 @@ TREC0, //OD NA RWPU = 8 //OD NA, see DS2484 datasheet page 13 }; + + enum SEARCH_DIRECTION + { + DIRECTION_WRITE_ZERO = 0, + DIRECTION_WRITE_ONE = 1 + }; static const size_t POLL_LIMIT = 200; + static const int I2C_WRITE_OK = 0; + + static const int I2C_READ_OK = 0; + /** * Member functions that directly support DS248x I2C to 1-wire * masters are documented in this file. Virtual function @@ -185,7 +183,7 @@ * FALSE device not detected or failure to write * configuration byte **************************************************************/ - bool detect(void); + OneWireInterface::CmdResult detect(void); /**********************************************************//** @@ -199,7 +197,7 @@ * @return TRUE if device was reset * FALSE device not detected or failure to perform reset **************************************************************/ - bool reset(void); + OneWireInterface::CmdResult reset(void); /**********************************************************//** @@ -217,7 +215,7 @@ * @return TRUE: config written and response correct * FALSE: response incorrect **************************************************************/ - bool write_config(uint8_t config); + OneWireInterface::CmdResult write_config(uint8_t config); /**********************************************************//** @@ -233,7 +231,7 @@ * @return TRUE if channel selected * FALSE device not detected or failure to perform select **************************************************************/ - bool channel_select(uint8_t channel); + OneWireInterface::CmdResult channel_select(uint8_t channel); /**********************************************************//** @@ -250,7 +248,7 @@ * @return TRUE: parameter successfully adjusted * FALSE: failed to adjust parameter **************************************************************/ - bool adjust_timing(uint8_t param, uint8_t val); + OneWireInterface::CmdResult adjust_timing(uint8_t param, uint8_t val); /**********************************************************//** @@ -269,31 +267,35 @@ * On Exit: * @return The Ds248x status byte result from the triplet command **************************************************************/ - uint8_t search_triplet(uint8_t search_direction); + OneWireInterface::CmdResult search_triplet(uint8_t search_direction, uint8_t & status); //Part of OneWireInterface that should be implemented for each master //See OneWireInterface.h for documentation - virtual bool OWInitMaster(); + virtual OneWireInterface::CmdResult OWInitMaster(void); - virtual bool OWReset(); + virtual OneWireInterface::CmdResult OWReset(void); - virtual uint8_t OWTouchBit(uint8_t sendbit); + virtual OneWireInterface::CmdResult OWTouchBit(uint8_t & sendrecvbit); + + virtual OneWireInterface::CmdResult OWWriteByte(uint8_t sendbyte); - virtual bool OWWriteByte(uint8_t sendbyte); - - virtual uint8_t OWReadByte(void); + virtual OneWireInterface::CmdResult OWReadByte(uint8_t & recvbyte); + + virtual OneWireInterface::CmdResult OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len); - virtual bool OWSearch(void); + virtual OneWireInterface::CmdResult OWReadBlock(uint8_t *rx_buf, uint8_t rx_len); + + virtual OneWireInterface::CmdResult OWSearch(RomId & romId); - virtual uint8_t OWSpeed(OW_SPEED new_speed); + virtual OneWireInterface::CmdResult OWSpeed(OW_SPEED new_speed); - virtual uint8_t OWLevel(OW_LEVEL new_level); + virtual OneWireInterface::CmdResult OWLevel(OW_LEVEL new_level); - virtual bool OWWriteBytePower(uint8_t sendbyte); + virtual OneWireInterface::CmdResult OWWriteBytePower(uint8_t sendbyte); - virtual bool OWReadBitPower(uint8_t applyPowerResponse); + virtual OneWireInterface::CmdResult OWReadBitPower(uint8_t applyPowerResponse); private: