comparison chipsetsw/drivers/drv_core/timer/timer1.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 : 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 "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 "timer1.h"
41
42 /*--------------------------------------------------------------*/
43 /* Dtimer1_Get_cntlreg() */
44 /*--------------------------------------------------------------*/
45 /* Parameters : none */
46 /* Return : none */
47 /* Functionality : read one of the TIMER register */
48 /*--------------------------------------------------------------*/
49
50 SYS_UWORD16 Dtimer1_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 /* Dtimer_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 Dtimer1_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 /* Dtimer1_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 Dtimer1_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 /* Dtimer1_PTV() */
110 /*--------------------------------------------------------------*/
111 /* Parameters : pre scale */
112 /* Return : none */
113 /* Functionality : set the Ptv bits Ptv = 0 => 7 */
114 /*--------------------------------------------------------------*/
115
116 void Dtimer1_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 Dtimer1_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 /* Dtimer_Start() */
152 /*--------------------------------------------------------------*/
153 /* Parameters : on/off */
154 /* Return : none */
155 /* Functionality : Start or stop the timer */
156 /*--------------------------------------------------------------*/
157
158 void Dtimer1_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 /* Dtimer_ReadValue() */
167 /*--------------------------------------------------------------*/
168 /* Parameters : on/off */
169 /* Return : none */
170 /* Functionality : Read timer value */
171 /*--------------------------------------------------------------*/
172 SYS_UWORD16 Dtimer1_ReadValue (void)
173 {
174 return(* (SYS_UWORD16 *) D_TIMER_READ);
175
176 }
177
178 /*--------------------------------------------------------------*/
179 /* Parameters : on/off */
180 /* Return : none */
181 /* Functionality : Write timer value */
182 /*--------------------------------------------------------------*/
183 void Dtimer1_WriteValue (SYS_UWORD16 value)
184 {
185 (* (SYS_UWORD16 *) D_TIMER_LOAD) = value;
186
187 }