r_pdl_iic_rx62nxfp.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*""FILE COMMENT""*******************************************************
  2. * System Name : I²C API for RX62Nxx (FP suffix)
  3. * File Name : r_pdl_iic_RX62NxFP.h
  4. * Version : 1.02
  5. * Contents : I²C 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_IIC_RX62NxFP_H
  23. #define R_PDL_IIC_RX62NxFP_H
  24. #define IIC_CHANNELS 1
  25. /* Globals */
  26. extern volatile uint8_t rpdl_IIC_stop[IIC_CHANNELS];
  27. extern volatile uint8_t rpdl_IIC_current_state[IIC_CHANNELS];
  28. extern volatile uint8_t rpdl_IIC_next_state[IIC_CHANNELS];
  29. extern volatile uint8_t rpdl_IIC_slave_address_lower[IIC_CHANNELS];
  30. extern volatile uint8_t rpdl_IIC_slave_address_upper[IIC_CHANNELS];
  31. extern const volatile uint8_t * rpdl_IIC_tx_data_pointer[IIC_CHANNELS];
  32. extern const volatile uint8_t * rpdl_IIC_tx_data_start[IIC_CHANNELS];
  33. extern volatile uint8_t * rpdl_IIC_rx_data_pointer[IIC_CHANNELS];
  34. extern volatile uint8_t * rpdl_IIC_rx_data_start[IIC_CHANNELS];
  35. extern volatile uint16_t rpdl_IIC_rx_counter[IIC_CHANNELS];
  36. extern volatile uint16_t rpdl_IIC_tx_counter[IIC_CHANNELS];
  37. extern volatile uint16_t rpdl_IIC_rx_threshold[IIC_CHANNELS];
  38. extern volatile uint16_t rpdl_IIC_tx_threshold[IIC_CHANNELS];
  39. extern volatile uint8_t rpdl_IIC_detected_address[IIC_CHANNELS];
  40. extern volatile uint8_t rpdl_IIC_rx_transfer_method[IIC_CHANNELS];
  41. extern volatile uint8_t rpdl_IIC_rx_dmac_channel[IIC_CHANNELS];
  42. extern volatile uint8_t rpdl_IIC_tx_dmac_channel[IIC_CHANNELS];
  43. /* IIC state machine states */
  44. typedef enum {
  45. IIC_SEND_START,
  46. IIC_MASTER_SEND_SLAVE_ADDRESS_7,
  47. IIC_MASTER_SEND_SLAVE_ADDRESS_10a,
  48. IIC_MASTER_SEND_SLAVE_ADDRESS_10b,
  49. IIC_MASTER_SEND_SLAVE_ADDRESS_10c,
  50. IIC_MASTER_SEND_SLAVE_ADDRESS_10d,
  51. IIC_MASTER_SEND_DATA,
  52. IIC_MASTER_WAIT_FOR_TX_COMPLETE,
  53. IIC_MASTER_WAIT_FOR_STOP,
  54. IIC_EXIT_LOOP,
  55. IIC_MASTER_START_READ,
  56. IIC_MASTER_READ_DATA,
  57. IIC_SEND_STOP,
  58. IIC_SLAVE_MONITOR,
  59. IIC_SLAVE_SEND_DATA,
  60. IIC_SLAVE_READ_SLAVE_ADDRESS,
  61. IIC_SLAVE_READ_DATA
  62. } iic_states;
  63. /* Transfer options */
  64. #define IIC_TRANSFER_CPU 0
  65. #define IIC_TRANSFER_DMAC 2
  66. #define IIC_TRANSFER_DTC 1
  67. /* Callback function prototype */
  68. extern VoidCallBackFunc rpdl_IIC_callback_func[IIC_CHANNELS];
  69. /* Library prototypes */
  70. bool R_IIC_CreateAll(
  71. const uint8_t,
  72. const uint32_t,
  73. const uint32_t,
  74. const uint16_t,
  75. const uint16_t,
  76. const uint16_t,
  77. const uint32_t,
  78. const uint32_t
  79. );
  80. bool R_IIC_DestroyAll(
  81. const uint8_t
  82. );
  83. bool R_IIC_MasterSendAll(
  84. const uint8_t,
  85. const uint16_t,
  86. const uint16_t,
  87. const volatile uint8_t * const,
  88. const uint16_t,
  89. VoidCallBackFunc const,
  90. const uint8_t
  91. );
  92. bool R_IIC_MasterReceiveAll(
  93. const uint8_t,
  94. const uint16_t,
  95. const uint16_t,
  96. volatile uint8_t * const,
  97. const uint16_t,
  98. VoidCallBackFunc const,
  99. const uint8_t
  100. );
  101. bool R_IIC_MasterReceiveLastAll(
  102. const uint8_t,
  103. volatile uint8_t * const
  104. );
  105. bool R_IIC_SlaveMonitorAll(
  106. const uint8_t,
  107. const uint16_t,
  108. volatile uint8_t * const,
  109. const uint16_t,
  110. VoidCallBackFunc const,
  111. const uint8_t
  112. );
  113. bool R_IIC_SlaveSendAll(
  114. const uint8_t,
  115. const volatile uint8_t * const,
  116. const uint16_t
  117. );
  118. bool R_IIC_ControlAll(
  119. const uint8_t,
  120. const uint8_t
  121. );
  122. bool R_IIC_GetStatusAll(
  123. const uint8_t,
  124. volatile uint32_t * const,
  125. volatile uint16_t * const,
  126. volatile uint16_t * const
  127. );
  128. bool ReturnFalse(void);
  129. /* Macro definitions */
  130. #define R_IIC_Create(a, b, c, d, e, f, g, h) \
  131. ( \
  132. ( (a) < IIC_CHANNELS ) ? \
  133. R_IIC_CreateAll( (a), (b), (c), (d), (e), (f), (g), (h) ) : \
  134. ReturnFalse() \
  135. )
  136. #define R_IIC_Destroy(a) \
  137. ( \
  138. ( (a) < IIC_CHANNELS ) ? \
  139. R_IIC_DestroyAll( (a) ) : \
  140. ReturnFalse() \
  141. )
  142. #define R_IIC_MasterSend(a, b, c, d, e, f, g) \
  143. ( \
  144. ( ( (a) < IIC_CHANNELS ) && ((g) <= IPL_MAX) ) ? \
  145. R_IIC_MasterSendAll( (a), (b), (c), (d), (e), (f), (g) ) : \
  146. ReturnFalse() \
  147. )
  148. #define R_IIC_MasterReceive(a, b, c, d, e, f, g) \
  149. ( \
  150. ( ( (a) < IIC_CHANNELS ) && ((g) <= IPL_MAX) ) ? \
  151. R_IIC_MasterReceiveAll( (a), (b), (c), (d), (e), (f), (g) ) : \
  152. ReturnFalse() \
  153. )
  154. #define R_IIC_MasterReceiveLast(a, b) \
  155. ( \
  156. ( (a) < IIC_CHANNELS ) ? \
  157. R_IIC_MasterReceiveLastAll( (a), (b) ) : \
  158. ReturnFalse() \
  159. )
  160. #define R_IIC_SlaveMonitor(a, b, c, d, e, f) \
  161. ( \
  162. ( ( (a) < IIC_CHANNELS ) && ((f) <= IPL_MAX) ) ? \
  163. R_IIC_SlaveMonitorAll( (a), (b), (c), (d), (e), (f) ) : \
  164. ReturnFalse() \
  165. )
  166. #define R_IIC_SlaveSend(a, b, c) \
  167. ( \
  168. ( (a) < IIC_CHANNELS ) ? \
  169. R_IIC_SlaveSendAll( (a), (b), (c) ) : \
  170. ReturnFalse() \
  171. )
  172. #define R_IIC_Control(a, b) \
  173. ( \
  174. ( (a) < IIC_CHANNELS ) ? \
  175. R_IIC_ControlAll( (a), (b) ) : \
  176. ReturnFalse() \
  177. )
  178. #define R_IIC_GetStatus(a, b, c, d) \
  179. ( \
  180. ( (a) < IIC_CHANNELS ) ? \
  181. R_IIC_GetStatusAll( (a), (b), (c), (d) ) : \
  182. ReturnFalse() \
  183. )
  184. #endif
  185. /* End of file */