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:
- 75:8b627804927c
- Parent:
- 74:23be10c32fa3
- Child:
- 76:84e6c4994e29
--- a/Bridge/DS28E17/DS28E17.cpp Fri May 13 07:48:35 2016 -0500
+++ b/Bridge/DS28E17/DS28E17.cpp Fri May 13 14:52:50 2016 -0500
@@ -36,6 +36,22 @@
using OneWire::Bridge::DS28E17;
using OneWire::Masters::OneWireMaster;
+
+enum Command
+{
+ WriteDataWithStopCmd = 0x4B,
+ WriteDataNoStopCmd = 0x5A,
+ WriteDataOnlyCmd = 0x69,
+ WriteDataOnlyWithStopCmd = 0x78,
+ ReadDataWithStopCmd = 0x87,
+ WriteReadDataWithStopCmd = 0x2D,
+ WriteConfigurationCmd = 0xD2,
+ ReadConfigurationCmd = 0xE1,
+ EnableSleepModeCmd = 0x1E,
+ ReadDeviceRevisionCmd = 0xC3
+};
+
+
const uint16_t DS28E17::_oddparity[] = { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 };
@@ -57,7 +73,7 @@
size_t send_cnt = 0;
uint8_t send_block[0xff];
- OneWireMaster::CmdResult ow_result = _owm.OWMatchROM(romId);
+ OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
if (ow_result == OneWireMaster::Success)
{
@@ -67,7 +83,7 @@
// Form the 1-Wire Packet
// I2C Write Data with Stop command
- send_block[send_cnt] = CMD_I2C_WRITE_W_STOP;
+ send_block[send_cnt] = WriteDataWithStopCmd;
docrc16(send_block[send_cnt++]);
// I2C Address
@@ -108,7 +124,7 @@
size_t send_cnt = 0;
uint8_t send_block[0xff];
- OneWireMaster::CmdResult ow_result = _owm.OWMatchROM(romId);
+ OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
if (ow_result == OneWireMaster::Success)
{
@@ -116,7 +132,7 @@
_crc16 = 0;
// I2C Write Data with Stop command
- send_block[send_cnt] = CMD_I2C_WRITE_NO_STOP;
+ send_block[send_cnt] = WriteDataNoStopCmd;
docrc16(send_block[send_cnt++]);
// I2C Address
@@ -156,7 +172,7 @@
size_t send_cnt = 0;
uint8_t send_block[0xff];
- OneWireMaster::CmdResult ow_result = _owm.OWMatchROM(romId);
+ OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
if (ow_result == OneWireMaster::Success)
{
@@ -166,7 +182,7 @@
// Form the 1-Wire Packet
// I2C Write Data with Stop command
- send_block[send_cnt] = CMD_I2C_WRITE_ONLY;
+ send_block[send_cnt] = WriteDataOnlyCmd;
docrc16(send_block[send_cnt++]);
// Length field
@@ -202,7 +218,7 @@
size_t send_cnt = 0;
uint8_t send_block[0xff];
- OneWireMaster::CmdResult ow_result = _owm.OWMatchROM(romId);
+ OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
if (ow_result == OneWireMaster::Success)
{
@@ -212,7 +228,7 @@
// Form the 1-Wire Packet
// I2C Write Data with Stop command
- send_block[send_cnt] = CMD_I2C_WRITE_ONLY_W_STOP;
+ send_block[send_cnt] = WriteDataOnlyWithStopCmd;
docrc16(send_block[send_cnt++]);
// Length field
@@ -251,7 +267,7 @@
size_t idx = 0;
uint8_t send_block[0xff];
- OneWireMaster::CmdResult ow_result = _owm.OWMatchROM(romId);
+ OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
if (ow_result == OneWireMaster::Success)
{
@@ -261,7 +277,7 @@
// Form the 1-Wire Packet
// I2C Write Data with Stop command
- send_block[send_cnt] = CMD_I2C_WRITE_READ_W_STOP;
+ send_block[send_cnt] = WriteReadDataWithStopCmd;
docrc16(send_block[send_cnt++]);
// I2C Address
@@ -317,7 +333,7 @@
size_t send_cnt = 0;
uint8_t send_block[0xff];
- OneWireMaster::CmdResult ow_result = _owm.OWMatchROM(romId);
+ OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
if (ow_result == OneWireMaster::Success)
{
@@ -327,7 +343,7 @@
// Form the 1-Wire Packet to send
// I2C Write Data with Stop command
- send_block[send_cnt] = CMD_I2C_READ_W_STOP;
+ send_block[send_cnt] = ReadDataWithStopCmd;
docrc16(send_block[send_cnt++]);
// I2C Address
@@ -368,12 +384,12 @@
{
DS28E17::CmdResult bridge_result = DS28E17::OperationFailure;
- OneWireMaster::CmdResult ow_result = _owm.OWMatchROM(romId);
+ OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
if (ow_result == OneWireMaster::Success)
{
// Send CMD and Data
- uint8_t send_block[] = { CMD_WRITE_CONFIG_REG, data };
+ uint8_t send_block[] = { WriteConfigurationCmd, data };
ow_result = _owm.OWWriteBlock(send_block, 2);
if (ow_result == OneWireMaster::Success)
@@ -396,12 +412,12 @@
{
DS28E17::CmdResult bridge_result = DS28E17::OperationFailure;
- OneWireMaster::CmdResult ow_result = _owm.OWMatchROM(romId);
+ OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
if (ow_result == OneWireMaster::Success)
{
// Send CMD and receive Data
- ow_result = _owm.OWWriteByte(CMD_READ_CONFIG_REG);
+ ow_result = _owm.OWWriteByte(ReadConfigurationCmd);
if (ow_result == OneWireMaster::Success)
{
ow_result = _owm.OWReadByte(config);
@@ -425,41 +441,16 @@
//*********************************************************************
-DS28E17::CmdResult DS28E17::DisableOWMode()
+DS28E17::CmdResult DS28E17::EnableSleepMode()
{
DS28E17::CmdResult bridge_result = DS28E17::OperationFailure;
- OneWireMaster::CmdResult ow_result = _owm.OWMatchROM(romId);
+ OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
if (ow_result == OneWireMaster::Success)
{
// Send CMD
- ow_result = _owm.OWWriteByte(CMD_DISABLE_OW_MODE);
- if (ow_result == OneWireMaster::Success)
- {
- bridge_result = DS28E17::Success;
- }
- else
- {
- bridge_result = DS28E17::CommsWriteByteError;
- }
- }
-
- return bridge_result;
-}
-
-
-//*********************************************************************
-DS28E17::CmdResult DS28E17::EnableSleepMode()
-{
- DS28E17::CmdResult bridge_result = DS28E17::OperationFailure;
-
- OneWireMaster::CmdResult ow_result = _owm.OWMatchROM(romId);
-
- if (ow_result == OneWireMaster::Success)
- {
- // Send CMD
- ow_result = _owm.OWWriteByte(CMD_ENABLE_SLEEP_MODE);
+ ow_result = _owm.OWWriteByte(EnableSleepModeCmd);
if (ow_result == OneWireMaster::Success)
{
bridge_result = DS28E17::Success;
@@ -479,12 +470,12 @@
{
DS28E17::CmdResult bridge_result = DS28E17::OperationFailure;
- OneWireMaster::CmdResult ow_result = _owm.OWMatchROM(romId);
+ OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
if (ow_result == OneWireMaster::Success)
{
// Send CMD and receive Data
- ow_result = _owm.OWWriteByte(CMD_READ_DEVICE_REV);
+ ow_result = _owm.OWWriteByte(ReadDeviceRevisionCmd);
if (ow_result == OneWireMaster::Success)
{
ow_result = _owm.OWReadByte(rev);
@@ -543,11 +534,11 @@
do
{
ow_result = _owm.OWReadBit(recvbit);
- } while (recvbit && (poll_count++ < POLL_LIMIT) && (ow_result == OneWireMaster::Success));
+ } while (recvbit && (poll_count++ < pollLimit) && (ow_result == OneWireMaster::Success));
if (ow_result == OneWireMaster::Success)
{
- if (poll_count < POLL_LIMIT)
+ if (poll_count < pollLimit)
{
//Read Status and write status
uint8_t read_block[2];
@@ -596,11 +587,11 @@
do
{
ow_result = _owm.OWReadBit(recvbit);
- } while (recvbit && (poll_count++ < POLL_LIMIT) && (ow_result == OneWireMaster::Success));
+ } while (recvbit && (poll_count++ < pollLimit) && (ow_result == OneWireMaster::Success));
if (ow_result == OneWireMaster::Success)
{
- if (poll_count < POLL_LIMIT)
+ if (poll_count < pollLimit)
{
//Read Status
ow_result = _owm.OWReadByte(status);