Embedded Xinu Operating System
An ongoing research project and educational operating system.
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
Data Structures | Macros | Functions
timer.c File Reference
#include <clock.h>
#include "bcm2837.h"

Data Structures

struct  bcm2835_timer_regs
 

Macros

#define BCM2835_SYSTEM_TIMER_MATCH_0   (1 << 0)
 
#define BCM2835_SYSTEM_TIMER_MATCH_1   (1 << 1)
 
#define BCM2835_SYSTEM_TIMER_MATCH_2   (1 << 2)
 
#define BCM2835_SYSTEM_TIMER_MATCH_3   (1 << 3)
 

Functions

ulong clkcount (void)
 
void clkupdate (ulong cycles)
 

Detailed Description

This file contains code that interfaces with the system timer of the BCM2835 SoC used in the Raspberry Pi.

See 12. "System Timer" of the BCM2835-ARM-Peripherals.pdf document for details about this hardware. However, this document does not say the frequency the timer runs at (it's 1 MHz), nor does it say that some of the output compare registers (0 and 2) are used by the GPU and therefore cannot be used by ARM code, nor does it say what interrupt line the system timer is connected to (it's IRQs 0-3 mapped linearly onto the output compare registers).

See http://xinu-os.org/BCM2835_System_Timer for more information about this hardware.

Function Documentation

ulong clkcount ( void  )

Raspberry-Pi specific note: This function returns the low-order 32 bits of the BCM2835's free-running counter. This counter runs at 1 MHz and therefore overflows every 4295 seconds.