nu_psio.h 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191
  1. /**************************************************************************//**
  2. * @file nu_psio.h
  3. * @version V3.00
  4. * @brief M460 series PSIO driver header file
  5. *
  6. * @copyright SPDX-License-Identifier: Apache-2.0
  7. * @copyright Copyright (C) 2021 Nuvoton Technology Corp. All rights reserved.
  8. *****************************************************************************/
  9. #ifndef __NU_PSIO_H__
  10. #define __NU_PSIO_H__
  11. #ifdef __cplusplus
  12. extern "C"
  13. {
  14. #endif
  15. /** @addtogroup Standard_Driver Standard Driver
  16. @{
  17. */
  18. /** @addtogroup PSIO_Driver PSIO Driver
  19. @{
  20. */
  21. /** @addtogroup PSIO_EXPORTED_CONSTANTS PSIO Exported Constants
  22. @{
  23. */
  24. /*---------------------------------------------------------------------------------------------------------*/
  25. /* Operation Mode Constant Definitions */
  26. /*---------------------------------------------------------------------------------------------------------*/
  27. #define PSIO_SC0 0x00000000UL /*!<PSIO Slot Controller 0 \hideinitializer */
  28. #define PSIO_SC1 0x00000001UL /*!<PSIO Slot Controller 1 \hideinitializer */
  29. #define PSIO_SC2 0x00000002UL /*!<PSIO Slot Controller 2 \hideinitializer */
  30. #define PSIO_SC3 0x00000003UL /*!<PSIO Slot Controller 3 \hideinitializer */
  31. #define PSIO_INT0 0x00000000UL /*!<PSIO Interrupt 0 \hideinitializer */
  32. #define PSIO_INT1 0x00000001UL /*!<PSIO Interrupt 1 \hideinitializer */
  33. #define PSIO_SLOT_DISABLE 0x00000000UL /*!<PSIO Slot disable \hideinitializer */
  34. #define PSIO_SLOT0 0x00000001UL /*!<PSIO Slot 0 \hideinitializer */
  35. #define PSIO_SLOT1 0x00000002UL /*!<PSIO Slot 1 \hideinitializer */
  36. #define PSIO_SLOT2 0x00000003UL /*!<PSIO Slot 2 \hideinitializer */
  37. #define PSIO_SLOT3 0x00000004UL /*!<PSIO Slot 3 \hideinitializer */
  38. #define PSIO_SLOT4 0x00000005UL /*!<PSIO Slot 4 \hideinitializer */
  39. #define PSIO_SLOT5 0x00000006UL /*!<PSIO Slot 5 \hideinitializer */
  40. #define PSIO_SLOT6 0x00000007UL /*!<PSIO Slot 6 \hideinitializer */
  41. #define PSIO_SLOT7 0x00000008UL /*!<PSIO Slot 7 \hideinitializer */
  42. #define PSIO_PIN0 0x00000000UL /*!<PSIO Pin 0 \hideinitializer */
  43. #define PSIO_PIN1 0x00000001UL /*!<PSIO Pin 1 \hideinitializer */
  44. #define PSIO_PIN2 0x00000002UL /*!<PSIO Pin 2 \hideinitializer */
  45. #define PSIO_PIN3 0x00000003UL /*!<PSIO Pin 3 \hideinitializer */
  46. #define PSIO_PIN4 0x00000004UL /*!<PSIO Pin 4 \hideinitializer */
  47. #define PSIO_PIN5 0x00000005UL /*!<PSIO Pin 5 \hideinitializer */
  48. #define PSIO_PIN6 0x00000006UL /*!<PSIO Pin 6 \hideinitializer */
  49. #define PSIO_PIN7 0x00000007UL /*!<PSIO Pin 7 \hideinitializer */
  50. #define PSIO_CP0 0x00000000UL /*!<PSIO Check Point 0 \hideinitializer */
  51. #define PSIO_CP1 0x00000001UL /*!<PSIO Check Point 1 \hideinitializer */
  52. #define PSIO_CP2 0x00000002UL /*!<PSIO Check Point 2 \hideinitializer */
  53. #define PSIO_CP3 0x00000003UL /*!<PSIO Check Point 3 \hideinitializer */
  54. #define PSIO_CP4 0x00000004UL /*!<PSIO Check Point 4 \hideinitializer */
  55. #define PSIO_CP5 0x00000005UL /*!<PSIO Check Point 5 \hideinitializer */
  56. #define PSIO_CP6 0x00000006UL /*!<PSIO Check Point 6 \hideinitializer */
  57. #define PSIO_CP7 0x00000007UL /*!<PSIO Check Point 7 \hideinitializer */
  58. #define PSIO_PIN_ENABLE 0x00000001UL /*!<PSIO Pin Enable \hideinitializer */
  59. #define PSIO_PIN_DISABLE 0x00000000UL /*!<PSIO Pin Disable \hideinitializer */
  60. #define PSIO_SW_TRIGGER (0x0UL<<PSIO_SCCT_SCCTL_TRIGSRC_Pos) /*!<PSIO Software Trigger \hideinitializer */
  61. #define PSIO_FALLING_TRIGGER (0x1UL<<PSIO_SCCT_SCCTL_TRIGSRC_Pos) /*!<PSIO Falling Edge Trigger \hideinitializer */
  62. #define PSIO_RISING_TRIGGER (0x2UL<<PSIO_SCCT_SCCTL_TRIGSRC_Pos) /*!<PSIO Rising Edge Trigger \hideinitializer */
  63. #define PSIO_BOTH_EDGE_TRIGGER (0x3UL<<PSIO_SCCT_SCCTL_TRIGSRC_Pos) /*!<PSIO Both Edge Trigger \hideinitializer */
  64. #define PSIO_REPEAT_ENABLE 0x00000001UL /*!<PSIO Repeat Mode Enable \hideinitializer */
  65. #define PSIO_REPEAT_DISABLE 0x00000000UL /*!<PSIO Repeat Mode Disable \hideinitializer */
  66. #define PSIO_INPUT_MODE 0x00000000UL /*!<PSIO Input Mode \hideinitializer */
  67. #define PSIO_OUTPUT_MODE 0x00000001UL /*!<PSIO Output Mode \hideinitializer */
  68. #define PSIO_OPENDRAIN_MODE 0x00000002UL /*!<PSIO Open-drain Mode \hideinitializer */
  69. #define PSIO_QUASI_MODE 0x00000003UL /*!<PSIO Quasi Mode \hideinitializer */
  70. #define PSIO_LOW_LEVEL 0x00000000UL /*!<PSIO Low Level \hideinitializer */
  71. #define PSIO_HIGH_LEVEL 0x00000001UL /*!<PSIO High Level \hideinitializer */
  72. #define PSIO_LAST_OUTPUT 0x00000002UL /*!<PSIO Last Output \hideinitializer */
  73. #define PSIO_Toggle 0x00000003UL /*!<PSIO Toggle \hideinitializer */
  74. #define PSIO_SWITCH_P0 0x00000000UL /*!<PSIO Switch Point 0 \hideinitializer */
  75. #define PSIO_SWITCH_P1 0x00000001UL /*!<PSIO Switch Point 1 \hideinitializer */
  76. #define PSIO_LSB (0x0UL<<PSIO_GNCT_DATCTL_ORDER_Pos) /*!<PSIO Data LSB \hideinitializer */
  77. #define PSIO_MSB (0x1UL<<PSIO_GNCT_DATCTL_ORDER_Pos) /*!<PSIO Data MSB \hideinitializer */
  78. #define PSIO_DEPTH1 0x00000000UL /*!<PSIO Data Depth 1 \hideinitializer */
  79. #define PSIO_DEPTH2 0x00000001UL /*!<PSIO Data Depth 2 \hideinitializer */
  80. #define PSIO_DEPTH3 0x00000002UL /*!<PSIO Data Depth 3 \hideinitializer */
  81. #define PSIO_DEPTH4 0x00000003UL /*!<PSIO Data Depth 4 \hideinitializer */
  82. #define PSIO_NO_ACTION 0x00000000UL /*!<PSIO no action \hideinitializer */
  83. #define PSIO_OUT_LOW 0x00000000UL /*!<PSIO Output Low \hideinitializer */
  84. #define PSIO_OUT_HIGH 0x00000001UL /*!<PSIO Output High \hideinitializer */
  85. #define PSIO_OUT_BUFFER 0x00000002UL /*!<PSIO Output form Buffer \hideinitializer */
  86. #define PSIO_OUT_TOGGLE 0x00000003UL /*!<PSIO Output Toggle \hideinitializer */
  87. #define PSIO_IN_BUFFER 0x00000004UL /*!<PSIO Input to Buffer \hideinitializer */
  88. #define PSIO_IN_STATUS 0x00000005UL /*!<PSIO Input to Status \hideinitializer */
  89. #define PSIO_IN_STATUS_UPDATE 0x00000006UL /*!<PSIO Input to Status and Update \hideinitializer */
  90. /*@}*/ /* end of group PSIO_EXPORTED_CONSTANTS */
  91. /** @addtogroup PSIO_EXPORTED_STRUCTS PSIO Exported Structs
  92. @{
  93. */
  94. /**
  95. * @brief A structure holds psio configuration
  96. */
  97. typedef struct
  98. {
  99. unsigned CKPT0SLT: 4; ///< Link check point and slot controller slot. \ref PSIO_SLOT_DISABLE, \ref PSIO_SLOT0, \ref PSIO_SLOT1, \ref PSIO_SLOT2, \ref PSIO_SLOT3, \ref PSIO_SLOT4, \ref PSIO_SLOT5, \ref PSIO_SLOT6, \ref PSIO_SLOT7
  100. unsigned CKPT1SLT: 4; ///< Link check point and slot controller slot. Reference to \ref S_PSIO_CP_CONFIG::CKPT0SLT
  101. unsigned CKPT2SLT: 4; ///< Link check point and slot controller slot. Reference to \ref S_PSIO_CP_CONFIG::CKPT0SLT
  102. unsigned CKPT3SLT: 4; ///< Link check point and slot controller slot. Reference to \ref S_PSIO_CP_CONFIG::CKPT0SLT
  103. unsigned CKPT4SLT: 4; ///< Link check point and slot controller slot. Reference to \ref S_PSIO_CP_CONFIG::CKPT0SLT
  104. unsigned CKPT5SLT: 4; ///< Link check point and slot controller slot. Reference to \ref S_PSIO_CP_CONFIG::CKPT0SLT
  105. unsigned CKPT6SLT: 4; ///< Link check point and slot controller slot. Reference to \ref S_PSIO_CP_CONFIG::CKPT0SLT
  106. unsigned CKPT7SLT: 4; ///< Link check point and slot controller slot. Reference to \ref S_PSIO_CP_CONFIG::CKPT0SLT
  107. unsigned CKPT0ACT: 4; ///< Select action at check point0. \ref PSIO_NO_ACTION, \ref PSIO_OUT_LOW, \ref PSIO_OUT_HIGH, \ref PSIO_OUT_BUFFER, \ref PSIO_OUT_TOGGLE, \ref PSIO_IN_BUFFER, \ref PSIO_IN_STATUS, \ref PSIO_IN_STATUS_UPDATE
  108. unsigned CKPT1ACT: 4; ///< Select action at check point1. Reference to \ref S_PSIO_CP_CONFIG::CKPT0ACT
  109. unsigned CKPT2ACT: 4; ///< Select action at check point2. Reference to \ref S_PSIO_CP_CONFIG::CKPT0ACT
  110. unsigned CKPT3ACT: 4; ///< Select action at check point3. Reference to \ref S_PSIO_CP_CONFIG::CKPT0ACT
  111. unsigned CKPT4ACT: 4; ///< Select action at check point4. Reference to \ref S_PSIO_CP_CONFIG::CKPT0ACT
  112. unsigned CKPT5ACT: 4; ///< Select action at check point5. Reference to \ref S_PSIO_CP_CONFIG::CKPT0ACT
  113. unsigned CKPT6ACT: 4; ///< Select action at check point6. Reference to \ref S_PSIO_CP_CONFIG::CKPT0ACT
  114. unsigned CKPT7ACT: 4; ///< Select action at check point7. Reference to \ref S_PSIO_CP_CONFIG::CKPT0ACT
  115. } S_PSIO_CP_CONFIG;
  116. /*@}*/ /* end of group PSIO_EXPORTED_STRUCTS */
  117. /** @addtogroup PSIO_EXPORTED_FUNCTIONS PSIO Exported Functions
  118. @{
  119. */
  120. /**
  121. * @brief Enable specified PSIO interrupt
  122. *
  123. * @param[in] psio The pointer of the specified PSIO module
  124. * @param[in] u32IntSel Interrupt type select
  125. * - \ref PSIO_INTEN_CON0IE_Msk
  126. * - \ref PSIO_INTEN_CON1IE_Msk
  127. * - \ref PSIO_INTEN_MISMATIE_Msk
  128. * - \ref PSIO_INTEN_TERRIE_Msk
  129. * - \ref PSIO_INTEN_SC0IE_Msk
  130. * - \ref PSIO_INTEN_SC1IE_Msk
  131. * - \ref PSIO_INTEN_SC2IE_Msk
  132. * - \ref PSIO_INTEN_SC3IE_Msk
  133. *
  134. * @return None
  135. *
  136. * @details This macro enable specified PSIO interrupt.
  137. * \hideinitializer
  138. */
  139. #define PSIO_ENABLE_INT(psio, u32IntSel) ((psio)->INTEN |= (u32IntSel))
  140. /**
  141. * @brief Disable specified PSIO interrupt
  142. *
  143. * @param[in] psio The pointer of the specified PSIO module
  144. * @param[in] u32IntSel Interrupt type select
  145. * - \ref PSIO_INTEN_CON0IE_Msk
  146. * - \ref PSIO_INTEN_CON1IE_Msk
  147. * - \ref PSIO_INTEN_MISMATIE_Msk
  148. * - \ref PSIO_INTEN_TERRIE_Msk
  149. * - \ref PSIO_INTEN_SC0IE_Msk
  150. * - \ref PSIO_INTEN_SC1IE_Msk
  151. * - \ref PSIO_INTEN_SC2IE_Msk
  152. * - \ref PSIO_INTEN_SC3IE_Msk
  153. *
  154. * @return None
  155. *
  156. * @details This macro disable specified PSIO interrupt.
  157. * \hideinitializer
  158. */
  159. #define PSIO_DISABLE_INT(psio, u32IntSel) ((psio)->INTEN &= ~(u32IntSel))
  160. /**
  161. * @brief Get specified interrupt flag/status
  162. *
  163. * @param[in] psio The pointer of the specified PSIO module
  164. * @param[in] u32IntTypeFlag Interrupt Type Flag, Valid values are
  165. * - \ref PSIO_INTSTS_CON0IF_Msk
  166. * - \ref PSIO_INTSTS_CON1IF_Msk
  167. * - \ref PSIO_INTSTS_MISMATIF_Msk
  168. * - \ref PSIO_INTSTS_TERRIF_Msk
  169. * - \ref PSIO_INTSTS_SC0IF_Msk
  170. * - \ref PSIO_INTSTS_SC1IF_Msk
  171. * - \ref PSIO_INTSTS_SC2IF_Msk
  172. * - \ref PSIO_INTSTS_SC3IF_Msk
  173. *
  174. * @return 0 The specified interrupt is not happened.
  175. * 1 The specified interrupt is happened.
  176. *
  177. * @details This macro get specified interrupt flag or interrupt indicator status.
  178. * \hideinitializer
  179. */
  180. #define PSIO_GET_INT_FLAG(psio, u32IntTypeFlag) (((psio)->INTSTS & (u32IntTypeFlag))?1:0)
  181. /**
  182. * @brief Clear specified interrupt flag/status
  183. *
  184. * @param[in] psio The pointer of the specified PSIO module
  185. * @param[in] u32IntTypeFlag Interrupt Type Flag, Valid values are
  186. * - \ref PSIO_INTSTS_CON0IF_Msk
  187. * - \ref PSIO_INTSTS_CON1IF_Msk
  188. * - \ref PSIO_INTSTS_MISMATIF_Msk
  189. * - \ref PSIO_INTSTS_TERRIF_Msk
  190. * - \ref PSIO_INTSTS_SC0IF_Msk
  191. * - \ref PSIO_INTSTS_SC1IF_Msk
  192. * - \ref PSIO_INTSTS_SC2IF_Msk
  193. * - \ref PSIO_INTSTS_SC3IF_Msk
  194. *
  195. * @return None
  196. *
  197. * @details This macro clear specified interrupt flag or interrupt indicator status.
  198. * \hideinitializer
  199. */
  200. #define PSIO_CLEAR_INT_FLAG(psio, u32IntTypeFlag) ((psio)->INTSTS = u32IntTypeFlag)
  201. /**
  202. * @brief Get specified transfer status
  203. *
  204. * @param[in] psio The pointer of the specified PSIO module
  205. * @param[in] u32Status Transfer status, Valid values are
  206. * - \ref PSIO_TRANSTS_INFULL0_Msk
  207. * - \ref PSIO_TRANSTS_INOVER0_Msk
  208. * - \ref PSIO_TRANSTS_OUTEPY0_Msk
  209. * - \ref PSIO_TRANSTS_OUTUF0_Msk
  210. * - \ref PSIO_TRANSTS_INFULL1_Msk
  211. * - \ref PSIO_TRANSTS_INOVER1_Msk
  212. * - \ref PSIO_TRANSTS_OUTEPY1_Msk
  213. * - \ref PSIO_TRANSTS_OUTUF1_Msk
  214. * - \ref PSIO_TRANSTS_INFULL2_Msk
  215. * - \ref PSIO_TRANSTS_INOVER2_Msk
  216. * - \ref PSIO_TRANSTS_OUTEPY2_Msk
  217. * - \ref PSIO_TRANSTS_OUTUF2_Msk
  218. * - \ref PSIO_TRANSTS_INFULL3_Msk
  219. * - \ref PSIO_TRANSTS_INOVER3_Msk
  220. * - \ref PSIO_TRANSTS_OUTEPY3_Msk
  221. * - \ref PSIO_TRANSTS_OUTUF3_Msk
  222. * - \ref PSIO_TRANSTS_INFULL4_Msk
  223. * - \ref PSIO_TRANSTS_INOVER4_Msk
  224. * - \ref PSIO_TRANSTS_OUTEPY4_Msk
  225. * - \ref PSIO_TRANSTS_OUTUF4_Msk
  226. * - \ref PSIO_TRANSTS_INFULL5_Msk
  227. * - \ref PSIO_TRANSTS_INOVER5_Msk
  228. * - \ref PSIO_TRANSTS_OUTEPY5_Msk
  229. * - \ref PSIO_TRANSTS_OUTUF5_Msk
  230. * - \ref PSIO_TRANSTS_INFULL6_Msk
  231. * - \ref PSIO_TRANSTS_INOVER6_Msk
  232. * - \ref PSIO_TRANSTS_OUTEPY6_Msk
  233. * - \ref PSIO_TRANSTS_OUTUF6_Msk
  234. * - \ref PSIO_TRANSTS_INFULL7_Msk
  235. * - \ref PSIO_TRANSTS_INOVER7_Msk
  236. * - \ref PSIO_TRANSTS_OUTEPY7_Msk
  237. * - \ref PSIO_TRANSTS_OUTUF7_Msk
  238. *
  239. * @return 0 The specified status is not happened.
  240. * 1 The specified status is happened.
  241. *
  242. * @details This macro get specified transfer status.
  243. * \hideinitializer
  244. */
  245. #define PSIO_GET_TRANSFER_STATUS(psio, u32Status) (((psio)->TRANSTS & (u32Status))?1:0)
  246. /**
  247. * @brief Clear specified transfer status
  248. *
  249. * @param[in] psio The pointer of the specified PSIO module
  250. * @param[in] u32Status Transfer status, Valid values are
  251. * - \ref PSIO_TRANSTS_INOVER0_Msk
  252. * - \ref PSIO_TRANSTS_OUTUF0_Msk
  253. * - \ref PSIO_TRANSTS_INOVER1_Msk
  254. * - \ref PSIO_TRANSTS_OUTUF1_Msk
  255. * - \ref PSIO_TRANSTS_INOVER2_Msk
  256. * - \ref PSIO_TRANSTS_OUTUF2_Msk
  257. * - \ref PSIO_TRANSTS_INOVER3_Msk
  258. * - \ref PSIO_TRANSTS_OUTUF3_Msk
  259. * - \ref PSIO_TRANSTS_INOVER4_Msk
  260. * - \ref PSIO_TRANSTS_OUTUF4_Msk
  261. * - \ref PSIO_TRANSTS_INOVER5_Msk
  262. * - \ref PSIO_TRANSTS_OUTUF5_Msk
  263. * - \ref PSIO_TRANSTS_INOVER6_Msk
  264. * - \ref PSIO_TRANSTS_OUTUF6_Msk
  265. * - \ref PSIO_TRANSTS_INOVER7_Msk
  266. * - \ref PSIO_TRANSTS_OUTUF7_Msk
  267. *
  268. * @return None
  269. *
  270. * @details This macro clear specified transfer status.
  271. * \hideinitializer
  272. */
  273. #define PSIO_CLEAR_TRANSFER_STATUS(psio, u32Status) ((psio)->TRANSTS = u32Status)
  274. /**
  275. * @brief Get specified input status state
  276. *
  277. * @param[in] psio The pointer of the specified PSIO module
  278. * @param[in] u32Status Transfer input status state, Valid values are
  279. * - \ref PSIO_ISSTS_VALID0_Msk
  280. * - \ref PSIO_ISSTS_INSTSOV0_Msk
  281. * - \ref PSIO_ISSTS_VALID1_Msk
  282. * - \ref PSIO_ISSTS_INSTSOV1_Msk
  283. * - \ref PSIO_ISSTS_VALID2_Msk
  284. * - \ref PSIO_ISSTS_INSTSOV2_Msk
  285. * - \ref PSIO_ISSTS_VALID3_Msk
  286. * - \ref PSIO_ISSTS_INSTSOV3_Msk
  287. * - \ref PSIO_ISSTS_VALID4_Msk
  288. * - \ref PSIO_ISSTS_INSTSOV4_Msk
  289. * - \ref PSIO_ISSTS_VALID5_Msk
  290. * - \ref PSIO_ISSTS_INSTSOV5_Msk
  291. * - \ref PSIO_ISSTS_VALID6_Msk
  292. * - \ref PSIO_ISSTS_INSTSOV6_Msk
  293. * - \ref PSIO_ISSTS_VALID7_Msk
  294. * - \ref PSIO_ISSTS_INSTSOV7_Msk
  295. *
  296. * @return 0 The specified status is not happened.
  297. * 1 The specified status is happened.
  298. *
  299. * @details This macro get input status state.
  300. * \hideinitializer
  301. */
  302. #define PSIO_GET_INPUT_STATUS_STATE(psio, u32Status) (((psio)->ISSTS & (u32Status))?1:0)
  303. /**
  304. * @brief Clear specified input status state
  305. *
  306. * @param[in] psio The pointer of the specified PSIO module
  307. * @param[in] u32Status Transfer input status state, Valid values are
  308. * - \ref PSIO_ISSTS_INSTSOV0_Msk
  309. * - \ref PSIO_ISSTS_INSTSOV1_Msk
  310. * - \ref PSIO_ISSTS_INSTSOV2_Msk
  311. * - \ref PSIO_ISSTS_INSTSOV3_Msk
  312. * - \ref PSIO_ISSTS_INSTSOV4_Msk
  313. * - \ref PSIO_ISSTS_INSTSOV5_Msk
  314. * - \ref PSIO_ISSTS_INSTSOV6_Msk
  315. * - \ref PSIO_ISSTS_INSTSOV7_Msk
  316. *
  317. * @return None
  318. *
  319. * @details This macro clear input status state.
  320. * \hideinitializer
  321. */
  322. #define PSIO_CLEAR_INPUT_STATUS_STATE(psio, u32Status) ((psio)->ISSTS = u32Status)
  323. /**
  324. * @brief Set PSIO PDMA control input
  325. *
  326. * @param[in] psio The pointer of the specified PSIO module
  327. * @param[in] u32SC The selected slot controller. Valid values are
  328. * - \ref PSIO_SC0
  329. * - \ref PSIO_SC1
  330. * - \ref PSIO_SC2
  331. * - \ref PSIO_SC3
  332. * @param[in] u32InPin The selected input pin
  333. * - \ref PSIO_PDMACTL_IPIN0EN_Msk
  334. * - \ref PSIO_PDMACTL_IPIN1EN_Msk
  335. * - \ref PSIO_PDMACTL_IPIN2EN_Msk
  336. * - \ref PSIO_PDMACTL_IPIN3EN_Msk
  337. * - \ref PSIO_PDMACTL_IPIN4EN_Msk
  338. * - \ref PSIO_PDMACTL_IPIN5EN_Msk
  339. * - \ref PSIO_PDMACTL_IPIN6EN_Msk
  340. * - \ref PSIO_PDMACTL_IPIN7EN_Msk
  341. *
  342. * @return None
  343. *
  344. * @details This macro set PSIO input with PDMA.
  345. * \hideinitializer
  346. */
  347. #define PSIO_SET_PDMA_INPUT(psio, u32SC, u32InPin) ((psio)->PDMACTL = ((psio)->PDMACTL & ~PSIO_PDMACTL_INSCSEL_Msk) \
  348. |((u32SC)<<PSIO_PDMACTL_INSCSEL_Pos)|(u32InPin))
  349. /**
  350. * @brief Clear PSIO PDMA control input
  351. *
  352. * @param[in] psio The pointer of the specified PSIO module
  353. * @param[in] u32InPin The selected input pin
  354. * - \ref PSIO_PDMACTL_IPIN0EN_Msk
  355. * - \ref PSIO_PDMACTL_IPIN1EN_Msk
  356. * - \ref PSIO_PDMACTL_IPIN2EN_Msk
  357. * - \ref PSIO_PDMACTL_IPIN3EN_Msk
  358. * - \ref PSIO_PDMACTL_IPIN4EN_Msk
  359. * - \ref PSIO_PDMACTL_IPIN5EN_Msk
  360. * - \ref PSIO_PDMACTL_IPIN6EN_Msk
  361. * - \ref PSIO_PDMACTL_IPIN7EN_Msk
  362. *
  363. * @return None
  364. *
  365. * @details This macro clear PSIO input with PDMA.
  366. * \hideinitializer
  367. */
  368. #define PSIO_CLEAR_PDMA_INPUT(psio, u32InPin) ((psio)->PDMACTL = (psio)->PDMACTL & ~PSIO_PDMACTL_INSCSEL_Msk & ~(u32InPin))
  369. /**
  370. * @brief Set PSIO PDMA control output
  371. *
  372. * @param[in] psio The pointer of the specified PSIO module
  373. * @param[in] u32SC The selected slot controller. Valid values are
  374. * - \ref PSIO_SC0
  375. * - \ref PSIO_SC1
  376. * - \ref PSIO_SC2
  377. * - \ref PSIO_SC3
  378. * @param[in] u32OutPin The selected output pin
  379. * - \ref PSIO_PDMACTL_OPIN0EN_Msk
  380. * - \ref PSIO_PDMACTL_OPIN1EN_Msk
  381. * - \ref PSIO_PDMACTL_OPIN2EN_Msk
  382. * - \ref PSIO_PDMACTL_OPIN3EN_Msk
  383. * - \ref PSIO_PDMACTL_OPIN4EN_Msk
  384. * - \ref PSIO_PDMACTL_OPIN5EN_Msk
  385. * - \ref PSIO_PDMACTL_OPIN6EN_Msk
  386. * - \ref PSIO_PDMACTL_OPIN7EN_Msk
  387. *
  388. * @return None
  389. *
  390. * @details This macro set PSIO output with PDMA.
  391. * \hideinitializer
  392. */
  393. #define PSIO_SET_PDMA_OUTPUT(psio, u32SC, u32OutPin) ((psio)->PDMACTL = ((psio)->PDMACTL & ~PSIO_PDMACTL_OUTSCSEL_Msk) \
  394. |((u32SC)<<PSIO_PDMACTL_OUTSCSEL_Pos)|(u32OutPin))
  395. /**
  396. * @brief Clear PSIO PDMA control output
  397. *
  398. * @param[in] psio The pointer of the specified PSIO module
  399. * @param[in] u32OutPin The selected output pin
  400. * - \ref PSIO_PDMACTL_OPIN0EN_Msk
  401. * - \ref PSIO_PDMACTL_OPIN1EN_Msk
  402. * - \ref PSIO_PDMACTL_OPIN2EN_Msk
  403. * - \ref PSIO_PDMACTL_OPIN3EN_Msk
  404. * - \ref PSIO_PDMACTL_OPIN4EN_Msk
  405. * - \ref PSIO_PDMACTL_OPIN5EN_Msk
  406. * - \ref PSIO_PDMACTL_OPIN6EN_Msk
  407. * - \ref PSIO_PDMACTL_OPIN7EN_Msk
  408. *
  409. * @return None
  410. *
  411. * @details This macro clear PSIO output with PDMA.
  412. * \hideinitializer
  413. */
  414. #define PSIO_CLEAR_PDMA_OUTPUT(psio, u32OutPin) ((psio)->PDMACTL = (psio)->PDMACTL & ~PSIO_PDMACTL_OUTSCSEL_Msk & ~(u32OutPin))
  415. /**
  416. * @brief Set slot controller trigger source
  417. *
  418. * @param[in] psio The pointer of the specified PSIO module
  419. * @param[in] u32SC The selected slot controller. Valid values are
  420. * - \ref PSIO_SC0
  421. * - \ref PSIO_SC1
  422. * - \ref PSIO_SC2
  423. * - \ref PSIO_SC3
  424. * @param[in] u32SrcType The selected trigger source type
  425. * - \ref PSIO_SW_TRIGGER
  426. * - \ref PSIO_FALLING_TRIGGER
  427. * - \ref PSIO_RISING_TRIGGER
  428. * - \ref PSIO_BOTH_EDGE_TRIGGER
  429. *
  430. * @return None
  431. *
  432. * @details This macro set slot controller trigger source.
  433. * \hideinitializer
  434. */
  435. #define PSIO_SET_TRIGSRC(psio, u32SC, u32SrcType) ((psio)->SCCT[(u32SC)].SCCTL=((psio)->SCCT[(u32SC)].SCCTL & ~PSIO_SCCT_SCCTL_TRIGSRC_Msk)|(u32SrcType))
  436. /**
  437. * @brief Start PSIO slot controller
  438. *
  439. * @param[in] psio The pointer of the specified PSIO module
  440. * @param[in] u32SC The selected slot controller. Valid values are
  441. * - \ref PSIO_SC0
  442. * - \ref PSIO_SC1
  443. * - \ref PSIO_SC2
  444. * - \ref PSIO_SC3
  445. *
  446. * @return None
  447. *
  448. * @details This macro start PSIO slot controller.
  449. * \hideinitializer
  450. */
  451. #define PSIO_START_SC(psio, u32SC) ((psio)->SCCT[(u32SC)].SCCTL |= PSIO_SCCT_SCCTL_START_Msk)
  452. /**
  453. * @brief Stop PSIO slot controller
  454. *
  455. * @param[in] psio The pointer of the specified PSIO module
  456. * @param[in] u32SC The selected slot controller. Valid values are
  457. * - \ref PSIO_SC0
  458. * - \ref PSIO_SC1
  459. * - \ref PSIO_SC2
  460. * - \ref PSIO_SC3
  461. *
  462. * @return None
  463. *
  464. * @details This macro stop PSIO slot controller.
  465. * \hideinitializer
  466. */
  467. #define PSIO_STOP_SC(psio, u32SC) ((psio)->SCCT[(u32SC)].SCCTL |= PSIO_SCCT_SCCTL_STOP_Msk)
  468. /**
  469. * @brief Get PSIO busy flag
  470. *
  471. * @param[in] psio The pointer of the specified PSIO module
  472. * @param[in] u32SC The selected slot controller. Valid values are
  473. * - \ref PSIO_SC0
  474. * - \ref PSIO_SC1
  475. * - \ref PSIO_SC2
  476. * - \ref PSIO_SC3
  477. *
  478. * @return 0 The busy flag is not happened.
  479. * 1 The busy flag is happened.
  480. *
  481. * @details This macro get PSIO busy flag.
  482. * \hideinitializer
  483. */
  484. #define PSIO_GET_BUSY_FLAG(psio, u32SC) (((psio)->SCCT[(u32SC)].SCCTL & PSIO_SCCT_SCCTL_BUSY_Msk)?1:0)
  485. /**
  486. * @brief Get PSIO idle flag
  487. *
  488. * @param[in] psio The pointer of the specified PSIO module
  489. * @param[in] u32SC The selected slot controller. Valid values are
  490. * - \ref PSIO_SC0
  491. * - \ref PSIO_SC1
  492. * - \ref PSIO_SC2
  493. * - \ref PSIO_SC3
  494. *
  495. * @return 0 The idle flag is not happened.
  496. * 1 The idle flag is happened.
  497. *
  498. * @details This macro get PSIO idle flag.
  499. * \hideinitializer
  500. */
  501. #define PSIO_GET_IDLE_FLAG(psio, u32SC) (((psio)->SCCT[(u32SC)].SCCTL & PSIO_SCCT_SCCTL_IDLE_Msk)?1:0)
  502. /**
  503. * @brief Clear PSIO idle flag
  504. *
  505. * @param[in] psio The pointer of the specified PSIO module
  506. * @param[in] u32SC The selected slot controller. Valid values are
  507. * - \ref PSIO_SC0
  508. * - \ref PSIO_SC1
  509. * - \ref PSIO_SC2
  510. * - \ref PSIO_SC3
  511. *
  512. * @return None
  513. *
  514. * @details This macro clear PSIO idle flag.
  515. * \hideinitializer
  516. */
  517. #define PSIO_SET_IDLE_FLAG(psio, u32SC) ((psio)->SCCT[(u32SC)].SCCTL |= PSIO_SCCT_SCCTL_IDLE_Msk)
  518. /**
  519. * @brief Set PSIO slot tick count
  520. *
  521. * @param[in] psio The pointer of the specified PSIO module
  522. * @param[in] u32SC The selected slot controller. Valid values are
  523. * - \ref PSIO_SC0
  524. * - \ref PSIO_SC1
  525. * - \ref PSIO_SC2
  526. * - \ref PSIO_SC3
  527. * @param[in] u32Slot The selected slot. Valid values are
  528. * - \ref PSIO_SLOT0
  529. * - \ref PSIO_SLOT1
  530. * - \ref PSIO_SLOT2
  531. * - \ref PSIO_SLOT3
  532. * - \ref PSIO_SLOT4
  533. * - \ref PSIO_SLOT5
  534. * - \ref PSIO_SLOT6
  535. * - \ref PSIO_SLOT7
  536. * @param[in] u32Cnt The slot tick count. Valid values are 0x0~0xF
  537. *
  538. * @return None
  539. *
  540. * @details This macro set PSIO slot tick count.
  541. * \hideinitializer
  542. */
  543. #define PSIO_SCSLOT_SET_SLOT(psio, u32SC, u32Slot, u32Cnt) ((psio)->SCCT[(u32SC)].SCSLOT= \
  544. ((psio)->SCCT[(u32SC)].SCSLOT & ~(PSIO_SCCT_SCSLOT_SLOT0CNT_Msk<<((u32Slot-1)*PSIO_SCCT_SCSLOT_SLOT1CNT_Pos)))|((u32Cnt&0xF)<<((u32Slot-1)*PSIO_SCCT_SCSLOT_SLOT1CNT_Pos)))
  545. /**
  546. * @brief Set PSIO all slot tick count
  547. *
  548. * @param[in] psio The pointer of the specified PSIO module
  549. * @param[in] u32SC The selected slot controller. Valid values are
  550. * - \ref PSIO_SC0
  551. * - \ref PSIO_SC1
  552. * - \ref PSIO_SC2
  553. * - \ref PSIO_SC3
  554. * @param[in] u32Cnt The slot tick count. Valid values are 0x0~0xF
  555. *
  556. * @return None
  557. *
  558. * @details This macro set PSIO all slot tick count.
  559. * \hideinitializer
  560. */
  561. #define PSIO_SCSLOT_SET_ALL_SLOT(psio, u32SC, u32Cnt) ((psio)->SCCT[(u32SC)].SCSLOT= \
  562. ((u32Cnt&0xF)<<PSIO_SCCT_SCSLOT_SLOT0CNT_Pos)|((u32Cnt&0xF)<<PSIO_SCCT_SCSLOT_SLOT1CNT_Pos)\
  563. |((u32Cnt&0xF)<<PSIO_SCCT_SCSLOT_SLOT2CNT_Pos)|((u32Cnt&0xF)<<PSIO_SCCT_SCSLOT_SLOT3CNT_Pos)\
  564. |((u32Cnt&0xF)<<PSIO_SCCT_SCSLOT_SLOT4CNT_Pos)|((u32Cnt&0xF)<<PSIO_SCCT_SCSLOT_SLOT5CNT_Pos)\
  565. |((u32Cnt&0xF)<<PSIO_SCCT_SCSLOT_SLOT6CNT_Pos)|((u32Cnt&0xF)<<PSIO_SCCT_SCSLOT_SLOT7CNT_Pos))
  566. /**
  567. * @brief Enable Pin function
  568. *
  569. * @param[in] psio The pointer of the specified PSIO module
  570. * @param[in] u32Pin The selected Pin. Valid values are
  571. * - \ref PSIO_PIN0
  572. * - \ref PSIO_PIN1
  573. * - \ref PSIO_PIN2
  574. * - \ref PSIO_PIN3
  575. * - \ref PSIO_PIN4
  576. * - \ref PSIO_PIN5
  577. * - \ref PSIO_PIN6
  578. * - \ref PSIO_PIN7
  579. *
  580. * @return None
  581. *
  582. * @details This function is used to Enable this Pin.
  583. * \hideinitializer
  584. */
  585. #define PSIO_ENABLE_PIN(psio, u32Pin) ((psio)->GNCT[(u32Pin)].GENCTL = \
  586. ((psio)->GNCT[(u32Pin)].GENCTL & ~PSIO_GNCT_GENCTL_PINEN_Msk)|PSIO_GNCT_GENCTL_PINEN_Msk)
  587. /**
  588. * @brief Disable Pin function
  589. *
  590. * @param[in] psio The pointer of the specified PSIO module
  591. * @param[in] u32Pin The selected Pin. Valid values are
  592. * - \ref PSIO_PIN0
  593. * - \ref PSIO_PIN1
  594. * - \ref PSIO_PIN2
  595. * - \ref PSIO_PIN3
  596. * - \ref PSIO_PIN4
  597. * - \ref PSIO_PIN5
  598. * - \ref PSIO_PIN6
  599. * - \ref PSIO_PIN7
  600. *
  601. * @return None
  602. *
  603. * @details This function is used to disable this Pin.
  604. * \hideinitializer
  605. */
  606. #define PSIO_DISABLE_PIN(psio, u32Pin) ((psio)->GNCT[(u32Pin)].GENCTL = \
  607. ((psio)->GNCT[(u32Pin)].GENCTL & ~PSIO_GNCT_GENCTL_PINEN_Msk))
  608. /**
  609. * @brief Set specified pin data width
  610. *
  611. * @param[in] psio The pointer of the specified PSIO module
  612. * @param[in] u32Pin The selected Pin. Valid values are
  613. * - \ref PSIO_PIN0
  614. * - \ref PSIO_PIN1
  615. * - \ref PSIO_PIN2
  616. * - \ref PSIO_PIN3
  617. * - \ref PSIO_PIN4
  618. * - \ref PSIO_PIN5
  619. * - \ref PSIO_PIN6
  620. * - \ref PSIO_PIN7
  621. * @param[in] u32InWidth The input data width. Valid values are 0~32
  622. * @param[in] u32OutWidth The output data width. Valid values are 0~32
  623. *
  624. * @return None
  625. *
  626. * @details This macro set in/out data width.
  627. * \hideinitializer
  628. */
  629. #define PSIO_SET_WIDTH(psio, u32Pin, u32InWidth, u32OutWidth) (((psio)->GNCT[(u32Pin)].DATCTL)= \
  630. ((psio)->GNCT[(u32Pin)].DATCTL & ~PSIO_GNCT_DATCTL_INDATWD_Msk & ~PSIO_GNCT_DATCTL_OUTDATWD_Msk) \
  631. |((u32InWidth==0?0:(u32InWidth-1))<<PSIO_GNCT_DATCTL_INDATWD_Pos)|((u32OutWidth==0?0:(u32OutWidth-1))<<PSIO_GNCT_DATCTL_OUTDATWD_Pos))
  632. /**
  633. * @brief Set specified pin data order
  634. *
  635. * @param[in] psio The pointer of the specified PSIO module
  636. * @param[in] u32Pin The selected Pin. Valid values are
  637. * - \ref PSIO_PIN0
  638. * - \ref PSIO_PIN1
  639. * - \ref PSIO_PIN2
  640. * - \ref PSIO_PIN3
  641. * - \ref PSIO_PIN4
  642. * - \ref PSIO_PIN5
  643. * - \ref PSIO_PIN6
  644. * - \ref PSIO_PIN7
  645. * @param[in] u32Order The data order. Valid values are
  646. * - \ref PSIO_LSB
  647. * - \ref PSIO_MSB
  648. *
  649. * @return None
  650. *
  651. * @details This macro set data order.
  652. * \hideinitializer
  653. */
  654. #define PSIO_SET_ORDER(psio, u32Pin, u32Order) (((psio)->GNCT[(u32Pin)].DATCTL)= \
  655. (PSIO->GNCT[(u32Pin)].DATCTL & ~PSIO_GNCT_DATCTL_ORDER_Msk)|(u32Order))
  656. /**
  657. * @brief Set specified pin output data depth
  658. *
  659. * @param[in] psio The pointer of the specified PSIO module
  660. * @param[in] u32Pin The selected Pin. Valid values are
  661. * - \ref PSIO_PIN0
  662. * - \ref PSIO_PIN1
  663. * - \ref PSIO_PIN2
  664. * - \ref PSIO_PIN3
  665. * - \ref PSIO_PIN4
  666. * - \ref PSIO_PIN5
  667. * - \ref PSIO_PIN6
  668. * - \ref PSIO_PIN7
  669. * @param[in] u32Depth The data depth. Valid values are
  670. * - \ref PSIO_DEPTH1
  671. * - \ref PSIO_DEPTH2
  672. * - \ref PSIO_DEPTH3
  673. * - \ref PSIO_DEPTH4
  674. *
  675. * @return None
  676. *
  677. * @details This macro set output data order.
  678. * \hideinitializer
  679. */
  680. #define PSIO_SET_OUTPUT_DEPTH(psio, u32Pin, u32Depth) ((psio)->GNCT[(u32Pin)].DATCTL= \
  681. (PSIO->GNCT[(u32Pin)].DATCTL & ~PSIO_GNCT_DATCTL_OUTDEPTH_Msk)|((u32Depth)<<PSIO_GNCT_DATCTL_OUTDEPTH_Pos))
  682. /**
  683. * @brief Set specified pin input data depth
  684. *
  685. * @param[in] psio The pointer of the specified PSIO module
  686. * @param[in] u32Pin The selected Pin. Valid values are
  687. * - \ref PSIO_PIN0
  688. * - \ref PSIO_PIN1
  689. * - \ref PSIO_PIN2
  690. * - \ref PSIO_PIN3
  691. * - \ref PSIO_PIN4
  692. * - \ref PSIO_PIN5
  693. * - \ref PSIO_PIN6
  694. * - \ref PSIO_PIN7
  695. * @param[in] u32Depth The data depth. Valid values are
  696. * - \ref PSIO_DEPTH1
  697. * - \ref PSIO_DEPTH2
  698. * - \ref PSIO_DEPTH3
  699. * - \ref PSIO_DEPTH4
  700. *
  701. * @return None
  702. *
  703. * @details This macro set input data order.
  704. * \hideinitializer
  705. */
  706. #define PSIO_SET_INPUT_DEPTH(psio, u32Pin, u32Depth) ((psio)->GNCT[(u32Pin)].DATCTL= \
  707. (PSIO->GNCT[(u32Pin)].DATCTL & ~PSIO_GNCT_DATCTL_INDEPTH_Msk)|((u32Depth)<<PSIO_GNCT_DATCTL_INDEPTH_Pos))
  708. /**
  709. * @brief Get specified pin input status
  710. *
  711. * @param[in] psio The pointer of the specified PSIO module
  712. * @param[in] u32Pin The selected Pin. Valid values are
  713. * - \ref PSIO_PIN0
  714. * - \ref PSIO_PIN1
  715. * - \ref PSIO_PIN2
  716. * - \ref PSIO_PIN3
  717. * - \ref PSIO_PIN4
  718. * - \ref PSIO_PIN5
  719. * - \ref PSIO_PIN6
  720. * - \ref PSIO_PIN7
  721. *
  722. * @return The specified pin input status
  723. *
  724. * @details This macro get specified pin input status.
  725. * \hideinitializer
  726. */
  727. #define PSIO_GET_INPUT_STATUS(psio, u32Pin) (psio->GNCT[u32Pin].INSTS&0xFF)
  728. /**
  729. * @brief Get specified pin input data
  730. *
  731. * @param[in] psio The pointer of the specified PSIO module
  732. * @param[in] u32Pin The selected Pin. Valid values are
  733. * - \ref PSIO_PIN0
  734. * - \ref PSIO_PIN1
  735. * - \ref PSIO_PIN2
  736. * - \ref PSIO_PIN3
  737. * - \ref PSIO_PIN4
  738. * - \ref PSIO_PIN5
  739. * - \ref PSIO_PIN6
  740. * - \ref PSIO_PIN7
  741. *
  742. * @return The specified pin input data
  743. *
  744. * @details This macro get specified pin input data.
  745. * \hideinitializer
  746. */
  747. #define PSIO_GET_INPUT_DATA(psio, u32Pin) (psio->GNCT[u32Pin].INDAT)
  748. /**
  749. * @brief Set specified pin output data
  750. *
  751. * @param[in] psio The pointer of the specified PSIO module
  752. * @param[in] u32Pin The selected Pin. Valid values are
  753. * - \ref PSIO_PIN0
  754. * - \ref PSIO_PIN1
  755. * - \ref PSIO_PIN2
  756. * - \ref PSIO_PIN3
  757. * - \ref PSIO_PIN4
  758. * - \ref PSIO_PIN5
  759. * - \ref PSIO_PIN6
  760. * - \ref PSIO_PIN7
  761. * @param[in] u32Data The output data
  762. *
  763. * @return None
  764. *
  765. * @details This macro set specified pin output data.
  766. * \hideinitializer
  767. */
  768. #define PSIO_SET_OUTPUT_DATA(psio, u32Pin, u32Data) (psio->GNCT[u32Pin].OUTDAT = (u32Data))
  769. /**
  770. * @brief Set specified pin check point and slot link
  771. *
  772. * @param[in] psio The pointer of the specified PSIO module
  773. * @param[in] u32Pin The selected Pin. Valid values are
  774. * - \ref PSIO_PIN0
  775. * - \ref PSIO_PIN1
  776. * - \ref PSIO_PIN2
  777. * - \ref PSIO_PIN3
  778. * - \ref PSIO_PIN4
  779. * - \ref PSIO_PIN5
  780. * - \ref PSIO_PIN6
  781. * - \ref PSIO_PIN7
  782. * @param[in] u32CheckPoint The selected check point. Valid values are
  783. * - \ref PSIO_CP0
  784. * - \ref PSIO_CP1
  785. * - \ref PSIO_CP2
  786. * - \ref PSIO_CP3
  787. * - \ref PSIO_CP4
  788. * - \ref PSIO_CP5
  789. * - \ref PSIO_CP6
  790. * - \ref PSIO_CP7
  791. * @param[in] u32Slot The selected slot. Valid values are
  792. * - \ref PSIO_SLOT0
  793. * - \ref PSIO_SLOT1
  794. * - \ref PSIO_SLOT2
  795. * - \ref PSIO_SLOT3
  796. * - \ref PSIO_SLOT4
  797. * - \ref PSIO_SLOT5
  798. * - \ref PSIO_SLOT6
  799. * - \ref PSIO_SLOT7
  800. *
  801. * @return None
  802. *
  803. * @details This macro used to link check point and slot.
  804. * \hideinitializer
  805. */
  806. #define PSIO_SET_CHECKPOINT(psio, u32Pin, u32CheckPoint, u32Slot) (psio->GNCT[(u32Pin)].CPCTL0= \
  807. (psio->GNCT[(u32Pin)].CPCTL0 & ~(PSIO_GNCT_CPCTL0_CKPT0_Msk<<((u32CheckPoint)*PSIO_GNCT_CPCTL0_CKPT1_Pos))) \
  808. |((u32Slot)<<((u32CheckPoint)*PSIO_GNCT_CPCTL0_CKPT1_Pos)))
  809. /**
  810. * @brief Clear specified pin check point and slot link
  811. *
  812. * @param[in] psio The pointer of the specified PSIO module
  813. * @param[in] u32Pin The selected Pin. Valid values are
  814. * - \ref PSIO_PIN0
  815. * - \ref PSIO_PIN1
  816. * - \ref PSIO_PIN2
  817. * - \ref PSIO_PIN3
  818. * - \ref PSIO_PIN4
  819. * - \ref PSIO_PIN5
  820. * - \ref PSIO_PIN6
  821. * - \ref PSIO_PIN7
  822. * @param[in] u32CheckPoint The selected check point. Valid values are
  823. * - \ref PSIO_CP0
  824. * - \ref PSIO_CP1
  825. * - \ref PSIO_CP2
  826. * - \ref PSIO_CP3
  827. * - \ref PSIO_CP4
  828. * - \ref PSIO_CP5
  829. * - \ref PSIO_CP6
  830. * - \ref PSIO_CP7
  831. *
  832. * @return None
  833. *
  834. * @details This macro used to clear the link of check point and slot.
  835. * \hideinitializer
  836. */
  837. #define PSIO_CLEAR_CHECKPOINT(psio, u32Pin, u32CheckPoint) (psio->GNCT[(u32Pin)].CPCTL0= \
  838. psio->GNCT[(u32Pin)].CPCTL0 & ~(PSIO_GNCT_CPCTL0_CKPT0_Msk<<((u32CheckPoint)*PSIO_GNCT_CPCTL0_CKPT1_Pos)))
  839. /**
  840. * @brief Set specified pin action of check point
  841. *
  842. * @param[in] psio The pointer of the specified PSIO module
  843. * @param[in] u32Pin The selected Pin. Valid values are
  844. * - \ref PSIO_PIN0
  845. * - \ref PSIO_PIN1
  846. * - \ref PSIO_PIN2
  847. * - \ref PSIO_PIN3
  848. * - \ref PSIO_PIN4
  849. * - \ref PSIO_PIN5
  850. * - \ref PSIO_PIN6
  851. * - \ref PSIO_PIN7
  852. * @param[in] u32CheckPoint The selected check point. Valid values are
  853. * - \ref PSIO_CP0
  854. * - \ref PSIO_CP1
  855. * - \ref PSIO_CP2
  856. * - \ref PSIO_CP3
  857. * - \ref PSIO_CP4
  858. * - \ref PSIO_CP5
  859. * - \ref PSIO_CP6
  860. * - \ref PSIO_CP7
  861. * @param[in] u32Action The selected action. Valid values are
  862. * - \ref PSIO_OUT_LOW
  863. * - \ref PSIO_OUT_HIGH
  864. * - \ref PSIO_OUT_BUFFER
  865. * - \ref PSIO_OUT_TOGGLE
  866. * - \ref PSIO_IN_BUFFER
  867. * - \ref PSIO_IN_STATUS
  868. * - \ref PSIO_IN_STATUS_UPDATE
  869. *
  870. * @return None
  871. *
  872. * @details This macro used to set specified pin action of check point.
  873. * \hideinitializer
  874. */
  875. #define PSIO_SET_ACTION(psio, u32Pin, u32CheckPoint, u32Action) (psio->GNCT[(u32Pin)].CPCTL1= \
  876. (psio->GNCT[(u32Pin)].CPCTL1 & ~(PSIO_GNCT_CPCTL1_CKPT0ACT_Msk<<((u32CheckPoint)*PSIO_GNCT_CPCTL1_CKPT1ACT_Pos))) \
  877. |((u32Action)<<((u32CheckPoint)*PSIO_GNCT_CPCTL1_CKPT1ACT_Pos)))
  878. /*---------------------------------------------------------------------------------------------------------*/
  879. /* inline functions */
  880. /*---------------------------------------------------------------------------------------------------------*/
  881. /**
  882. * @brief Set interrupt control
  883. *
  884. * @param[in] psio The pointer of the specified PSIO module
  885. * @param[in] u32SC The selected slot controller
  886. * @param[in] u32Int The interrupt type. Valid values are
  887. * - \ref PSIO_INT0
  888. * - \ref PSIO_INT1
  889. * @param[in] u32Slot The selected slot. Valid values are
  890. * - \ref PSIO_SLOT0
  891. * - \ref PSIO_SLOT1
  892. * - \ref PSIO_SLOT2
  893. * - \ref PSIO_SLOT3
  894. * - \ref PSIO_SLOT4
  895. * - \ref PSIO_SLOT5
  896. * - \ref PSIO_SLOT6
  897. * - \ref PSIO_SLOT7
  898. *
  899. * @return None
  900. *
  901. * @details This function is used to set the selected slot controller, interrupt type and slot.
  902. * \hideinitializer
  903. */
  904. __STATIC_INLINE void PSIO_SET_INTCTL(PSIO_T *psio, uint32_t u32SC, uint32_t u32Int, uint32_t u32Slot)
  905. {
  906. if (u32Int == PSIO_INT0)
  907. {
  908. (psio)->INTCTL = (((psio)->INTCTL & ~PSIO_INTCTL_CONI0SS_Msk & ~PSIO_INTCTL_CONI0SCS_Msk)
  909. | ((u32SC) << PSIO_INTCTL_CONI0SCS_Pos)
  910. | ((u32Slot) << PSIO_INTCTL_CONI0SS_Pos));
  911. }
  912. else if (u32Int == PSIO_INT1)
  913. {
  914. (psio)->INTCTL = (((psio)->INTCTL & ~PSIO_INTCTL_CONI1SS_Msk & ~PSIO_INTCTL_CONI1SCS_Msk)
  915. | ((u32SC) << PSIO_INTCTL_CONI1SCS_Pos)
  916. | ((u32Slot) << PSIO_INTCTL_CONI1SS_Pos));
  917. }
  918. }
  919. /**
  920. * @brief Clear interrupt control setting
  921. *
  922. * @param[in] psio The pointer of the specified PSIO module
  923. * @param[in] u32Int The interrupt type. Valid values are
  924. * - \ref PSIO_INT0
  925. * - \ref PSIO_INT1
  926. *
  927. * @return None
  928. *
  929. * @details This function is used to clear the selected slot controller, interrupt type and slot.
  930. * \hideinitializer
  931. */
  932. __STATIC_INLINE void PSIO_CLEAR_INTCTL(PSIO_T *psio, uint32_t u32Int)
  933. {
  934. if (u32Int == PSIO_INT0)
  935. {
  936. (psio)->INTCTL = ((psio)->INTCTL & ~PSIO_INTCTL_CONI0SS_Msk & ~PSIO_INTCTL_CONI0SCS_Msk);
  937. }
  938. else if (u32Int == PSIO_INT1)
  939. {
  940. (psio)->INTCTL = ((psio)->INTCTL & ~PSIO_INTCTL_CONI1SS_Msk & ~PSIO_INTCTL_CONI1SCS_Msk);
  941. }
  942. }
  943. /**
  944. * @brief Set Slot controller control
  945. *
  946. * @param[in] psio The pointer of the specified PSIO module
  947. * @param[in] u32SC The selected slot controller
  948. * @param[in] u32InitSlot The selected initial slot of the repeat period. Valid values are
  949. * - \ref PSIO_SLOT0
  950. * - \ref PSIO_SLOT1
  951. * - \ref PSIO_SLOT2
  952. * - \ref PSIO_SLOT3
  953. * - \ref PSIO_SLOT4
  954. * - \ref PSIO_SLOT5
  955. * - \ref PSIO_SLOT6
  956. * - \ref PSIO_SLOT7
  957. * @param[in] u32EndSlot The selected end slot of the repeat period. Valid values are
  958. * - \ref PSIO_SLOT0
  959. * - \ref PSIO_SLOT1
  960. * - \ref PSIO_SLOT2
  961. * - \ref PSIO_SLOT3
  962. * - \ref PSIO_SLOT4
  963. * - \ref PSIO_SLOT5
  964. * - \ref PSIO_SLOT6
  965. * - \ref PSIO_SLOT7
  966. * @param[in] u32LoopCnt The slot period loop count. Valid values are
  967. * - 0x0 : Disable
  968. * - 0x1~0x3E : Repeat slot 0x2~0x3F times
  969. * - 0x3F : Loop until stop PSIO slot controller
  970. * @param[in] u32Repeat Repeat mode Enable/Disable. Valid values are
  971. * - \ref PSIO_REPEAT_ENABLE
  972. * - \ref PSIO_REPEAT_DISABLE
  973. *
  974. * @return None
  975. *
  976. * @details This function is used to set the slot controller loop and repeat configuration.
  977. * \hideinitializer
  978. */
  979. __STATIC_INLINE void PSIO_SET_SCCTL(PSIO_T *psio, uint32_t u32SC, uint32_t u32InitSlot, uint32_t u32EndSlot, uint32_t u32LoopCnt, uint32_t u32Repeat)
  980. {
  981. (psio)->SCCT[u32SC].SCCTL = ((psio)->SCCT[u32SC].SCCTL & ~PSIO_SCCT_SCCTL_INISLOT_Msk & ~PSIO_SCCT_SCCTL_ENDSLOT_Msk & ~PSIO_SCCT_SCCTL_SPLCNT_Msk)
  982. | ((u32InitSlot) << PSIO_SCCT_SCCTL_INISLOT_Pos)
  983. | ((u32EndSlot) << PSIO_SCCT_SCCTL_ENDSLOT_Pos)
  984. | ((u32LoopCnt & 0x3F) << PSIO_SCCT_SCCTL_SPLCNT_Pos);
  985. if (u32Repeat == PSIO_REPEAT_ENABLE)
  986. (psio)->SCCT[u32SC].SCCTL |= PSIO_SCCT_SCCTL_REPEAT_Msk;
  987. else if (u32Repeat == PSIO_REPEAT_DISABLE)
  988. (psio)->SCCT[u32SC].SCCTL &= ~PSIO_SCCT_SCCTL_REPEAT_Msk;
  989. }
  990. /**
  991. * @brief Set Pin general control
  992. *
  993. * @param[in] psio The pointer of the specified PSIO module
  994. * @param[in] u32Pin The selected Pin. Valid values are
  995. * - \ref PSIO_PIN0
  996. * - \ref PSIO_PIN1
  997. * - \ref PSIO_PIN2
  998. * - \ref PSIO_PIN3
  999. * - \ref PSIO_PIN4
  1000. * - \ref PSIO_PIN5
  1001. * - \ref PSIO_PIN6
  1002. * - \ref PSIO_PIN7
  1003. * @param[in] u32PinEn The selected Pin enable/disable. Valid values are
  1004. * - \ref PSIO_PIN_ENABLE
  1005. * - \ref PSIO_PIN_DISABLE
  1006. * @param[in] u32SC The selected slot controller for check point. Valid values are
  1007. * - \ref PSIO_SC0
  1008. * - \ref PSIO_SC1
  1009. * - \ref PSIO_SC2
  1010. * - \ref PSIO_SC3
  1011. * @param[in] u32IOMode The pin I/O mode. Valid values are
  1012. * - \ref PSIO_INPUT_MODE
  1013. * - \ref PSIO_OUTPUT_MODE
  1014. * - \ref PSIO_OPENDRAIN_MODE
  1015. * - \ref PSIO_QUASI_MODE
  1016. * @param[in] u32PinInit The pin initial status. Valid values are
  1017. * - \ref PSIO_LOW_LEVEL
  1018. * - \ref PSIO_HIGH_LEVEL
  1019. * - \ref PSIO_LAST_OUTPUT
  1020. * - \ref PSIO_Toggle
  1021. * @param[in] u32PinInterval The pin interval status. Valid values are
  1022. * - \ref PSIO_LOW_LEVEL
  1023. * - \ref PSIO_HIGH_LEVEL
  1024. * - \ref PSIO_LAST_OUTPUT
  1025. * - \ref PSIO_Toggle
  1026. *
  1027. * @return None
  1028. *
  1029. * @details This function is used to set the general control.
  1030. * \hideinitializer
  1031. */
  1032. __STATIC_INLINE void PSIO_SET_GENCTL(PSIO_T *psio, uint32_t u32Pin, uint32_t u32PinEn, uint32_t u32SC, uint32_t u32IOMode, uint32_t u32PinInit, uint32_t u32PinInterval)
  1033. {
  1034. (psio)->GNCT[u32Pin].GENCTL = ((psio)->GNCT[u32Pin].GENCTL & ~PSIO_GNCT_GENCTL_SCSEL_Msk & ~PSIO_GNCT_GENCTL_IOMODE_Msk
  1035. & ~PSIO_GNCT_GENCTL_INITIAL_Msk & ~PSIO_GNCT_GENCTL_INTERVAL_Msk)
  1036. | ((u32SC) << PSIO_GNCT_GENCTL_SCSEL_Pos) | ((u32IOMode) << PSIO_GNCT_GENCTL_IOMODE_Pos)
  1037. | ((u32PinInit) << PSIO_GNCT_GENCTL_INITIAL_Pos) | ((u32PinInterval) << PSIO_GNCT_GENCTL_INTERVAL_Pos);
  1038. if (u32PinEn == PSIO_PIN_ENABLE)
  1039. (psio)->GNCT[u32Pin].GENCTL |= PSIO_GNCT_GENCTL_PINEN_Msk;
  1040. else if (u32PinEn == PSIO_PIN_DISABLE)
  1041. (psio)->GNCT[u32Pin].GENCTL &= ~PSIO_GNCT_GENCTL_PINEN_Msk;
  1042. }
  1043. /**
  1044. * @brief Set Pin mode switch
  1045. *
  1046. * @param[in] psio The pointer of the specified PSIO module
  1047. * @param[in] u32Pin The selected Pin. Valid values are
  1048. * - \ref PSIO_PIN0
  1049. * - \ref PSIO_PIN1
  1050. * - \ref PSIO_PIN2
  1051. * - \ref PSIO_PIN3
  1052. * - \ref PSIO_PIN4
  1053. * - \ref PSIO_PIN5
  1054. * - \ref PSIO_PIN6
  1055. * - \ref PSIO_PIN7
  1056. * @param[in] u32SwPoint The switch point. Valid values are
  1057. * - \ref PSIO_SWITCH_P0
  1058. * - \ref PSIO_SWITCH_P1
  1059. * @param[in] u32SwMode The switch mode. Valid values are
  1060. * - \ref PSIO_INPUT_MODE
  1061. * - \ref PSIO_OUTPUT_MODE
  1062. * - \ref PSIO_OPENDRAIN_MODE
  1063. * - \ref PSIO_QUASI_MODE
  1064. * @param[in] u32SwCP The switch I/O mode at which point. Valid values are
  1065. * - \ref PSIO_CP0
  1066. * - \ref PSIO_CP1
  1067. * - \ref PSIO_CP2
  1068. * - \ref PSIO_CP3
  1069. * - \ref PSIO_CP4
  1070. * - \ref PSIO_CP5
  1071. * - \ref PSIO_CP6
  1072. * - \ref PSIO_CP7
  1073. * @return None
  1074. *
  1075. * @details This function is used to set the pin mode switch.
  1076. * \hideinitializer
  1077. */
  1078. __STATIC_INLINE void PSIO_SWITCH_MODE(PSIO_T *psio, uint32_t u32Pin, uint32_t u32SwPoint, uint32_t u32SwMode, uint32_t u32SwCP)
  1079. {
  1080. if (u32SwPoint == PSIO_SWITCH_P0)
  1081. {
  1082. (psio)->GNCT[u32Pin].GENCTL = ((psio)->GNCT[u32Pin].GENCTL & ~PSIO_GNCT_GENCTL_MODESW0_Msk & ~PSIO_GNCT_GENCTL_SW0CP_Msk)
  1083. | ((u32SwMode) << PSIO_GNCT_GENCTL_MODESW0_Pos) | ((u32SwCP + 1) << PSIO_GNCT_GENCTL_SW0CP_Pos);
  1084. }
  1085. else if (u32SwPoint == PSIO_SWITCH_P1)
  1086. {
  1087. (psio)->GNCT[u32Pin].GENCTL = ((psio)->GNCT[u32Pin].GENCTL & ~PSIO_GNCT_GENCTL_MODESW1_Msk & ~PSIO_GNCT_GENCTL_SW1CP_Msk)
  1088. | ((u32SwMode) << PSIO_GNCT_GENCTL_MODESW1_Pos) | ((u32SwCP + 1) << PSIO_GNCT_GENCTL_SW1CP_Pos);
  1089. }
  1090. }
  1091. /**
  1092. * @brief Set specified pin check point and slot link, and pin action of check point
  1093. *
  1094. * @param[in] psio The pointer of the specified PSIO module
  1095. * @param[in] u32Pin The selected Pin. Valid values are
  1096. * - \ref PSIO_PIN0
  1097. * - \ref PSIO_PIN1
  1098. * - \ref PSIO_PIN2
  1099. * - \ref PSIO_PIN3
  1100. * - \ref PSIO_PIN4
  1101. * - \ref PSIO_PIN5
  1102. * - \ref PSIO_PIN6
  1103. * - \ref PSIO_PIN7
  1104. * @param[in] sConfig The selected check point configurations.
  1105. *
  1106. * @return None
  1107. *
  1108. * @details This macro used to link check point and slot, and set pin action of check point.
  1109. * \hideinitializer
  1110. */
  1111. __STATIC_INLINE void PSIO_SET_CP_CONFIG(PSIO_T *psio, uint32_t u32Pin, const S_PSIO_CP_CONFIG *sConfig)
  1112. {
  1113. psio->GNCT[u32Pin].CPCTL0 = *(uint32_t *)sConfig;
  1114. psio->GNCT[u32Pin].CPCTL1 = *((uint32_t *)sConfig + 1);
  1115. }
  1116. /*@}*/ /* end of group PSIO_EXPORTED_FUNCTIONS */
  1117. /*@}*/ /* end of group PSIO_Driver */
  1118. /*@}*/ /* end of group Standard_Driver */
  1119. #ifdef __cplusplus
  1120. }
  1121. #endif
  1122. #endif /* __NU_PSIO_H__ */