Header file for CPU-Timer module.
More...
Go to the source code of this file.
Header file for CPU-Timer module.
Definition in file cpu_timer.h.
◆ CPUTimer_interruptAck()
void CPUTimer_interruptAck |
( |
void |
| ) |
|
Set Acknowledge to receive another interrupt from CPU-Timer.
Definition at line 171 of file cpu_timer.c.
172 TMC_BASE_PIE->ACK |= 0x1;
◆ CPUTimer_start()
Start CPU-Timer 0/1/2 || make sure CPU-Timer has been initialized.
- Parameters
-
[in] | | 1) CPU-Timer as Uint16 --> valid value: 0-2
2) Period for Timer-Interrupt in microseconds
|
- Returns
- Result of operations as int16
--> 0 = operation successful
--> -19 = invalid value of CPU-Timer
--> -20 = requested CPU-Timer not configured
Definition at line 89 of file cpu_timer.c.
91 temp = (long) ((
float)150 * Period);
94 case 0:
if(g_cpu_timer_0_in_use){
95 TMC_BASE_TIMER0->PRD = (
Uint16)(temp&0xFFFF);
96 TMC_BASE_TIMER0->PRDH = (
Uint16)(temp >> 16);
97 TMC_BASE_TIMER0->TPR = 0;
98 TMC_BASE_TIMER0->TPRH = 0;
99 TMC_BASE_TIMER0->TCR |= (0x1 << 4);
100 TMC_BASE_TIMER0->TCR |= (0x1 << 5);
101 TMC_BASE_TIMER0->TCR |= (0x2 << 10);
102 TMC_BASE_TIMER0->TCR |= ((
Uint32)0x1 << 14);
103 TMC_BASE_TIMER0->TCR &= ~(0x1 << 4);
110 case 1:
if(g_cpu_timer_1_in_use){
111 TMC_BASE_TIMER1->PRD = (
Uint16)(temp&0xFFFF);
112 TMC_BASE_TIMER1->PRDH = (
Uint16)(temp >> 16);
113 TMC_BASE_TIMER1->TPR = 0;
114 TMC_BASE_TIMER1->TPRH = 0;
115 TMC_BASE_TIMER1->TCR |= (0x1 << 4);
116 TMC_BASE_TIMER1->TCR |= (0x1 << 5);
117 TMC_BASE_TIMER1->TCR |= (0x2 << 10);
118 TMC_BASE_TIMER1->TCR |= ((
Uint32)0x1 << 14);
119 TMC_BASE_TIMER1->TCR &= ~(0x1 << 4);
125 case 2:
if(g_cpu_timer_2_in_use){
126 TMC_BASE_TIMER2->PRD = (
Uint16)(temp&0xFFFF);
127 TMC_BASE_TIMER2->PRDH = (
Uint16)(temp >> 16);
128 TMC_BASE_TIMER2->TPR = 0;
129 TMC_BASE_TIMER2->TPRH = 0;
130 TMC_BASE_TIMER2->TCR |= (0x1 << 4);
131 TMC_BASE_TIMER2->TCR |= (0x1 << 5);
132 TMC_BASE_TIMER2->TCR |= (0x2 << 10);
133 TMC_BASE_TIMER2->TCR |= ((
Uint32)0x1 << 14);
134 TMC_BASE_TIMER2->TCR &= ~(0x1 << 4);
◆ CPUTimer_stop()
Stop CPU-Timer 0/1/2 || make sure CPU-Timer has been initialized.
- Parameters
-
[in] | | 1) CPU-Timer as Uint16 --> valid value: 0-2
|
- Returns
- Result of operations as int16
--> 0 = operation successful
--> -19 = invalid value of CPU-Timer
Definition at line 152 of file cpu_timer.c.
154 case 0: TMC_BASE_TIMER0->TCR &= ~((
Uint32)0x1 << 14);
155 TMC_BASE_TIMER0->TCR |= (0x1 << 4);
157 case 1: TMC_BASE_TIMER1->TCR &= ~((
Uint32)0x1 << 14);
158 TMC_BASE_TIMER1->TCR |= (0x1 << 4);
160 case 2: TMC_BASE_TIMER2->TCR &= ~((
Uint32)0x1 << 14);
161 TMC_BASE_TIMER2->TCR |= (0x1 << 4);
◆ init_CPUTimer()
Init CPU-Timer 0/1/2.
- Parameters
-
[in] | | 1) CPU-Timer as Uint16 --> valid value: 0-2
2) Interrupt Service routine
|
- Returns
- Result of operations as int16
--> 0 = operation successful
--> -19 = invalid value of CPU-Timer
--> -10 = CPU-Timer already in use
Definition at line 27 of file cpu_timer.c.
29 case 0:
if(!g_cpu_timer_0_in_use){
30 g_cpu_timer_0_in_use=1;
33 TMC_BASE_INT_REGS->CPU_TIMER0 = (
Uint32)isr;
35 TMC_BASE_PIE->CTRL |= 0x01;
36 TMC_BASE_PIE->GROUP[0].IER |= 0x40;
39 TMC_BASE_TIMER0->TCR = (0x1 << 4);
45 case 1:
if(!g_cpu_timer_1_in_use){
46 g_cpu_timer_1_in_use=1;
49 TMC_BASE_INT_REGS2->CPU_TIMER1 = (
Uint32)isr;
51 TMC_BASE_PIE->CTRL |= 0x01;
54 TMC_BASE_TIMER1->TCR = (0x1 << 4);
60 case 2:
if(!g_cpu_timer_2_in_use){
61 g_cpu_timer_2_in_use=1;
64 TMC_BASE_INT_REGS2->CPU_TIMER2 = (
Uint32)isr;
66 TMC_BASE_PIE->CTRL |= 0x01;
69 TMC_BASE_TIMER2->TCR = (0x1 << 4);