furi_hal_ibutton.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * @file furi_hal_ibutton.h
  3. * iButton HAL API
  4. */
  5. #pragma once
  6. #include <stdbool.h>
  7. #include <stdint.h>
  8. #include "furi_hal_gpio.h"
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. typedef void (*FuriHalIbuttonEmulateCallback)(void* context);
  13. /** Initialize */
  14. void furi_hal_ibutton_init();
  15. void furi_hal_ibutton_emulate_start(
  16. uint32_t period,
  17. FuriHalIbuttonEmulateCallback callback,
  18. void* context);
  19. void furi_hal_ibutton_emulate_set_next(uint32_t period);
  20. void furi_hal_ibutton_emulate_stop();
  21. /**
  22. * Sets the pin to normal mode (open collector), and sets it to float
  23. */
  24. void furi_hal_ibutton_start_drive();
  25. /**
  26. * Sets the pin to normal mode (open collector), and clears pin EXTI interrupt.
  27. * Used in EXTI interrupt context.
  28. */
  29. void furi_hal_ibutton_start_drive_in_isr();
  30. /**
  31. * Sets the pin to interrupt mode (EXTI interrupt on rise or fall), and sets it to float
  32. */
  33. void furi_hal_ibutton_start_interrupt();
  34. /**
  35. * Sets the pin to interrupt mode (EXTI interrupt on rise or fall), and clears pin EXTI interrupt.
  36. * Used in EXTI interrupt context.
  37. */
  38. void furi_hal_ibutton_start_interrupt_in_isr();
  39. /**
  40. * Sets the pin to analog mode, and sets it to float
  41. */
  42. void furi_hal_ibutton_stop();
  43. /**
  44. * Attach interrupt callback to iButton pin
  45. * @param cb callback
  46. * @param context context
  47. */
  48. void furi_hal_ibutton_add_interrupt(GpioExtiCallback cb, void* context);
  49. /**
  50. * Remove interrupt callback from iButton pin
  51. */
  52. void furi_hal_ibutton_remove_interrupt();
  53. /**
  54. * Sets the pin to low
  55. */
  56. void furi_hal_ibutton_pin_low();
  57. /**
  58. * Sets the pin to high (float in iButton pin modes)
  59. */
  60. void furi_hal_ibutton_pin_high();
  61. /**
  62. * Get pin level
  63. * @return true if level is high
  64. * @return false if level is low
  65. */
  66. bool furi_hal_ibutton_pin_get_level();
  67. #ifdef __cplusplus
  68. }
  69. #endif