MCPcopy Index your code
hub / github.com/endbasic/endbasic / setup

Method setup

rpi/src/gpio.rs:66–85  ·  view source on GitHub ↗
(&mut self, pin: Pin, mode: PinMode)

Source from the content-addressed store, hash-verified

64 }
65
66 fn setup(&mut self, pin: Pin, mode: PinMode) -> io::Result<()> {
67 self.clear(pin)?;
68 let chip = self.get_chip()?;
69 let gpio_pin = chip.get(pin.0).map_err(gpio_error_to_io_error)?;
70 match mode {
71 PinMode::In => {
72 self.inputs.insert(pin, gpio_pin.into_input());
73 }
74 PinMode::InPullDown => {
75 self.inputs.insert(pin, gpio_pin.into_input_pulldown());
76 }
77 PinMode::InPullUp => {
78 self.inputs.insert(pin, gpio_pin.into_input_pullup());
79 }
80 PinMode::Out => {
81 self.outputs.insert(pin, gpio_pin.into_output());
82 }
83 };
84 Ok(())
85 }
86
87 fn clear(&mut self, pin: Pin) -> io::Result<()> {
88 self.inputs.remove(&pin);

Callers

nothing calls this directly

Calls 4

get_chipMethod · 0.80
clearMethod · 0.45
getMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected