Skip to content

Commit

Permalink
Deinline pad functions
Browse files Browse the repository at this point in the history
It turns out that even tiny functions are better called than inlined
on ZPU, so making pad_set/pad_clear/... regular functions instead of
static inline saves ~130 bytes in total.
  • Loading branch information
ikorb committed May 21, 2020
1 parent c2e9615 commit ab9733f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
20 changes: 20 additions & 0 deletions Firmware/pad.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ static uint32_t paddata[3];
volatile tick_t pad_last_change;
volatile uint32_t pad_buttons;

void pad_set(uint32_t which) {
IRQController->TempDisable = IRQ_TempDisable;
pad_buttons |= which;
IRQController->TempDisable = 0;
}

void pad_clear(uint32_t which) {
IRQController->TempDisable = IRQ_TempDisable;
pad_buttons &= ~which;
IRQController->TempDisable = 0;
}

void pad_set_irq(uint32_t which) {
pad_buttons |= which;
}

void pad_clear_irq(uint32_t which) {
pad_buttons &= ~which;
}

void pad_wait_for_release(void) {
/* wait until all controller buttons are released */
while (pad_buttons & PAD_ALL_GC)
Expand Down
22 changes: 4 additions & 18 deletions Firmware/pad.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,12 @@ extern volatile uint32_t pad_buttons;
extern volatile tick_t pad_last_change;

/* these two functions shouldn't be used in an interrupt handler! */
static inline void pad_set(uint32_t which) {
IRQController->TempDisable = IRQ_TempDisable;
pad_buttons |= which;
IRQController->TempDisable = 0;
}

static inline void pad_clear(uint32_t which) {
IRQController->TempDisable = IRQ_TempDisable;
pad_buttons &= ~which;
IRQController->TempDisable = 0;
}
void pad_set(uint32_t which);
void pad_clear(uint32_t which);

/* same functions without disabling IRQ for atomicity */
static inline void pad_set_irq(uint32_t which) {
pad_buttons |= which;
}

static inline void pad_clear_irq(uint32_t which) {
pad_buttons &= ~which;
}
void pad_set_irq(uint32_t which);
void pad_clear_irq(uint32_t which);

void pad_wait_for_release(void);
void pad_handler(void);
Expand Down

0 comments on commit ab9733f

Please sign in to comment.