EE445M RTOS
Taken at the University of Texas Spring 2015
timer Class Reference

#include <timerpp.hpp>

Inheritance diagram for timer:
Inheritance graph
Collaboration diagram for timer:
Collaboration graph

Public Member Functions

 timer ()
 
 timer (timer_t timer_id, subtimer_t timer_subtimer, uint32_t timer_configuration, reload_t timer_load_val, uint32_t timer_interrupt, bool timer_start=false)
 
virtual void start ()
 
virtual void stop ()
 
virtual uint32_t ack ()
 
virtual uint32_t get ()
 
const subtimer_t get_subtimer ()
 
const uint32_t get_base ()
 
void reload (void)
 
void load (uint32_t load_value)
 
- Public Member Functions inherited from interruptable
 interruptable ()
 

Private Attributes

timer_t id
 
uint32_t base
 
subtimer_t subtimer
 
reload_t reload_value
 
uint32_t configuration
 
uint32_t interrupt
 

Detailed Description

Definition at line 26 of file timerpp.hpp.

Constructor & Destructor Documentation

timer::timer ( )

Definition at line 10 of file timerpp.cpp.

10 {}
timer::timer ( timer_t  timer_id,
subtimer_t  timer_subtimer,
uint32_t  timer_configuration,
reload_t  timer_load_val,
uint32_t  timer_interrupt,
bool  timer_start = false 
)

Definition at line 12 of file timerpp.cpp.

References base, configuration, interrupt, reload(), reload_value, start(), and subtimer.

14  {
15 
16  id = timer_id;
17  base = TIMER0_BASE + 0x1000 * timer_id;
18  subtimer = timer_subtimer;
19  reload_value = timer_load_val;
20  configuration = timer_configuration;
21  interrupt = timer_interrupt;
22 
23  SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0 + id);
24  TimerConfigure(base, configuration);
25 
26  switch(subtimer) {
27  case TIMER_A:
28  case TIMER_BOTH:
29  IntEnable(INT_TIMER0A + id*2);
30  break;
31  case TIMER_B:
32  IntEnable(INT_TIMER0A + id*2 + 1);
33  break;
34  default:
35  while (1) {}
36  }
37 
38  reload();
39  if (timer_start) { start(); }
40 }
void reload(void)
Definition: timerpp.cpp:42
reload_t reload_value
Definition: timerpp.hpp:38
uint32_t configuration
Definition: timerpp.hpp:42
uint32_t interrupt
Definition: timerpp.hpp:46
virtual void start()
Definition: timerpp.cpp:62
uint32_t base
Definition: timerpp.hpp:32
subtimer_t subtimer
Definition: timerpp.hpp:35

Here is the call graph for this function:

Member Function Documentation

uint32_t timer::ack ( void  )
virtual

Acknowledge an interrupt. Clears the interrupt bits for this timer.

Implements interruptable.

Definition at line 74 of file timerpp.cpp.

References base, and subtimer.

Referenced by lswitch::end_debounce(), ping::handle_timer(), Timer0A_Handler(), Timer1A_Handler(), and Timer2A_Handler().

74  {
75 
76  switch(subtimer) {
77  case TIMER_A:
78  case TIMER_BOTH:
79  TimerIntClear(base, INT_TIMER0A + id*2);
80  break;
81  case TIMER_B:
82  TimerIntClear(base, INT_TIMER0A + id*2 + 1);
83  break;
84  default:
85  while (1) {}
86  }
87  return 0xDEADBEEF;
88 }
uint32_t base
Definition: timerpp.hpp:32
subtimer_t subtimer
Definition: timerpp.hpp:35

Here is the caller graph for this function:

uint32_t timer::get ( void  )
virtual

Definition at line 90 of file timerpp.cpp.

References base, and subtimer.

Referenced by ping::handle_gpio().

90  {
91 
92  switch(subtimer) {
93  case TIMER_A:
94  case TIMER_BOTH:
95  TimerValueGet(base, TIMER_A);
96  break;
97  case TIMER_B:
98  TimerValueGet(base, TIMER_B);
99  break;
100  default:
101  while (1) {}
102  }
103 }
uint32_t base
Definition: timerpp.hpp:32
subtimer_t subtimer
Definition: timerpp.hpp:35

