Skip to content

Commit

Permalink
Prevent timer status writes from clearing out-of-range delay status bits
Browse files Browse the repository at this point in the history
  • Loading branch information
calc84maniac committed Jun 28, 2024
1 parent 0c11081 commit 561d757
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ static void gpt_write(uint16_t address, uint8_t value, bool poke) {
(void)poke;

if (address >= 0x34 && address < 0x38) {
((uint8_t *)&gpt)[address] &= ~value;
uint8_t bit_offset = (address & 3) << 3;
uint32_t mask = ~((uint32_t)value << bit_offset & 0x1FF);
gpt.status &= mask;
if (sched_active(SCHED_TIMER_DELAY) && sched_ticks_remaining(SCHED_TIMER_DELAY) == 1) {
((uint8_t *)&gpt.delayStatus)[address - 0x34] &= ~value;
gpt.delayStatus &= mask;
}
} else if (address < 0x3C) {
counter_delay = address < 0x30 && (address & 0xC) == 0;
Expand Down

0 comments on commit 561d757

Please sign in to comment.