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: Bridge/DS28E17/DS28E17.cpp
- Revision:
- 77:529edb329ee0
- Parent:
- 76:84e6c4994e29
- Child:
- 78:0cbbac7f2016
--- a/Bridge/DS28E17/DS28E17.cpp Sat May 14 14:27:56 2016 -0500
+++ b/Bridge/DS28E17/DS28E17.cpp Mon May 16 10:36:30 2016 -0500
@@ -32,11 +32,9 @@
#include "DS28E17.h"
#include "Masters/OneWireMaster.h"
-#include "RomCommands.h"
using OneWire::DS28E17;
using OneWire::OneWireMaster;
-using namespace OneWire::RomCommands;
enum Command
@@ -58,8 +56,8 @@
//*********************************************************************
-DS28E17::DS28E17(OneWireMaster &owm)
- : OneWireSlave(&owm)
+DS28E17::DS28E17(RandomAccessRomIterator &selector)
+ : OneWireSlave(selector)
{
}
@@ -75,7 +73,7 @@
size_t send_cnt = 0;
uint8_t send_block[0xff];
- OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
+ OneWireMaster::CmdResult ow_result = selectDevice();
if (ow_result == OneWireMaster::Success)
{
@@ -126,7 +124,7 @@
size_t send_cnt = 0;
uint8_t send_block[0xff];
- OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
+ OneWireMaster::CmdResult ow_result = selectDevice();
if (ow_result == OneWireMaster::Success)
{
@@ -174,7 +172,7 @@
size_t send_cnt = 0;
uint8_t send_block[0xff];
- OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
+ OneWireMaster::CmdResult ow_result = selectDevice();
if (ow_result == OneWireMaster::Success)
{
@@ -220,7 +218,7 @@
size_t send_cnt = 0;
uint8_t send_block[0xff];
- OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
+ OneWireMaster::CmdResult ow_result = selectDevice();
if (ow_result == OneWireMaster::Success)
{
@@ -269,7 +267,7 @@
size_t idx = 0;
uint8_t send_block[0xff];
- OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
+ OneWireMaster::CmdResult ow_result = selectDevice();
if (ow_result == OneWireMaster::Success)
{
@@ -310,7 +308,7 @@
bridge_result = send_packet(send_block, send_cnt, status, wr_status);
if (bridge_result == DS28E17::Success)
{
- ow_result = p_owMaster->OWReadBlock(read_data, nu_bytes_read);
+ ow_result = master().OWReadBlock(read_data, nu_bytes_read);
if (ow_result == OneWireMaster::Success)
{
bridge_result = DS28E17::Success;
@@ -335,7 +333,7 @@
size_t send_cnt = 0;
uint8_t send_block[0xff];
- OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
+ OneWireMaster::CmdResult ow_result = selectDevice();
if (ow_result == OneWireMaster::Success)
{
@@ -365,7 +363,7 @@
bridge_result = send_packet(send_block, send_cnt, status);
if (bridge_result == DS28E17::Success)
{
- ow_result = p_owMaster->OWReadBlock(read_data, nu_bytes_read);
+ ow_result = master().OWReadBlock(read_data, nu_bytes_read);
if (ow_result == OneWireMaster::Success)
{
bridge_result = DS28E17::Success;
@@ -386,14 +384,14 @@
{
DS28E17::CmdResult bridge_result = DS28E17::OperationFailure;
- OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
+ OneWireMaster::CmdResult ow_result = selectDevice();
if (ow_result == OneWireMaster::Success)
{
// Send CMD and Data
uint8_t send_block[] = { WriteConfigurationCmd, data };
- ow_result = p_owMaster->OWWriteBlock(send_block, 2);
+ ow_result = master().OWWriteBlock(send_block, 2);
if (ow_result == OneWireMaster::Success)
{
_i2c_speed = data & 0x03; // Save off _i2c_speed setting to be used by other functions
@@ -414,15 +412,15 @@
{
DS28E17::CmdResult bridge_result = DS28E17::OperationFailure;
- OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
+ OneWireMaster::CmdResult ow_result = selectDevice();
if (ow_result == OneWireMaster::Success)
{
// Send CMD and receive Data
- ow_result = p_owMaster->OWWriteByte(ReadConfigurationCmd);
+ ow_result = master().OWWriteByte(ReadConfigurationCmd);
if (ow_result == OneWireMaster::Success)
{
- ow_result = p_owMaster->OWReadByte(config);
+ ow_result = master().OWReadByte(config);
if (ow_result == OneWireMaster::Success)
{
bridge_result = DS28E17::Success;
@@ -447,12 +445,12 @@
{
DS28E17::CmdResult bridge_result = DS28E17::OperationFailure;
- OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
+ OneWireMaster::CmdResult ow_result = selectDevice();
if (ow_result == OneWireMaster::Success)
{
// Send CMD
- ow_result = p_owMaster->OWWriteByte(EnableSleepModeCmd);
+ ow_result = master().OWWriteByte(EnableSleepModeCmd);
if (ow_result == OneWireMaster::Success)
{
bridge_result = DS28E17::Success;
@@ -472,15 +470,15 @@
{
DS28E17::CmdResult bridge_result = DS28E17::OperationFailure;
- OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
+ OneWireMaster::CmdResult ow_result = selectDevice();
if (ow_result == OneWireMaster::Success)
{
// Send CMD and receive Data
- ow_result = p_owMaster->OWWriteByte(ReadDeviceRevisionCmd);
+ ow_result = master().OWWriteByte(ReadDeviceRevisionCmd);
if (ow_result == OneWireMaster::Success)
{
- ow_result = p_owMaster->OWReadByte(rev);
+ ow_result = master().OWReadByte(rev);
if (ow_result == OneWireMaster::Success)
{
bridge_result = DS28E17::Success;
@@ -527,7 +525,7 @@
DS28E17::CmdResult bridge_result = DS28E17::CommsWriteBlockError;
uint32_t poll_count = 0;
- OneWireMaster::CmdResult ow_result = p_owMaster->OWWriteBlock(data, data_length);
+ OneWireMaster::CmdResult ow_result = master().OWWriteBlock(data, data_length);
if (ow_result == OneWireMaster::Success)
{
@@ -535,7 +533,7 @@
uint8_t recvbit = 0x01;
do
{
- ow_result = p_owMaster->OWReadBit(recvbit);
+ ow_result = master().OWReadBit(recvbit);
} while (recvbit && (poll_count++ < pollLimit) && (ow_result == OneWireMaster::Success));
if (ow_result == OneWireMaster::Success)
@@ -545,7 +543,7 @@
//Read Status and write status
uint8_t read_block[2];
- ow_result = p_owMaster->OWReadBlock(read_block, 2);
+ ow_result = master().OWReadBlock(read_block, 2);
if (ow_result == OneWireMaster::Success)
{
@@ -580,7 +578,7 @@
DS28E17::CmdResult bridge_result = DS28E17::CommsWriteBlockError;
uint32_t poll_count = 0;
- OneWireMaster::CmdResult ow_result = p_owMaster->OWWriteBlock(data, data_length);
+ OneWireMaster::CmdResult ow_result = master().OWWriteBlock(data, data_length);
if (ow_result == OneWireMaster::Success)
{
@@ -588,7 +586,7 @@
uint8_t recvbit = 0x01;
do
{
- ow_result = p_owMaster->OWReadBit(recvbit);
+ ow_result = master().OWReadBit(recvbit);
} while (recvbit && (poll_count++ < pollLimit) && (ow_result == OneWireMaster::Success));
if (ow_result == OneWireMaster::Success)
@@ -596,7 +594,7 @@
if (poll_count < pollLimit)
{
//Read Status
- ow_result = p_owMaster->OWReadByte(status);
+ ow_result = master().OWReadByte(status);
if (ow_result == OneWireMaster::Success)
{
bridge_result = DS28E17::Success;