FreeNOS
BroadcomTimer.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "BroadcomInterrupt.h"
19 #include "BroadcomTimer.h"
20 
22 {
23  m_cycles = BCM_SYSTIMER_FREQ / hertz;
24  m_frequency = hertz;
26 
27  // Use timer slot 1. Enable.
30 
31  // Done
32  return Success;
33 }
34 
36 {
37  // Clear+acknowledge the timer interrupt
40 
41  // Done
42  return Timer::tick();;
43 }
Timer::Success
@ Success
Definition: Timer.h:54
Timer::m_int
Size m_int
Timer interrupt number.
Definition: Timer.h:165
ARMIO::write
void write(u32 reg, u32 data)
write to memory mapped I/O register
Definition: ARMIO.h:46
Timer::m_frequency
Size m_frequency
Frequency of the Timer.
Definition: Timer.h:162
BroadcomTimer::setFrequency
virtual Result setFrequency(Size hertz)
Set timer frequency.
Definition: BroadcomTimer.cpp:21
BCM_SYSTIMER_FREQ
#define BCM_SYSTIMER_FREQ
BCM Sys Timer runs at 1Mhz.
Definition: BroadcomTimer.h:55
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
SYSTIMER_C1
#define SYSTIMER_C1
Definition: BroadcomTimer.h:44
SYSTIMER_CS
#define SYSTIMER_CS
Definition: BroadcomTimer.h:39
ARMIO::read
u32 read(u32 reg) const
read from memory mapped I/O register
Definition: ARMIO.h:62
BroadcomTimer::m_io
ARMIO m_io
I/O instance.
Definition: BroadcomTimer.h:90
BCM_IRQ_SYSTIMERM1
#define BCM_IRQ_SYSTIMERM1
Triggered when the system timer matches the C1 register.
Definition: BroadcomInterrupt.h:40
BroadcomInterrupt.h
BroadcomTimer.h
Timer::Result
Result
Result codes.
Definition: Timer.h:52
M1
#define M1
Definition: BroadcomTimer.h:51
SYSTIMER_CLO
#define SYSTIMER_CLO
Definition: BroadcomTimer.h:40
BroadcomTimer::tick
virtual Result tick()
Process timer tick.
Definition: BroadcomTimer.cpp:35
BroadcomTimer::m_cycles
u32 m_cycles
Number of internal cycles needed to provide the current timer frequency.
Definition: BroadcomTimer.h:87
Timer::tick
virtual Result tick()
Process timer tick.
Definition: Timer.cpp:74