Flipper Zero Firmware
Loading...
Searching...
No Matches
one_wire_slave.h File Reference

1-Wire slave library. More...

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <furi_hal_gpio.h>

Go to the source code of this file.

Typedefs

typedef struct OneWireDevice OneWireDevice
 
typedef struct OneWireSlave OneWireSlave
 
typedef bool(* OneWireSlaveResetCallback) (bool is_short, void *context)
 
typedef bool(* OneWireSlaveCommandCallback) (uint8_t command, void *context)
 
typedef void(* OneWireSlaveResultCallback) (void *context)
 

Functions

OneWireSlaveonewire_slave_alloc (const GpioPin *gpio_pin)
 Allocate OneWireSlave instance.
 
void onewire_slave_free (OneWireSlave *bus)
 Destroy OneWireSlave instance, free resources.
 
void onewire_slave_start (OneWireSlave *bus)
 Start working with the bus.
 
void onewire_slave_stop (OneWireSlave *bus)
 Stop working with the bus.
 
bool onewire_slave_receive_bit (OneWireSlave *bus)
 Receive one bit.
 
bool onewire_slave_send_bit (OneWireSlave *bus, bool value)
 Send one bit.
 
bool onewire_slave_send (OneWireSlave *bus, const uint8_t *data, size_t data_size)
 Send one or more bytes of data.
 
bool onewire_slave_receive (OneWireSlave *bus, uint8_t *data, size_t data_size)
 Receive one or more bytes of data.
 
void onewire_slave_set_overdrive (OneWireSlave *bus, bool set)
 Enable overdrive mode.
 
void onewire_slave_set_reset_callback (OneWireSlave *bus, OneWireSlaveResetCallback callback, void *context)
 Set a callback function to be called on each reset.
 
void onewire_slave_set_command_callback (OneWireSlave *bus, OneWireSlaveCommandCallback callback, void *context)
 Set a callback function to be called on each command.
 
void onewire_slave_set_result_callback (OneWireSlave *bus, OneWireSlaveResultCallback result_cb, void *context)
 Set a callback to report emulation success.
 

Detailed Description

1-Wire slave library.

Function Documentation

◆ onewire_slave_alloc()

OneWireSlave * onewire_slave_alloc ( const GpioPin * gpio_pin)

Allocate OneWireSlave instance.

Parameters
[in]gpio_pinconnection pin
Returns
pointer to OneWireSlave instance

◆ onewire_slave_free()

void onewire_slave_free ( OneWireSlave * bus)

Destroy OneWireSlave instance, free resources.

Parameters
[in]buspointer to OneWireSlave instance

◆ onewire_slave_receive()

bool onewire_slave_receive ( OneWireSlave * bus,
uint8_t * data,
size_t data_size )

Receive one or more bytes of data.

Parameters
[in]buspointer to OneWireSlave instance
[out]datapointer to the receive buffer
[in]data_sizenumber of bytes to receive
Returns
true on success, false on failure

◆ onewire_slave_receive_bit()

bool onewire_slave_receive_bit ( OneWireSlave * bus)

Receive one bit.

Parameters
[in]buspointer to OneWireSlave instance
Returns
received bit value

◆ onewire_slave_send()

bool onewire_slave_send ( OneWireSlave * bus,
const uint8_t * data,
size_t data_size )

Send one or more bytes of data.

Parameters
[in]buspointer to OneWireSlave instance
[in]datapointer to the data to send
[in]data_sizesize of the data to send
Returns
true on success, false on failure

◆ onewire_slave_send_bit()

bool onewire_slave_send_bit ( OneWireSlave * bus,
bool value )

Send one bit.

Parameters
[in]buspointer to OneWireSlave instance
[in]valuebit value to send
Returns
true on success, false on failure

◆ onewire_slave_set_command_callback()

void onewire_slave_set_command_callback ( OneWireSlave * bus,
OneWireSlaveCommandCallback callback,
void * context )

Set a callback function to be called on each command.

The return value of the callback determines whether further operation is possible. As a rule of thumb, return true unless a critical error happened.

Parameters
[in]buspointer to OneWireSlave instance
[in]callbackpointer to a callback function
[in]contextadditional parameter to be passed to the callback

◆ onewire_slave_set_overdrive()

void onewire_slave_set_overdrive ( OneWireSlave * bus,
bool set )

Enable overdrive mode.

Parameters
[in]buspointer to OneWireSlave instance
[in]settrue to turn overdrive on, false to turn it off

◆ onewire_slave_set_reset_callback()

void onewire_slave_set_reset_callback ( OneWireSlave * bus,
OneWireSlaveResetCallback callback,
void * context )

Set a callback function to be called on each reset.

The return value of the callback determines whether the emulated device supports the short reset (passed as the is_short parameter). In most applications, it should also call onewire_slave_set_overdrive() to set the appropriate speed mode.

Parameters
[in]buspointer to OneWireSlave instance
[in]callbackpointer to a callback function
[in]contextadditional parameter to be passed to the callback

◆ onewire_slave_set_result_callback()

void onewire_slave_set_result_callback ( OneWireSlave * bus,
OneWireSlaveResultCallback result_cb,
void * context )

Set a callback to report emulation success.

Parameters
[in]buspointer to OneWireSlave instance
[in]result_cbpointer to a callback function
[in]contextadditional parameter to be passed to the callback

◆ onewire_slave_start()

void onewire_slave_start ( OneWireSlave * bus)

Start working with the bus.

Parameters
[in]buspointer to OneWireSlave instance

◆ onewire_slave_stop()

void onewire_slave_stop ( OneWireSlave * bus)

Stop working with the bus.

Parameters
[in]buspointer to OneWireSlave instance