hsk-libs-dev  270
High Speed Karlsruhe XC878 library collection
Macros | Functions | Variables
hsk_timer01.c File Reference

HSK Timer 0/1 implementation. More...

#include <Infineon/XC878.h>
#include "hsk_timer01.h"
Include dependency graph for hsk_timer01.c:

Macros

#define BIT_ET0   1
 IEN0 Timer 0 Overflow Interrupt Enable bit. More...
 
#define BIT_ET1   3
 IEN0 Timer 1 Overflow Interrupt Enable bit. More...
 
#define BIT_T0M   0
 TMOD Timer 0 Mode select bits. More...
 
#define CNT_T0M   2
 T0M bit count. More...
 
#define BIT_T1M   4
 TMOD Timer 0 Mode select bits. More...
 
#define CNT_T1M   2
 T1M bit count. More...
 
#define BIT_RMAP   0
 SYSCON0 Special Function Register Map Control bit. More...
 

Functions

void ISR_hsk_timer0 (void)
 The ISR for timer 0. More...
 
void ISR_hsk_timer1 (void)
 The ISR for timer 1. More...
 
void hsk_timer01_setup (const ubyte id, const uword interval, const void(*const callback)(void))
 Setup timer 0 or 1 to tick at a given interval. More...
 
void hsk_timer0_setup (const uword interval, const void(*const callback)(void))
 Setup timer 0 to tick at a given interval. More...
 
void hsk_timer0_enable (void)
 Enables the timer 0 and its interrupt. More...
 
void hsk_timer0_disable (void)
 Disables timer 0 and its interrupt. More...
 
void hsk_timer1_setup (const uword interval, const void(*const callback)(void))
 Setup timer 1 to tick at a given interval. More...
 
void hsk_timer1_enable (void)
 Enables the timer 1 and its interrupt. More...
 
void hsk_timer1_disable (void)
 Disables timer 1 and its interrupt. More...
 

Variables

struct {
   uword   overflow
 The value to load into the timer upon overflow. More...
 
   void(*   callback )(void)
 A callback function pointer used by the ISR. More...
 
timers [2]
 Struct representing runtime information for a timer. More...
 

Detailed Description

HSK Timer 0/1 implementation.

This simple library implements access to the timers T0 and T1, as 16 bit timers to use as a ticking source.

Author
kami

Macro Definition Documentation

§ BIT_ET0

#define BIT_ET0   1

IEN0 Timer 0 Overflow Interrupt Enable bit.

§ BIT_ET1

#define BIT_ET1   3

IEN0 Timer 1 Overflow Interrupt Enable bit.

§ BIT_RMAP

#define BIT_RMAP   0

SYSCON0 Special Function Register Map Control bit.

§ BIT_T0M

#define BIT_T0M   0

TMOD Timer 0 Mode select bits.

§ BIT_T1M

#define BIT_T1M   4

TMOD Timer 0 Mode select bits.

§ CNT_T0M

#define CNT_T0M   2

T0M bit count.

§ CNT_T1M

#define CNT_T1M   2

T1M bit count.

Function Documentation

§ hsk_timer01_setup()

void hsk_timer01_setup ( const ubyte  id,
const uword  interval,
const void(*)(void)  callback 
)
private

Setup timer 0 or 1 to tick at a given interval.

The callback function will be called by the interrupt once the interrupt has been enabled. Note that the callback function is entered with the current page unknown.

This works on the assumption, that PCLK is set to 24MHz.

Parameters
idTimer 0 or 1.
intervalThe ticking interval in µs, don't go beyond 5461.
callbackA function pointer to a callback function.

The timer ticks with PCLK / 2, which means 12 timer ticks per µs.

§ hsk_timer0_disable()

void hsk_timer0_disable ( void  )

Disables timer 0 and its interrupt.

§ hsk_timer0_enable()

void hsk_timer0_enable ( void  )

Enables the timer 0 and its interrupt.

§ hsk_timer0_setup()

void hsk_timer0_setup ( const uword  interval,
const void(*)(void)  callback 
)

Setup timer 0 to tick at a given interval.

The callback function will be called by the interrupt once the interrupt has been enabled. Note that the callback function is entered with the current page unknown.

This works on the assumption, that PCLK is set to 24MHz.

Parameters
intervalThe ticking interval in µs, don't go beyond 5461.
callbackA function pointer to a callback function.
Here is the call graph for this function:

§ hsk_timer1_disable()

void hsk_timer1_disable ( void  )

Disables timer 1 and its interrupt.

§ hsk_timer1_enable()

void hsk_timer1_enable ( void  )

Enables the timer 1 and its interrupt.

§ hsk_timer1_setup()

void hsk_timer1_setup ( const uword  interval,
const void(*)(void)  callback 
)

Setup timer 1 to tick at a given interval.

The callback function will be called by the interrupt once the interrupt has been enabled. Note that the callback function is entered with the current page unknown.

This works on the assumption, that PCLK is set to 24MHz.

Parameters
intervalThe ticking interval in µs, don't go beyond 5461.
callbackA function pointer to a callback function.
Here is the call graph for this function:

§ ISR_hsk_timer0()

void ISR_hsk_timer0 ( void  )
private

The ISR for timer 0.

Sets up the timer 0 count registers and calls the callback function.

§ ISR_hsk_timer1()

void ISR_hsk_timer1 ( void  )
private

The ISR for timer 1.

Sets up the timer 1 count registers and calls the callback function.

Variable Documentation

§ callback

void( * callback) (void)

A callback function pointer used by the ISR.

§ overflow

uword overflow

The value to load into the timer upon overflow.

§ timers

timers
static

Struct representing runtime information for a timer.