Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
1-Wire data link layer

1-Wire data link layer More...

Functions

int w1_reset_bus (const struct device *dev)
 Reset the 1-Wire bus to prepare slaves for communication.
 
int w1_read_bit (const struct device *dev)
 Read a single bit from the 1-Wire bus.
 
int w1_write_bit (const struct device *dev, const bool bit)
 Write a single bit to the 1-Wire bus.
 
int w1_read_byte (const struct device *dev)
 Read a single byte from the 1-Wire bus.
 
int w1_write_byte (const struct device *dev, uint8_t byte)
 Write a single byte to the 1-Wire bus.
 
int w1_read_block (const struct device *dev, uint8_t *buffer, size_t len)
 Read a block of data from the 1-Wire bus.
 
int w1_write_block (const struct device *dev, const uint8_t *buffer, size_t len)
 Write a block of data from the 1-Wire bus.
 
size_t w1_get_slave_count (const struct device *dev)
 Get the number of slaves on the bus.
 
int w1_configure (const struct device *dev, enum w1_settings_type type, uint32_t value)
 Configure parameters of the 1-Wire master.
 

Detailed Description

1-Wire data link layer

Function Documentation

◆ w1_configure()

int w1_configure ( const struct device * dev,
enum w1_settings_type type,
uint32_t value )

#include <zephyr/drivers/w1.h>

Configure parameters of the 1-Wire master.

Allowed configuration parameters are defined in enum w1_settings_type, but master devices may not support all types.

Parameters
[in]devPointer to the device structure for the driver instance.
typeEnum specifying the setting type.
valueThe new value for the passed settings type.
Return values
0If successful.
-ENOTSUPThe master doesn't support the configuration of the supplied type.
-EIOGeneral input / output error, failed to configure master devices.

◆ w1_get_slave_count()

size_t w1_get_slave_count ( const struct device * dev)

#include <zephyr/drivers/w1.h>

Get the number of slaves on the bus.

Parameters
[in]devPointer to the device structure for the driver instance.
Return values
slave_countPositive Number of connected 1-Wire slaves on success.
-errnoNegative error code on error.

◆ w1_read_bit()

int w1_read_bit ( const struct device * dev)

#include <zephyr/drivers/w1.h>

Read a single bit from the 1-Wire bus.

Parameters
[in]devPointer to the device structure for the driver instance.
Return values
rx_bitThe read bit value on success.
-errnoNegative error code on error.

◆ w1_read_block()

int w1_read_block ( const struct device * dev,
uint8_t * buffer,
size_t len )

#include <zephyr/drivers/w1.h>

Read a block of data from the 1-Wire bus.

Parameters
[in]devPointer to the device structure for the driver instance.
[out]bufferPointer to receive buffer.
lenLength of receiving buffer (in bytes).
Return values
0If successful.
-errnoNegative error code on error.

◆ w1_read_byte()

int w1_read_byte ( const struct device * dev)

#include <zephyr/drivers/w1.h>

Read a single byte from the 1-Wire bus.

Parameters
[in]devPointer to the device structure for the driver instance.
Return values
rx_byteThe read byte value on success.
-errnoNegative error code on error.

◆ w1_reset_bus()

int w1_reset_bus ( const struct device * dev)

#include <zephyr/drivers/w1.h>

Reset the 1-Wire bus to prepare slaves for communication.

This routine resets all 1-Wire bus slaves such that they are ready to receive a command. Connected slaves answer with a presence pulse once they are ready to receive data.

In case the driver supports both standard speed and overdrive speed, the reset routine takes care of sendig either a short or a long reset pulse depending on the current state. The speed can be changed using w1_configure().

Parameters
[in]devPointer to the device structure for the driver instance.
Return values
0If no slaves answer with a present pulse.
1If at least one slave answers with a present pulse.
-errnoNegative error code on error.

◆ w1_write_bit()

int w1_write_bit ( const struct device * dev,
const bool bit )

#include <zephyr/drivers/w1.h>

Write a single bit to the 1-Wire bus.

Parameters
[in]devPointer to the device structure for the driver instance.
bitTransmitting bit value 1 or 0.
Return values
0If successful.
-errnoNegative error code on error.

◆ w1_write_block()

int w1_write_block ( const struct device * dev,
const uint8_t * buffer,
size_t len )

#include <zephyr/drivers/w1.h>

Write a block of data from the 1-Wire bus.

Parameters
[in]devPointer to the device structure for the driver instance.
[in]bufferPointer to transmitting buffer.
lenLength of transmitting buffer (in bytes).
Return values
0If successful.
-errnoNegative error code on error.

◆ w1_write_byte()

int w1_write_byte ( const struct device * dev,
uint8_t byte )

#include <zephyr/drivers/w1.h>

Write a single byte to the 1-Wire bus.

Parameters
[in]devPointer to the device structure for the driver instance.
byteTransmitting byte.
Return values
0If successful.
-errnoNegative error code on error.