summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-06-17 19:57:17 +0100
committerDamien George <damien.p.george@gmail.com>2014-06-17 19:57:17 +0100
commitbcb3ab451baefdebb48589f822986c0ce8588b18 (patch)
treeeb3dee250979f959b38a9996f97b76e2c43013d6
parent2547928148aefcf163953057979e14f46bef1170 (diff)
downloadmicropython-bcb3ab451baefdebb48589f822986c0ce8588b18.tar.gz
micropython-bcb3ab451baefdebb48589f822986c0ce8588b18.zip
stmhal: Toggle LED using ODR ^= pin_mask.
-rw-r--r--stmhal/led.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/stmhal/led.c b/stmhal/led.c
index 8cef02425a..e23b30ab75 100644
--- a/stmhal/led.c
+++ b/stmhal/led.c
@@ -148,18 +148,9 @@ void led_toggle(pyb_led_t led) {
}
#endif
+ // toggle the output data register to toggle the LED state
const pin_obj_t *led_pin = pyb_led_obj[led - 1].led_pin;
- GPIO_TypeDef *gpio = led_pin->gpio;
-
- // We don't know if we're turning the LED on or off, but we don't really
- // care. Just invert the state.
- if (gpio->ODR & led_pin->pin_mask) {
- // pin is high, make it low
- gpio->BSRRH = led_pin->pin_mask;
- } else {
- // pin is low, make it high
- gpio->BSRRL = led_pin->pin_mask;
- }
+ led_pin->gpio->ODR ^= led_pin->pin_mask;
}
int led_get_intensity(pyb_led_t led) {