BEEP-8 SDK 1.0.0
Loading...
Searching...
No Matches
tmr.h File Reference

Timer functions for the BEEP-8 system. More...

Go to the source code of this file.

Functions

int b8TmrSetup (u32 tmr_ch, u32 cycval)
 Set up a timer with a specified cycle value.
 
int b8TmrWait (u32 tmr_ch)
 Wait for a timer interrupt.
 

Detailed Description

Timer functions for the BEEP-8 system.

This file provides function prototypes for timer setup and wait operations in the BEEP-8 system. It includes functions to configure and wait for timer interrupts.

Functions provided:

  • b8TmrSetup: Set up a timer with a specified cycle value
  • b8TmrWait: Wait for a timer interrupt

Example usage (prints 10 characteres every second):

#define TIMER_CH (2)
#define TIMER_HZ (10)
int main(void){
b8TmrSetup(TIMER_CH, (b8SysGetCpuClock() / TIMER_HZ) >> 8);
while(1){
b8TmrWait(TIMER_CH);
printf("T");
}
return 0;
}
u32 b8SysGetCpuClock(void)
Get the CPU clock speed.
Definition sys.c:62
int b8TmrWait(u32 tmr_ch)
Wait for a timer interrupt.
Definition tmr.c:20
int b8TmrSetup(u32 tmr_ch, u32 cycval)
Set up a timer with a specified cycle value.
Definition tmr.c:4

For more detailed information, please refer to the BEEP-8 data sheet.

Function Documentation

◆ b8TmrSetup()

int b8TmrSetup ( u32 tmr_ch,
u32 cycval )
extern

Set up a timer with a specified cycle value.

This function configures the specified timer channel with the given cycle value. It sets the timer mode to periodic, initializes the counter and period registers, and enables the timer. Additionally, it sets up an IRQ wait handler for the timer.

Parameters
tmr_chThe timer channel to set up.
cycvalThe cycle value for the timer.
Returns
0 on success; an error code on failure.

◆ b8TmrWait()

int b8TmrWait ( u32 tmr_ch)
extern

Wait for a timer interrupt.

This function waits for an interrupt from the specified timer channel. It blocks until the timer interrupt occurs.

Parameters
tmr_chThe timer channel to wait for.
Returns
0 on success; an error code on failure.