Fix inline ASM for GCC 4.9

This commit is contained in:
William Toohey
2017-02-17 01:16:02 +10:00
parent 771b32b88a
commit 7aadd02dd8
2 changed files with 11 additions and 10 deletions
+10 -9
View File
@@ -28,6 +28,7 @@
#define G 1
#define B 0
uint8_t leds[LED_PHYSICAL_COUNT];
static volatile uint8_t leds_frontbuffer[LED_PHYSICAL_COUNT];
void led_init() {
@@ -128,15 +129,15 @@ void led_set_indiv(uint8_t num, uint8_t val) {
if(*led++ > brightness)
out |= _BV(outPin)
*/
#define LED_PIN_SET(led, outPin) \
__asm__ volatile( \
"ld __tmp_reg__, %a["#led"]+ \n\t\
cp %[bright], __tmp_reg__ \n\t\
brcc skip%= \n\t\
ori %[out], (1 << "#outPin") \n\t\
skip%=:" \
: [out] "=r" (out), "=z" (led) /* outputs */ \
: "r" (out), [led] "z" (led), [bright] "r" (brightness) /* inputs */ )
#define LED_PIN_SET(led, outPin) \
__asm__ volatile( \
"ld __tmp_reg__, %a["#led"]+ \n\t\
cp %[bright], __tmp_reg__ \n\t\
brcc skip%= \n\t\
ori %[out], (1 << "#outPin") \n\t\
skip%=:" \
: [out] "+a" (out), [led] "+z" (led) /* outputs */ \
: [bright] "r" (brightness) /* inputs */ )
// This function once took about 279 clock cycles.
// Optimised GND accesses got it to 157
+1 -1
View File
@@ -25,7 +25,7 @@ typedef struct {
// Arranged left to right, top to bottom
// LED order is BGR...BGR
uint8_t leds[LED_PHYSICAL_COUNT];
extern uint8_t leds[LED_PHYSICAL_COUNT];
// Maps BT/FX keys to their associated LED
// Order is BT-1-4, FX-L, FX-R