要約:DS2482は、1-WireネットワークプロトコルへのI²Cブリッジです。DS2482をブリッジとして使用することによって、I²C通信を備えたホストは、タイミングとスルーレートを正しく制御した1-Wire波形を生成することができます。このアプリケーションノートはDS2482 I²C 1-Wireラインドライバのユーザガイドであり、1-Wireマスタの一般オペレーションのための通信セッションを詳細に説明します。
1. はじめに
DS2482を使用して1-Wire通信プロトコルを生成することができます。DS2482は、I²C通信のための1-Wireネットワークへのブリッジです。このブリッジによって、I²Cを備えたいずれのホストも、正しいタイミングの1-Wire波形を生成することができます。DS2482の簡単な構造図については、図1を参照してください。このプロトコルを実装して、利用可能なDS2482のコマンドを紹介するには時間がかかり、また混乱を招くおそれがあります。このアプリケーションノートでは、DS2482を使用した1-Wireの基本オペレーションと拡張オペレーションの効率的な実装について説明します。また1-Wire通信を処理するI²C入力パケットの構造について説明します。これらのオペレーションは現在および将来の1-Wireデバイスであらゆる機能を実施するための完全な基礎となるものです。この方法で1-Wireのオペレーションを構成すると、1-Wireマスタのタイプに左右されない1-Wireアプリケーションを構築することができます。
このアプリケーションノートは、DS2482のデータシートを補足するものであり、データシートに代わるものではありません。DS2482は、シングルチャネル1-Wireマスタ(DS2482-100)と8チャネル1-Wireマスタ(DS2482-800)の2つの構成で利用可能です。

