There was an error while loading. Please reload this page.
1 parent 2547928 commit bcb3ab4Copy full SHA for bcb3ab4
stmhal/led.c
@@ -148,18 +148,9 @@ void led_toggle(pyb_led_t led) {
148
}
149
#endif
150
151
+ // toggle the output data register to toggle the LED state
152
const pin_obj_t *led_pin = pyb_led_obj[led - 1].led_pin;
- GPIO_TypeDef *gpio = led_pin->gpio;
153
-
154
- // We don't know if we're turning the LED on or off, but we don't really
155
- // care. Just invert the state.
156
- if (gpio->ODR & led_pin->pin_mask) {
157
- // pin is high, make it low
158
- gpio->BSRRH = led_pin->pin_mask;
159
- } else {
160
- // pin is low, make it high
161
- gpio->BSRRL = led_pin->pin_mask;
162
- }
+ led_pin->gpio->ODR ^= led_pin->pin_mask;
163
164
165
int led_get_intensity(pyb_led_t led) {
0 commit comments