summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2022-06-06 15:37:45 +0700
committerGitHub <[email protected]>2022-06-06 15:37:45 +0700
commitafd9b1883de4d0927433c2286dfc56ed2a5e2203 (patch)
treece79fa00a15c59339f3df0c253d0278b53e74e06
parentb6a8d0dd71e20e9dce6073734700a46837016e71 (diff)
parent731ac3d3d60daf4831f2e9491a45d30cc2492d5b (diff)
Merge pull request #1481 from cr1901/msp430-misopt-fix
msp430x5xx: Add fix for possible bug in msp430-elf-gcc 9.3.0.
-rw-r--r--src/portable/ti/msp430x5xx/dcd_msp430x5xx.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c b/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
index 605c13b4a..b4dfda575 100644
--- a/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
+++ b/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
@@ -631,7 +631,18 @@ void dcd_int_handler(uint8_t rhport)
handle_setup_packet();
}
- uint16_t curr_vector = USBVECINT;
+ // Workaround possible bug in MSP430 GCC 9.3.0 where volatile variable
+ // USBVECINT is read from twice when only once is intended. The second
+ // (garbage) read seems to be triggered by certain switch statement
+ // configurations.
+ uint16_t curr_vector;
+ #if __GNUC__ > 9 || (__GNUC__ == 9 && __GNUC_MINOR__ > 2)
+ asm volatile ("mov %1, %0"
+ : "=r" (curr_vector)
+ : "m" (USBVECINT));
+ #else
+ curr_vector = USBVECINT;
+ #endif
switch(curr_vector)
{