XBee Firmware Library  1.6.0
Functions
1-Wire driver

Functions

uint8_t crc_check (uint8_t *buffer, uint8_t len)
 Performs a CRC (Cyclic Redundancy Check) over a buffer. More...
 
ssize_t one_wire_address (uint8_t *romcode)
 Used for addressing a specific device connected to the 1-Wire bus. Usually used after a one_wire_reset() command. More...
 
int one_wire_config (void)
 Initializes and configures the 1-Wire interface. More...
 
ssize_t one_wire_read (uint8_t *rxbuf, uint8_t len)
 Reads from the 1-Wire bus determined number of bytes. More...
 
ssize_t one_wire_read_byte (uint8_t *rxbyte)
 Reads one byte from the 1-Wire bus. More...
 
ssize_t one_wire_read_rom (uint8_t *romcode)
 If there is only one device connected to the 1-Wire bus, reads its ROM code. This ROM is CRC8 checked before reporting a success. More...
 
ssize_t one_wire_reset (void)
 Performs a reset on the 1-Wire bus. More...
 
ssize_t one_wire_search (uint8_t *rombuf, uint8_t len)
 Performs the 1-Wire search algorithm and store ROM codes found. More...
 
uint8_t one_wire_single_bit_rx (void)
 Reads 1 bit from the 1-Wire bus. More...
 
uint8_t one_wire_single_bit_tx (uint8_t bit)
 Sends 1 bit over the 1-Wire bus. More...
 
ssize_t one_wire_skip_rom (void)
 Used when only one device is connected to the 1-Wire bus, so sending 32-bit ROM code is unnecessary. Usually used after a one_wire_reset() command. More...
 
void one_wire_spp_enable (bool_t val)
 Activates or deactivates the strong pull-up (if enabled) on the 1-Wire bus. More...
 
ssize_t one_wire_write (const uint8_t *txbuf, uint8_t len)
 Sends over the 1-Wire bus a buffer with a determined length. More...
 
ssize_t one_wire_write_byte (uint8_t byte)
 Sends 1 byte over the 1-Wire bus. More...
 

Detailed Description

Platform-specific layer provides a consistent 1-Wire API to upper layers of the driver.

1-Wire API Overview

1-Wire is a device communications bus system designed by Dallas Semiconductor Corp. that provides low-speed data, signaling, and power over a single signal.

This API contains the functions to configure and control a 1 Wire bus by bit-banging a GPIO of the programmable XBee devices.

Platform-specific layer provides a consistent MACROS API to upper layers of the driver.

1-Wire ROM-Commands

The 1-Wire protocol has 5 generic ROM-Commands that may be used with one_wire_write() and one_wire_write_byte() functions:

Function Documentation

uint8_t crc_check ( uint8_t buffer,
uint8_t  len 
)

Performs a CRC (Cyclic Redundancy Check) over a buffer.

Parameters
[in]bufferthe buffer which will be checked.
[in]lenthe number of bytes to be considered.
Return values
intthe CRC result.
ssize_t one_wire_address ( uint8_t romcode)

Used for addressing a specific device connected to the 1-Wire bus. Usually used after a one_wire_reset() command.

Parameters
[in]romcodethe ROM code of the device to be addressed.
Return values
ssize_t0 on success.
ssize_t<0 if there is an error.
int one_wire_config ( void  )

Initializes and configures the 1-Wire interface.

Return values
0on success.
ssize_t one_wire_read ( uint8_t rxbuf,
uint8_t  len 
)

Reads from the 1-Wire bus determined number of bytes.

Parameters
[out]rxbufthe buffer where the received bytes will be stored.
[in]lenthe number of bytes to be read.
Return values
int0 on success.
int<0 if there is an error while reading.
ssize_t one_wire_read_byte ( uint8_t rxbyte)

Reads one byte from the 1-Wire bus.

Parameters
[out]rxbytethe buffer where the received byte will be stored.
Return values
int0 on success.
ssize_t one_wire_read_rom ( uint8_t romcode)

If there is only one device connected to the 1-Wire bus, reads its ROM code. This ROM is CRC8 checked before reporting a success.

Parameters
[out]romcodethe buffer where the ROM code will be stored.
Return values
int0 on success.
int<0 if there is an error while reading.
ssize_t one_wire_reset ( void  )

Performs a reset on the 1-Wire bus.

Return values
0on success.
<0if there is an error
ssize_t one_wire_search ( uint8_t rombuf,
uint8_t  len 
)

Performs the 1-Wire search algorithm and store ROM codes found.

Parameters
[in]rombufthe buffer where ROM codes will be stored (should be big enough to store maximum number of devices (e.g.: rombuf[8 * len]).
[in]lenthe maximum number of device that can be found.
Return values
intnumber of devices found.
<0if there is any error while looking for devices.
uint8_t one_wire_single_bit_rx ( void  )

Reads 1 bit from the 1-Wire bus.

Return values
bitread.
uint8_t one_wire_single_bit_tx ( uint8_t  bit)

Sends 1 bit over the 1-Wire bus.

Parameters
[in]bitbit to be transferred.
Return values
0on success.
ssize_t one_wire_skip_rom ( void  )

Used when only one device is connected to the 1-Wire bus, so sending 32-bit ROM code is unnecessary. Usually used after a one_wire_reset() command.

Return values
ssize_t0 on success.
ssize_t<0 if there is an error while reading.
void one_wire_spp_enable ( bool_t  val)

Activates or deactivates the strong pull-up (if enabled) on the 1-Wire bus.

Parameters
[in]val1 for enabling, 0 for disabling.
Return values
none
ssize_t one_wire_write ( const uint8_t txbuf,
uint8_t  len 
)

Sends over the 1-Wire bus a buffer with a determined length.

Parameters
[in]txbufthe buffer containing the bytes to be transferred. Frist byte may be 1-Wire ROM-Commands or device-specific commands.
[in]lenthe number of bytes to be transferred.
Return values
int0 on success.
int<0 if there is an error while transferring.
ssize_t one_wire_write_byte ( uint8_t  byte)

Sends 1 byte over the 1-Wire bus.

Parameters
[in]bytebyte to be transferred. This may be 1-Wire ROM-Commands or device-specific commands.
Return values
int0 on success.