hpm_pla_drv.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. /*
  2. * Copyright (c) 2022 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_PLA_DRV_H
  8. #define HPM_PLA_DRV_H
  9. #include "hpm_common.h"
  10. #include "hpm_pla_regs.h"
  11. /**
  12. * @brief PLA driver APIs
  13. * @defgroup pla_interface PLA driver APIs
  14. * @ingroup io_interfaces
  15. * @{
  16. */
  17. #define PLA_AOI_16TO8_SIGNAL_NUM (16U)
  18. #define PLA_AOI_8TO7_SIGNAL_NUM (8U)
  19. #define PLA_CHN_CFG_ACTIVE_WORD (0xF00DU)
  20. #define PLA_AOI_16TO8_CONNECT_(input, value) \
  21. PLA_CHN_AOI_16TO8_AOI_16TO8_##input##_SET(value)
  22. /**
  23. * @brief Input signal configuration for synthetic aoi_16to8
  24. *
  25. */
  26. #define PLA_AOI_16TO8_CONNECT(input_signal, operation) \
  27. PLA_AOI_16TO8_CONNECT_(input_signal, operation)
  28. /**
  29. * @brief aoi_16to8 operation on input signals
  30. *
  31. */
  32. typedef enum pla_aoi_signal_operation_type {
  33. pla_aoi_operation_and_0 = 0, /**< signal & 0 */
  34. pla_aoi_operation_and_1 = 1, /**< signal & 1 */
  35. pla_aoi_operation_xor_1 = 2, /**< signal xor 1 */
  36. pla_aoi_operation_or_1 = 3, /**< signal | 1 */
  37. } pla_aoi_signal_operation_type_t;
  38. typedef enum pla_filter_sw_inject_type {
  39. pla_filter_sw_inject_low = 0,
  40. pla_filter_sw_inject_height = 1,
  41. pla_filter_sw_inject_disable = 2,
  42. } pla_filter_sw_inject_type_t;
  43. /**
  44. * @brief aoi channel index
  45. *
  46. */
  47. typedef enum pla_channel_type {
  48. pla_chn_0 = PLA_CHN_0, /**< channel 0 */
  49. pla_chn_1 = PLA_CHN_1, /**< channel 1 */
  50. pla_chn_2 = PLA_CHN_2, /**< channel 2 */
  51. pla_chn_3 = PLA_CHN_3, /**< channel 3 */
  52. pla_chn_4 = PLA_CHN_4, /**< channel 4 */
  53. pla_chn_5 = PLA_CHN_5, /**< channel 5 */
  54. pla_chn_6 = PLA_CHN_6, /**< channel 6 */
  55. pla_chn_7 = PLA_CHN_7, /**< channel 7 */
  56. } pla_channel_type_t;
  57. /**
  58. * @brief Raw input signal for aoi16to8 module
  59. *
  60. */
  61. typedef enum pla_aoi_16to8_input_signal_type {
  62. pla_level1_filter_out_0 = 0,
  63. pla_level1_filter_out_1 = 1,
  64. pla_level1_filter_out_2 = 2,
  65. pla_level1_filter_out_3 = 3,
  66. pla_level1_filter_out_4 = 4,
  67. pla_level1_filter_out_5 = 5,
  68. pla_level1_filter_out_6 = 6,
  69. pla_level1_filter_out_7 = 7,
  70. pla_level1_filter_out_8 = 8,
  71. pla_level1_filter_out_9 = 9,
  72. pla_level1_filter_out_10 = 10,
  73. pla_level1_filter_out_11 = 11,
  74. pla_level1_filter_out_12 = 12,
  75. pla_level1_filter_out_13 = 13,
  76. pla_level1_filter_out_14 = 14,
  77. pla_level1_filter_out_15 = 15,
  78. } pla_aoi_16to8_input_signal_type_t;
  79. /**
  80. * @brief aoi_16to8 channel index
  81. *
  82. */
  83. typedef enum pla_aoi_16to8_channel_type {
  84. pla_aoi_16to8_chn_0 = PLA_CHN_AOI_16TO8_AOI_16TO8_00, /**< channel 0 */
  85. pla_aoi_16to8_chn_1 = PLA_CHN_AOI_16TO8_AOI_16TO8_01, /**< channel 1 */
  86. pla_aoi_16to8_chn_2 = PLA_CHN_AOI_16TO8_AOI_16TO8_02, /**< channel 2 */
  87. pla_aoi_16to8_chn_3 = PLA_CHN_AOI_16TO8_AOI_16TO8_03, /**< channel 3 */
  88. pla_aoi_16to8_chn_4 = PLA_CHN_AOI_16TO8_AOI_16TO8_04, /**< channel 4 */
  89. pla_aoi_16to8_chn_5 = PLA_CHN_AOI_16TO8_AOI_16TO8_05, /**< channel 5 */
  90. pla_aoi_16to8_chn_6 = PLA_CHN_AOI_16TO8_AOI_16TO8_06, /**< channel 6 */
  91. pla_aoi_16to8_chn_7 = PLA_CHN_AOI_16TO8_AOI_16TO8_07, /**< channel 7 */
  92. } pla_aoi_16to8_channel_type_t;
  93. /**
  94. * @brief aoi_16to8 config unit
  95. *
  96. */
  97. typedef struct pla_aoi_16to8_cfg_unit {
  98. pla_aoi_16to8_input_signal_type_t signal;
  99. pla_aoi_signal_operation_type_t op;
  100. } pla_aoi_16to8_cfg_unit_t;
  101. /**
  102. * @brief aoi_16to8 channel config
  103. *
  104. */
  105. typedef struct pla_aoi_16to8_chn_cfg {
  106. pla_channel_type_t chn; /**< pla channel */
  107. pla_aoi_16to8_channel_type_t aoi_16to8_chn; /**< aoi_16to8 channel */
  108. pla_aoi_16to8_cfg_unit_t input[PLA_AOI_16TO8_SIGNAL_NUM]; /**< Configuration of each aoi_16to8 input signal */
  109. } pla_aoi_16to8_chn_cfg_t;
  110. /**
  111. * @brief aoi_8_to_7 input signal
  112. *
  113. */
  114. typedef enum pla_aoi_8to7_input_signal_type {
  115. pla_level2_filter_out_0 = 0,
  116. pla_level2_filter_out_1 = 1,
  117. pla_level2_filter_out_2 = 2,
  118. pla_level2_filter_out_3 = 3,
  119. pla_level2_filter_out_4 = 4,
  120. pla_level2_filter_out_5 = 5,
  121. pla_level2_filter_out_6 = 6,
  122. pla_level2_filter_out_7 = 7,
  123. } pla_aoi_8to7_input_signal_type_t;
  124. /**
  125. * @brief aoi_8to7 channel number
  126. *
  127. */
  128. typedef enum pla_aoi_8to7_channel_type {
  129. pla_aoi_8to7_chn_0 = 0, /**< channel 0 */
  130. pla_aoi_8to7_chn_1 = 1, /**< channel 1 */
  131. pla_aoi_8to7_chn_2 = 2, /**< channel 2 */
  132. pla_aoi_8to7_chn_3 = 3, /**< channel 3 */
  133. pla_aoi_8to7_chn_4 = 4, /**< channel 4 */
  134. pla_aoi_8to7_chn_5 = 5, /**< channel 5 */
  135. pla_aoi_8to7_chn_6 = 6, /**< channel 6 */
  136. } pla_aoi_8to7_channel_type_t;
  137. /**
  138. * @brief aoi_8to7 config unit
  139. *
  140. */
  141. typedef struct pla_aoi_8to7_cfg_unit {
  142. pla_aoi_8to7_input_signal_type_t signal;
  143. pla_aoi_signal_operation_type_t op;
  144. } pla_aoi_8to7_cfg_unit_t;
  145. /**
  146. * @brief aoi_8_to_7 channel config
  147. *
  148. */
  149. typedef struct pla_aoi_8to7_chn_cfg {
  150. pla_channel_type_t chn; /**< pla channel */
  151. pla_aoi_8to7_channel_type_t aoi_8to7_chn; /**< aoi_16to8 channel */
  152. pla_aoi_8to7_cfg_unit_t input[PLA_AOI_8TO7_SIGNAL_NUM]; /**< Configuration of each aoi_16to8 input signal */
  153. } pla_aoi_8to7_chn_cfg_t;
  154. /**
  155. * @brief pla filter config
  156. *
  157. */
  158. typedef union pla_filter_cfg {
  159. struct {
  160. uint32_t sync_edge_filter_disable:1;
  161. uint32_t software_inject:2;
  162. uint32_t filter_reverse:1;
  163. uint32_t edge_dect_en:1;
  164. uint32_t nege_edge_dect_en:1;
  165. uint32_t pose_edge_dect_en:1;
  166. uint32_t filter_sync_level:1;
  167. uint32_t filter_ext_en:1;
  168. uint32_t reserved0:3;
  169. uint32_t filter_ext_type:3;
  170. uint32_t reserved1:1;
  171. uint32_t filter_ext_counter:16;
  172. };
  173. uint32_t val;
  174. } pla_filter_cfg_t;
  175. /**
  176. * @brief pla function selection config
  177. *
  178. */
  179. typedef union pla_ff_cfg {
  180. struct {
  181. uint32_t sel_cfg_ff_type:3;
  182. uint32_t sel_clk_source:1;
  183. uint32_t sel_adder_minus:1;
  184. uint32_t reserved0:11;
  185. uint32_t dis_osc_loop_clamp:1;
  186. uint32_t osc_loop_clamp_value:1;
  187. uint32_t reserved1:14;
  188. };
  189. uint32_t val;
  190. } pla_ff_cfg_t;
  191. /**
  192. * @brief pla configurable functions
  193. *
  194. */
  195. typedef enum pla_ff_type {
  196. pla_ff_type_dff = 0,
  197. pla_ff_type_level3_filter0 = 1,
  198. pla_ff_type_dual_edge_DFF = 2,
  199. pla_ff_type_trigger_ff = 3,
  200. pla_ff_type_jk_ff = 4,
  201. pla_ff_type_latch = 5,
  202. pla_ff_type_adder_minus = 6
  203. } pla_ff_type_t;
  204. typedef enum pla_filter1_inchannel_type {
  205. pla_filter1_inchn0 = PLA_FILTER_1ST_PLA_IN_FRIST_FILTER_PLA_IN_0,
  206. pla_filter1_inchn1 = PLA_FILTER_1ST_PLA_IN_FRIST_FILTER_PLA_IN_1,
  207. pla_filter1_inchn2 = PLA_FILTER_1ST_PLA_IN_FRIST_FILTER_PLA_IN_2,
  208. pla_filter1_inchn3 = PLA_FILTER_1ST_PLA_IN_FRIST_FILTER_PLA_IN_3,
  209. pla_filter1_inchn4 = PLA_FILTER_1ST_PLA_IN_FRIST_FILTER_PLA_IN_4,
  210. pla_filter1_inchn5 = PLA_FILTER_1ST_PLA_IN_FRIST_FILTER_PLA_IN_5,
  211. pla_filter1_inchn6 = PLA_FILTER_1ST_PLA_IN_FRIST_FILTER_PLA_IN_6,
  212. pla_filter1_inchn7 = PLA_FILTER_1ST_PLA_IN_FRIST_FILTER_PLA_IN_7,
  213. } pla_filter1_inchannel_type_t;
  214. typedef enum pla_filter1_outchannel_type {
  215. pla_filter1_outchn0 = PLA_FILTER_1ST_PLA_OUT_FRIST_FILTER_PLA_OUT_0,
  216. pla_filter1_outchn1 = PLA_FILTER_1ST_PLA_OUT_FRIST_FILTER_PLA_OUT_1,
  217. pla_filter1_outchn2 = PLA_FILTER_1ST_PLA_OUT_FRIST_FILTER_PLA_OUT_2,
  218. pla_filter1_outchn3 = PLA_FILTER_1ST_PLA_OUT_FRIST_FILTER_PLA_OUT_3,
  219. pla_filter1_outchn4 = PLA_FILTER_1ST_PLA_OUT_FRIST_FILTER_PLA_OUT_4,
  220. pla_filter1_outchn5 = PLA_FILTER_1ST_PLA_OUT_FRIST_FILTER_PLA_OUT_5,
  221. pla_filter1_outchn6 = PLA_FILTER_1ST_PLA_OUT_FRIST_FILTER_PLA_OUT_6,
  222. pla_filter1_outchn7 = PLA_FILTER_1ST_PLA_OUT_FRIST_FILTER_PLA_OUT_7,
  223. } pla_filter1_outchannel_type_t;
  224. typedef enum pla_filter2_channel_type {
  225. pla_filter2_chn0 = PLA_CHN_FILTER_2ND_SECOND_FILTER_0,
  226. pla_filter2_chn1 = PLA_CHN_FILTER_2ND_SECOND_FILTER_1,
  227. pla_filter2_chn2 = PLA_CHN_FILTER_2ND_SECOND_FILTER_2,
  228. pla_filter2_chn3 = PLA_CHN_FILTER_2ND_SECOND_FILTER_3,
  229. pla_filter2_chn4 = PLA_CHN_FILTER_2ND_SECOND_FILTER_4,
  230. pla_filter2_chn5 = PLA_CHN_FILTER_2ND_SECOND_FILTER_5,
  231. pla_filter2_chn6 = PLA_CHN_FILTER_2ND_SECOND_FILTER_6,
  232. pla_filter2_chn7 = PLA_CHN_FILTER_2ND_SECOND_FILTER_7,
  233. } pla_filter2_channel_type_t;
  234. typedef enum pla_filter3_channel_type {
  235. pla_filter3_chn0 = PLA_CHN_FILTER_3RD_THIRD_FILTER_0,
  236. pla_filter3_chn1 = PLA_CHN_FILTER_3RD_THIRD_FILTER_1,
  237. pla_filter3_chn2 = PLA_CHN_FILTER_3RD_THIRD_FILTER_2,
  238. pla_filter3_chn3 = PLA_CHN_FILTER_3RD_THIRD_FILTER_3,
  239. pla_filter3_chn4 = PLA_CHN_FILTER_3RD_THIRD_FILTER_4,
  240. pla_filter3_chn5 = PLA_CHN_FILTER_3RD_THIRD_FILTER_5,
  241. pla_filter3_chn6 = PLA_CHN_FILTER_3RD_THIRD_FILTER_6,
  242. } pla_filter3_channel_type_t;
  243. #ifdef __cplusplus
  244. extern "C" {
  245. #endif
  246. /**
  247. * @brief Configure one channel of aoi_16to8
  248. *
  249. * @param pla @ref PLA_Type
  250. * @param cfg @ref pla_aoi_16to8_cfg_t
  251. */
  252. void pla_set_aoi_16to8_one_channel(PLA_Type * pla,
  253. pla_aoi_16to8_chn_cfg_t *cfg);
  254. /**
  255. * @brief Get one channel of aoi_16to8
  256. *
  257. * @param pla @ref PLA_Type
  258. * @param chn @ref pla_channel_type_t
  259. * @param aoi_16to8_chn @ref pla_aoi_16to8_channel_type_t
  260. * @param cfg @ref pla_aoi_16to8_chn_cfg_t
  261. */
  262. void pla_get_aoi_16to8_one_channel(PLA_Type *pla,
  263. pla_channel_type_t chn,
  264. pla_aoi_16to8_channel_type_t aoi_16to8_chn,
  265. pla_aoi_16to8_chn_cfg_t *cfg);
  266. /**
  267. * @brief Set one signal of aoi_16to8
  268. *
  269. * @param pla @ref PLA_Type
  270. * @param chn @ref pla_channel_type_t
  271. * @param aoi_16to8_chn @ref pla_aoi_16to8_channel_type_t
  272. * @param cfg @ref pla_aoi_16to8_cfg_unit_t
  273. */
  274. static inline void pla_set_aoi_16to8_input_signal(PLA_Type *pla,
  275. pla_channel_type_t chn,
  276. pla_aoi_16to8_channel_type_t aoi_16to8_chn,
  277. pla_aoi_16to8_cfg_unit_t *cfg)
  278. {
  279. pla->CHN[chn].AOI_16TO8[aoi_16to8_chn] = pla->CHN[chn].AOI_16TO8[aoi_16to8_chn] &
  280. ~(((uint32_t)cfg->op) << (cfg->signal << 1));
  281. }
  282. /**
  283. * @brief Get one signal of aoi_16to8
  284. *
  285. * @param pla @ref PLA_Type
  286. * @param chn @ref pla_channel_type_t
  287. * @param aoi_16to8_chn @ref pla_aoi_16to8_channel_type_t
  288. * @param signal @ref pla_aoi_16to8_input_signal_type_t
  289. * @param cfg @ref pla_aoi_16to8_cfg_unit_t
  290. */
  291. static inline void pla_get_aoi_16to8_input_signal(PLA_Type *pla,
  292. pla_channel_type_t chn,
  293. pla_aoi_16to8_channel_type_t aoi_16to8_chn,
  294. pla_aoi_16to8_input_signal_type_t signal,
  295. pla_aoi_16to8_cfg_unit_t *cfg)
  296. {
  297. cfg->op = (pla->CHN[chn].AOI_16TO8[aoi_16to8_chn] >> (signal << 1)) & 0x03;
  298. cfg->signal = signal;
  299. }
  300. /**
  301. * @brief Configure one channel of aoi_8to7
  302. *
  303. * @param pla @ref PLA_Type
  304. * @param cfg @ref pla_aoi_8to7_chn_cfg_t
  305. */
  306. void pla_set_aoi_8to7_one_channel(PLA_Type *pla,
  307. pla_aoi_8to7_chn_cfg_t *cfg);
  308. /**
  309. * @brief Get one channel of aoi_8to7
  310. *
  311. * @param pla @ref PLA_Type
  312. * @param cfg @ref pla_aoi_8to7_chn_cfg_t
  313. */
  314. void pla_get_aoi_8to7_one_channel(PLA_Type *pla,
  315. pla_aoi_8to7_chn_cfg_t *cfg);
  316. /**
  317. * @brief Configure one signal of aoi_8to7
  318. *
  319. * @param pla @ref PLA_Type
  320. * @param chn @ref pla_channel_type_t
  321. * @param aoi_16to8_chn @ref pla_aoi_8to7_channel_type_t
  322. * @param cfg @ref pla_aoi_8to7_cfg_unit_t
  323. */
  324. void pla_set_aoi_8to7_input_signal(PLA_Type *pla,
  325. pla_channel_type_t chn,
  326. pla_aoi_8to7_channel_type_t aoi_8to7_chn,
  327. pla_aoi_8to7_cfg_unit_t *cfg);
  328. /**
  329. * @brief Get one signal of aoi_8to7
  330. *
  331. * @param pla @ref PLA_Type
  332. * @param chn @ref pla_channel_type_t
  333. * @param aoi_8to7_chn @ref pla_aoi_8to7_channel_type_t
  334. * @param signal @ref pla_aoi_8to7_input_signal_type_t
  335. * @param cfg @ref pla_aoi_8to7_cfg_unit_t
  336. */
  337. void pla_get_aoi_8to7_input_signal(PLA_Type *pla,
  338. pla_channel_type_t chn,
  339. pla_aoi_8to7_channel_type_t aoi_8to7_chn,
  340. pla_aoi_8to7_input_signal_type_t signal,
  341. pla_aoi_8to7_cfg_unit_t *cfg);
  342. /**
  343. * @brief Configure filter1 out
  344. *
  345. * @param pla @ref PLA_Type
  346. * @param filter1_out_chn @ref pla_filter1_outchannel_type_t
  347. * @param cfg @ref pla_filter_cfg_t
  348. */
  349. static inline void pla_set_filter1_out(PLA_Type *pla,
  350. pla_filter1_outchannel_type_t filter1_out_chn,
  351. pla_filter_cfg_t *cfg)
  352. {
  353. pla->FILTER_1ST_PLA_OUT[filter1_out_chn] = cfg->val;
  354. }
  355. /**
  356. * @brief Get filter1 out
  357. *
  358. * @param pla @ref PLA_Type
  359. * @param filter1_out_chn @ref pla_filter1_outchannel_type_t
  360. * @param cfg @ref pla_filter_cfg_t
  361. */
  362. static inline void pla_get_filter1_out(PLA_Type *pla,
  363. pla_filter1_outchannel_type_t filter1_out_chn,
  364. pla_filter_cfg_t *cfg)
  365. {
  366. cfg->val = pla->FILTER_1ST_PLA_OUT[filter1_out_chn];
  367. }
  368. /**
  369. * @brief Configure filter1 in
  370. *
  371. * @param pla @ref PLA_Type
  372. * @param filter1_in_chn @ref pla_filter1_inchannel_type_t
  373. * @param cfg @ref pla_filter_cfg_t
  374. */
  375. static inline void pla_set_filter1_in(PLA_Type *pla,
  376. pla_filter1_inchannel_type_t filter1_in_chn,
  377. pla_filter_cfg_t *cfg)
  378. {
  379. pla->FILTER_1ST_PLA_IN[filter1_in_chn] = cfg->val;
  380. }
  381. /**
  382. * @brief Get filter 1
  383. *
  384. * @param pla @ref PLA_Type
  385. * @param filter1_in_chn @ref pla_filter1_inchannel_type_t
  386. * @param cfg @ref pla_filter_cfg_t
  387. */
  388. static inline void pla_get_filter1_in(PLA_Type *pla,
  389. pla_filter1_inchannel_type_t filter1_in_chn,
  390. pla_filter_cfg_t *cfg)
  391. {
  392. cfg->val = pla->FILTER_1ST_PLA_IN[filter1_in_chn];
  393. }
  394. /**
  395. * @brief Configure filter 2
  396. *
  397. * @param pla @ref PLA_Type
  398. * @param chn @ref pla_channel_type_t
  399. * @param filter2_chn @ref pla_filter2_channel_type_t
  400. * @param cfg @ref pla_filter_cfg_t
  401. */
  402. static inline void pla_set_filter2(PLA_Type *pla,
  403. pla_channel_type_t chn,
  404. pla_filter2_channel_type_t filter2_chn,
  405. pla_filter_cfg_t *cfg)
  406. {
  407. pla->CHN[chn].FILTER_2ND[filter2_chn] = cfg->val;
  408. }
  409. /**
  410. * @brief Get filter2
  411. *
  412. * @param pla @ref PLA_Type
  413. * @param chn @ref pla_channel_type_t
  414. * @param filter2_chn @ref pla_filter2_channel_type_t
  415. * @param cfg @ref pla_filter_cfg_t
  416. */
  417. static inline void pla_get_filter2(PLA_Type *pla,
  418. pla_channel_type_t chn,
  419. pla_filter2_channel_type_t filter2_chn,
  420. pla_filter_cfg_t *cfg)
  421. {
  422. cfg->val = pla->CHN[chn].FILTER_2ND[filter2_chn];
  423. }
  424. /**
  425. * @brief Configure filter3
  426. *
  427. * @param pla @ref PLA_Type
  428. * @param chn @ref pla_channel_type_t
  429. * @param filter3_chn @ref pla_filter3_channel_type_t
  430. * @param cfg @ref pla_filter_cfg_t
  431. */
  432. static inline void pla_set_filter3(PLA_Type *pla,
  433. pla_channel_type_t chn,
  434. pla_filter3_channel_type_t filter3_chn,
  435. pla_filter_cfg_t *cfg)
  436. {
  437. pla->CHN[chn].FILTER_3RD[filter3_chn] = cfg->val;
  438. }
  439. /**
  440. * @brief Get filter3
  441. *
  442. * @param pla @ref PLA_Type
  443. * @param chn @ref pla_channel_type_t
  444. * @param filter3_chn @ref pla_filter3_channel_type_t
  445. * @param cfg @ref pla_filter_cfg_t
  446. */
  447. static inline void pla_get_filter3(PLA_Type *pla,
  448. pla_channel_type_t chn,
  449. pla_filter3_channel_type_t filter3_chn,
  450. pla_filter_cfg_t *cfg)
  451. {
  452. cfg->val = pla->CHN[chn].FILTER_3RD[filter3_chn];
  453. }
  454. /**
  455. * @brief Set ff function
  456. *
  457. * @param pla @ref PLA_Type
  458. * @param chn @ref pla_channel_type_t
  459. * @param cfg @ref pla_ff_cfg_t
  460. */
  461. static inline void pla_set_ff(PLA_Type *pla,
  462. pla_channel_type_t chn,
  463. pla_ff_cfg_t *cfg)
  464. {
  465. pla->CHN[chn].CFG_FF = cfg->val;
  466. }
  467. /**
  468. * @brief Get ff function
  469. *
  470. * @param pla @ref PLA_Type
  471. * @param chn @ref pla_channel_type_t
  472. * @param cfg @ref pla_ff_cfg_t
  473. */
  474. static inline void pla_get_ff(PLA_Type *pla,
  475. pla_channel_type_t chn,
  476. pla_ff_cfg_t *cfg)
  477. {
  478. cfg->val = pla->CHN[chn].CFG_FF;
  479. }
  480. /**
  481. * @brief enable pla channel
  482. *
  483. * @param pla @ref PLA_Type
  484. * @param chn @ref pla_channel_type_t
  485. */
  486. static inline void pla_channel_enable(PLA_Type *pla,
  487. pla_channel_type_t chn)
  488. {
  489. pla->CHN_CFG_ACTIVE[chn] = PLA_CHN_CFG_ACTIVE_WORD;
  490. }
  491. /**
  492. * @brief disable pla channel
  493. *
  494. * @param pla @ref PLA_Type
  495. * @param chn @ref pla_channel_type_t
  496. */
  497. static inline void pla_channel_disable(PLA_Type *pla,
  498. pla_channel_type_t chn)
  499. {
  500. pla->CHN_CFG_ACTIVE[chn] = false;
  501. }
  502. /**
  503. * @}
  504. */
  505. #ifdef __cplusplus
  506. }
  507. #endif
  508. #endif /* HPM_PLA_DRV_H */