Инструменты пользователя

Инструменты сайта


ow_api

Мастеры шины и их подключение

На практике замечено, что не все UART работают нормально с DS2480. См. таблицу.

UARTИсполнениеОССтатус
FTDIКабель TTL-232R-5VLinuxOK
CP210xКитайский модульLinuxOK
ProlificАдаптер USB-RS-232 через MAX232LinuxOK
CH340GКитайский модульLinuxОпределяется только мастер, не определяются устройства на шине

Литература

Белов А. Конструирование устройств на микроконтроллерах. Наука и техника, 2005. - 256 с.

Описана шина 1-Wire и примеры реализации устройств на ассемблере.

Dallas 1-Wire C API

Общее описание библиотеки 1-Wire Public Domain Kit

iButton: 1-Wire Public Domain Kit http://www.maximintegrated.com/products/ibutton/software/1wire/wirekit.cfm

APPLICATION NOTE 1097 White Paper 2: Using the 1-Wire® Public Domain Kit Jul 16, 2008 http://www.maximintegrated.com/app-notes/index.mvp/id/1097

Функции API

owSerialNum (ownet.h)

The function either reads or sets the SerialNum buffer that is used in the search functions 'owFirst' and 'owNext'.

  void owSerialNum(int portnum, uchar *serialnum_buf, SMALLINT do_read);
 
//--------------------------------------------------------------------------
// The 'owSerialNum' function either reads or sets the SerialNum buffer
// that is used in the search functions 'owFirst' and 'owNext'.
// This function contains two parameters, 'serialnum_buf' is a pointer
// to a buffer provided by the caller.  'serialnum_buf' should point to
// an array of 8 unsigned chars.  The second parameter is a flag called
// 'do_read' that is TRUE (1) if the operation is to read and FALSE
// (0) if the operation is to set the internal SerialNum buffer from
// the data in the provided buffer.
//
// 'portnum'       - number 0 to MAX_PORTNUM-1.  This number was provided to
//                   OpenCOM to indicate the port number.
// 'serialnum_buf' - buffer to that contains the serial number to set
//                   when do_read = FALSE (0) and buffer to get the serial
//                   number when do_read = TRUE (1).
// 'do_read'       - flag to indicate reading (1) or setting (0) the current
//                   serial number.
//

owAccess (ownet.h)

The function resets the 1-Wire and sends a MATCH Serial Number command followed by the current SerialNum code.

  SMALLINT owAccess(int portnum);
 
//--------------------------------------------------------------------------
// The 'owAccess' function resets the 1-Wire and sends a MATCH Serial
// Number command followed by the current SerialNum code. After this
// function is complete the 1-Wire device is ready to accept device-specific
// commands.
//
// 'portnum'  - number 0 to MAX_PORTNUM-1.  This number was provided to
//              OpenCOM to indicate the port number.
//
// Returns:   TRUE (1) : reset indicates present and device is ready
//                       for commands.
//            FALSE (0): reset does not indicate presence or echos 'writes'
//                       are not correct.
//

owWriteByte (ownet.h)

Send or receive a single byte of data to the 1-Wire bus.

  SMALLINT owWriteByte(int portnum, SMALLINT sendbyte);
 
//--------------------------------------------------------------------------
// Send 8 bits of communication to the 1-Wire Net and verify that the
// 8 bits read from the 1-Wire Net is the same (write operation).
// The parameter 'sendbyte' least significant 8 bits are used.
//
// 'portnum'  - number 0 to MAX_PORTNUM-1.  This number was provided to
//              OpenCOM to indicate the port number.
// 'sendbyte' - 8 bits to send (least significant byte)
//
// Returns:  TRUE: bytes written and echo was the same
//           FALSE: echo was not the same
//

owWriteBytePower (ownet.h)

Send a single byte of data to the 1-Wire bus and apply power-delivery immediately after the byte is complete.

  SMALLINT owWriteBytePower(int portnum, SMALLINT sendbyte);
 
//--------------------------------------------------------------------------
// Send 8 bits of communication to the 1-Wire Net and verify that the
// 8 bits read from the 1-Wire Net is the same (write operation).
// The parameter 'sendbyte' least significant 8 bits are used.  After the
// 8 bits are sent change the level of the 1-Wire net.
//
// 'portnum'  - number 0 to MAX_PORTNUM-1.  This number was provided to
//              OpenCOM to indicate the port number.
// 'sendbyte' - 8 bits to send (least significant bit)
//
// Returns:  TRUE: bytes written and echo was the same, strong pullup now on
//           FALSE: echo was not the same
//

owBlock (ownet.h)

Send and receive multiple bytes of data to and from the 1-Wire bus.

  SMALLINT owBlock(int portnum, SMALLINT do_reset, uchar *tran_buf, SMALLINT tran_len);
 
//--------------------------------------------------------------------------
// The 'owBlock' transfers a block of data to and from the
// 1-Wire Net with an optional reset at the begining of communication.
// The result is returned in the same buffer.
//
// 'portnum'  - number 0 to MAX_PORTNUM-1.  This number is provided to
//              indicate the symbolic port number.
// 'do_reset' - cause a owTouchReset to occure at the begining of
//              communication TRUE(1) or not FALSE(0)
// 'tran_buf' - pointer to a block of unsigned
//              chars of length 'tran_len' that will be sent
//              to the 1-Wire Net
// 'tran_len' - length in bytes to transfer
 
// Supported devices: all
//
// Returns:   TRUE (1) : The optional reset returned a valid
//                       presence (do_reset == TRUE) or there
//                       was no reset required.
//            FALSE (0): The reset did not return a valid prsence
//                       (do_reset == TRUE).
//
//  The maximum tran_length is (160)
//
ow_api.txt · Последние изменения: 2017/04/24 12:28 — reug