@@ -11,9 +11,10 @@ use cortex_m::{asm, peripheral::NVIC};
11
11
use cortex_m_rt:: entry;
12
12
use stm32l0xx_hal:: {
13
13
prelude:: * ,
14
- exti,
14
+ exti:: {
15
+ line:: DirectLine ,
16
+ } ,
15
17
gpio:: {
16
- self ,
17
18
Output ,
18
19
PushPull ,
19
20
gpiob:: PB ,
@@ -23,13 +24,15 @@ use stm32l0xx_hal::{
23
24
LpTimer ,
24
25
ClockSrc ,
25
26
} ,
26
- pac,
27
+ pac:: {
28
+ self ,
29
+ EXTI ,
30
+ } ,
27
31
pwr:: {
28
32
self ,
29
33
PWR ,
30
34
} ,
31
35
rcc,
32
- syscfg:: SYSCFG ,
33
36
} ;
34
37
35
38
@@ -46,21 +49,15 @@ fn main() -> ! {
46
49
47
50
let mut led = gpiob. pb2 . into_push_pull_output ( ) . downgrade ( ) ;
48
51
49
- let mut syscfg = SYSCFG :: new ( dp. SYSCFG , & mut rcc) ;
50
52
let mut lptim = LpTimer :: init_periodic ( dp. LPTIM , & mut pwr, & mut rcc, ClockSrc :: Lse ) ;
51
53
52
- let exti_line = 29 ; // LPTIM1 wakeup
54
+ let exti_line = DirectLine :: Lptim1 ;
53
55
54
56
lptim. enable_interrupts ( lptim:: Interrupts {
55
57
autoreload_match : true ,
56
58
..lptim:: Interrupts :: default ( )
57
59
} ) ;
58
- exti. listen (
59
- & mut syscfg,
60
- gpio:: Port :: PA , // argument ignored; next argument is not a GPIO line
61
- exti_line,
62
- exti:: TriggerEdge :: Rising ,
63
- ) ;
60
+ exti. listen_direct ( exti_line) ;
64
61
65
62
// Blink twice to signal the start of the program
66
63
blink ( & mut led) ;
@@ -70,7 +67,7 @@ fn main() -> ! {
70
67
lptim. start ( 1 . hz ( ) ) ;
71
68
block ! ( lptim. wait( ) ) . unwrap ( ) ;
72
69
73
- exti . clear_irq ( exti_line) ;
70
+ EXTI :: unpend ( exti_line) ;
74
71
NVIC :: unpend ( pac:: Interrupt :: LPTIM1 ) ;
75
72
76
73
blink ( & mut led) ;
@@ -79,8 +76,8 @@ fn main() -> ! {
79
76
pwr. enter_low_power_run_mode ( rcc. clocks ) ;
80
77
block ! ( lptim. wait( ) ) . unwrap ( ) ;
81
78
pwr. exit_low_power_run_mode ( ) ;
82
- exti . clear_irq ( exti_line) ;
83
- cortex_m :: peripheral :: NVIC :: unpend ( pac:: Interrupt :: LPTIM1 ) ;
79
+ EXTI :: unpend ( exti_line) ;
80
+ NVIC :: unpend ( pac:: Interrupt :: LPTIM1 ) ;
84
81
85
82
blink ( & mut led) ;
86
83
@@ -90,8 +87,8 @@ fn main() -> ! {
90
87
pwr. sleep_mode ( & mut scb) ,
91
88
) ;
92
89
lptim. wait ( ) . unwrap ( ) ; // returns immediately; we just got the interrupt
93
- exti . clear_irq ( exti_line) ;
94
- cortex_m :: peripheral :: NVIC :: unpend ( pac:: Interrupt :: LPTIM1 ) ;
90
+ EXTI :: unpend ( exti_line) ;
91
+ NVIC :: unpend ( pac:: Interrupt :: LPTIM1 ) ;
95
92
96
93
blink ( & mut led) ;
97
94
@@ -101,8 +98,8 @@ fn main() -> ! {
101
98
pwr. low_power_sleep_mode ( & mut scb, & mut rcc) ,
102
99
) ;
103
100
lptim. wait ( ) . unwrap ( ) ; // returns immediately; we just got the interrupt
104
- exti . clear_irq ( exti_line) ;
105
- cortex_m :: peripheral :: NVIC :: unpend ( pac:: Interrupt :: LPTIM1 ) ;
101
+ EXTI :: unpend ( exti_line) ;
102
+ NVIC :: unpend ( pac:: Interrupt :: LPTIM1 ) ;
106
103
107
104
blink ( & mut led) ;
108
105
@@ -122,7 +119,7 @@ fn main() -> ! {
122
119
blink ( & mut led) ;
123
120
124
121
// 1 second of standby mode
125
- cortex_m :: peripheral :: NVIC :: unpend ( pac:: Interrupt :: LPTIM1 ) ;
122
+ NVIC :: unpend ( pac:: Interrupt :: LPTIM1 ) ;
126
123
exti. wait_for_irq (
127
124
exti_line,
128
125
pwr. standby_mode ( & mut scb) ,
0 commit comments