# HG changeset patch # User Mychaela Falconia # Date 1477541078 0 # Node ID e3d40f49d8c48334783dcc9fdb1b1588ed7fe6aa # Parent 0f11da299b7df29756951fa9618eaaf9cb5ef9ba buzplayer timer implementation finished diff -r 0f11da299b7d -r e3d40f49d8c4 target-utils/buzplayer/timer.c --- a/target-utils/buzplayer/timer.c Thu Oct 27 04:01:16 2016 +0000 +++ b/target-utils/buzplayer/timer.c Thu Oct 27 04:04:38 2016 +0000 @@ -11,9 +11,24 @@ #include "types.h" #include "timer.h" +void timer_init() { TIMER1_REGS.cntl = CNTL_CLOCK_ENABLE; TIMER1_REGS.load = 1875; TIMER1_REGS.cntl = CNTL_CLOCK_ENABLE | CNTL_AUTO_RELOAD | CNTL_START; } + +void +wait_for_tdma_frame() +{ + u16 read1, read2; + + read1 = TIMER1_REGS.read; + for (;;) { + read2 = TIMER1_REGS.read; + if (read2 > read1) + return; + read1 = read2; + } +}