Skip to content

Commit 86fefec

Browse files
committed
zephyr: sys: gpio: Add configure and pin toggle
Create wrappers for config and pin toggle on the gpios. This is enough to allow the blink app to work. Signed-off-by: David Brown <[email protected]>
1 parent 81d4bac commit 86fefec

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

zephyr/src/sys.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,24 @@ pub mod gpio {
123123
device: self.pin.port,
124124
}
125125
}
126+
127+
/// Configure a single pin.
128+
pub fn configure(&mut self, extra_flags: raw::gpio_flags_t) {
129+
// TODO: Error?
130+
unsafe {
131+
raw::gpio_pin_configure(self.pin.port,
132+
self.pin.pin,
133+
self.pin.dt_flags as raw::gpio_flags_t | extra_flags);
134+
}
135+
}
136+
137+
/// Toggle pin level.
138+
pub fn toggle_pin(&mut self) {
139+
// TODO: Error?
140+
unsafe {
141+
raw::gpio_pin_toggle_dt(&self.pin);
142+
}
143+
}
126144
}
127145
}
128146

0 commit comments

Comments
 (0)