one_wire_slave.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * @file one_wire_slave.h
  3. *
  4. * 1-Wire slave library. Currently it can only emulate ID.
  5. */
  6. #pragma once
  7. #include <stdint.h>
  8. #include <stdbool.h>
  9. #include <furi_hal_gpio.h>
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. typedef struct OneWireDevice OneWireDevice;
  14. typedef struct OneWireSlave OneWireSlave;
  15. typedef void (*OneWireSlaveResultCallback)(void* context);
  16. /**
  17. * Allocate onewire slave
  18. * @param pin
  19. * @return OneWireSlave*
  20. */
  21. OneWireSlave* onewire_slave_alloc();
  22. /**
  23. * Free onewire slave
  24. * @param bus
  25. */
  26. void onewire_slave_free(OneWireSlave* bus);
  27. /**
  28. * Start working with the bus
  29. * @param bus
  30. */
  31. void onewire_slave_start(OneWireSlave* bus);
  32. /**
  33. * Stop working with the bus
  34. * @param bus
  35. */
  36. void onewire_slave_stop(OneWireSlave* bus);
  37. /**
  38. * Attach device for emulation
  39. * @param bus
  40. * @param device
  41. */
  42. void onewire_slave_attach(OneWireSlave* bus, OneWireDevice* device);
  43. /**
  44. * Detach device from bus
  45. * @param bus
  46. */
  47. void onewire_slave_detach(OneWireSlave* bus);
  48. /**
  49. * Set a callback to report emulation success
  50. * @param bus
  51. * @param result_cb
  52. * @param context
  53. */
  54. void onewire_slave_set_result_callback(
  55. OneWireSlave* bus,
  56. OneWireSlaveResultCallback result_cb,
  57. void* context);
  58. #ifdef __cplusplus
  59. }
  60. #endif