図1. I²C通信ブリッジであるDS2482の機能と1-Wireネットワークの簡略図
2. 1-Wireインタフェース
基本命令と呼ばれる1-Wireの基本機能がいくつかあります。アプリケーションが1-Wireオペレーションを実施するためには、この基本機能が必要となります。基本命令の最初の機能は、バス上の1-Wireスレーブをすべてリセットし、1-Wireマスタからのコマンドを受信することができるように準備するものです。2番目の機能は、1-Wireマスタのビットをスレーブに書き込み、3番目の機能は1-Wireスレーブからビットを読み出します。1-Wireマスタはすべての1-Wireビット通信を開始しなければならないため、「読出し」は、サンプリングした結果を用いてシングルビットを技術的に「書き込む」ことになります。他のほとんどすべての1-Wireオペレーションは、これらの3つのオペレーションから構成することができます。たとえば、1バイトを1-Wireバスに書き込むことは、8つのシングルビットを書き込むことにすぎません。
上記の同じ3つの基本命令を使用すると、1-Wire検索アルゴリズムを構築することもできます。DS2482は1-WireのTripletコマンドを使用して検索を実現しているため、検索の実行に必要な通信が大幅に低減されます。
表1は、3つの基本命令(OWReset、OWWriteBit/OWReadBit、およびOWWriteByte/OWReadByte)に加えて、1-Wireの基本オペレーションの中核セットをともに構成する他の3つの便利な機能(OWBlock、OWSearch、msDelay)を示します。これ以降、このアプリケーションノート全体を通じて、これらのオペレーションの名前を使用します。
表1. 1-Wireの基本オペレーション
| Operation |
Description |
| OWReset |
Sends the 1-Wire reset stimulus and check for pulses of 1-Wire slave devices. |
| OWWriteBit/OWReadBit |
Sends or receives a single bit of data to the 1-Wire bus. |
| OWWriteByte/OWReadByte |
Sends or receives a single byte of data to the 1-Wire bus. |
| OWBlock |
Sends and receives multiple bytes of data to and from the 1-Wire bus. |
| OWSearch |
Performs the 1-Wire Search Algorithm (see Application Note 187 mentioned above). |
| msDelay |
Delays at least the specified number of milliseconds. |
1-Wireの拡張機能(オーバドライブ通信機能など)は、上の表の基本オペレーションでは取り扱っていません。1-Wireスレーブデバイスによっては、標準とオーバドライブの2種類の通信速度で動作可能なものもあります。すべてのデバイスは標準速度をサポートしています。オーバドライブは標準よりも約10倍の速さになります。DS2482は、両方の1-Wire速度をサポートしています。
1-Wireデバイスは通常、1-Wireバスから、一部またはすべての動作エネルギーを得ます。ただし、デバイスによっては、プロトコルの特定の箇所でさらなる給電を必要とするものもあります。たとえば、温度の変換やSHA-1ハッシュの計算を必要とするデバイスがあります。この作業を行うための電力は、1-Wireバス上により大きなストロングプルアップを設けることによって供給されます。この給電中に通常の通信を行うことはできません。DS2482は、「ストロングプルアップ(SPU)」フラグをセットして電力を供給します。フラグをセットすることで、1-Wire通信の次のバイト(ビット)の後でストロングプルアップが発行されます。DS2482-100には、予備である大電流のストロングプルアップを制御する外部ピン(PCTLZ)があります。
表2は、1-Wireの速度、給電、およびプログラミングパルスについての1-Wireの拡張オペレーションを示しています。
表2. 1-Wireの拡張オペレーション
| Operation |
Description |
| OWSpeed |
Sets the 1-Wire communication speed, either standard or overdrive. Note that this only changes the communication speed of the 1-Wire master; the 1-Wire slave device must be instructed to make the switch when going from normal to overdrive. The 1-Wire slave will always revert to standard speed when it encounters a standard-speed 1-Wire reset. |
| OWLevel |
Sets the 1-Wire power level (normal or power delivery). |
| OWReadBitPower |
Reads a single bit of data from the 1-Wire bus and optionally applies power delivery immediately after the bit is complete. |
| OWWriteBytePower |
Sends a single byte of data to the 1-Wire bus and applies power delivery immediately after the byte is complete. |
3. ホストの構成
DS2482のホストにはI²Cの通信ポートが必要です。このアプリケーションノートでは、ホストの構成については取り扱いません。ただし、ホストは、標準的なインタフェースI²Cのオペレーションを備えている必要があります。必要なオペレーションを表3に示します。
表3. ホストに必要なI²Cオペレーション
| Operation |
Description |
| InitI2C |
Sets the I²C communication speed and selects the DS2482 device. The I2C_clock_delay is the time between clock pulses for I²C communication. The DS2482_slave_address is the I²C address for the DS2482. |
| I2CBus_write |
Writes an I²C byte to the selected DS2482. The byte is passed to the function to write. |
| I2CBus_write_packet |
Writes a packet of I²C bytes to the selected DS2482. The buffer of bytes along with the length of the buffer is passed to the function. |
| I2CBus_read |
Reads an I²C byte from the DS2482. The byte that was read is returned. |
3.1. DS2482の構成
1-Wireオペレーションを試す前に、ホストはDS2482のI²C 1-Wireラインドライバをセットアップして、このドライバと同期をとる必要があります。DS2482と通信するには、スレーブアドレスを知る必要があります。図2は、DS2482-100とDS2482-800のスレーブアドレスを示します。

