comparison chipsetsw/drivers/drv_core/timer/timer2.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
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 "l1sw.cfg"
33
34 #if (OP_L1_STANDALONE == 0)
35 #include "main/sys_types.h"
36 #else
37 #include "sys_types.h"
38 #endif
39 #include "memif/mem.h"
40 #include "timer2.h"
41
42 /*--------------------------------------------------------------*/
43 /* Dtimer2_Get_cntlreg() */
44 /*--------------------------------------------------------------*/
45 /* Parameters : none */
46 /* Return : none */
47 /* Functionality : read one of the TIMER register */
48 /*--------------------------------------------------------------*/
49
50 SYS_UWORD16 Dtimer2_Get_cntlreg(void)
51 {
52 volatile SYS_UWORD16 timerReg;
53
54 timerReg = (( * (SYS_UWORD16 *) D_TIMER_CNTL) & D_TIMER_CNTL_MASK);
55 return(timerReg);
56 }
57
58
59 /*--------------------------------------------------------------*/
60 /* Dtimer2_Init_cntl() */
61 /*--------------------------------------------------------------*/
62 /* Parameters :start/stop,reload yes/no,pre scale,ext clk on/off*/
63 /* Return : none */
64 /* Functionality : initialize the timer start, autoreload, Ptv */
65 /* and clock enable */
66 /*--------------------------------------------------------------*/
67
68 void Dtimer2_Init_cntl (SYS_UWORD16 St, SYS_UWORD16 Reload, SYS_UWORD16 clockScale, SYS_UWORD16 clkon)
69 {
70 SYS_UWORD16 cntl = * (SYS_UWORD16 *) D_TIMER_CNTL;
71
72
73 cntl &= ~(D_TIMER_ST | D_TIMER_PTV); /* stop and reset values */
74
75 (Reload) ? (cntl |= D_TIMER_AR) : (cntl &= ~D_TIMER_AR);
76
77 cntl |= (clockScale << 2 );
78
79 cntl |= ( clkon << 5 );
80
81
82 * (SYS_UWORD16 *) D_TIMER_LOAD = St;
83
84 * (SYS_UWORD16 *) D_TIMER_CNTL = cntl;
85 }
86
87 /*--------------------------------------------------------------*/
88 /* Dtimer2_AR() */
89 /*--------------------------------------------------------------*/
90 /* Parameters :start/stop,reload yes/no,pre scale,ext clk on/off*/
91 /* Return : none */
92 /* Functionality : set the AR bit Ar = 0 | 1 */
93 /*--------------------------------------------------------------*/
94
95 void Dtimer2_AR(SYS_UWORD16 Ar)
96 {
97 SYS_UWORD16 cntl = * (SYS_UWORD16 *) D_TIMER_CNTL;
98
99 cntl &= ~(D_TIMER_ST); /* stop the timer */
100
101 cntl &= ~(D_TIMER_AR);
102
103 cntl |= ( Ar << 1 );
104
105 * (SYS_UWORD16 *) D_TIMER_CNTL = cntl;
106 }
107
108 /*--------------------------------------------------------------*/
109 /* Dtimer2_PTV() */
110 /*--------------------------------------------------------------*/
111 /* Parameters : pre scale */
112 /* Return : none */
113 /* Functionality : set the Ptv bits Ptv = 0 => 7 */
114 /*--------------------------------------------------------------*/
115
116 void Dtimer2_PTV(SYS_UWORD16 Ptv)
117 {
118 SYS_UWORD16 cntl = * (SYS_UWORD16 *) D_TIMER_CNTL;
119
120 cntl &= ~(D_TIMER_ST); /* stop the timer */
121
122 cntl &= ~(D_TIMER_PTV); /* Ptv[4:0] set to 0 */
123
124 cntl |= ( Ptv << 2 );
125
126 * (SYS_UWORD16 *) D_TIMER_CNTL = cntl;
127 }
128
129 /*--------------------------------------------------------------*/
130 /* Dtimer1_Clken() */
131 /*--------------------------------------------------------------*/
132 /* Parameters : ext clk on/off */
133 /* Return : none */
134 /* Functionality : set the clock_enable bit En = 0 | 1 */
135 /*--------------------------------------------------------------*/
136
137 void Dtimer2_Clken(SYS_UWORD16 En)
138 {
139 SYS_UWORD16 cntl = * (SYS_UWORD16 *) D_TIMER_CNTL;
140
141 cntl &= ( ~D_TIMER_CLK_EN);
142
143 cntl |= ( En << 5 );
144
145 * (SYS_UWORD16 *) D_TIMER_CNTL = cntl;
146 }
147
148
149
150 /*--------------------------------------------------------------*/
151 /* Dtimer2_Start() */
152 /*--------------------------------------------------------------*/
153 /* Parameters : on/off */
154 /* Return : none */
155 /* Functionality : Start or stop the timer */
156 /*--------------------------------------------------------------*/
157
158 void Dtimer2_Start (SYS_UWORD16 startStop)
159 {
160 (startStop == D_TIMER_ST) ?
161 ((* (SYS_UWORD16 *) D_TIMER_CNTL) |= D_TIMER_ST) : /* condition vrai */
162 ((* (SYS_UWORD16 *) D_TIMER_CNTL) &= ~D_TIMER_ST); /* condition fausse */
163 }
164
165 /*--------------------------------------------------------------*/
166 /* Dtimer2_ReadValue() */
167 /*--------------------------------------------------------------*/
168 /* Parameters : on/off */
169 /* Return : none */
170 /* Functionality : Read timer value */
171 /*--------------------------------------------------------------*/
172
173 SYS_UWORD16 Dtimer2_ReadValue (void)
174 {
175 return(* (SYS_UWORD16 *) D_TIMER_READ);
176
177 }
178
179 /*--------------------------------------------------------------*/
180 /* Parameters : on/off */
181 /* Return : none */
182 /* Functionality : Write timer value */
183 /*--------------------------------------------------------------*/
184
185 void Dtimer2_WriteValue (SYS_UWORD16 value)
186 {
187 (* (SYS_UWORD16 *) D_TIMER_LOAD) = value;
188
189 }