/
gpio.rbs
64 lines (57 loc) · 1.73 KB
/
gpio.rbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# @sidebar error
class IOError
ERROR_NONE: 0
ERROR_TIMEOUT: -1
ERROR_GENERIC: -2
ERROR_NO_DATA: -3
ERROR_NOT_PERMITTED: -4
ERROR_INVALID_ARG: -5
ERROR_IO: -6
def self.peripheral_error: (Integer code, ?String name) -> Integer
end
# @sidebar io_peripheral
class GPIO
IN: 1 # 0b0000001
OUT: 2 # 0b0000010
HIGH_Z: 4 # 0b0000100
PULL_UP: 8 # 0b0001000
PULL_DOWN: 16 # 0b0010000
OPEN_DRAIN: 32 # 0b0100000
ALT: 64 # 0b1000000
type gpio_pin_t = (Integer|String|Symbol)
type gpio_logic_t = (0 | 1)
@pin: gpio_pin_t
@dir: (Integer|nil)
@alt_function: (Integer|nil)
@pull: (Integer|nil)
@open_drain: bool
# Ruby method
def self.new: (gpio_pin_t pin, Integer flags, ?Integer alt_function) -> instance
def setmode: (Integer flags, ?Integer alt_function) -> 0
# C function
def self.read_at: (gpio_pin_t) -> gpio_logic_t
def self.high_at?: (gpio_pin_t) -> bool
def self.low_at?: (Integer) -> bool
def self.write_at: (gpio_pin_t, Integer) -> 0
def read: () -> gpio_logic_t
def write: (Integer) -> 0
def high?: () -> bool
def low?: () -> bool
private def set_function: (Integer flags, Integer alt_function) -> 0
private def set_dir: (Integer flags) -> 0
private def set_pull: (Integer flags) -> 0
private def open_drain: (Integer flags) -> 0
private def on_initialize?: () -> bool
# @private
def self._init: (gpio_pin_t) -> 0
# @private
def self.set_function_at: (gpio_pin_t, Integer) -> 0
# @private
def self.set_dir_at: (gpio_pin_t, Integer) -> 0
# @private
def self.pull_up_at: (gpio_pin_t) -> 0
# @private
def self.pull_down_at: (gpio_pin_t) -> 0
# @private
def self.open_drain_at: (gpio_pin_t) -> 0
end