summaryrefslogtreecommitdiff
path: root/bsp/rx/RPDL/r_pdl_tmr_rx62nxx.h
blob: d1e2978dce60dc827f16f834441dc5e2507fb4ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
/*""FILE COMMENT""*******************************************************
* System Name	: Timer TMR API for RX62Nxx
* File Name		: r_pdl_tmr_RX62Nxx.h
* Version		: 1.02
* Contents		: Timer TMR API header
* Customer		: 
* Model			: 
* Order			: 
* CPU			: RX
* Compiler		: RXC
* OS			: Nothing
* Programmer	: 
* Note			: 
************************************************************************
* Copyright, 2011. Renesas Electronics Corporation
* and Renesas Solutions Corporation
************************************************************************
* History		: 2011.04.08
*				: Ver 1.02
*				: CS-5 release.
*""FILE COMMENT END""**************************************************/

#ifndef R_PDL_TMR_RX62Nxx_H
#define R_PDL_TMR_RX62Nxx_H

#define TMR_UNITS 				2
#define TMR_CHANNELS_PER_UNIT	2
#define TMR_CHANNELS (uint8_t)(TMR_UNITS * TMR_CHANNELS_PER_UNIT)

/* One-shot modes */
#define CHANNEL_MODE	0x01u
#define UNIT_MODE		0x02u

/* Callback function storage */
extern VoidCallBackFunc rpdl_TMR_Overflow_callback_func[TMR_CHANNELS];
extern VoidCallBackFunc rpdl_TMR_CMA_callback_func[TMR_CHANNELS];
extern VoidCallBackFunc rpdl_TMR_CMB_callback_func[TMR_CHANNELS];

/* Global variables */
extern volatile  uint8_t rpdl_TMR_tcsr_setting[TMR_CHANNELS];
extern volatile  uint8_t rpdl_TMR_tccr8_setting[TMR_CHANNELS];
extern volatile uint16_t rpdl_TMR_tccr16_setting[TMR_UNITS];
extern volatile  uint8_t rpdl_TMR_one_shot[TMR_CHANNELS];

/* Library prototypes */
bool R_TMR_SetAll(
	const uint8_t
);
bool R_TMR_CreateChannelAll(
	const uint8_t,
	const uint32_t,
	const uint8_t,
	const uint8_t,
	const uint8_t,
	const uint8_t,
	VoidCallBackFunc const,
	VoidCallBackFunc const,
	VoidCallBackFunc const,
	const uint8_t
);
bool R_TMR_CreateUnitAll(
	const uint8_t,
	const uint32_t,
	const uint8_t,
	const uint16_t,
	const uint16_t,
	const uint16_t,
	VoidCallBackFunc const,
	VoidCallBackFunc const,
	VoidCallBackFunc const,
	const uint8_t
);
bool R_TMR_CreatePeriodicChannelAll(
	const uint8_t,
	const uint32_t,
	const float,
	const float,
	VoidCallBackFunc const,
	VoidCallBackFunc const,
	const uint8_t
);
bool R_TMR_CreatePeriodicUnitAll(
	const uint8_t,
	const uint32_t,
	const float,
	const float,
	VoidCallBackFunc const,
	VoidCallBackFunc const,
	const uint8_t
);
bool R_TMR_CreateOneShotChannelAll(
	const uint8_t,
	const uint32_t,
	const float,
	VoidCallBackFunc const,
	const uint8_t
);
bool R_TMR_CreateOneShotUnitAll(
	const uint8_t,
	const uint32_t,
	const float,
	VoidCallBackFunc const,
	const uint8_t
);
bool R_TMR_DestroyAll(
	const uint8_t
);
bool R_TMR_ControlChannelAll(
	const uint8_t,
	const uint32_t,
	const uint8_t,
	const uint8_t,
	const uint8_t
);
bool R_TMR_ControlUnitAll(
	const uint8_t,
	const uint32_t,
	const uint16_t,
	const uint16_t,
	const uint16_t
);
bool R_TMR_ControlPeriodicChannelAll(
	const uint8_t,
	const uint32_t,
	const float,
	const float
);
bool R_TMR_ControlPeriodicUnitAll(
	const uint8_t,
	const uint32_t,
	const float,
	const float
);
bool R_TMR_ReadChannelAll(
	const uint8_t,
	volatile uint8_t * const,
	volatile uint8_t * const,
	volatile uint8_t * const,
	volatile uint8_t * const
);
bool R_TMR_ReadUnitAll(
	const uint8_t,
	volatile uint8_t * const,
	volatile uint16_t * const,
	volatile uint16_t * const,
	volatile uint16_t * const
);
bool ReturnFalse(void);

