fsl_port.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. /*
  2. * The Clear BSD License
  3. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  4. * Copyright 2016-2017 NXP
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without modification,
  8. * are permitted (subject to the limitations in the disclaimer below) provided
  9. * that the following conditions are met:
  10. *
  11. * o Redistributions of source code must retain the above copyright notice, this list
  12. * of conditions and the following disclaimer.
  13. *
  14. * o Redistributions in binary form must reproduce the above copyright notice, this
  15. * list of conditions and the following disclaimer in the documentation and/or
  16. * other materials provided with the distribution.
  17. *
  18. * o Neither the name of the copyright holder nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  27. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  28. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  30. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #ifndef _FSL_PORT_H_
  35. #define _FSL_PORT_H_
  36. #include "fsl_common.h"
  37. /*!
  38. * @addtogroup port
  39. * @{
  40. */
  41. /*******************************************************************************
  42. * Definitions
  43. ******************************************************************************/
  44. /*! @name Driver version */
  45. /*@{*/
  46. /*! Version 2.0.2. */
  47. #define FSL_PORT_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
  48. /*@}*/
  49. #if defined(FSL_FEATURE_PORT_HAS_PULL_ENABLE) && FSL_FEATURE_PORT_HAS_PULL_ENABLE
  50. /*! @brief Internal resistor pull feature selection */
  51. enum _port_pull
  52. {
  53. kPORT_PullDisable = 0U, /*!< Internal pull-up/down resistor is disabled. */
  54. kPORT_PullDown = 2U, /*!< Internal pull-down resistor is enabled. */
  55. kPORT_PullUp = 3U, /*!< Internal pull-up resistor is enabled. */
  56. };
  57. #endif /* FSL_FEATURE_PORT_HAS_PULL_ENABLE */
  58. #if defined(FSL_FEATURE_PORT_HAS_SLEW_RATE) && FSL_FEATURE_PORT_HAS_SLEW_RATE
  59. /*! @brief Slew rate selection */
  60. enum _port_slew_rate
  61. {
  62. kPORT_FastSlewRate = 0U, /*!< Fast slew rate is configured. */
  63. kPORT_SlowSlewRate = 1U, /*!< Slow slew rate is configured. */
  64. };
  65. #endif /* FSL_FEATURE_PORT_HAS_SLEW_RATE */
  66. #if defined(FSL_FEATURE_PORT_HAS_OPEN_DRAIN) && FSL_FEATURE_PORT_HAS_OPEN_DRAIN
  67. /*! @brief Open Drain feature enable/disable */
  68. enum _port_open_drain_enable
  69. {
  70. kPORT_OpenDrainDisable = 0U, /*!< Open drain output is disabled. */
  71. kPORT_OpenDrainEnable = 1U, /*!< Open drain output is enabled. */
  72. };
  73. #endif /* FSL_FEATURE_PORT_HAS_OPEN_DRAIN */
  74. #if defined(FSL_FEATURE_PORT_HAS_PASSIVE_FILTER) && FSL_FEATURE_PORT_HAS_PASSIVE_FILTER
  75. /*! @brief Passive filter feature enable/disable */
  76. enum _port_passive_filter_enable
  77. {
  78. kPORT_PassiveFilterDisable = 0U, /*!< Passive input filter is disabled. */
  79. kPORT_PassiveFilterEnable = 1U, /*!< Passive input filter is enabled. */
  80. };
  81. #endif
  82. #if defined(FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH) && FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH
  83. /*! @brief Configures the drive strength. */
  84. enum _port_drive_strength
  85. {
  86. kPORT_LowDriveStrength = 0U, /*!< Low-drive strength is configured. */
  87. kPORT_HighDriveStrength = 1U, /*!< High-drive strength is configured. */
  88. };
  89. #endif /* FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH */
  90. #if defined(FSL_FEATURE_PORT_HAS_PIN_CONTROL_LOCK) && FSL_FEATURE_PORT_HAS_PIN_CONTROL_LOCK
  91. /*! @brief Unlock/lock the pin control register field[15:0] */
  92. enum _port_lock_register
  93. {
  94. kPORT_UnlockRegister = 0U, /*!< Pin Control Register fields [15:0] are not locked. */
  95. kPORT_LockRegister = 1U, /*!< Pin Control Register fields [15:0] are locked. */
  96. };
  97. #endif /* FSL_FEATURE_PORT_HAS_PIN_CONTROL_LOCK */
  98. #if defined(FSL_FEATURE_PORT_PCR_MUX_WIDTH) && FSL_FEATURE_PORT_PCR_MUX_WIDTH
  99. /*! @brief Pin mux selection */
  100. typedef enum _port_mux
  101. {
  102. kPORT_PinDisabledOrAnalog = 0U, /*!< Corresponding pin is disabled, but is used as an analog pin. */
  103. kPORT_MuxAsGpio = 1U, /*!< Corresponding pin is configured as GPIO. */
  104. kPORT_MuxAlt2 = 2U, /*!< Chip-specific */
  105. kPORT_MuxAlt3 = 3U, /*!< Chip-specific */
  106. kPORT_MuxAlt4 = 4U, /*!< Chip-specific */
  107. kPORT_MuxAlt5 = 5U, /*!< Chip-specific */
  108. kPORT_MuxAlt6 = 6U, /*!< Chip-specific */
  109. kPORT_MuxAlt7 = 7U, /*!< Chip-specific */
  110. kPORT_MuxAlt8 = 8U, /*!< Chip-specific */
  111. kPORT_MuxAlt9 = 9U, /*!< Chip-specific */
  112. kPORT_MuxAlt10 = 10U, /*!< Chip-specific */
  113. kPORT_MuxAlt11 = 11U, /*!< Chip-specific */
  114. kPORT_MuxAlt12 = 12U, /*!< Chip-specific */
  115. kPORT_MuxAlt13 = 13U, /*!< Chip-specific */
  116. kPORT_MuxAlt14 = 14U, /*!< Chip-specific */
  117. kPORT_MuxAlt15 = 15U, /*!< Chip-specific */
  118. } port_mux_t;
  119. #endif /* FSL_FEATURE_PORT_PCR_MUX_WIDTH */
  120. /*! @brief Configures the interrupt generation condition. */
  121. typedef enum _port_interrupt
  122. {
  123. kPORT_InterruptOrDMADisabled = 0x0U, /*!< Interrupt/DMA request is disabled. */
  124. #if defined(FSL_FEATURE_PORT_HAS_DMA_REQUEST) && FSL_FEATURE_PORT_HAS_DMA_REQUEST
  125. kPORT_DMARisingEdge = 0x1U, /*!< DMA request on rising edge. */
  126. kPORT_DMAFallingEdge = 0x2U, /*!< DMA request on falling edge. */
  127. kPORT_DMAEitherEdge = 0x3U, /*!< DMA request on either edge. */
  128. #endif
  129. #if defined(FSL_FEATURE_PORT_HAS_IRQC_FLAG) && FSL_FEATURE_PORT_HAS_IRQC_FLAG
  130. kPORT_FlagRisingEdge = 0x05U, /*!< Flag sets on rising edge. */
  131. kPORT_FlagFallingEdge = 0x06U, /*!< Flag sets on falling edge. */
  132. kPORT_FlagEitherEdge = 0x07U, /*!< Flag sets on either edge. */
  133. #endif
  134. kPORT_InterruptLogicZero = 0x8U, /*!< Interrupt when logic zero. */
  135. kPORT_InterruptRisingEdge = 0x9U, /*!< Interrupt on rising edge. */
  136. kPORT_InterruptFallingEdge = 0xAU, /*!< Interrupt on falling edge. */
  137. kPORT_InterruptEitherEdge = 0xBU, /*!< Interrupt on either edge. */
  138. kPORT_InterruptLogicOne = 0xCU, /*!< Interrupt when logic one. */
  139. #if defined(FSL_FEATURE_PORT_HAS_IRQC_TRIGGER) && FSL_FEATURE_PORT_HAS_IRQC_TRIGGER
  140. kPORT_ActiveHighTriggerOutputEnable = 0xDU, /*!< Enable active high-trigger output. */
  141. kPORT_ActiveLowTriggerOutputEnable = 0xEU, /*!< Enable active low-trigger output. */
  142. #endif
  143. } port_interrupt_t;
  144. #if defined(FSL_FEATURE_PORT_HAS_DIGITAL_FILTER) && FSL_FEATURE_PORT_HAS_DIGITAL_FILTER
  145. /*! @brief Digital filter clock source selection */
  146. typedef enum _port_digital_filter_clock_source
  147. {
  148. kPORT_BusClock = 0U, /*!< Digital filters are clocked by the bus clock. */
  149. kPORT_LpoClock = 1U, /*!< Digital filters are clocked by the 1 kHz LPO clock. */
  150. } port_digital_filter_clock_source_t;
  151. /*! @brief PORT digital filter feature configuration definition */
  152. typedef struct _port_digital_filter_config
  153. {
  154. uint32_t digitalFilterWidth; /*!< Set digital filter width */
  155. port_digital_filter_clock_source_t clockSource; /*!< Set digital filter clockSource */
  156. } port_digital_filter_config_t;
  157. #endif /* FSL_FEATURE_PORT_HAS_DIGITAL_FILTER */
  158. #if defined(FSL_FEATURE_PORT_PCR_MUX_WIDTH) && FSL_FEATURE_PORT_PCR_MUX_WIDTH
  159. /*! @brief PORT pin configuration structure */
  160. typedef struct _port_pin_config
  161. {
  162. #if defined(FSL_FEATURE_PORT_HAS_PULL_ENABLE) && FSL_FEATURE_PORT_HAS_PULL_ENABLE
  163. uint16_t pullSelect : 2; /*!< No-pull/pull-down/pull-up select */
  164. #else
  165. uint16_t : 2;
  166. #endif /* FSL_FEATURE_PORT_HAS_PULL_ENABLE */
  167. #if defined(FSL_FEATURE_PORT_HAS_SLEW_RATE) && FSL_FEATURE_PORT_HAS_SLEW_RATE
  168. uint16_t slewRate : 1; /*!< Fast/slow slew rate Configure */
  169. #else
  170. uint16_t : 1;
  171. #endif /* FSL_FEATURE_PORT_HAS_SLEW_RATE */
  172. uint16_t : 1;
  173. #if defined(FSL_FEATURE_PORT_HAS_PASSIVE_FILTER) && FSL_FEATURE_PORT_HAS_PASSIVE_FILTER
  174. uint16_t passiveFilterEnable : 1; /*!< Passive filter enable/disable */
  175. #else
  176. uint16_t : 1;
  177. #endif /* FSL_FEATURE_PORT_HAS_PASSIVE_FILTER */
  178. #if defined(FSL_FEATURE_PORT_HAS_OPEN_DRAIN) && FSL_FEATURE_PORT_HAS_OPEN_DRAIN
  179. uint16_t openDrainEnable : 1; /*!< Open drain enable/disable */
  180. #else
  181. uint16_t : 1;
  182. #endif /* FSL_FEATURE_PORT_HAS_OPEN_DRAIN */
  183. #if defined(FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH) && FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH
  184. uint16_t driveStrength : 1; /*!< Fast/slow drive strength configure */
  185. #else
  186. uint16_t : 1;
  187. #endif
  188. uint16_t : 1;
  189. #if defined(FSL_FEATURE_PORT_PCR_MUX_WIDTH) && (FSL_FEATURE_PORT_PCR_MUX_WIDTH == 3)
  190. uint16_t mux : 3; /*!< Pin mux Configure */
  191. uint16_t : 4;
  192. #elif defined(FSL_FEATURE_PORT_PCR_MUX_WIDTH) && (FSL_FEATURE_PORT_PCR_MUX_WIDTH == 4)
  193. uint16_t mux : 4; /*!< Pin mux Configure */
  194. uint16_t : 3;
  195. #else
  196. uint16_t : 7,
  197. #endif
  198. #if defined(FSL_FEATURE_PORT_HAS_PIN_CONTROL_LOCK) && FSL_FEATURE_PORT_HAS_PIN_CONTROL_LOCK
  199. uint16_t lockRegister : 1; /*!< Lock/unlock the PCR field[15:0] */
  200. #else
  201. uint16_t : 1;
  202. #endif /* FSL_FEATURE_PORT_HAS_PIN_CONTROL_LOCK */
  203. } port_pin_config_t;
  204. #endif /* FSL_FEATURE_PORT_PCR_MUX_WIDTH */
  205. /*******************************************************************************
  206. * API
  207. ******************************************************************************/
  208. #if defined(__cplusplus)
  209. extern "C" {
  210. #endif
  211. #if defined(FSL_FEATURE_PORT_PCR_MUX_WIDTH) && FSL_FEATURE_PORT_PCR_MUX_WIDTH
  212. /*! @name Configuration */
  213. /*@{*/
  214. /*!
  215. * @brief Sets the port PCR register.
  216. *
  217. * This is an example to define an input pin or output pin PCR configuration.
  218. * @code
  219. * // Define a digital input pin PCR configuration
  220. * port_pin_config_t config = {
  221. * kPORT_PullUp,
  222. * kPORT_FastSlewRate,
  223. * kPORT_PassiveFilterDisable,
  224. * kPORT_OpenDrainDisable,
  225. * kPORT_LowDriveStrength,
  226. * kPORT_MuxAsGpio,
  227. * kPORT_UnLockRegister,
  228. * };
  229. * @endcode
  230. *
  231. * @param base PORT peripheral base pointer.
  232. * @param pin PORT pin number.
  233. * @param config PORT PCR register configuration structure.
  234. */
  235. static inline void PORT_SetPinConfig(PORT_Type *base, uint32_t pin, const port_pin_config_t *config)
  236. {
  237. assert(config);
  238. uint32_t addr = (uint32_t)&base->PCR[pin];
  239. *(volatile uint16_t *)(addr) = *((const uint16_t *)config);
  240. }
  241. /*!
  242. * @brief Sets the port PCR register for multiple pins.
  243. *
  244. * This is an example to define input pins or output pins PCR configuration.
  245. * @code
  246. * // Define a digital input pin PCR configuration
  247. * port_pin_config_t config = {
  248. * kPORT_PullUp ,
  249. * kPORT_PullEnable,
  250. * kPORT_FastSlewRate,
  251. * kPORT_PassiveFilterDisable,
  252. * kPORT_OpenDrainDisable,
  253. * kPORT_LowDriveStrength,
  254. * kPORT_MuxAsGpio,
  255. * kPORT_UnlockRegister,
  256. * };
  257. * @endcode
  258. *
  259. * @param base PORT peripheral base pointer.
  260. * @param mask PORT pin number macro.
  261. * @param config PORT PCR register configuration structure.
  262. */
  263. static inline void PORT_SetMultiplePinsConfig(PORT_Type *base, uint32_t mask, const port_pin_config_t *config)
  264. {
  265. assert(config);
  266. uint16_t pcrl = *((const uint16_t *)config);
  267. if (mask & 0xffffU)
  268. {
  269. base->GPCLR = ((mask & 0xffffU) << 16) | pcrl;
  270. }
  271. if (mask >> 16)
  272. {
  273. base->GPCHR = (mask & 0xffff0000U) | pcrl;
  274. }
  275. }
  276. #if defined(FSL_FEATURE_PORT_HAS_MULTIPLE_IRQ_CONFIG) && FSL_FEATURE_PORT_HAS_MULTIPLE_IRQ_CONFIG
  277. /*!
  278. * @brief Sets the port interrupt configuration in PCR register for multiple pins.
  279. *
  280. * @param base PORT peripheral base pointer.
  281. * @param mask PORT pin number macro.
  282. * @param config PORT pin interrupt configuration.
  283. * - #kPORT_InterruptOrDMADisabled: Interrupt/DMA request disabled.
  284. * - #kPORT_DMARisingEdge : DMA request on rising edge(if the DMA requests exit).
  285. * - #kPORT_DMAFallingEdge: DMA request on falling edge(if the DMA requests exit).
  286. * - #kPORT_DMAEitherEdge : DMA request on either edge(if the DMA requests exit).
  287. * - #kPORT_FlagRisingEdge : Flag sets on rising edge(if the Flag states exit).
  288. * - #kPORT_FlagFallingEdge : Flag sets on falling edge(if the Flag states exit).
  289. * - #kPORT_FlagEitherEdge : Flag sets on either edge(if the Flag states exit).
  290. * - #kPORT_InterruptLogicZero : Interrupt when logic zero.
  291. * - #kPORT_InterruptRisingEdge : Interrupt on rising edge.
  292. * - #kPORT_InterruptFallingEdge: Interrupt on falling edge.
  293. * - #kPORT_InterruptEitherEdge : Interrupt on either edge.
  294. * - #kPORT_InterruptLogicOne : Interrupt when logic one.
  295. * - #kPORT_ActiveHighTriggerOutputEnable : Enable active high-trigger output (if the trigger states exit).
  296. * - #kPORT_ActiveLowTriggerOutputEnable : Enable active low-trigger output (if the trigger states exit)..
  297. */
  298. static inline void PORT_SetMultipleInterruptPinsConfig(PORT_Type *base, uint32_t mask, port_interrupt_t config)
  299. {
  300. assert(config);
  301. if (mask & 0xffffU)
  302. {
  303. base->GICLR = (config << 16) | (mask & 0xffffU);
  304. }
  305. if (mask >> 16)
  306. {
  307. base->GICHR = (config << 16) | (mask & 0xffff0000U);
  308. }
  309. }
  310. #endif
  311. /*!
  312. * @brief Configures the pin muxing.
  313. *
  314. * @param base PORT peripheral base pointer.
  315. * @param pin PORT pin number.
  316. * @param mux pin muxing slot selection.
  317. * - #kPORT_PinDisabledOrAnalog: Pin disabled or work in analog function.
  318. * - #kPORT_MuxAsGpio : Set as GPIO.
  319. * - #kPORT_MuxAlt2 : chip-specific.
  320. * - #kPORT_MuxAlt3 : chip-specific.
  321. * - #kPORT_MuxAlt4 : chip-specific.
  322. * - #kPORT_MuxAlt5 : chip-specific.
  323. * - #kPORT_MuxAlt6 : chip-specific.
  324. * - #kPORT_MuxAlt7 : chip-specific.
  325. * @Note : This function is NOT recommended to use together with the PORT_SetPinsConfig, because
  326. * the PORT_SetPinsConfig need to configure the pin mux anyway (Otherwise the pin mux is
  327. * reset to zero : kPORT_PinDisabledOrAnalog).
  328. * This function is recommended to use to reset the pin mux
  329. *
  330. */
  331. static inline void PORT_SetPinMux(PORT_Type *base, uint32_t pin, port_mux_t mux)
  332. {
  333. base->PCR[pin] = (base->PCR[pin] & ~PORT_PCR_MUX_MASK) | PORT_PCR_MUX(mux);
  334. }
  335. #endif /* FSL_FEATURE_PORT_PCR_MUX_WIDTH */
  336. #if defined(FSL_FEATURE_PORT_HAS_DIGITAL_FILTER) && FSL_FEATURE_PORT_HAS_DIGITAL_FILTER
  337. /*!
  338. * @brief Enables the digital filter in one port, each bit of the 32-bit register represents one pin.
  339. *
  340. * @param base PORT peripheral base pointer.
  341. * @param mask PORT pin number macro.
  342. */
  343. static inline void PORT_EnablePinsDigitalFilter(PORT_Type *base, uint32_t mask, bool enable)
  344. {
  345. if (enable == true)
  346. {
  347. base->DFER |= mask;
  348. }
  349. else
  350. {
  351. base->DFER &= ~mask;
  352. }
  353. }
  354. /*!
  355. * @brief Sets the digital filter in one port, each bit of the 32-bit register represents one pin.
  356. *
  357. * @param base PORT peripheral base pointer.
  358. * @param config PORT digital filter configuration structure.
  359. */
  360. static inline void PORT_SetDigitalFilterConfig(PORT_Type *base, const port_digital_filter_config_t *config)
  361. {
  362. assert(config);
  363. base->DFCR = PORT_DFCR_CS(config->clockSource);
  364. base->DFWR = PORT_DFWR_FILT(config->digitalFilterWidth);
  365. }
  366. #endif /* FSL_FEATURE_PORT_HAS_DIGITAL_FILTER */
  367. /*@}*/
  368. /*! @name Interrupt */
  369. /*@{*/
  370. /*!
  371. * @brief Configures the port pin interrupt/DMA request.
  372. *
  373. * @param base PORT peripheral base pointer.
  374. * @param pin PORT pin number.
  375. * @param config PORT pin interrupt configuration.
  376. * - #kPORT_InterruptOrDMADisabled: Interrupt/DMA request disabled.
  377. * - #kPORT_DMARisingEdge : DMA request on rising edge(if the DMA requests exit).
  378. * - #kPORT_DMAFallingEdge: DMA request on falling edge(if the DMA requests exit).
  379. * - #kPORT_DMAEitherEdge : DMA request on either edge(if the DMA requests exit).
  380. * - #kPORT_FlagRisingEdge : Flag sets on rising edge(if the Flag states exit).
  381. * - #kPORT_FlagFallingEdge : Flag sets on falling edge(if the Flag states exit).
  382. * - #kPORT_FlagEitherEdge : Flag sets on either edge(if the Flag states exit).
  383. * - #kPORT_InterruptLogicZero : Interrupt when logic zero.
  384. * - #kPORT_InterruptRisingEdge : Interrupt on rising edge.
  385. * - #kPORT_InterruptFallingEdge: Interrupt on falling edge.
  386. * - #kPORT_InterruptEitherEdge : Interrupt on either edge.
  387. * - #kPORT_InterruptLogicOne : Interrupt when logic one.
  388. * - #kPORT_ActiveHighTriggerOutputEnable : Enable active high-trigger output (if the trigger states exit).
  389. * - #kPORT_ActiveLowTriggerOutputEnable : Enable active low-trigger output (if the trigger states exit).
  390. */
  391. static inline void PORT_SetPinInterruptConfig(PORT_Type *base, uint32_t pin, port_interrupt_t config)
  392. {
  393. base->PCR[pin] = (base->PCR[pin] & ~PORT_PCR_IRQC_MASK) | PORT_PCR_IRQC(config);
  394. }
  395. #if defined(FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH) && FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH
  396. /*!
  397. * @brief Configures the port pin drive strength.
  398. *
  399. * @param base PORT peripheral base pointer.
  400. * @param pin PORT pin number.
  401. * @param config PORT pin drive strength
  402. * - #kPORT_LowDriveStrength = 0U - Low-drive strength is configured.
  403. * - #kPORT_HighDriveStrength = 1U - High-drive strength is configured.
  404. */
  405. static inline void PORT_SetPinDriveStrength(PORT_Type* base, uint32_t pin, uint8_t strength)
  406. {
  407. base->PCR[pin] = (base->PCR[pin] & ~PORT_PCR_DSE_MASK) | PORT_PCR_DSE(strength);
  408. }
  409. #endif
  410. /*!
  411. * @brief Reads the whole port status flag.
  412. *
  413. * If a pin is configured to generate the DMA request, the corresponding flag
  414. * is cleared automatically at the completion of the requested DMA transfer.
  415. * Otherwise, the flag remains set until a logic one is written to that flag.
  416. * If configured for a level sensitive interrupt that remains asserted, the flag
  417. * is set again immediately.
  418. *
  419. * @param base PORT peripheral base pointer.
  420. * @return Current port interrupt status flags, for example, 0x00010001 means the
  421. * pin 0 and 16 have the interrupt.
  422. */
  423. static inline uint32_t PORT_GetPinsInterruptFlags(PORT_Type *base)
  424. {
  425. return base->ISFR;
  426. }
  427. /*!
  428. * @brief Clears the multiple pin interrupt status flag.
  429. *
  430. * @param base PORT peripheral base pointer.
  431. * @param mask PORT pin number macro.
  432. */
  433. static inline void PORT_ClearPinsInterruptFlags(PORT_Type *base, uint32_t mask)
  434. {
  435. base->ISFR = mask;
  436. }
  437. /*@}*/
  438. #if defined(__cplusplus)
  439. }
  440. #endif
  441. /*! @}*/
  442. #endif /* _FSL_PORT_H_ */