Skip to content

Commit 0104c33

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 85bfbde commit 0104c33

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
@@ -125,6 +125,24 @@ pub mod gpio {
125125
device: self.pin.port,
126126
}
127127
}
128+
129+
/// Configure a single pin.
130+
pub fn configure(&mut self, extra_flags: raw::gpio_flags_t) {
131+
// TODO: Error?
132+
unsafe {
133+
raw::gpio_pin_configure(self.pin.port,
134+
self.pin.pin,
135+
self.pin.dt_flags as raw::gpio_flags_t | extra_flags);
136+
}
137+
}
138+
139+
/// Toggle pin level.
140+
pub fn toggle_pin(&mut self) {
141+
// TODO: Error?
142+
unsafe {
143+
raw::gpio_pin_toggle_dt(&self.pin);
144+
}
145+
}
128146
}
129147
}
130148

0 commit comments

Comments
 (0)