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: MAXREFDES131_Qt_Demo MAX32630FTHR_iButton_uSD_Logger MAX32630FTHR_DS18B20_uSD_Logger MAXREFDES130_131_Demo ... more
Diff: OneWire_Bridge/DS28E17/ds28e17.cpp
- Revision:
- 13:d1bdb03703de
- Parent:
- 7:78a8857b3810
- Child:
- 17:b646b1e3970b
--- a/OneWire_Bridge/DS28E17/ds28e17.cpp Mon Mar 07 21:18:19 2016 +0000
+++ b/OneWire_Bridge/DS28E17/ds28e17.cpp Tue Mar 08 18:00:40 2016 -0800
@@ -50,23 +50,13 @@
//*********************************************************************
Ds28e17::Ds28e17(OneWireInterface &owm)
-:_p_owm(&owm), _owm_owner(false)
+:_p_owm(owm)
{
}
//*********************************************************************
-Ds28e17::~Ds28e17()
-{
- if(_owm_owner)
- {
- delete _p_owm;
- }
-}
-
-
-//*********************************************************************
bool Ds28e17::I2C_WriteDataWithStop(uint8_t I2C_addr, uint8_t length,
uint8_t *data, uint8_t &status,
uint8_t &wr_status)
@@ -78,7 +68,7 @@
uint32_t poll_count = 0;
uint8_t send_block[0xff];
- if(_p_owm->OWMatchROM())
+ if(_p_owm.OWMatchROM())
{
//seed the crc
_crc16 = 0;
@@ -110,18 +100,18 @@
send_block[send_cnt++] = ((uint8_t)((_crc16 >> 8) & 0xFF));
// Send Packet
- _p_owm->OWWriteBlock(send_block, send_cnt);
+ _p_owm.OWWriteBlock(send_block, send_cnt);
// Poll for Zero 1-Wire bit and return if an error occurs
- while(_p_owm->OWReadBit() && (poll_count++ < POLL_LIMIT));
+ while(_p_owm.OWReadBit() && (poll_count++ < POLL_LIMIT));
if(poll_count < POLL_LIMIT)
{
//Read Status
- status = _p_owm->OWReadByte();
+ status = _p_owm.OWReadByte();
//Read Write Status
- wr_status = _p_owm->OWReadByte();
+ wr_status = _p_owm.OWReadByte();
rtn_val = true;
}
@@ -152,7 +142,7 @@
uint32_t poll_count = 0;
uint8_t send_block[0xff];
- if(_p_owm->OWMatchROM())
+ if(_p_owm.OWMatchROM())
{
// seed the crc
_crc16 = 0;
@@ -182,18 +172,18 @@
send_block[send_cnt++] = ((uint8_t)((_crc16 >> 8) & 0xFF));
// Send Packet
- _p_owm->OWBlock(send_block, send_cnt);
+ _p_owm.OWBlock(send_block, send_cnt);
// Poll for Zero 1-Wire bit and return if an error occurs
- while(_p_owm->OWReadBit() && (poll_count++ < POLL_LIMIT));
+ while(_p_owm.OWReadBit() && (poll_count++ < POLL_LIMIT));
if(poll_count < POLL_LIMIT)
{
//Read Status
- status = _p_owm->OWReadByte();
+ status = _p_owm.OWReadByte();
//Read Write Status
- wr_status = _p_owm->OWReadByte();
+ wr_status = _p_owm.OWReadByte();
rtn_val = true;
}
@@ -222,7 +212,7 @@
uint32_t poll_count = 0;
uint8_t send_block[0xff];
- if(_p_owm->OWMatchROM())
+ if(_p_owm.OWMatchROM())
{
// seed the crc
_crc16 = 0;
@@ -250,19 +240,19 @@
send_block[send_cnt++] = ((_crc16 >> 8) & 0xFF);
// Send Packet
- _p_owm->OWBlock(send_block, send_cnt);
+ _p_owm.OWBlock(send_block, send_cnt);
// Poll for Zero 1-Wire bit and return if an error occurs
- while(_p_owm->OWReadBit() && (poll_count++ < POLL_LIMIT));
+ while(_p_owm.OWReadBit() && (poll_count++ < POLL_LIMIT));
if(poll_count < POLL_LIMIT)
{
// Read Status
- status = _p_owm->OWReadByte();
+ status = _p_owm.OWReadByte();
// Read Write Status
- wr_status = _p_owm->OWReadByte();
+ wr_status = _p_owm.OWReadByte();
rtn_val = true;
}
@@ -292,7 +282,7 @@
uint32_t poll_count = 0;
uint8_t send_block[0xff];
- if(_p_owm->OWMatchROM())
+ if(_p_owm.OWMatchROM())
{
//seed the crc
_crc16 = 0;
@@ -320,18 +310,18 @@
send_block[send_cnt++] = ((_crc16 >> 8) & 0xFF);
// Send Packet
- _p_owm->OWBlock(send_block, send_cnt);
+ _p_owm.OWBlock(send_block, send_cnt);
// Poll for Zero 1-Wire bit and return if an error occurs
- while(_p_owm->OWReadBit() && (poll_count++ < POLL_LIMIT));
+ while(_p_owm.OWReadBit() && (poll_count++ < POLL_LIMIT));
if(poll_count < POLL_LIMIT)
{
// Read Status
- status = _p_owm->OWReadByte();
+ status = _p_owm.OWReadByte();
// Read Write Status
- wr_status = _p_owm->OWReadByte();
+ wr_status = _p_owm.OWReadByte();
rtn_val = true;
}
@@ -362,7 +352,7 @@
uint32_t poll_count = 0;
uint8_t send_block[0xff];
- if(_p_owm->OWMatchROM())
+ if(_p_owm.OWMatchROM())
{
//seed the crc
_crc16 = 0;
@@ -398,18 +388,18 @@
send_block[send_cnt++] = ((_crc16 >> 8) & 0xFF);
// Send Packet
- _p_owm->OWBlock(send_block, send_cnt);
+ _p_owm.OWBlock(send_block, send_cnt);
// Poll for Zero 1-Wire bit and return if an error occurs
- while(_p_owm->OWReadBit() && (poll_count++ < POLL_LIMIT));
+ while(_p_owm.OWReadBit() && (poll_count++ < POLL_LIMIT));
if(poll_count < POLL_LIMIT)
{
// Read Status
- status = _p_owm->OWReadByte();
+ status = _p_owm.OWReadByte();
// Read Write Status
- wr_status = _p_owm->OWReadByte();
+ wr_status = _p_owm.OWReadByte();
//seed the crc for read bytes
_crc16 = 0;
@@ -417,7 +407,7 @@
// Read Data
for(idx = 0; idx < nu_bytes_read; idx++)
{
- read_data[idx] = _p_owm->OWReadByte();
+ read_data[idx] = _p_owm.OWReadByte();
docrc16(read_data[idx]);
}
@@ -460,7 +450,7 @@
uint32_t poll_count = 0;
uint8_t send_block[0xff];
- if(_p_owm->OWMatchROM())
+ if(_p_owm.OWMatchROM())
{
//seed the crc for transmit bytes
_crc16 = 0;
@@ -485,15 +475,15 @@
send_block[send_cnt++] = ((_crc16 >> 8) & 0xFF);
// Send Packet
- _p_owm->OWBlock(send_block, send_cnt);
+ _p_owm.OWBlock(send_block, send_cnt);
// Poll for Zero 1-Wire bit and return if an error occurs
- while(_p_owm->OWReadBit() && (poll_count++ < POLL_LIMIT));
+ while(_p_owm.OWReadBit() && (poll_count++ < POLL_LIMIT));
if(poll_count < POLL_LIMIT)
{
// Read Status
- status = _p_owm->OWReadByte();
+ status = _p_owm.OWReadByte();
//seed the crc for read bytes
_crc16 = 0;
@@ -501,7 +491,7 @@
// Read Data
for(idx = 0; idx < nu_bytes_read; idx++)
{
- read_data[idx] = _p_owm->OWReadByte();
+ read_data[idx] = _p_owm.OWReadByte();
docrc16(read_data[idx]);
}
@@ -538,11 +528,11 @@
{
bool rtn_val = false;
- if(_p_owm->OWMatchROM())
+ if(_p_owm.OWMatchROM())
{
// Send CMD and Data
- _p_owm->OWWriteByte(CMD_WRITE_CONFIG_REG);
- _p_owm->OWWriteByte(data);
+ _p_owm.OWWriteByte(CMD_WRITE_CONFIG_REG);
+ _p_owm.OWWriteByte(data);
_i2c_speed = data & 0x03; // Save off _i2c_speed setting to be used by other functions
rtn_val = true;
}
@@ -560,11 +550,11 @@
{
uint8_t rtn_val = false;
- if(_p_owm->OWMatchROM())
+ if(_p_owm.OWMatchROM())
{
// Send CMD and receive Data
- _p_owm->OWWriteByte(CMD_READ_CONFIG_REG);
- rtn_val = _p_owm->OWReadByte();
+ _p_owm.OWWriteByte(CMD_READ_CONFIG_REG);
+ rtn_val = _p_owm.OWReadByte();
}
else
{
@@ -580,10 +570,10 @@
{
bool rtn_val = false;
- if(_p_owm->OWMatchROM())
+ if(_p_owm.OWMatchROM())
{
// Send CMD
- _p_owm->OWWriteByte(CMD_DISABLE_OW_MODE);
+ _p_owm.OWWriteByte(CMD_DISABLE_OW_MODE);
rtn_val = true;
}
else
@@ -600,10 +590,10 @@
{
bool rtn_val = false;
- if(_p_owm->OWMatchROM())
+ if(_p_owm.OWMatchROM())
{
// Send CMD
- _p_owm->OWWriteByte(CMD_ENABLE_SLEEP_MODE);
+ _p_owm.OWWriteByte(CMD_ENABLE_SLEEP_MODE);
rtn_val = true;
}
else
@@ -620,11 +610,11 @@
{
uint8_t rtn_val;
- if(_p_owm->OWMatchROM())
+ if(_p_owm.OWMatchROM())
{
// Send CMD and receive Data
- _p_owm->OWWriteByte(CMD_READ_DEVICE_REV);
- rtn_val = _p_owm->OWReadByte();
+ _p_owm.OWWriteByte(CMD_READ_DEVICE_REV);
+ rtn_val = _p_owm.OWReadByte();
}
else
{