図2. DS2482のI²Cのスレーブアドレス
3.2. DS2482のI²Cコマンド
以下の凡例はDS2482のデータシートから引用したものであり、このデバイスによるI²C通信のシーケンスを表すための簡易表記です。今後、これらの通信シーケンスを繰り返して使用することになるため、ここで追加の説明を行って、1-Wireの基本オペレーションと拡張オペレーションを実装するためのCのサンプルコードを示します。
I²C通信のシーケンス - 凡例
| SYMBOL |
DESCRIPTION |
| S |
START Condition |
| AD, 0 |
Select DS2482 for Write Access |
| AD, 1 |
Select DS2482 for Read Access |
| Sr |
Repeated START Condition |
| P |
STOP Condition |
| A |
Acknowledged |
| A\ |
Not acknowledged |
| (Idle) |
Bus not busy |
| <byte> |
Transfer of one byte |
| DRST |
Command 'Device Reset', F0h |
| WCFG |
Command 'Write Configuration', D2h |
| SRP |
Command 'Set Read Pointer', E1h |
| 1WRS |
Command '1-Wire Reset', B4h |
| 1WWB |
Command '1-Wire Write Byte', A5h |
| 1WRB |
Command '1-Wire Read Byte', 96h |
| 1WSB |
Command '1-Wire Single Bit', 87h |
| 1WT |
Command '1-Wire Triplet', 78h |
3.3. データ方向コード
| Master-to-Slave |
Slave-to-Master |
このアプリケーションノートの多くの図に見られるデータ方向コードは、マスタからスレーブへの通信(灰色)、またはその逆の、スレーブからマスタへの通信(白)を示します。各コードの陰影を見ることによって、通信方向を確認することができます。
4. デバイスリセット
図3は、Device ResetのI²C通信の例です。リセットの例1はDS2482のリセットコマンドを示し、デバイスのステートマシンロジックのグローバルリセットを実行し、進行中の1-Wire通信を終了します。Device Resetのコマンドコードは0xF0です。

図3. パワーアップ後のDevice Reset。この例には、コマンドの成功を検証するための読出しアクセスがオプションで含まれています。
// initialize the I2C port
if(!InitI2C(I2C_clock_delay,DS2482_slave_address))
{
// Report an error that occurred
}
// reset the DS2482
// DRST is 0xF0
if(!I2CBus_write(DRST))
{
// Report an error that occurred
}
例1. Device Resetのコード
5. DS2482の1-Wireオペレーション
以下は、DS2482に送信されるコマンドであり、1-Wire通信に影響を及ぼします。
5.1. OWReset
Resetコマンド(0xB4)は、1-Wireラインにて1-Wire Reset/Presence Detectを生成します。1-Wireラインの状態をサンプリングし、ステータスレジスタのPresence-Pulse Detect (PPD)とShort Detected (SD)の各フィールドを用いて状態を報告します。図4は1-WireのResetコマンドのI²C通信を示します。例2は、送信されるコマンドとプレゼンスパルスの有無を確認するステータスレジスタを示します。

図4. 1-Wire Reset。1-Wire通信を開始または終了します。1-Wireアイドル(1WB = 0)、1-Wireコマンドが終了するまでビジーポーリング、その後に結果を読み出します。
// OWReset
//
// Resets the 1-Wire using I2C through the DS2482.
//
// returns Success or Failure
//
uchar OWReset()
{
uchar buffer;
uchar test;
// reset the 1-Wire line
// resetOneWireCommand is 0xB4
if(!I2CBus_write(resetOneWireCommand))
{
// Report an error that occurred
}
for(;;)// checking if 1-Wire busy
{
// checking LSB of status register
// to see if 1-Wire is busy.
test = I2CBus_read()| 0xFE;
if(test == 0xFE)
{break;}
}
// checking for presence pulse detect
test = I2CBus_read() | 0xFC;
if(test == 0xFE)
{
return Success; // Presence Pulse found
}
else
{
return Failure; // No presence pulse
}
}
例2. OWResetのコード
5.2. OWWriteBit/OWReadBit
1-WireのBitコマンド(0x87)は、1-Wireビットの1つのタイムスロットを生成します。図5は、1-Wire Single Bitコマンドを例にしたI²C通信コードを示します。図6はビット割当てバイトであり、Vが1bの場合、書込み1タイムスロットが生成されます。またVが0bの場合、書込み0タイムスロットが生成されます。例3はOWWriteBitのコードを、例4はOWReadBitのコードを示します。

図5. 1-Wire Single Bit。1-Wireライン上に単一のタイムスロットを生成します。1WBが1から0に変化すると、ステータスレジスタは1-Wire Single Bitコマンドの有効な結果を保持します。
 図6. 1-Wire Single Bit。1-Wireライン上に単一のタイムスロットを生成します。