Here is the caller graph for this function:

const uint32_t timer::get_base ( )

Definition at line 109 of file timerpp.cpp.

References base.

Referenced by adc::configure_timer_interrupt().

109  {
110  return base;
111 }
uint32_t base
Definition: timerpp.hpp:32

Here is the caller graph for this function:

const subtimer_t timer::get_subtimer ( )

Definition at line 105 of file timerpp.cpp.

References subtimer.

Referenced by adc::configure_timer_interrupt().

105  {
106  return subtimer;
107 }
subtimer_t subtimer
Definition: timerpp.hpp:35

Here is the caller graph for this function:

void timer::load ( uint32_t  load_value)

Definition at line 47 of file timerpp.cpp.

References base, and subtimer.

Referenced by ping::handle_gpio(), and reload().

47  {
48 
49  switch(subtimer) {
50  case TIMER_A:
51  case TIMER_BOTH:
52  TimerLoadSet(base, TIMER_A, load_value);
53  break;
54  case TIMER_B:
55  TimerLoadSet(base, TIMER_B, load_value);
56  break;
57  default:
58  while (1) {}
59  }
60 }
uint32_t base
Definition: timerpp.hpp:32
subtimer_t subtimer
Definition: timerpp.hpp:35

Here is the caller graph for this function:

void timer::reload ( void  )

Reload the timer with the initial reload value

Definition at line 42 of file timerpp.cpp.

References load(), and reload_value.

Referenced by ping::handle_gpio(), and timer().

42  {
43 
45 }
void load(uint32_t load_value)
Definition: timerpp.cpp:47
reload_t reload_value
Definition: timerpp.hpp:38

Here is the call graph for this function:

Here is the caller graph for this function:

void timer::start ( void  )
virtual

Start a timer.

Implements interruptable.

Definition at line 62 of file timerpp.cpp.

References base, interrupt, and subtimer.

Referenced by lswitch::debounce(), ping::handle_gpio(), and timer().

62  {
63 
64  TimerIntEnable(base, interrupt);
65  TimerEnable(base, subtimer);
66 }
uint32_t interrupt
Definition: timerpp.hpp:46
uint32_t base
Definition: timerpp.hpp:32
subtimer_t subtimer
Definition: timerpp.hpp:35

Here is the caller graph for this function:

void timer::stop ( void  )
virtual

Stop a timer.

Implements interruptable.

Definition at line 68 of file timerpp.cpp.

References base, interrupt, and subtimer.

68  {
69 
70  TimerIntDisable(base, interrupt);
71  TimerDisable(base, subtimer);
72 }
uint32_t interrupt
Definition: timerpp.hpp:46
uint32_t base
Definition: timerpp.hpp:32
subtimer_t subtimer
Definition: timerpp.hpp:35

Member Data Documentation

uint32_t timer::base
private

The base address of the specified timer

Definition at line 32 of file timerpp.hpp.

Referenced by ack(), get(), get_base(), load(), start(), stop(), and timer().

uint32_t timer::configuration
private

The configuration bitset for the timer

Note
Reference timer.h for possible options (e.g. TIMER_CFG_PERIODIC)

Definition at line 42 of file timerpp.hpp.

Referenced by timer().

timer_t timer::id
private

Defined between 0 to 4, where 0 indicates TIMER0

Definition at line 29 of file timerpp.hpp.

uint32_t timer::interrupt
private

The timer interrupt to be acknowdeged, enabled, disabled

Note
Reference timer.h for possible options (e.g. TIMER_TIMA_TIMEOUT)

Definition at line 46 of file timerpp.hpp.

Referenced by start(), stop(), and timer().

reload_t timer::reload_value
private

The reload value for the timer

Definition at line 38 of file timerpp.hpp.

Referenced by reload(), and timer().

subtimer_t timer::subtimer
private

TIMER_A, TIMER_B, or TIMER_BOTH

Definition at line 35 of file timerpp.hpp.

Referenced by ack(), get(), get_subtimer(), load(), start(), stop(), and timer().


The documentation for this class was generated from the following files: