Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Max32630_One_Wire_Interface
Diff: OneWire_Masters/DS248x/ds248x.h
- Revision:
- 5:ce108eeb878d
- Parent:
- 3:644fc630f958
- Child:
- 6:1faafa0b3cd7
--- a/OneWire_Masters/DS248x/ds248x.h Tue Feb 02 21:34:27 2016 +0000
+++ b/OneWire_Masters/DS248x/ds248x.h Tue Feb 09 03:30:22 2016 +0000
@@ -49,13 +49,14 @@
#include "mbed.h"
#include "OneWireInterface.h"
+#include "OneWireMastersShared.h"
class Ds248x: public OneWireInterface
{
public:
- typedef enum
+ enum DS248X_I2C_ADRS
{
DS248X_I2C_ADRS0 = 0x18,
DS248X_I2C_ADRS1,
@@ -64,8 +65,56 @@
DS248X_I2C_ADRS4,
DS248X_I2C_ADRS5,
DS248X_I2C_ADRS6,
- DS248X_I2C_ADRS7,
- }ds248x_i2c_adrs_t;
+ DS248X_I2C_ADRS7
+ };
+
+ enum DS248X_CMDS
+ {
+ CMD_DRST = 0xF0,
+ CMD_WCFG = 0xD2,
+ CMD_A1WP = 0xC3, //DS2484 only
+ CMD_CHSL = 0xC3, //DS2482-800 only
+ CMD_SRP = 0xE1,
+ CMD_1WRS = 0xB4,
+ CMD_1WWB = 0xA5,
+ CMD_1WRB = 0x96,
+ CMD_1WSB = 0x87,
+ CMD_1WT = 0x78
+ };
+
+ enum DS248X_CONFIG_BITS
+ {
+ CONFIG_APU = 0x01,
+ CONFIG_PDN = 0x02,
+ CONFIG_SPU = 0x04,
+ CONFIG_1WS = 0x08
+ };
+
+ enum DS248X_STATUS_BITS
+ {
+ STATUS_1WB = 0x01,
+ STATUS_PPD = 0x02,
+ STATUS_SD = 0x04,
+ STATUS_LL = 0x08,
+ STATUS_RST = 0x10,
+ STATUS_SBR = 0x20,
+ STATUS_TSB = 0x40,
+ STATUS_DIR = 0x80
+ };
+
+ enum DS2484_ADJST_PARAMS
+ {
+ TRSTL = 0,
+ TRSTL_OD,
+ TMSP,
+ TMSP_OD,
+ TW0L,
+ TW0L_OD,
+ TREC0, //OD NA
+ RWPU = 8 //OD NA, see DS2484 datasheet page 13
+ };
+
+ static const size_t POLL_LIMIT = 200;
/**
* Member functions that directly support DS248x I2C to 1-wire
@@ -86,7 +135,7 @@
* On Exit:
* @return
**************************************************************/
- Ds248x(I2C *p_i2c_bus, ds248x_i2c_adrs_t adrs);
+ Ds248x(I2C &i2c_bus, DS248X_I2C_ADRS adrs);
/**********************************************************//**
@@ -102,7 +151,7 @@
* On Exit:
* @return
**************************************************************/
- Ds248x(PinName sda, PinName scl, ds248x_i2c_adrs_t adrs);
+ Ds248x(PinName sda, PinName scl, DS248X_I2C_ADRS adrs);
/**********************************************************//**
@@ -115,7 +164,7 @@
* On Exit:
* @return
**************************************************************/
- ~Ds248x();
+ virtual ~Ds248x();
/**********************************************************//**
@@ -222,6 +271,7 @@
**************************************************************/
uint8_t search_triplet(uint8_t search_direction);
+
/***** OW API ****************************************************/
virtual bool OWReset();
@@ -238,6 +288,10 @@
virtual uint8_t OWTouchByte(uint8_t sendbyte);
virtual void OWBlock(uint8_t *tran_buf, uint8_t tran_len);
+
+ virtual void OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len);
+
+ virtual void OWReadBlock(uint8_t *recv_buf, uint8_t recv_len);
virtual bool OWFirst(void);
@@ -250,35 +304,47 @@
virtual void OWFamilySkipSetup(void);
virtual bool OWSearch(void);
+
+ virtual bool OWReadROM(void);
+
+ virtual bool OWSkipROM(void);
+
+ virtual bool OWMatchROM(void);
+
+ virtual bool OWOverdriveSkipROM(void);
+
+ virtual bool OWOverdriveMatchROM(void);
+
+ virtual bool OWResume(void);
- virtual uint8_t OWSpeed(uint8_t new_speed);
+ virtual uint8_t OWSpeed(OW_SPEED new_speed);
- virtual uint8_t OWLevel(uint8_t new_level);
+ virtual uint8_t OWLevel(OW_LEVEL new_level);
virtual bool OWWriteBytePower(uint8_t sendbyte);
virtual bool OWReadBitPower(uint8_t applyPowerResponse);
- virtual uint8_t OWCalc_crc8(uint8_t data);
-
- virtual void OWgetROMnumber(uint8_t *p_rom_buff);
+ virtual const uint8_t (&OWgetROMnumber() const)[ROMnumberLen];
private:
+ Ds248x(DS248X_I2C_ADRS adrs);
+
I2C *_p_i2c_bus;
- bool i2c_owner;
uint8_t _w_adrs, _r_adrs;
+ bool _i2c_owner;
// ds248x state
uint8_t _short_detected;
uint8_t _c1WS, _cSPU, _cPDN, _cAPU;
// Search state
- uint8_t _rom_number[8];
+ uint8_t _rom_number[ROMnumberLen];
uint8_t _last_discrepancy;
uint8_t _last_family_discrepancy;
uint8_t _last_device_flag;
- uint8_t _crc8;
+ uint8_t _crc8;
};
#endif /*DS248X_H*/
\ No newline at end of file