// OWWriteBit - Writes a single bit to 1-Wire using the DS2482.
//
// value - bit to be written to the 1-Wire (0 or 1)
//
// Return Success or Failure
//
uchar OWWriteBit(uchar value)
{
uchar buff[3];
uchar test;
buff[0] = onewireBitCommand; // 1-Wire bit command
if(value)
{
buff[1] = 0xFF;
}
else
{
buff[1] = 0x7F;
}
if(!I2CBus_write(&buff[0],2))
{
return FAILURE;
}
// checking if 1-Wire busy
// Check here to make sure the 1-Wire isn’t
// busy so other commands don’t have to check
// before proceeding.
for(;;)
{
if(!I2CBus_read(&buff[0],1))
{
return FAILURE;
}
test = buff[0] | 0xFE;
if(test == 0xFE)
{
break;
}
}
return SUCCESS;
}
例3. OWWriteBitのコード
// OWReadBit
//
// Returns 0 or 1 for the bit read.
uchar OWReadBit()
{
uchar buff[3];
OWWriteBit(1);
buff[0] = setReadPointerCommand;
buff[1] = statusRegister;
if(!I2CBus_write(&buff[0],2))
{
// Report an error that occurred
}
else if(!I2CBus_read(&buff[2],1))
{
// Report an error that occurred
}
if(buff[2] & 0x20)
{
return 1;
}
else
{
return 0;
}
}
例4. OWReadBitのコード
5.3. OWWriteByte
1-Wire Write Byteコマンド(0xA5)は、1-Wireラインに単一のデータバイトを書き込みます。DS2482がこのコマンドを処理するためには、1-Wireの動作が終了している必要があります。図7は、I²Cの1-Wireバイト書込みの例を示します。コード例5では、Write Byteコマンドを発行する前に1-Wireの動作をチェックしています。

図7. 1-Wire Write Byte。1-Wireラインにコマンドコードを送信します。1WBが1から0に変化すると、1-Wire Write Byteコマンドが完了します。
// OWWriteByte
//
// Writes a 1-Wire byte using I2C commands sent to the DS2482.
//
// wrByte - The byte to be written to the 1-Wire.
//
void OWWriteByte(uchar wrByte)
{
uchar buffer[2];
uchar test;
// set the read pointer to the status
// register to check 1-Wire busy
buffer[0] = setReadPointerCommand; // 0xE1
buffer[1] = statusRegister; // 0xF0
if(!I2CBus_write(buffer,2))
{
// Report an error that occurred
}
// checking if 1-Wire busy
for(;;)
{
test = I2CBus_read() | 0xFE;
if(test == 0xFE)
{
break;
}
}
buffer[0] = writeByteCommand; // 0xA5
buffer[1] = wrByte;
if(!I2CBus_write_packet(buffer,2))
{
// Report an error that occurred
}
// checking if 1-Wire busy
for(;;)
{
test = I2CBus_read() | 0xFE;
if(test == 0xFE)
{
break;
}
}
}
例5. OWWriteByteのコード
5.4. OWReadByte
1-Wire Read Byteコマンド(0x96)は、1-Wireラインから単一のデータバイトを読み出します。DS2482がこのコマンドを処理するためには、1-Wireの動作が終了している必要があります。図8は、I²Cの例を示します。1-Wire Read Byteコマンドは、コード例6で使用されています。Read Byteコマンドを発行する前に1-Wireの動作をチェックしています。

