OneWire + DS18X20 Library
Basic functions for OneWire operations + specific DS18x20 operations
 All Functions Groups Pages
Functions
ONEWIRE FUNCTIONS

Functions

uint8_t onewire_reset (void)
 OneWire reset. More...
 
uint8_t onewire_read_byte (void)
 read one byte More...
 
void onewire_write_byte (uint8_t data)
 write one byte More...
 
void onewire_search_init (uint8_t buffer[8])
 init rom search buffer and internal variables More...
 
uint8_t onewire_alarm_search (uint8_t buffer[8])
 scan OneWire bus for devices with active alarm flag More...
 
uint8_t onewire_search_rom (uint8_t buffer[8])
 scan OneWire bus for ROMs More...
 
uint8_t onewire_match_rom (const uint8_t rom[8])
 select device on bus More...
 
uint8_t onewire_read_rom (uint8_t rom[8])
 read ROM ID of device More...
 
uint8_t onewire_skip_rom (void)
 select device on bus More...
 
uint8_t onewire_crc (const uint8_t *data, uint8_t cnt)
 calculate CRC over data array, fast version, 0.3ms for 8 bytes @1MHz More...
 
uint8_t onewire_crc_serial (const uint8_t *data, uint8_t cnt)
 calculate CRC over data array, serial version, 1ms for 8 bytes @1MHz More...
 

Detailed Description

standard functions

Function Documentation

uint8_t onewire_reset ( void  )

OneWire reset.

reset onewire bus

Parameters
none
Returns
error code
ONEWIRE_OK no error
ONEWIRE_NO_PRESENCE no presence pulse detected
ONEWIRE_GND_SHORT bus short circuit to ground

Definition at line 27 of file onewire.cpp.

uint8_t onewire_read_byte ( void  )

read one byte

Parameters
none
Returns
read data byte

Definition at line 83 of file onewire.cpp.

void onewire_write_byte ( uint8_t  data)

write one byte

Parameters
databyte to write
Returns
none

Definition at line 96 of file onewire.cpp.

void onewire_search_init ( uint8_t  buffer[8])

init rom search buffer and internal variables

Parameters
buffer[8]pointer to buffer array
Returns
none

Definition at line 107 of file onewire.cpp.

uint8_t onewire_alarm_search ( uint8_t  buffer[8])

scan OneWire bus for devices with active alarm flag

call onewire_search_init() before first call of this function after each call, the buffer contains the new scaned ROM code

Parameters
buffer[8]pointer to buffer array
Returns
error code
ONEWIRE_OK new ROM code scanned successfully
ONEWIRE_NO_PRESENCE no bus response during reset
ONEWIRE_GND_SHORT bus short circuit to GND
ONEWIRE_CRC_ERROR CRC error in received rom code
ONEWIRE_SCAN_ERROR no bus response during scan
ONEWIRE_LAST_CODE last scan, no more codes available

Definition at line 116 of file onewire.cpp.

uint8_t onewire_search_rom ( uint8_t  buffer[8])

scan OneWire bus for ROMs

call onewire_search_init() before first call of this function after each call, the buffer contains the new scaned ROM code

Parameters
buffer[8]pointer to buffer array
Returns
error code
ONEWIRE_OK new ROM code scanned successfully
ONEWIRE_NO_PRESENCE no bus response during reset
ONEWIRE_GND_SHORT bus short circuit to GND
ONEWIRE_CRC_ERROR CRC error in received rom code
ONEWIRE_SCAN_ERROR no bus response during scan
ONEWIRE_LAST_CODE last scan, no more codes available

Definition at line 112 of file onewire.cpp.

uint8_t onewire_match_rom ( const uint8_t  rom[8])

select device on bus

Parameters
rom[8]pointer to ROM ID
Returns
error code
ONEWIRE_OK code access successfully
ONEWIRE_NO_PRESENCE no bus response during reset
ONEWIRE_GND_SHORT bus short circuit to GND

Definition at line 208 of file onewire.cpp.

uint8_t onewire_read_rom ( uint8_t  rom[8])

read ROM ID of device

can only be used for a single device on bus

Parameters
rom[8]pointer to buffer array
Returns
error code
ONEWIRE_OK code access successfully
ONEWIRE_NO_PRESENCE no bus response during reset
ONEWIRE_GND_SHORT bus short circuit to GND
ONEWIRE_CRC_ERROR CRC error in rom data

Definition at line 235 of file onewire.cpp.

uint8_t onewire_skip_rom ( void  )

select device on bus

can only be used for a single device on bus

Parameters
none
Returns
error code
ONEWIRE_OK code access successfully
ONEWIRE_NO_PRESENCE no bus response during reset
ONEWIRE_GND_SHORT bus short circuit to GND

Definition at line 223 of file onewire.cpp.

uint8_t onewire_crc ( const uint8_t *  data,
uint8_t  cnt 
)

calculate CRC over data array, fast version, 0.3ms for 8 bytes @1MHz

Parameters
*datapointer to buffer array
cntnumber of data bytes
Returns
calculated CRC
Calculating a CRC over a data array including the received CRC
(last byte) will return zero in case of a valid CRC
Calculating a CRC over a data array without the received CRC
(last byte zero, placeholder for CRC) will return the calculated CRC.
If all data bytes are zero, 0xFF is returned to indicate an error

Definition at line 286 of file onewire.cpp.

uint8_t onewire_crc_serial ( const uint8_t *  data,
uint8_t  cnt 
)

calculate CRC over data array, serial version, 1ms for 8 bytes @1MHz

Parameters
*datapointer to buffer array
cntnumber of data bytes
Returns
calculated CRC
Calculating a CRC over a data array including the received CRC
(last byte) will return zero in case of a valid CRC
Calculating a CRC over a data array without the received CRC
(last byte zero, placeholder for CRC) will return the calculated CRC.
If all data bytes are zero, 0xFF is returned to indicate an error

Definition at line 354 of file onewire.cpp.