Skip to content

Commit 8b120ef

Browse files
committed
wip: gpio async test: Force to work stm32
This is a bit of a hack to force this test to work on an stm32 board. Although, it mostly just demonstrates that stm32 doesn't have level triggered interrupts. Signed-off-by: David Brown <[email protected]>
1 parent 2768b8b commit 8b120ef

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

dt-rust.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@
3535
value: gpios
3636
device: crate::device::gpio::GpioPin
3737

38+
# Hook up the gpio-keys as gpio pins as well
39+
- name: gpio-keys
40+
rules:
41+
- type: compatible
42+
value:
43+
names:
44+
- gpio-keys
45+
level: 1
46+
actions:
47+
- type: instance
48+
value:
49+
raw:
50+
type: phandle
51+
value: gpios
52+
device: crate::device::gpio::GpioPin
53+
3854
# Flash controllers don't have any particular property to identify them, so we need a list of
3955
# compatible values that should match.
4056
- name: flash-controller
@@ -46,6 +62,7 @@
4662
- "nordic,nrf51-flash-controller"
4763
- "raspberrypi,pico-flash-controller"
4864
- "st,stm32g4-flash-controller"
65+
- "st,stm32l5-flash-controller"
4966
- "zephyr,sim-flash"
5067
level: 0
5168
actions:

samples/blinky/prj.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ CONFIG_MAIN_STACK_SIZE=8192
88

99
# Verify that userspace builds work.
1010
# CONFIG_USERSPACE=y
11+
12+
CONFIG_UART_CONSOLE=n
13+
CONFIG_RTT_CONSOLE=y
14+
CONFIG_USE_SEGGER_RTT=y

tests/drivers/gpio-async/prj.conf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ CONFIG_RUST_ALLOC=y
1313
CONFIG_GPIO=y
1414
CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT=y
1515

16-
CONFIG_LOG_BACKEND_RTT=n
16+
# CONFIG_LOG_BACKEND_RTT=n
17+
18+
CONFIG_UART_CONSOLE=n
19+
CONFIG_RTT_CONSOLE=y
20+
CONFIG_USE_SEGGER_RTT=y

tests/drivers/gpio-async/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,18 @@ async fn main(spawner: Spawner) {
3535
info!("Hello world");
3636
let _ = spawner;
3737

38+
/*
3839
let mut col0 = zephyr::devicetree::labels::col0::get_instance().unwrap();
3940
let mut row0 = zephyr::devicetree::labels::row0::get_instance().unwrap();
41+
*/
42+
let mut row0 = zephyr::devicetree::aliases::sw0::get_instance().unwrap();
4043
let mut gpio_token = unsafe { zephyr::device::gpio::GpioToken::get_instance().unwrap() };
4144

4245
unsafe {
46+
/*
4347
col0.configure(&mut gpio_token, GPIO_OUTPUT_ACTIVE);
4448
col0.set(&mut gpio_token, true);
49+
*/
4550
row0.configure(&mut gpio_token, GPIO_INPUT | GPIO_PULL_DOWN);
4651
}
4752

zephyr/src/device/gpio.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ mod async_io {
3535
ZR_GPIO_INT_MODE_DISABLE_ONLY,
3636
};
3737

38-
use crate::sync::atomic::{AtomicBool, AtomicU32};
38+
use crate::{printkln, sync::atomic::{AtomicBool, AtomicU32}};
3939

4040
use super::{GpioPin, GpioToken};
4141

@@ -112,6 +112,7 @@ mod async_io {
112112
cb: *mut gpio_callback,
113113
mut pins: gpio_port_pins_t,
114114
) {
115+
printkln!("GPIO callback: {}", pins);
115116
let data = unsafe {
116117
cb.cast::<u8>()
117118
.sub(mem::offset_of!(Self, callback))

0 commit comments

Comments
 (0)