Skip to content

Commit e1c7372

Browse files
committed
SYS_WKUPx can have the same value (NC)
Depending of the mcu package some SYS_WKUPx pins are not available even if the PWR_WAKEUP_PINx is defined. So they are defined as NC. Remove switch/case usage to allow this. Signed-off-by: Frederic Pillon <[email protected]>
1 parent a1bfa56 commit e1c7372

File tree

1 file changed

+42
-45
lines changed

1 file changed

+42
-45
lines changed

src/low_power.c

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -97,79 +97,76 @@ void LowPower_EnableWakeUpPin(uint32_t pin, uint32_t mode)
9797
uint32_t wkup_pin;
9898
PinName p = digitalPinToPinName(pin);
9999
if (p != NC) {
100-
switch (p) {
101-
default :
102100
#ifdef PWR_WAKEUP_PIN1
103-
case SYS_WKUP1 :
104-
wkup_pin = PWR_WAKEUP_PIN1;
101+
if (p == SYS_WKUP1) {
102+
wkup_pin = PWR_WAKEUP_PIN1;
105103
#ifdef PWR_WAKEUP_PIN1_HIGH
106-
if (mode != RISING) {
107-
wkup_pin = PWR_WAKEUP_PIN1_LOW;
108-
}
104+
if (mode != RISING) {
105+
wkup_pin = PWR_WAKEUP_PIN1_LOW;
106+
}
109107
#endif
110-
break;
108+
}
111109
#endif /* PWR_WAKEUP_PIN1 */
112110
#ifdef PWR_WAKEUP_PIN2
113-
case SYS_WKUP2 :
114-
wkup_pin = PWR_WAKEUP_PIN2;
111+
if (p == SYS_WKUP2) {
112+
wkup_pin = PWR_WAKEUP_PIN2;
115113
#ifdef PWR_WAKEUP_PIN2_HIGH
116-
if (mode != RISING) {
117-
wkup_pin = PWR_WAKEUP_PIN2_LOW;
118-
}
114+
if (mode != RISING) {
115+
wkup_pin = PWR_WAKEUP_PIN2_LOW;
116+
}
119117
#endif
120-
break;
118+
}
121119
#endif /* PWR_WAKEUP_PIN2 */
122120
#ifdef PWR_WAKEUP_PIN3
123-
case SYS_WKUP3 :
124-
wkup_pin = PWR_WAKEUP_PIN3;
121+
if (p == SYS_WKUP3) {
122+
wkup_pin = PWR_WAKEUP_PIN3;
125123
#ifdef PWR_WAKEUP_PIN3_HIGH
126-
if (mode != RISING) {
127-
wkup_pin = PWR_WAKEUP_PIN3_LOW;
128-
}
124+
if (mode != RISING) {
125+
wkup_pin = PWR_WAKEUP_PIN3_LOW;
126+
}
129127
#endif
130-
break;
128+
}
131129
#endif /* PWR_WAKEUP_PIN3 */
132130
#ifdef PWR_WAKEUP_PIN4
133-
case SYS_WKUP4 :
134-
wkup_pin = PWR_WAKEUP_PIN4;
131+
if (p == SYS_WKUP4) {
132+
wkup_pin = PWR_WAKEUP_PIN4;
135133
#ifdef PWR_WAKEUP_PIN4_HIGH
136-
if (mode != RISING) {
137-
wkup_pin = PWR_WAKEUP_PIN4_LOW;
138-
}
134+
if (mode != RISING) {
135+
wkup_pin = PWR_WAKEUP_PIN4_LOW;
136+
}
139137
#endif
140-
break;
138+
}
141139
#endif /* PWR_WAKEUP_PIN4 */
142140
#ifdef PWR_WAKEUP_PIN5
143-
case SYS_WKUP5 :
144-
wkup_pin = PWR_WAKEUP_PIN5;
141+
if (p == SYS_WKUP5) {
142+
wkup_pin = PWR_WAKEUP_PIN5;
145143
#ifdef PWR_WAKEUP_PIN5_HIGH
146-
if (mode != RISING) {
147-
wkup_pin = PWR_WAKEUP_PIN5_LOW;
148-
}
144+
if (mode != RISING) {
145+
wkup_pin = PWR_WAKEUP_PIN5_LOW;
146+
}
149147
#endif
150-
break;
148+
}
151149
#endif /* PWR_WAKEUP_PIN5 */
152150
#ifdef PWR_WAKEUP_PIN6
153-
case SYS_WKUP6 :
154-
wkup_pin = PWR_WAKEUP_PIN6;
151+
if (p == SYS_WKUP6) {
152+
wkup_pin = PWR_WAKEUP_PIN6;
155153
#ifdef PWR_WAKEUP_PIN6_HIGH
156-
if (mode != RISING) {
157-
wkup_pin = PWR_WAKEUP_PIN6_LOW;
158-
}
154+
if (mode != RISING) {
155+
wkup_pin = PWR_WAKEUP_PIN6_LOW;
156+
}
159157
#endif
160-
break;
158+
}
161159
#endif /* PWR_WAKEUP_PIN6 */
162160
#ifdef PWR_WAKEUP_PIN7
163-
case SYS_WKUP7 :
164-
wkup_pin = PWR_WAKEUP_PIN7;
165-
break;
161+
if (p == SYS_WKUP7) {
162+
wkup_pin = PWR_WAKEUP_PIN7;
163+
}
166164
#endif /* PWR_WAKEUP_PIN7 */
167165
#ifdef PWR_WAKEUP_PIN8
168-
case SYS_WKUP8 :
169-
wkup_pin = PWR_WAKEUP_PIN8;
170-
break;
171-
#endif /* PWR_WAKEUP_PIN8 */
166+
if (p == SYS_WKUP8) {
167+
wkup_pin = PWR_WAKEUP_PIN8;
172168
}
169+
#endif /* PWR_WAKEUP_PIN8 */
173170
HAL_PWR_EnableWakeUpPin(wkup_pin);
174171
}
175172
}

0 commit comments

Comments
 (0)