We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dec0074 commit 26acab6Copy full SHA for 26acab6
zephyr/src/device/gpio.rs
@@ -7,6 +7,8 @@
7
//! pervasively throughout Zephyr device drivers. As such, most of the calls in this module are
8
//! unsafe.
9
10
+use core::ffi::c_int;
11
+
12
use crate::raw;
13
use super::Unique;
14
@@ -117,4 +119,18 @@ impl GpioPin {
117
119
raw::gpio_pin_toggle_dt(&self.pin);
118
120
}
121
122
123
+ /// Set the logical level of the pin.
124
+ pub unsafe fn set(&mut self, _token: &mut GpioToken, value: bool) {
125
+ raw::gpio_pin_set_dt(&self.pin, value as c_int);
126
+ }
127
128
+ /// Read the logical level of the pin.
129
+ pub unsafe fn get(&mut self, _token: &mut GpioToken) -> bool {
130
+ match raw::gpio_pin_get_dt(&self.pin) {
131
+ 0 => false,
132
+ 1 => true,
133
+ _ => panic!("TODO: Handle gpio get error"),
134
135
136
0 commit comments