Skip to content

Commit

Permalink
- Fix issues with timer 2+.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Jan 3, 2020
1 parent e1232b9 commit f32ecd5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions cube/patches/alt/emulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ void service_exception(OSException exception, OSContext *context, uint32_t dsisr
timer2_stop();
change_disc();
}
restore_timer_interrupts();
break;
}
}
Expand Down
12 changes: 10 additions & 2 deletions cube/patches/alt/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static inline void timer1_start(uint32_t ticks)
mmcr0.dms = false;
mmcr0.dmr = false;
mmcr0.enint = true;
mmcr0.discount = true;
mmcr0.discount = false;
mmcr0.rtcselect = 0;
mmcr0.intonbittrans = false;
mmcr0.threshold = 0;
Expand Down Expand Up @@ -98,7 +98,7 @@ static inline void timer2_start(uint32_t ticks)
mmcr0.dms = false;
mmcr0.dmr = false;
mmcr0.enint = true;
mmcr0.discount = true;
mmcr0.discount = false;
mmcr0.rtcselect = 0;
mmcr0.intonbittrans = false;
mmcr0.threshold = 0;
Expand Down Expand Up @@ -128,4 +128,12 @@ static inline void timer2_stop(void)
asm volatile("mtpmc2 %0" :: "r" (0));
}

static inline void restore_timer_interrupts(void)
{
union mmcr0 mmcr0;
asm volatile("mfmmcr0 %0" : "=r" (mmcr0.val));
mmcr0.enint = mmcr0.pmc1select || mmcr0.pmc2select;
asm volatile("mtmmcr0 %0" :: "r" (mmcr0.val));
}

#endif /* TIMER_H */

0 comments on commit f32ecd5

Please sign in to comment.