Update GPIO led code to match hardware
Update the code so that the value GPIO_LED_ON indicates that the
given led is on. Prior to this patch the value GPIO_LED_ON indicated
that the led was off.
@@ -196,9 +196,9 @@ __task void main_task(void)
// State processing
uint16_t flags = 0;
// LED
- gpio_led_state_t hid_led_value = GPIO_LED_ON;
- gpio_led_state_t cdc_led_value = GPIO_LED_ON;
- gpio_led_state_t msc_led_value = GPIO_LED_ON;
+ gpio_led_state_t hid_led_value = GPIO_LED_OFF;
+ gpio_led_state_t cdc_led_value = GPIO_LED_OFF;
+ gpio_led_state_t msc_led_value = GPIO_LED_OFF;
// USB
uint32_t usb_state_count = USB_BUSY_TIME;
// thread running after usb connected started
@@ -347,49 +347,46 @@ __task void main_task(void)
break;
}
+ // DAP LED
if (hid_led_usb_activity && ((hid_led_state == MAIN_LED_FLASH) || (hid_led_state == MAIN_LED_FLASH_PERMANENT))) {
- // Flash DAP LED ONCE
- if (hid_led_value) {
- hid_led_value = GPIO_LED_OFF;
- } else {
- hid_led_value = GPIO_LED_ON; // Turn on
- if (hid_led_state == MAIN_LED_FLASH) {
+ // Toggle LED value
+ hid_led_value = GPIO_LED_ON == hid_led_value ? GPIO_LED_OFF : GPIO_LED_ON;
+
+ // If in flash mode stop after one cycle
+ if ((GPIO_LED_OFF == hid_led_value) && (MAIN_LED_FLASH == hid_led_state)) {
hid_led_usb_activity = 0;
}
- }
// Update hardware
gpio_set_hid_led(hid_led_value);
}
+ // MSD LED
if (msc_led_usb_activity && ((msc_led_state == MAIN_LED_FLASH) || (msc_led_state == MAIN_LED_FLASH_PERMANENT))) {
- // Flash MSD LED ONCE
- if (msc_led_value) {
- msc_led_value = GPIO_LED_OFF;
- } else {
- msc_led_value = GPIO_LED_ON; // Turn on
- if (msc_led_state == MAIN_LED_FLASH) {
+ // Toggle LED value
+ msc_led_value = GPIO_LED_ON == msc_led_value ? GPIO_LED_OFF : GPIO_LED_ON;
+
+ // If in flash mode stop after one cycle
+ if ((GPIO_LED_OFF == msc_led_value) && (MAIN_LED_FLASH == msc_led_state)) {
msc_led_usb_activity = 0;
}
- }
// Update hardware
gpio_set_msc_led(msc_led_value);
}
+ // CDC LED
if (cdc_led_usb_activity && ((cdc_led_state == MAIN_LED_FLASH) || (cdc_led_state == MAIN_LED_FLASH_PERMANENT))) {
- // Flash CDC LED ONCE
- if (cdc_led_value) {
- cdc_led_value = GPIO_LED_OFF;
- } else {
- cdc_led_value = GPIO_LED_ON; // Turn on
- if (cdc_led_state == MAIN_LED_FLASH) {
+ // Toggle LED value
+ cdc_led_value = GPIO_LED_ON == cdc_led_value ? GPIO_LED_OFF : GPIO_LED_ON;
+
+ // If in flash mode stop after one cycle
+ if ((GPIO_LED_OFF == cdc_led_value) && (MAIN_LED_FLASH == cdc_led_state)) {
cdc_led_usb_activity = 0;
}
- }
// Update hardware
gpio_set_cdc_led(cdc_led_value);
