Skip to content

Commit 51afe26

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 6c6e977 commit 51afe26

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
@@ -119,6 +119,24 @@ pub mod gpio {
119119
device: self.pin.port,
120120
}
121121
}
122+
123+
/// Configure a single pin.
124+
pub fn configure(&mut self, extra_flags: raw::gpio_flags_t) {
125+
// TODO: Error?
126+
unsafe {
127+
raw::gpio_pin_configure(self.pin.port,
128+
self.pin.pin,
129+
self.pin.dt_flags as raw::gpio_flags_t | extra_flags);
130+
}
131+
}
132+
133+
/// Toggle pin level.
134+
pub fn toggle_pin(&mut self) {
135+
// TODO: Error?
136+
unsafe {
137+
raw::gpio_pin_toggle_dt(&self.pin);
138+
}
139+
}
122140
}
123141
}
124142

0 commit comments

Comments
 (0)