r_pdl_spi_rx62nxx.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*""FILE COMMENT""*******************************************************
  2. * System Name : Serial Peripheral Interface API for RX62Nxx
  3. * File Name : r_pdl_spi_RX62Nxx.h
  4. * Version : 1.02
  5. * Contents : SPI 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_SPI_RX62Nxx_H
  23. #define R_PDL_SPI_RX62Nxx_H
  24. #define SPI_CHANNELS 2
  25. #define SPI_COMMANDS 8
  26. /* Globals */
  27. extern volatile uint8_t rpdl_SPI_method[SPI_CHANNELS];
  28. extern volatile uint16_t rpdl_SPI_sequence_count[SPI_CHANNELS];
  29. extern volatile uint16_t rpdl_SPI_tx_sequence_counter[SPI_CHANNELS];
  30. extern volatile uint16_t rpdl_SPI_rx_sequence_counter[SPI_CHANNELS];
  31. extern volatile uint8_t rpdl_SPI_tx_frame_counter[SPI_CHANNELS];
  32. extern volatile uint8_t rpdl_SPI_frame_total[SPI_CHANNELS];
  33. extern volatile uint8_t rpdl_SPI_rx_frame_counter[SPI_CHANNELS];
  34. extern volatile const uint32_t * rpdl_SPI_tx_ptr[SPI_CHANNELS];
  35. extern volatile uint32_t * rpdl_SPI_rx_ptr[SPI_CHANNELS];
  36. /* Callback function prototypes */
  37. extern VoidCallBackFunc rpdl_SPI_callback_func[SPI_CHANNELS];
  38. /* Request trigger options */
  39. typedef enum {
  40. SPI_USING_POLLING,
  41. SPI_USING_IRQ,
  42. SPI_USING_DMAC_DTC
  43. } rpdl_spi_transfer_options;
  44. bool R_SPI_CreateAll(
  45. const uint8_t,
  46. const uint32_t,
  47. const uint32_t,
  48. const uint32_t,
  49. const uint32_t
  50. );
  51. bool R_SPI_DestroyAll(
  52. const uint8_t
  53. );
  54. bool R_SPI_CommandAll(
  55. const uint8_t,
  56. const uint8_t,
  57. const uint32_t,
  58. const uint8_t
  59. );
  60. bool R_SPI_TransferAll(
  61. const uint8_t,
  62. const uint8_t,
  63. volatile const uint32_t * const,
  64. volatile uint32_t * const,
  65. const uint16_t,
  66. VoidCallBackFunc const,
  67. const uint8_t
  68. );
  69. bool R_SPI_ControlAll(
  70. const uint8_t,
  71. const uint8_t,
  72. const uint32_t
  73. );
  74. bool R_SPI_GetStatusAll(
  75. const uint8_t,
  76. volatile uint16_t * const,
  77. volatile uint16_t * const
  78. );
  79. bool ReturnFalse(void);
  80. /* Macro definitions */
  81. #define R_SPI_Create(a, b, c, d, e) \
  82. ( \
  83. ( (a) < SPI_CHANNELS) ? \
  84. R_SPI_CreateAll( (a), (b), (c), (d), (e) ): \
  85. ReturnFalse() \
  86. )
  87. #define R_SPI_Destroy(a) \
  88. ( \
  89. ( (a) < SPI_CHANNELS) ? \
  90. R_SPI_DestroyAll( (a) ): \
  91. ReturnFalse() \
  92. )
  93. #define R_SPI_Command(a, b, c, d) \
  94. ( \
  95. ( ( ((a) < SPI_CHANNELS) && ((b) < SPI_COMMANDS) ) ) ? \
  96. R_SPI_CommandAll( (a), (b), (c), (d) ): \
  97. ReturnFalse() \
  98. )
  99. #define R_SPI_Transfer(a, b, c, d, e, f, g) \
  100. ( \
  101. ( ( ((a) < SPI_CHANNELS) && ((g) <= IPL_MAX) ) ) ? \
  102. R_SPI_TransferAll( (a), (b), (c), (d), (e), (f), (g) ): \
  103. ReturnFalse() \
  104. )
  105. #define R_SPI_Control(a, b, c) \
  106. ( \
  107. ( (a) < SPI_CHANNELS) ? \
  108. R_SPI_ControlAll( (a), (b), (c) ): \
  109. ReturnFalse() \
  110. )
  111. #define R_SPI_GetStatus(a, b, c) \
  112. ( \
  113. ( (a) < SPI_CHANNELS) ? \
  114. R_SPI_GetStatusAll( (a), (b), (c) ): \
  115. ReturnFalse() \
  116. )
  117. #endif
  118. /* End of file */