_gpio.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. GPIO_PIN_PC0: int
  2. '''
  3. Constant identifier for GPIO pin PC0.
  4. .. versionadded:: 1.2.0
  5. '''
  6. GPIO_PIN_PC1: int
  7. '''
  8. Constant identifier for GPIO pin PC1.
  9. .. versionadded:: 1.2.0
  10. '''
  11. GPIO_PIN_PC3: int
  12. '''
  13. Constant identifier for GPIO pin PC3.
  14. .. versionadded:: 1.2.0
  15. '''
  16. GPIO_PIN_PB2: int
  17. '''
  18. Constant identifier for GPIO pin PB2.
  19. .. versionadded:: 1.2.0
  20. '''
  21. GPIO_PIN_PB3: int
  22. '''
  23. Constant identifier for GPIO pin PB3.
  24. .. versionadded:: 1.2.0
  25. '''
  26. GPIO_PIN_PA4: int
  27. '''
  28. Constant identifier for GPIO pin PA4.
  29. .. versionadded:: 1.2.0
  30. '''
  31. GPIO_PIN_PA6: int
  32. '''
  33. Constant identifier for GPIO pin PA6.
  34. .. versionadded:: 1.2.0
  35. '''
  36. GPIO_PIN_PA7: int
  37. '''
  38. Constant identifier for GPIO pin PA7.
  39. .. versionadded:: 1.2.0
  40. '''
  41. GPIO_MODE_INPUT: int
  42. '''
  43. Constant configuration value for the GPIO input mode.
  44. .. versionadded:: 1.2.0
  45. '''
  46. GPIO_MODE_OUTPUT_PUSH_PULL: int
  47. '''
  48. Constant configuration value for the GPIO output as push-pull mode.
  49. .. versionadded:: 1.2.0
  50. '''
  51. GPIO_MODE_OUTPUT_OPEN_DRAIN: int
  52. '''
  53. Constant configuration value for the GPIO output as open-drain mode.
  54. .. versionadded:: 1.2.0
  55. '''
  56. GPIO_MODE_ANALOG: int
  57. '''
  58. Constant configuration value for the GPIO analog mode.
  59. .. versionadded:: 1.2.0
  60. '''
  61. GPIO_MODE_INTERRUPT_RISE: int
  62. '''
  63. Constant configuration value for the GPIO interrupt on rising edges mode.
  64. .. versionadded:: 1.2.0
  65. '''
  66. GPIO_MODE_INTERRUPT_FALL: int
  67. '''
  68. Constant configuration value for the GPIO interrupt on falling edges mode.
  69. .. versionadded:: 1.2.0
  70. '''
  71. def gpio_init_pin(pin: int, mode: int) -> None:
  72. '''
  73. Initialize a GPIO pin.
  74. :param pin: The pin to initialize (e.g. :const:`GPIO_PIN_PA4`).
  75. :param mode: The mode to use (e.g. :const:`GPIO_MODE_OUTPUT_PUSH_PULL`).
  76. .. versionadded:: 1.2.0
  77. .. hint::
  78. The interrupt modes :const:`GPIO_MODE_INTERRUPT_RISE` and :const:`GPIO_MODE_INTERRUPT_FALL` can be combined using bitwise OR.
  79. This allows you to handle rising `and` falling edges.
  80. '''
  81. pass
  82. def gpio_set_pin(pin: int, state: bool) -> None:
  83. '''
  84. Set the state of an output pin.
  85. :param pin: The pin to set (e.g. :const:`GPIO_PIN_PA4`).
  86. :param state: The state to set.
  87. .. versionadded:: 1.2.0
  88. .. hint::
  89. Don't forget to initialize the pin first.
  90. '''
  91. pass
  92. def gpio_get_pin(pin: int) -> bool:
  93. '''
  94. Read the state of an input pin.
  95. :param pin: The pin to read (e.g. :const:`GPIO_PIN_PA4`).
  96. :returns: :const:`True` if the pin is high, :const:`False` on a low signal.
  97. .. versionadded:: 1.2.0
  98. .. hint::
  99. Don't forget to initialize the pin first.
  100. '''
  101. pass