図8. 1-Wire Byte Read。1-Wireラインから1バイトを読み出します。1WBが1から0に変化するまで、ステータスレジスタをポーリングします。次に、読出しポインタをデータ読出しレジスタ(コードE1h)に設定し、デバイスに再びアクセスして、1-Wireラインから得られるデータを読み出します。
// OWReadByte
//
// Reads a 1-Wire byte using I2C commands to the DS2482.
//
// returns the byte read
//
uchar OWReadByte
{
uchar buffer[2];
uchar test;
// set the read pointer to the status
// register to check 1-Wire busy
buffer[0] = setReadPointerCommand; // 0xE1
buffer[1] = statusRegister; // 0xF0
if(!I2CBus_write_packet(buffer,2))
{
// Report an error that occurred
}
// checking if 1-Wire busy
for(;;)
{
test = I2CBus_read() | 0xFE;
if(test == 0xFE)
{
break;
}
}
// readByteCommand is 0x96
if(!I2CBus_write(readByteCommand))
{
// Report an error that occurred
}
buffer[0] = setReadPointerCommand; // 0xE1
buffer[1] = readDataRegister; // 0xE1
if(!I2CBus_write_packet(buffer,2))
{
// Report an error that occurred
}
// gets the byte that was read
else
{
buffer[2] = I2CBus_read();
}
return buffer[2];
}
例6. OWReadByteのコード
5.5. OWBlock
OWBlockオペレーションは、単にバイトオペレーションを呼び出すだけです。バイトコマンドを使用しなければデータのブロックを転送することができないからです。例7は、OWBlockのコード例を示します。
// OWBlock – writes/reads a block of data
// block – block of data
// return – Success or failure of the operation.
uchar OWBlock (uchar *block, uchar len)
{
uchar buffer[2];
int i;
for(i=0;i<len;i++)
{
owWriteByte(block[i]);
buffer[0] = setReadPointerCommand; // The read pointer value is 0xE1
buffer[1] = readDataRegister; // The read data register value is 0xE1
if(!I2CBus_write(&buffer[0],2))
{
return FAILURE;
}
else
block[i] = I2CBus_read();
}
return SUCCESS;
}
例7. OWBlockのコード
5.6 OWSearch/1-Wire Tripletコマンド
Tripletコマンド(0x78)は、3つのタイムスロット、2つの読出しタイムスロット、および1つの書込みタイムスロットを1-Wireライン上に生成します。方向バイト(DIR)は書込みタイムスロットのタイプを判断します(図9)。例8は、1つのデバイスのみを接続した状態で検索コマンドを使用した1-Wire Tripletコマンドを示します。1-Wire検索アルゴリズムの説明については、1-Wire TripletコマンドのためのI²Cセットアップを説明したアプリケーションノート187 (前出)を参照してください。
 図9. 1-Wire Triplet。Search ROM関数を1-Wireライン上で実施します。1-Wire関数が完了するにはアイドル時間が必要です。次に、読出しモードでデバイスにアクセスし、1-Wire Tripletコマンドの結果を取得します。
