Nut/OS  4.10.3
API Reference
ostimer.c File Reference
#include <cfg/os.h>
#include <sys/atom.h>
#include <dev/irqreg.h>
#include <arch/timer.h>
Include dependency graph for ostimer.c:

Go to the source code of this file.

Defines

#define NUT_TICK_NFREQ   1024L
 Nominal number of system ticks per second.
#define NUT_TIMER_CRYSTAL   32768L
#define NUT_TIMER_PRESCALE   1
#define OCR_VALUE   (((2 * NUT_TIMER_CRYSTAL / (NUT_TIMER_PRESCALE * NUT_TICK_NFREQ) + 1) / 2) - 1)
#define NUT_TICK_FREQ   ((2 * NUT_TIMER_CRYSTAL / (OCR_VALUE + 1) / NUT_TIMER_PRESCALE + 1) / 2)
#define TCCRx   TCCR0
#define TCNTx   TCNT0
#define OCRx   OCR0
#define TIFR_OCFx   _BV(OCF0)
#define TIFR_TOVx   _BV(TOV0)
#define sig_TIMER   sig_OUTPUT_COMPARE0

Functions

void NutRegisterTimer (void(*handler)(void *))
 Initialize system timer hardware.
uint32_t NutArchClockGet (int idx)
 Return the CPU clock in Hertz.
uint32_t NutGetTickClock (void)
 Return the number of system ticks per second.
uint32_t NutTimerMillisToTicks (uint32_t ms)
 Calculate system ticks for a given number of milliseconds.

Define Documentation

#define NUT_TICK_NFREQ   1024L

Nominal number of system ticks per second.

The actual frequency depends on the timer crystal.

Note:
Since version 3.9.8, the default frequency had been changed from 16 Hz to 1024 Hz, when the timer is running with an external 32 kHz clock crystal.

Definition at line 122 of file ostimer.c.

#define NUT_TIMER_CRYSTAL   32768L

Definition at line 135 of file ostimer.c.

#define NUT_TIMER_PRESCALE   1

Definition at line 138 of file ostimer.c.

#define OCR_VALUE   (((2 * NUT_TIMER_CRYSTAL / (NUT_TIMER_PRESCALE * NUT_TICK_NFREQ) + 1) / 2) - 1)

Definition at line 143 of file ostimer.c.

Referenced by NutRegisterTimer().

#define NUT_TICK_FREQ   ((2 * NUT_TIMER_CRYSTAL / (OCR_VALUE + 1) / NUT_TIMER_PRESCALE + 1) / 2)

Definition at line 146 of file ostimer.c.

Referenced by NutGetTickClock(), and NutTimerMillisToTicks().

#define TCCRx   TCCR0

Definition at line 187 of file ostimer.c.

Referenced by NutRegisterTimer().

#define TCNTx   TCNT0

Definition at line 188 of file ostimer.c.

Referenced by NutRegisterTimer().

#define OCRx   OCR0

Definition at line 189 of file ostimer.c.

Referenced by NutRegisterTimer().

#define TIFR_OCFx   _BV(OCF0)

Definition at line 190 of file ostimer.c.

Referenced by NutRegisterTimer().

#define TIFR_TOVx   _BV(TOV0)

Definition at line 191 of file ostimer.c.

#define sig_TIMER   sig_OUTPUT_COMPARE0

Definition at line 192 of file ostimer.c.

Referenced by NutRegisterTimer().