1 /*""FILE COMMENT""*******************************************************
2 * System Name	: Timer TMR API for RX62Nxx
3 * File Name		: r_pdl_tmr_RX62Nxx.h
4 * Version		: 1.02
5 * Contents		: Timer TMR API header
6 * Customer		:
7 * Model			:
8 * Order			:
9 * CPU			: RX
10 * Compiler		: RXC
11 * OS			: Nothing
12 * Programmer	:
13 * Note			:
14 ************************************************************************
15 * Copyright, 2011. Renesas Electronics Corporation
16 * and Renesas Solutions Corporation
17 ************************************************************************
18 * History		: 2011.04.08
19 *				: Ver 1.02
20 *				: CS-5 release.
21 *""FILE COMMENT END""**************************************************/
22 
23 #ifndef R_PDL_TMR_RX62Nxx_H
24 #define R_PDL_TMR_RX62Nxx_H
25 
26 #define TMR_UNITS 				2
27 #define TMR_CHANNELS_PER_UNIT	2
28 #define TMR_CHANNELS (uint8_t)(TMR_UNITS * TMR_CHANNELS_PER_UNIT)
29 
30 /* One-shot modes */
31 #define CHANNEL_MODE	0x01u
32 #define UNIT_MODE		0x02u
33 
34 /* Callback function storage */
35 extern VoidCallBackFunc rpdl_TMR_Overflow_callback_func[TMR_CHANNELS];
36 extern VoidCallBackFunc rpdl_TMR_CMA_callback_func[TMR_CHANNELS];
37 extern VoidCallBackFunc rpdl_TMR_CMB_callback_func[TMR_CHANNELS];
38 
39 /* Global variables */
40 extern volatile  uint8_t rpdl_TMR_tcsr_setting[TMR_CHANNELS];
41 extern volatile  uint8_t rpdl_TMR_tccr8_setting[TMR_CHANNELS];
42 extern volatile uint16_t rpdl_TMR_tccr16_setting[TMR_UNITS];
43 extern volatile  uint8_t rpdl_TMR_one_shot[TMR_CHANNELS];
44 
45 /* Library prototypes */
46 bool R_TMR_SetAll(
47 	const uint8_t
48 );
49 bool R_TMR_CreateChannelAll(
50 	const uint8_t,
51 	const uint32_t,
52 	const uint8_t,
53 	const uint8_t,
54 	const uint8_t,
55 	const uint8_t,
56 	VoidCallBackFunc const,
57 	VoidCallBackFunc const,
58 	VoidCallBackFunc const,
59 	const uint8_t
60 );
61 bool R_TMR_CreateUnitAll(
62 	const uint8_t,
63 	const uint32_t,
64 	const uint8_t,
65 	const uint16_t,
66 	const uint16_t,
67 	const uint16_t,
68 	VoidCallBackFunc const,
69 	VoidCallBackFunc const,
70 	VoidCallBackFunc const,
71 	const uint8_t
72 );
73 bool R_TMR_CreatePeriodicChannelAll(
74 	const uint8_t,
75 	const uint32_t,
76 	const float,
77 	const float,
78 	VoidCallBackFunc const,
79 	VoidCallBackFunc const,
80 	const uint8_t
81 );
82 bool R_TMR_CreatePeriodicUnitAll(
83 	const uint8_t,
84 	const uint32_t,
85 	const float,
86 	const float,
87 	VoidCallBackFunc const,
88 	VoidCallBackFunc const,
89 	const uint8_t
90 );
91 bool R_TMR_CreateOneShotChannelAll(
92 	const uint8_t,
93 	const uint32_t,
94 	const float,
95 	VoidCallBackFunc const,
96 	const uint8_t
97 );
98 bool R_TMR_CreateOneShotUnitAll(
99 	const uint8_t,
100 	const uint32_t,
101 	const float,
102 	VoidCallBackFunc const,
103 	const uint8_t
104 );
105 bool R_TMR_DestroyAll(
106 	const uint8_t
107 );
108 bool R_TMR_ControlChannelAll(
109 	const uint8_t,
110 	const uint32_t,
111 	const uint8_t,
112 	const uint8_t,
113 	const uint8_t
114 );
115 bool R_TMR_ControlUnitAll(
116 	const uint8_t,
117 	const uint32_t,
118 	const uint16_t,
119 	const uint16_t,
120 	const uint16_t
121 );
122 bool R_TMR_ControlPeriodicChannelAll(
123 	const uint8_t,
124 	const uint32_t,
125 	const float,
126 	const float
127 );
128 bool R_TMR_ControlPeriodicUnitAll(
129 	const uint8_t,
130 	const uint32_t,
131 	const float,
132 	const float
133 );
134 bool R_TMR_ReadChannelAll(
135 	const uint8_t,
136 	volatile uint8_t * const,
137 	volatile uint8_t * const,
138 	volatile uint8_t * const,
139 	volatile uint8_t * const
140 );
141 bool R_TMR_ReadUnitAll(
142 	const uint8_t,
143 	volatile uint8_t * const,
144 	volatile uint16_t * const,
145 	volatile uint16_t * const,
146 	volatile uint16_t * const
147 );
148 bool ReturnFalse(void);
149 
150 /* Macro definitions */
151 
152 #if defined (DEVICE_PACKAGE_LFBGA_176) || defined (DEVICE_PACKAGE_TFLGA_145) || \
153 	defined (DEVICE_PACKAGE_LQFP_144)
154 #define R_TMR_Set(a) \
155 ( R_TMR_SetAll( (a) ) )
156 #else
157 #define R_TMR_Set(a) \
158 ( ReturnFalse() )
159 #endif
160 
161 #define R_TMR_CreateChannel(a, b, c, d, e, f, g, h, i, j) \
162 ( \
163 ( ((a) < TMR_CHANNELS) && ((j) <= IPL_MAX) ) ? \
164 R_TMR_CreateChannelAll( (a), (b), (c), (d), (e), (f), (g), (h), (i), (j) ) : \
165 ReturnFalse() \
166 )
167 
168 #define R_TMR_CreateUnit(a, b, c, d, e, f, g, h, i, j) \
169 ( \
170 ( ((a) < TMR_UNITS) && ((j) <= IPL_MAX) ) ? \
171 R_TMR_CreateUnitAll( (a), (b), (c), (d), (e), (f), (g), (h), (i), (j) ): \
172 ReturnFalse() \
173 )
174 
175 #define R_TMR_CreatePeriodic(a, b, c, d, e, f, g) \
176 ( \
177 ( ((a) > PDL_TMR_UNIT1) || ((g) > IPL_MAX) ) ? \
178 ReturnFalse() : \
179 ( (a) <= PDL_TMR_TMR3) ? \
180 R_TMR_CreatePeriodicChannelAll( (a), (b), (c), (d), (e), (f), (g) ) : \
181 R_TMR_CreatePeriodicUnitAll( (a - PDL_TMR_UNIT0), (b), (c), (d), (e), (f), (g) ) \
182 )
183 
184 #define R_TMR_CreateOneShot(a, b, c, d, e) \
185 ( \
186 ( ((a) > PDL_TMR_UNIT1) || ((e) > IPL_MAX) ) ? \
187 ReturnFalse() : \
188 ( (a) <= PDL_TMR_TMR3 ) ? \
189 R_TMR_CreateOneShotChannelAll( (a), (b), (c), (d), (e) ) : \
190 R_TMR_CreateOneShotUnitAll( (a - PDL_TMR_UNIT0), (b), (c), (d), (e) ) \
191 )
192 
193 #define R_TMR_Destroy(a) \
194 ( \
195 ( (a) < TMR_UNITS ) ? \
196 R_TMR_DestroyAll( (a) ) : \
197 ReturnFalse() \
198 )
199 
200 #define R_TMR_ControlChannel(a, b, c, d, e) \
201 ( \
202 ( (a) < TMR_CHANNELS ) ? \
203 R_TMR_ControlChannelAll( (a), (b), (c), (d), (e) ) : \
204 ReturnFalse() \
205 )
206 
207 #define R_TMR_ControlUnit(a, b, c, d, e) \
208 ( \
209 ( (a) < TMR_UNITS ) ? \
210 R_TMR_ControlUnitAll( (a), (b), (c), (d), (e) ): \
211 ReturnFalse() \
212 )
213 
214 #define R_TMR_ControlPeriodic(a, b, c, d) \
215 ( \
216 ( (a) > PDL_TMR_UNIT1 ) ? \
217 ReturnFalse() : \
218 ( (a) <= PDL_TMR_TMR3 ) ? \
219 R_TMR_ControlPeriodicChannelAll( (a), (b), (float)(c), (float)(d) ) : \
220 R_TMR_ControlPeriodicUnitAll( (a - PDL_TMR_UNIT0), (b), (float)(c), (float)(d) ) \
221 )
222 
223 #define R_TMR_ReadChannel(a, b, c, d, e) \
224 ( \
225 ( (a) < TMR_CHANNELS ) ? \
226 R_TMR_ReadChannelAll( (a), (b), (c), (d), (uint8_t *)(e) ) : \
227 ReturnFalse() \
228 )
229 
230 #define R_TMR_ReadUnit(a, b, c, d, e) \
231 ( \
232 ( (a) < TMR_UNITS ) ? \
233 R_TMR_ReadUnitAll( (a), (b), (c), (d), (e) ) : \
234 ReturnFalse() \
235 )
236 
237 #endif
238 /* End of file */
239