// Global value for the current serial number
uchar SearchSerialNum[8];
// oneWireSearch
//
// Does a 1-Wire search using the 1-Wire Triplet command.
//
// resetSearch – Reset the search(1) or not(0).
// lastDevice - If the last device has been found(1) or not(0).
// deviceAddress – The returned serial number.
//
// returns SUCCES or FAILURE
//
uchar OWSearch(uchar resetSearch, uchar *lastDevice, uchar *deviceAddress)
{
uchar retVal = FAILURE;
uchar bit_number = 1;
uchar last_zero = 0;
uchar serial_byte_number = 0;
uchar serial_byte_mask = 1;
uchar firstBit, secondBit, dir;
uchar i = 0;
if(resetSearch)
{
lastDevice = 0;
LastDiscrepancy = 0;
}
// if the last call was not the last one
if (!(*lastDevice))
{
// reset the 1-wire
// if there are no parts on 1-wire, return FALSE
if(!OWReset())
{
// reset the search
lastDevice = 0;
LastDiscrepancy = 0;
return FAILURE;
}
// Issue the Search ROM command
OWWireByte(0xF0);
// loop to do the search
do
{
if (bit_number < LastDiscrepancy)
{
if(SearchSerialNum[serial_byte_number] & serial_byte_mask)
dir = 1;
else
dir = 0;
}
else
{
// if equal to last pick 1, if not then pick 0
if(bit_number==LastDiscrepancy)
dir = 1;
else
dir = 0;
}
if(!owTriplet(&dir, &firstBit, &secondBit))
{
return FAILURE;
}
// if 0 was picked then record its position in LastZero
if (firstBit==0 && secondBit==0 && dir == 0)
{
last_zero = bit_number;
}
// check for no devices on 1-wire
if (firstBit==1 && secondBit==1)
break;
// set or clear the bit in the SerialNum byte serial_byte_number
// with mask serial_byte_mask
if (dir == 1)
SearchSerialNum[serial_byte_number] |= serial_byte_mask;
else
SearchSerialNum[serial_byte_number] &= ~serial_byte_mask;
// increment the byte counter bit_number
// and shift the mask serial_byte_mask
bit_number++;
serial_byte_mask <<= 1;
// if the mask is 0 then go to new SerialNum[portnum] byte serial_byte_number
// and reset mask
if (serial_byte_mask == 0)
{
serial_byte_number++;
serial_byte_mask = 1;
}
}
while(serial_byte_number < 8); // loop until through all SerialNum[portnum]
retVal = FAILURE;
// if the search was successful then
if (bit_number == 65)//|| crcl))
{
// search successful so set LastDiscrepancy,LastDevice
LastDiscrepancy = last_zero;
if(LastDiscrepancy==0)
*lastDevice = SUCCESS;
else
*lastDevice = FAILURE;
for(i=0; i<8; i++)
{
deviceAddress[i] = SearchSerialNum[i];
}
return SUCCESS;
}
}
// if no device found then reset counters so next 'next' will be
// like a first
if (!retVal || !SearchSerialNum[0])
{
LastDiscrepancy = 0;
*lastDevice = FAILURE;
retVal = FAILURE;
}
return retVal;
}
// oneTriplet
//
// Uses the 1-Wire Triplet command.
//
// dir – Returns the direction that was chosen (1) or (0).
// firstBit - Returns the first bit of the search (1) or (0).
// secondBit – Returns the complement of the first bit (1) or (0).
//
// returns SUCCES or FAILURE
//
uchar owTriplet(uchar *dir, uchar *firstBit, uchar *secondBit)
{
uchar buff[3];
uchar test;
buff[0] = 0x78;
if(*dir>0)
*dir = (uchar)0xFF;
buff[1] = *dir;
if(!I2CBus_write(&buff[0],2))
{
lcd_putchar('f');
}
if(!I2CBus_read(&buff[2],1))
{
return FAILURE;
}
else
{
test = buff[2] & 0x20;
if(test == 0x20)
*firstBit = 1;
else
*firstBit = 0;
test = buff[2] & 0x40;
if(test == 0x40)
*secondBit = 1;
else
*secondBit = 0;
test = buff[2] & 0x80;
if(test == 0x80)
*dir = 1;
else
*dir = 0;
return SUCCESS;
}
return FAILURE;
}
例8. OWSearchのコード
6. 1-Wireの拡張オペレーション
6.1. OWSpeed
例9は、DS2482を使用して1-Wireバスの速度を変更する方法を示します。オーバドライブまたは標準の速度が利用可能です。
// OWSpeed – changes the 1-Wire speed to normal or overdrive.
// A Overdrive match rom or overdrive skip rom will be needed.
//
// speed – overdrive (Overdrive) or standard (Standard) speed.
// state_config – The current configuration byte settings.
//
// return – success or failure of the operation.
//
uchar OWSpeed(uchar speed, uchar state_config)
{
uchar buffer[2];
buffer[0] = writeConfigCommand;
if(speed == Overdrive)
buffer[1] = (state_config | 0x08) & 0x7F;
else
buffer[1] = (state_config | 0x80) & 0xF7;
if(!I2CBus_write_packet(buffer,2))
{
return FAILURE;
}
return SUCCESS;
}
例9. OWSpeedのコード
6.2. OWLevel
例10は、DS2482を使用して1-Wireバスのレベルを変更する方法を示します。通常モードまたは給電モードが利用可能です。
// OWLevel
//
// level – Normal or Power Delivery mode
// state_config – The current configuration settings
//
// Returns if the operation was Successful or not.
//
uchar OWLevel(uchar level, uchar state_config)
{
uchar buffer[2];
buffer[0] = writeConfigCommand;
// NORMAL = 0, POWER_DELIV = 1
if(level == NORMAL)
buffer[1] = (state_config | 0x01) & 0xEF;
else
buffer[1] = (state_config | 0x10) & 0xFE;
if(!I2CBus_write_packet(buffer,2))
{
return FAILURE;
}
return SUCCESS;
}
例10. OWLevelのコード
6.3. OWReadBitPower
例11は、OWReadBitPowerを使用するためのコードを示します。これは、1-Wireビットを読み出して給電を実行します。設定レジスタのストロングプルアップ(SPU)ビットがイネーブルになると、DS2482は次のビット(またはバイト)通信の後で1-Wireラインをハイにアクティブプルアップします。
// OWReadBitPower
//
// config_byte – current configuration settings
// delay – ms delay used before disabling active pullup
//
// Returns the bit information read.
//
uchar OWReadBitPower(uchar config_byte)
{
uchar buffer[2];
uchar return_bit;
buffer[0] = writeConfigCommand;
buffer[1] = (config_byte | 0x04) & 0xBF;
// Sets strong pullup active so after the next byte or bit
// strong pullup will be active
if(!I2CBus_write_packet(buffer,2))
{
Error;
}
return OWReadBit();
}
例11. OWReadBitPowerのコード
6.4. OWWriteBytePower
例12はOWWriteBytePowerを使用するためのコードを示します。1-Wireバイトを書き込み、給電を実行します。設定レジスタのストロングプルアップ(SPU)ビットがイネーブルにされると、DS2482は次のビットまたはバイト通信の後で1-Wireラインをハイへアクティブプルアップします。
// OWWriteBytePower
//
// config_byte – current configuration settings.
// wrbyte – byte to be written before the strong pullup is active
// delay – ms delay used before disabling active pullup
//
// Returns failure or success of the operation.
//
uchar OWWriteBytePower(uchar config_byte, uchar wrbyte)
{
uchar buffer[2];
buffer[0] = writeConfigCommand;
buffer[1] = (config_byte | 0x04) & 0xBF;
// Sets strong pullup active so after the next byte or bit
// strong pullup will be active
if(!I2CBus_write_packet(buffer,2))
{
return FAILURE;
}
OWWriteByte(wrbyte);
return SUCCESS;
}
例12. OWWriteBytePowerのコード
結論
DS2482は、I²Cコマンドを1-Wire通信に変換するテストに合格しています。このアプリケーションノートでは、DS2482のI²C 1-Wireラインドライバを使用して1-Wireインタフェースの完全ソリューションについて説明しました。I²C通信ポートを備えたホストシステムであれば、容易にサンプルコードを実装することができます。Cによる完全実装もダウンロードして利用可能です。
1-WireはMaxim Integrated Products, Inc.の登録商標です。
フィードバックをお寄せください。 内容に満足されましたか、あるいは満足されていませんか?もっと良いページにできると思いますか?あるいは、単なるコメントでも結構です。フィードバックをお待ちしています。—マキシムはお客様からいただく訂正、提案を元に改善していきます。
このページを評価し、フィードバックを送信する。
自動アップデート
お客様が関心のある分野でアプリケーションノートが新規に掲載された際に自動通知Eメールの受信を希望する場合は、EE-Mail™にご登録ください。
| その他の情報 | |
APP 3684: May 25, 2006
|
|
|
|
ダウンロード、PDFフォーマット (102kB)
AN3684,
AN 3684,
APP3684,
Appnote3684,
Appnote 3684
|
|