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.
|
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) |
|
|
OneWireSlave * | onewire_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.
|
|
◆ onewire_slave_alloc()
Allocate OneWireSlave instance.
- Parameters
-
[in] | gpio_pin | connection pin |
- Returns
- pointer to OneWireSlave instance
◆ onewire_slave_free()
Destroy OneWireSlave instance, free resources.
- Parameters
-
[in] | bus | pointer 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] | bus | pointer to OneWireSlave instance |
[out] | data | pointer to the receive buffer |
[in] | data_size | number of bytes to receive |
- Returns
- true on success, false on failure
◆ onewire_slave_receive_bit()
Receive one bit.
- Parameters
-
[in] | bus | pointer 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] | bus | pointer to OneWireSlave instance |
[in] | data | pointer to the data to send |
[in] | data_size | size 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] | bus | pointer to OneWireSlave instance |
[in] | value | bit 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] | bus | pointer to OneWireSlave instance |
[in] | callback | pointer to a callback function |
[in] | context | additional 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] | bus | pointer to OneWireSlave instance |
[in] | set | true 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] | bus | pointer to OneWireSlave instance |
[in] | callback | pointer to a callback function |
[in] | context | additional 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] | bus | pointer to OneWireSlave instance |
[in] | result_cb | pointer to a callback function |
[in] | context | additional parameter to be passed to the callback |
◆ onewire_slave_start()
Start working with the bus.
- Parameters
-
[in] | bus | pointer to OneWireSlave instance |
◆ onewire_slave_stop()
Stop working with the bus.
- Parameters
-
[in] | bus | pointer to OneWireSlave instance |