comparison gsm-fw/bsp/timer2.c @ 143:afceeeb2cba1

Our nuc-fw is destined to become gsm-fw, so I went ahead and did the big hg mv
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 12 Nov 2013 05:35:48 +0000
parents nuc-fw/bsp/timer2.c@17b0511b243c
children
comparison
equal deleted inserted replaced
142:15d5977390c2 143:afceeeb2cba1
1 /******************************************************************************
2 TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION
3
4 Property of Texas Instruments -- For Unrestricted Internal Use Only
5 Unauthorized reproduction and/or distribution is strictly prohibited. This
6 product is protected under copyright law and trade secret law as an
7 unpublished work. Created 1987, (C) Copyright 1997 Texas Instruments. All
8 rights reserved.
9
10
11 Filename : timer2.c
12
13 Description : Set of useful functions for TIMER module test cases
14
15 Project : drivers
16
17 Author : pmonteil@tif.ti.com Patrice Monteil.
18 Version number : 1.3
19
20 Date and time : 08/18/00 14:42:39
21
22 Previous delta : 07/10/00 16:15:18
23
24 SCCS file : /db/gsm_asp/db_ht96/dsp_0/gsw/rel_0/mcu_l1/release_gprs/RELEASE_GPRS/drivers1/common/SCCS/s.timer2.c
25
26 Sccs Id (SID) : '@(#) timer2.c 1.3 08/18/00 14:42:39 '
27
28
29
30 *****************************************************************************/
31
32 #include "../include/sys_types.h"
33
34 #include "mem.h"
35 #include "timer2.h"
36
37 /*--------------------------------------------------------------*/
38 /* Dtimer2_Get_cntlreg() */
39 /*--------------------------------------------------------------*/
40 /* Parameters : none */
41 /* Return : none */
42 /* Functionality : read one of the TIMER register */
43 /*--------------------------------------------------------------*/
44
45 SYS_UWORD16 Dtimer2_Get_cntlreg(void)
46 {
47 SYS_UWORD16 timerReg;
48
49 timerReg = (( * (volatile SYS_UWORD16 *) D_TIMER_CNTL) & D_TIMER_CNTL_MASK);
50 return(timerReg);
51 }
52
53
54 /*--------------------------------------------------------------*/
55 /* Dtimer2_Init_cntl() */
56 /*--------------------------------------------------------------*/
57 /* Parameters :start/stop,reload yes/no,pre scale,ext clk on/off*/
58 /* Return : none */
59 /* Functionality : initialize the timer start, autoreload, Ptv */
60 /* and clock enable */
61 /*--------------------------------------------------------------*/
62
63 void Dtimer2_Init_cntl (SYS_UWORD16 St, SYS_UWORD16 Reload, SYS_UWORD16 clockScale, SYS_UWORD16 clkon)
64 {
65 SYS_UWORD16 cntl = * (volatile SYS_UWORD16 *) D_TIMER_CNTL;
66
67
68 cntl &= ~(D_TIMER_ST | D_TIMER_PTV); /* stop and reset values */
69
70 (Reload) ? (cntl |= D_TIMER_AR) : (cntl &= ~D_TIMER_AR);
71
72 cntl |= (clockScale << 2 );
73
74 cntl |= ( clkon << 5 );
75
76
77 * (volatile SYS_UWORD16 *) D_TIMER_LOAD = St;
78
79 * (volatile SYS_UWORD16 *) D_TIMER_CNTL = cntl;
80 }
81
82 /*--------------------------------------------------------------*/
83 /* Dtimer2_AR() */
84 /*--------------------------------------------------------------*/
85 /* Parameters :start/stop,reload yes/no,pre scale,ext clk on/off*/
86 /* Return : none */
87 /* Functionality : set the AR bit Ar = 0 | 1 */
88 /*--------------------------------------------------------------*/
89
90 void Dtimer2_AR(SYS_UWORD16 Ar)
91 {
92 SYS_UWORD16 cntl = * (volatile SYS_UWORD16 *) D_TIMER_CNTL;
93
94 cntl &= ~(D_TIMER_ST); /* stop the timer */
95
96 cntl &= ~(D_TIMER_AR);
97
98 cntl |= ( Ar << 1 );
99
100 * (volatile SYS_UWORD16 *) D_TIMER_CNTL = cntl;
101 }
102
103 /*--------------------------------------------------------------*/
104 /* Dtimer2_PTV() */
105 /*--------------------------------------------------------------*/
106 /* Parameters : pre scale */
107 /* Return : none */
108 /* Functionality : set the Ptv bits Ptv = 0 => 7 */
109 /*--------------------------------------------------------------*/
110
111 void Dtimer2_PTV(SYS_UWORD16 Ptv)
112 {
113 SYS_UWORD16 cntl = * (volatile SYS_UWORD16 *) D_TIMER_CNTL;
114
115 cntl &= ~(D_TIMER_ST); /* stop the timer */
116
117 cntl &= ~(D_TIMER_PTV); /* Ptv[4:0] set to 0 */
118
119 cntl |= ( Ptv << 2 );
120
121 * (volatile SYS_UWORD16 *) D_TIMER_CNTL = cntl;
122 }
123
124 /*--------------------------------------------------------------*/
125 /* Dtimer1_Clken() */
126 /*--------------------------------------------------------------*/
127 /* Parameters : ext clk on/off */
128 /* Return : none */
129 /* Functionality : set the clock_enable bit En = 0 | 1 */
130 /*--------------------------------------------------------------*/
131
132 void Dtimer2_Clken(SYS_UWORD16 En)
133 {
134 SYS_UWORD16 cntl = * (volatile SYS_UWORD16 *) D_TIMER_CNTL;
135
136 cntl &= ( ~D_TIMER_CLK_EN);
137
138 cntl |= ( En << 5 );
139
140 * (volatile SYS_UWORD16 *) D_TIMER_CNTL = cntl;
141 }
142
143
144
145 /*--------------------------------------------------------------*/
146 /* Dtimer2_Start() */
147 /*--------------------------------------------------------------*/
148 /* Parameters : on/off */
149 /* Return : none */
150 /* Functionality : Start or stop the timer */
151 /*--------------------------------------------------------------*/
152
153 void Dtimer2_Start (SYS_UWORD16 startStop)
154 {
155 (startStop == D_TIMER_ST) ?
156 ((* (SYS_UWORD16 *) D_TIMER_CNTL) |= D_TIMER_ST) : /* condition vrai */
157 ((* (SYS_UWORD16 *) D_TIMER_CNTL) &= ~D_TIMER_ST); /* condition fausse */
158 }
159
160 /*--------------------------------------------------------------*/
161 /* Dtimer2_ReadValue() */
162 /*--------------------------------------------------------------*/
163 /* Parameters : on/off */
164 /* Return : none */
165 /* Functionality : Read timer value */
166 /*--------------------------------------------------------------*/
167
168 SYS_UWORD16 Dtimer2_ReadValue (void)
169 {
170 return(* (SYS_UWORD16 *) D_TIMER_READ);
171 }
172
173 /*--------------------------------------------------------------*/
174 /* Parameters : on/off */
175 /* Return : none */
176 /* Functionality : Write timer value */
177 /*--------------------------------------------------------------*/
178
179 void Dtimer2_WriteValue (SYS_UWORD16 value)
180 {
181 (* (SYS_UWORD16 *) D_TIMER_LOAD) = value;
182 }