comparison bsp/timer1.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
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 : timer1.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
19 Version number : 1.4
20
21 Date and time : 08/18/00 14:42:35
22
23 Previous delta : 06/30/00 11:40:43
24
25 SCCS file : /db/gsm_asp/db_ht96/dsp_0/gsw/rel_0/mcu_l1/release_gprs/RELEASE_GPRS/drivers1/common/SCCS/s.timer1.c
26
27 Sccs Id (SID) : '@(#) timer1.c 1.4 08/18/00 14:42:35 '
28
29
30 *****************************************************************************/
31
32 #include "../include/sys_types.h"
33
34 #include "mem.h"
35 #include "timer1.h"
36
37 /*--------------------------------------------------------------*/
38 /* Dtimer1_Get_cntlreg() */
39 /*--------------------------------------------------------------*/
40 /* Parameters : none */
41 /* Return : none */
42 /* Functionality : read one of the TIMER register */
43 /*--------------------------------------------------------------*/
44
45 SYS_UWORD16 Dtimer1_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 /* Dtimer_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 Dtimer1_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 /* Dtimer1_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 Dtimer1_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 /* Dtimer1_PTV() */
105 /*--------------------------------------------------------------*/
106 /* Parameters : pre scale */
107 /* Return : none */
108 /* Functionality : set the Ptv bits Ptv = 0 => 7 */
109 /*--------------------------------------------------------------*/
110
111 void Dtimer1_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 Dtimer1_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 /* Dtimer_Start() */
147 /*--------------------------------------------------------------*/
148 /* Parameters : on/off */
149 /* Return : none */
150 /* Functionality : Start or stop the timer */
151 /*--------------------------------------------------------------*/
152
153 void Dtimer1_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 /* Dtimer_ReadValue() */
162 /*--------------------------------------------------------------*/
163 /* Parameters : on/off */
164 /* Return : none */
165 /* Functionality : Read timer value */
166 /*--------------------------------------------------------------*/
167 SYS_UWORD16 Dtimer1_ReadValue (void)
168 {
169 return(* (SYS_UWORD16 *) D_TIMER_READ);
170 }
171
172 /*--------------------------------------------------------------*/
173 /* Parameters : on/off */
174 /* Return : none */
175 /* Functionality : Write timer value */
176 /*--------------------------------------------------------------*/
177 void Dtimer1_WriteValue (SYS_UWORD16 value)
178 {
179 (* (SYS_UWORD16 *) D_TIMER_LOAD) = value;
180 }