openchronos-ng
opensource firmware for the ez430 chronos
|
openchronos-ng timer driver More...
#include <openchronos.h>
Go to the source code of this file.
Enumerations | |
enum | timer0_event { TIMER0_EVENT_1HZ = BIT0, TIMER0_EVENT_20HZ = BIT1, TIMER0_EVENT_PROG = BIT2 } |
Bitfield of events produced by this driver. More... | |
Functions | |
void | timer0_init (void) |
Initializes the timer. | |
void | timer0_create_prog_timer (uint16_t duration) |
creates a 1000Hz - 1Hz programmable timer | |
void | timer0_destroy_prog_timer () |
destroys a running programmable timer | |
void | timer0_delay (uint16_t duration, uint16_t LPM_bits) |
1ms - 1s programmable delay | |
Variables | |
volatile uint16_t | timer0_20hz_counter |
20Hz counter. | |
enum timer0_event | timer0_last_event |
Bitfield holding the last generated (timer) event. |
openchronos-ng timer driver
This driver takes care of the Timer0 hardware timer. From this hardware timer the driver produces two hardware-based timers running at 20Hz and 1Hz. The events produced by those timers are available in sys_message. Beyound the fixed frequency timers, this driver also implements a programmable timer and a programmable delay.
enum timer0_event |
void timer0_create_prog_timer | ( | uint16_t | duration | ) |
creates a 1000Hz - 1Hz programmable timer
Creates a timer programmable from 1Hz up to 1000Hz. The timer event is available in sys_message.
duration | timer period between 1 and 1000 milliseconds. |
void timer0_delay | ( | uint16_t | duration, |
uint16_t | LPM_bits | ||
) |
1ms - 1s programmable delay
delays execution for duration milliseconds. During the delay, interrupts are still generated but sys_message only broadcasts the events after the delay has finished. The second argument is put directly into the _STATUS_ register. This could of course disrupt the state of the watch. Please be careful and take a look at http://mspgcc.sourceforge.net/manual/x1028.html for information regarding the _STATUS_ register.
duration | delay duration between 1 and 1000 milliseconds |
LPM_bits | LPM bits to put in the status register, so the user can choose LPM level |
void timer0_destroy_prog_timer | ( | ) |
destroys a running programmable timer
void timer0_init | ( | void | ) |
Initializes the timer.
This functions is called once upon system initialization.
volatile uint16_t timer0_20hz_counter |
20Hz counter.
This is a counter variable, its value is updated at 20Hz. You can use this to measure timings.
Bitfield holding the last generated (timer) event.
Timer0 interrupt routines update this variable with the last happening events. Inside the mainloop, the system then clears this variable after reading it. Read events are broadcasted in sys_message.