soc_ppi.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Copyright (c) 2020 Actions Technology Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file peripheral reset configuration macros for Actions SoC
  8. */
  9. #ifndef _ACTIONS_SOC_PPI_H_
  10. #define _ACTIONS_SOC_PPI_H_
  11. /******************************************************************************/
  12. //constants
  13. /******************************************************************************/
  14. // selection of ppi channel which wants to configure
  15. enum ppi_ch_cfg_sel {
  16. PPI_CH0 = 0,
  17. PPI_CH1,
  18. PPI_CH2,
  19. PPI_CH3,
  20. PPI_CH4,
  21. PPI_CH5,
  22. PPI_CH6,
  23. PPI_CH7,
  24. PPI_CH8,
  25. PPI_CH9,
  26. PPI_CH10,
  27. PPI_CH11
  28. };
  29. // selection of task which links to ppi channel
  30. enum ppi_ch_cfg_task_sel {
  31. SPIMT0_TASK0 = 0,
  32. SPIMT0_TASK1,
  33. SPIMT0_TASK2,
  34. SPIMT0_TASK3,
  35. SPIMT0_TASK4,
  36. SPIMT0_TASK5,
  37. SPIMT0_TASK6,
  38. SPIMT0_TASK7,
  39. SPIMT1_TASK0,
  40. SPIMT1_TASK1,
  41. SPIMT1_TASK2,
  42. SPIMT1_TASK3,
  43. SPIMT1_TASK4,
  44. SPIMT1_TASK5,
  45. SPIMT1_TASK6,
  46. SPIMT1_TASK7,
  47. I2CMT0_TASK0,
  48. I2CMT0_TASK1,
  49. I2CMT0_TASK2,
  50. I2CMT0_TASK3,
  51. I2CMT1_TASK0,
  52. I2CMT1_TASK1,
  53. I2CMT1_TASK2,
  54. I2CMT1_TASK3,
  55. };
  56. // selection of trigger source which acts on ppi channel
  57. enum ppi_trig_src_sel {
  58. TIMER0 = 0,
  59. TIMER1,
  60. TIMER2,
  61. TIMER3,
  62. TIMER4,
  63. IO0_IRQ,
  64. IO1_IRQ,
  65. IO2_IRQ,
  66. IO3_IRQ,
  67. IO4_IRQ,
  68. IO5_IRQ,
  69. IO6_IRQ,
  70. IO7_IRQ,
  71. IO8_IRQ,
  72. IO9_IRQ,
  73. IO10_IRQ,
  74. IO11_IRQ,
  75. SPIMT0_TASK0_CIP,
  76. SPIMT0_TASK1_CIP,
  77. SPIMT0_TASK2_CIP,
  78. SPIMT0_TASK3_CIP,
  79. SPIMT0_TASK4_CIP,
  80. SPIMT0_TASK5_CIP,
  81. SPIMT0_TASK6_CIP,
  82. SPIMT0_TASK7_CIP,
  83. SPIMT1_TASK0_CIP,
  84. SPIMT1_TASK1_CIP,
  85. SPIMT1_TASK2_CIP,
  86. SPIMT1_TASK3_CIP,
  87. SPIMT1_TASK4_CIP,
  88. SPIMT1_TASK5_CIP,
  89. SPIMT1_TASK6_CIP,
  90. SPIMT1_TASK7_CIP,
  91. I2CMT0_TASK0_CIP,
  92. I2CMT0_TASK1_CIP,
  93. I2CMT0_TASK2_CIP,
  94. I2CMT0_TASK3_CIP,
  95. I2CMT1_TASK0_CIP,
  96. I2CMT1_TASK1_CIP,
  97. I2CMT1_TASK2_CIP,
  98. I2CMT1_TASK3_CIP,
  99. TIMER5,
  100. };
  101. /******************************************************************************/
  102. //functions
  103. /******************************************************************************/
  104. /**
  105. * @brief Init PPI module.
  106. *
  107. * @param N/A
  108. *
  109. * @return N/A
  110. */
  111. void ppi_init(void);
  112. /**
  113. * @brief Enable ppi trigger source.
  114. *
  115. * @param trig_src The trigger source.
  116. * @param enable Enable or disable.
  117. *
  118. * @return N/A
  119. */
  120. void ppi_trig_src_en(int trig_src, int enable);
  121. /**
  122. * @brief Configure the attribute of a ppi channel.
  123. *
  124. * @param ppi_channel The channel which wants to configure. See enum ppi_ch_cfg_sel
  125. * for more details.
  126. * @param task_select The task which links to this ppi channel. See enum ppi_ch_cfg_task_sel
  127. * for more details.
  128. * @param trig_src_select The trigger source which wants to acts on this ppi channel.
  129. * See enum ppi_trig_src_sel for more details.
  130. *
  131. * @return N/A
  132. */
  133. void ppi_task_trig_config(int ppi_channel, int task_select, int trig_src_select);
  134. /**
  135. * @brief Check if ppi trigger source has pending.
  136. *
  137. * @param ppi_trig_src The trigger source which wants to check. See enum
  138. ppi_trig_src_sel for more details.
  139. *
  140. * @return 1: pending 0: no pending
  141. */
  142. int ppi_trig_src_is_pending(int ppi_trig_src);
  143. /**
  144. * @brief Clear ppi trigger source pending.
  145. *
  146. * @param ppi_trig_src The trigger source pending which wants to clear.
  147. * See enum ppi_trig_src_sel for more details.
  148. *
  149. * @return N/A
  150. */
  151. void ppi_trig_src_clr_pending(int ppi_trig_src);
  152. #endif /* _ACTIONS_SOC_PPI_H_ */