ibutton_writer.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * @file ibutton_writer.h
  3. *
  4. * iButton blanks writer
  5. */
  6. #pragma once
  7. #include <furi_hal_gpio.h>
  8. #include "ibutton_key.h"
  9. #include "../one_wire_host.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. typedef enum {
  14. iButtonWriterOK,
  15. iButtonWriterSameKey,
  16. iButtonWriterNoDetect,
  17. iButtonWriterCannotWrite,
  18. } iButtonWriterResult;
  19. typedef struct iButtonWriter iButtonWriter;
  20. /**
  21. * Allocate writer
  22. * @param host
  23. * @return iButtonWriter*
  24. */
  25. iButtonWriter* ibutton_writer_alloc(OneWireHost* host);
  26. /**
  27. * Deallocate writer
  28. * @param writer
  29. */
  30. void ibutton_writer_free(iButtonWriter* writer);
  31. /**
  32. * Write key to blank
  33. * @param writer
  34. * @param key
  35. * @return iButtonWriterResult
  36. */
  37. iButtonWriterResult ibutton_writer_write(iButtonWriter* writer, iButtonKey* key);
  38. /**
  39. * Start writing. Must be called before write attempt
  40. * @param writer
  41. */
  42. void ibutton_writer_start(iButtonWriter* writer);
  43. /**
  44. * Stop writing
  45. * @param writer
  46. */
  47. void ibutton_writer_stop(iButtonWriter* writer);
  48. #ifdef __cplusplus
  49. }
  50. #endif