/* Macro definitions */

#if defined (DEVICE_PACKAGE_LFBGA_176) || defined (DEVICE_PACKAGE_TFLGA_145) || \
	defined (DEVICE_PACKAGE_LQFP_144)
#define R_TMR_Set(a) \
( R_TMR_SetAll( (a) ) )
#else
#define R_TMR_Set(a) \
( ReturnFalse() )
#endif

#define R_TMR_CreateChannel(a, b, c, d, e, f, g, h, i, j) \
( \
( ((a) < TMR_CHANNELS) && ((j) <= IPL_MAX) ) ? \
R_TMR_CreateChannelAll( (a), (b), (c), (d), (e), (f), (g), (h), (i), (j) ) : \
ReturnFalse() \
)

#define R_TMR_CreateUnit(a, b, c, d, e, f, g, h, i, j) \
( \
( ((a) < TMR_UNITS) && ((j) <= IPL_MAX) ) ? \
R_TMR_CreateUnitAll( (a), (b), (c), (d), (e), (f), (g), (h), (i), (j) ): \
ReturnFalse() \
)

#define R_TMR_CreatePeriodic(a, b, c, d, e, f, g) \
( \
( ((a) > PDL_TMR_UNIT1) || ((g) > IPL_MAX) ) ? \
ReturnFalse() : \
( (a) <= PDL_TMR_TMR3) ? \
R_TMR_CreatePeriodicChannelAll( (a), (b), (c), (d), (e), (f), (g) ) : \
R_TMR_CreatePeriodicUnitAll( (a - PDL_TMR_UNIT0), (b), (c), (d), (e), (f), (g) ) \
)

#define R_TMR_CreateOneShot(a, b, c, d, e) \
( \
( ((a) > PDL_TMR_UNIT1) || ((e) > IPL_MAX) ) ? \
ReturnFalse() : \
( (a) <= PDL_TMR_TMR3 ) ? \
R_TMR_CreateOneShotChannelAll( (a), (b), (c), (d), (e) ) : \
R_TMR_CreateOneShotUnitAll( (a - PDL_TMR_UNIT0), (b), (c), (d), (e) ) \
)

#define R_TMR_Destroy(a) \
( \
( (a) < TMR_UNITS ) ? \
R_TMR_DestroyAll( (a) ) : \
ReturnFalse() \
)

#define R_TMR_ControlChannel(a, b, c, d, e) \
( \
( (a) < TMR_CHANNELS ) ? \
R_TMR_ControlChannelAll( (a), (b), (c), (d), (e) ) : \
ReturnFalse() \
)

#define R_TMR_ControlUnit(a, b, c, d, e) \
( \
( (a) < TMR_UNITS ) ? \
R_TMR_ControlUnitAll( (a), (b), (c), (d), (e) ): \
ReturnFalse() \
)

#define R_TMR_ControlPeriodic(a, b, c, d) \
( \
( (a) > PDL_TMR_UNIT1 ) ? \
ReturnFalse() : \
( (a) <= PDL_TMR_TMR3 ) ? \
R_TMR_ControlPeriodicChannelAll( (a), (b), (float)(c), (float)(d) ) : \
R_TMR_ControlPeriodicUnitAll( (a - PDL_TMR_UNIT0), (b), (float)(c), (float)(d) ) \
)

#define R_TMR_ReadChannel(a, b, c, d, e) \
( \
( (a) < TMR_CHANNELS ) ? \
R_TMR_ReadChannelAll( (a), (b), (c), (d), (uint8_t *)(e) ) : \
ReturnFalse() \
)

#define R_TMR_ReadUnit(a, b, c, d, e) \
( \
( (a) < TMR_UNITS ) ? \
R_TMR_ReadUnitAll( (a), (b), (c), (d), (e) ) : \
ReturnFalse() \
)

#endif
/* End of file */