r_pdl_tmr_rx62nxx.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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. #ifndef R_PDL_TMR_RX62Nxx_H
  23. #define R_PDL_TMR_RX62Nxx_H
  24. #define TMR_UNITS 2
  25. #define TMR_CHANNELS_PER_UNIT 2
  26. #define TMR_CHANNELS (uint8_t)(TMR_UNITS * TMR_CHANNELS_PER_UNIT)
  27. /* One-shot modes */
  28. #define CHANNEL_MODE 0x01u
  29. #define UNIT_MODE 0x02u
  30. /* Callback function storage */
  31. extern VoidCallBackFunc rpdl_TMR_Overflow_callback_func[TMR_CHANNELS];
  32. extern VoidCallBackFunc rpdl_TMR_CMA_callback_func[TMR_CHANNELS];
  33. extern VoidCallBackFunc rpdl_TMR_CMB_callback_func[TMR_CHANNELS];
  34. /* Global variables */
  35. extern volatile uint8_t rpdl_TMR_tcsr_setting[TMR_CHANNELS];
  36. extern volatile uint8_t rpdl_TMR_tccr8_setting[TMR_CHANNELS];
  37. extern volatile uint16_t rpdl_TMR_tccr16_setting[TMR_UNITS];
  38. extern volatile uint8_t rpdl_TMR_one_shot[TMR_CHANNELS];
  39. /* Library prototypes */
  40. bool R_TMR_SetAll(
  41. const uint8_t
  42. );
  43. bool R_TMR_CreateChannelAll(
  44. const uint8_t,
  45. const uint32_t,
  46. const uint8_t,
  47. const uint8_t,
  48. const uint8_t,
  49. const uint8_t,
  50. VoidCallBackFunc const,
  51. VoidCallBackFunc const,
  52. VoidCallBackFunc const,
  53. const uint8_t
  54. );
  55. bool R_TMR_CreateUnitAll(
  56. const uint8_t,
  57. const uint32_t,
  58. const uint8_t,
  59. const uint16_t,
  60. const uint16_t,
  61. const uint16_t,
  62. VoidCallBackFunc const,
  63. VoidCallBackFunc const,
  64. VoidCallBackFunc const,
  65. const uint8_t
  66. );
  67. bool R_TMR_CreatePeriodicChannelAll(
  68. const uint8_t,
  69. const uint32_t,
  70. const float,
  71. const float,
  72. VoidCallBackFunc const,
  73. VoidCallBackFunc const,
  74. const uint8_t
  75. );
  76. bool R_TMR_CreatePeriodicUnitAll(
  77. const uint8_t,
  78. const uint32_t,
  79. const float,
  80. const float,
  81. VoidCallBackFunc const,
  82. VoidCallBackFunc const,
  83. const uint8_t
  84. );
  85. bool R_TMR_CreateOneShotChannelAll(
  86. const uint8_t,
  87. const uint32_t,
  88. const float,
  89. VoidCallBackFunc const,
  90. const uint8_t
  91. );
  92. bool R_TMR_CreateOneShotUnitAll(
  93. const uint8_t,
  94. const uint32_t,
  95. const float,
  96. VoidCallBackFunc const,
  97. const uint8_t
  98. );
  99. bool R_TMR_DestroyAll(
  100. const uint8_t
  101. );
  102. bool R_TMR_ControlChannelAll(
  103. const uint8_t,
  104. const uint32_t,
  105. const uint8_t,
  106. const uint8_t,
  107. const uint8_t
  108. );
  109. bool R_TMR_ControlUnitAll(
  110. const uint8_t,
  111. const uint32_t,
  112. const uint16_t,
  113. const uint16_t,
  114. const uint16_t
  115. );
  116. bool R_TMR_ControlPeriodicChannelAll(
  117. const uint8_t,
  118. const uint32_t,
  119. const float,
  120. const float
  121. );
  122. bool R_TMR_ControlPeriodicUnitAll(
  123. const uint8_t,
  124. const uint32_t,
  125. const float,
  126. const float
  127. );
  128. bool R_TMR_ReadChannelAll(
  129. const uint8_t,
  130. volatile uint8_t * const,
  131. volatile uint8_t * const,
  132. volatile uint8_t * const,
  133. volatile uint8_t * const
  134. );
  135. bool R_TMR_ReadUnitAll(
  136. const uint8_t,
  137. volatile uint8_t * const,
  138. volatile uint16_t * const,
  139. volatile uint16_t * const,
  140. volatile uint16_t * const
  141. );
  142. bool ReturnFalse(void);
  143. /* Macro definitions */
  144. #if defined (DEVICE_PACKAGE_LFBGA_176) || defined (DEVICE_PACKAGE_TFLGA_145) || \
  145. defined (DEVICE_PACKAGE_LQFP_144)
  146. #define R_TMR_Set(a) \
  147. ( R_TMR_SetAll( (a) ) )
  148. #else
  149. #define R_TMR_Set(a) \
  150. ( ReturnFalse() )
  151. #endif
  152. #define R_TMR_CreateChannel(a, b, c, d, e, f, g, h, i, j) \
  153. ( \
  154. ( ((a) < TMR_CHANNELS) && ((j) <= IPL_MAX) ) ? \
  155. R_TMR_CreateChannelAll( (a), (b), (c), (d), (e), (f), (g), (h), (i), (j) ) : \
  156. ReturnFalse() \
  157. )
  158. #define R_TMR_CreateUnit(a, b, c, d, e, f, g, h, i, j) \
  159. ( \
  160. ( ((a) < TMR_UNITS) && ((j) <= IPL_MAX) ) ? \
  161. R_TMR_CreateUnitAll( (a), (b), (c), (d), (e), (f), (g), (h), (i), (j) ): \
  162. ReturnFalse() \
  163. )
  164. #define R_TMR_CreatePeriodic(a, b, c, d, e, f, g) \
  165. ( \
  166. ( ((a) > PDL_TMR_UNIT1) || ((g) > IPL_MAX) ) ? \
  167. ReturnFalse() : \
  168. ( (a) <= PDL_TMR_TMR3) ? \
  169. R_TMR_CreatePeriodicChannelAll( (a), (b), (c), (d), (e), (f), (g) ) : \
  170. R_TMR_CreatePeriodicUnitAll( (a - PDL_TMR_UNIT0), (b), (c), (d), (e), (f), (g) ) \
  171. )
  172. #define R_TMR_CreateOneShot(a, b, c, d, e) \
  173. ( \
  174. ( ((a) > PDL_TMR_UNIT1) || ((e) > IPL_MAX) ) ? \
  175. ReturnFalse() : \
  176. ( (a) <= PDL_TMR_TMR3 ) ? \
  177. R_TMR_CreateOneShotChannelAll( (a), (b), (c), (d), (e) ) : \
  178. R_TMR_CreateOneShotUnitAll( (a - PDL_TMR_UNIT0), (b), (c), (d), (e) ) \
  179. )
  180. #define R_TMR_Destroy(a) \
  181. ( \
  182. ( (a) < TMR_UNITS ) ? \
  183. R_TMR_DestroyAll( (a) ) : \
  184. ReturnFalse() \
  185. )
  186. #define R_TMR_ControlChannel(a, b, c, d, e) \
  187. ( \
  188. ( (a) < TMR_CHANNELS ) ? \
  189. R_TMR_ControlChannelAll( (a), (b), (c), (d), (e) ) : \
  190. ReturnFalse() \
  191. )
  192. #define R_TMR_ControlUnit(a, b, c, d, e) \
  193. ( \
  194. ( (a) < TMR_UNITS ) ? \
  195. R_TMR_ControlUnitAll( (a), (b), (c), (d), (e) ): \
  196. ReturnFalse() \
  197. )
  198. #define R_TMR_ControlPeriodic(a, b, c, d) \
  199. ( \
  200. ( (a) > PDL_TMR_UNIT1 ) ? \
  201. ReturnFalse() : \
  202. ( (a) <= PDL_TMR_TMR3 ) ? \
  203. R_TMR_ControlPeriodicChannelAll( (a), (b), (float)(c), (float)(d) ) : \
  204. R_TMR_ControlPeriodicUnitAll( (a - PDL_TMR_UNIT0), (b), (float)(c), (float)(d) ) \
  205. )
  206. #define R_TMR_ReadChannel(a, b, c, d, e) \
  207. ( \
  208. ( (a) < TMR_CHANNELS ) ? \
  209. R_TMR_ReadChannelAll( (a), (b), (c), (d), (uint8_t *)(e) ) : \
  210. ReturnFalse() \
  211. )
  212. #define R_TMR_ReadUnit(a, b, c, d, e) \
  213. ( \
  214. ( (a) < TMR_UNITS ) ? \
  215. R_TMR_ReadUnitAll( (a), (b), (c), (d), (e) ) : \
  216. ReturnFalse() \
  217. )
  218. #endif
  219. /* End of file */