![]() |
|
|||
File indexing completed on 2025-05-11 08:22:59
0001 /* 0002 * Copyright (c) 2015, Freescale Semiconductor, Inc. 0003 * Copyright 2016-2020, 2022 NXP 0004 * All rights reserved. 0005 * 0006 * SPDX-License-Identifier: BSD-3-Clause 0007 */ 0008 #ifndef _FSL_FLEXIO_H_ 0009 #define _FSL_FLEXIO_H_ 0010 0011 #include "fsl_common.h" 0012 0013 /*! 0014 * @addtogroup flexio_driver 0015 * @{ 0016 */ 0017 0018 /******************************************************************************* 0019 * Definitions 0020 ******************************************************************************/ 0021 0022 /*! @name Driver version */ 0023 /*@{*/ 0024 /*! @brief FlexIO driver version. */ 0025 #define FSL_FLEXIO_DRIVER_VERSION (MAKE_VERSION(2, 1, 0)) 0026 /*@}*/ 0027 0028 /*! @brief Calculate FlexIO timer trigger.*/ 0029 #define FLEXIO_TIMER_TRIGGER_SEL_PININPUT(x) ((uint32_t)(x) << 1U) 0030 #define FLEXIO_TIMER_TRIGGER_SEL_SHIFTnSTAT(x) (((uint32_t)(x) << 2U) | 0x1U) 0031 #define FLEXIO_TIMER_TRIGGER_SEL_TIMn(x) (((uint32_t)(x) << 2U) | 0x3U) 0032 0033 /*! @brief Define time of timer trigger polarity.*/ 0034 typedef enum _flexio_timer_trigger_polarity 0035 { 0036 kFLEXIO_TimerTriggerPolarityActiveHigh = 0x0U, /*!< Active high. */ 0037 kFLEXIO_TimerTriggerPolarityActiveLow = 0x1U, /*!< Active low. */ 0038 } flexio_timer_trigger_polarity_t; 0039 0040 /*! @brief Define type of timer trigger source.*/ 0041 typedef enum _flexio_timer_trigger_source 0042 { 0043 kFLEXIO_TimerTriggerSourceExternal = 0x0U, /*!< External trigger selected. */ 0044 kFLEXIO_TimerTriggerSourceInternal = 0x1U, /*!< Internal trigger selected. */ 0045 } flexio_timer_trigger_source_t; 0046 0047 /*! @brief Define type of timer/shifter pin configuration.*/ 0048 typedef enum _flexio_pin_config 0049 { 0050 kFLEXIO_PinConfigOutputDisabled = 0x0U, /*!< Pin output disabled. */ 0051 kFLEXIO_PinConfigOpenDrainOrBidirection = 0x1U, /*!< Pin open drain or bidirectional output enable. */ 0052 kFLEXIO_PinConfigBidirectionOutputData = 0x2U, /*!< Pin bidirectional output data. */ 0053 kFLEXIO_PinConfigOutput = 0x3U, /*!< Pin output. */ 0054 } flexio_pin_config_t; 0055 0056 /*! @brief Definition of pin polarity.*/ 0057 typedef enum _flexio_pin_polarity 0058 { 0059 kFLEXIO_PinActiveHigh = 0x0U, /*!< Active high. */ 0060 kFLEXIO_PinActiveLow = 0x1U, /*!< Active low. */ 0061 } flexio_pin_polarity_t; 0062 0063 /*! @brief Define type of timer work mode.*/ 0064 typedef enum _flexio_timer_mode 0065 { 0066 kFLEXIO_TimerModeDisabled = 0x0U, /*!< Timer Disabled. */ 0067 kFLEXIO_TimerModeDual8BitBaudBit = 0x1U, /*!< Dual 8-bit counters baud/bit mode. */ 0068 kFLEXIO_TimerModeDual8BitPWM = 0x2U, /*!< Dual 8-bit counters PWM mode. */ 0069 kFLEXIO_TimerModeSingle16Bit = 0x3U, /*!< Single 16-bit counter mode. */ 0070 } flexio_timer_mode_t; 0071 0072 /*! @brief Define type of timer initial output or timer reset condition.*/ 0073 typedef enum _flexio_timer_output 0074 { 0075 kFLEXIO_TimerOutputOneNotAffectedByReset = 0x0U, /*!< Logic one when enabled and is not affected by timer 0076 reset. */ 0077 kFLEXIO_TimerOutputZeroNotAffectedByReset = 0x1U, /*!< Logic zero when enabled and is not affected by timer 0078 reset. */ 0079 kFLEXIO_TimerOutputOneAffectedByReset = 0x2U, /*!< Logic one when enabled and on timer reset. */ 0080 kFLEXIO_TimerOutputZeroAffectedByReset = 0x3U, /*!< Logic zero when enabled and on timer reset. */ 0081 } flexio_timer_output_t; 0082 0083 /*! @brief Define type of timer decrement.*/ 0084 typedef enum _flexio_timer_decrement_source 0085 { 0086 kFLEXIO_TimerDecSrcOnFlexIOClockShiftTimerOutput = 0x0U, /*!< Decrement counter on FlexIO clock, Shift clock 0087 equals Timer output. */ 0088 kFLEXIO_TimerDecSrcOnTriggerInputShiftTimerOutput, /*!< Decrement counter on Trigger input (both edges), 0089 Shift clock equals Timer output. */ 0090 kFLEXIO_TimerDecSrcOnPinInputShiftPinInput, /*!< Decrement counter on Pin input (both edges), 0091 Shift clock equals Pin input. */ 0092 kFLEXIO_TimerDecSrcOnTriggerInputShiftTriggerInput /*!< Decrement counter on Trigger input (both edges), 0093 Shift clock equals Trigger input. */ 0094 #if (defined(FSL_FEATURE_FLEXIO_TIMCFG_TIMDCE_FIELD_WIDTH) && (FSL_FEATURE_FLEXIO_TIMCFG_TIMDCE_FIELD_WIDTH == 3)) 0095 , 0096 kFLEXIO_TimerDecSrcDiv16OnFlexIOClockShiftTimerOutput, /*!< Decrement counter on FlexIO clock divided by 16, 0097 Shift clock equals Timer output. */ 0098 kFLEXIO_TimerDecSrcDiv256OnFlexIOClockShiftTimerOutput, /*!< Decrement counter on FlexIO clock divided by 256, 0099 Shift clock equals Timer output. */ 0100 kFLEXIO_TimerRisSrcOnPinInputShiftPinInput, /*!< Decrement counter on Pin input (rising edges), 0101 Shift clock equals Pin input. */ 0102 kFLEXIO_TimerRisSrcOnTriggerInputShiftTriggerInput /*!< Decrement counter on Trigger input (rising edges), Shift 0103 clock equals Trigger input. */ 0104 #endif /* FSL_FEATURE_FLEXIO_TIMCFG_TIMDCE_FIELD_WIDTH */ 0105 } flexio_timer_decrement_source_t; 0106 0107 /*! @brief Define type of timer reset condition.*/ 0108 typedef enum _flexio_timer_reset_condition 0109 { 0110 kFLEXIO_TimerResetNever = 0x0U, /*!< Timer never reset. */ 0111 kFLEXIO_TimerResetOnTimerPinEqualToTimerOutput = 0x2U, /*!< Timer reset on Timer Pin equal to Timer Output. */ 0112 kFLEXIO_TimerResetOnTimerTriggerEqualToTimerOutput = 0x3U, /*!< Timer reset on Timer Trigger equal to 0113 Timer Output. */ 0114 kFLEXIO_TimerResetOnTimerPinRisingEdge = 0x4U, /*!< Timer reset on Timer Pin rising edge. */ 0115 kFLEXIO_TimerResetOnTimerTriggerRisingEdge = 0x6U, /*!< Timer reset on Trigger rising edge. */ 0116 kFLEXIO_TimerResetOnTimerTriggerBothEdge = 0x7U, /*!< Timer reset on Trigger rising or falling edge. */ 0117 } flexio_timer_reset_condition_t; 0118 0119 /*! @brief Define type of timer disable condition.*/ 0120 typedef enum _flexio_timer_disable_condition 0121 { 0122 kFLEXIO_TimerDisableNever = 0x0U, /*!< Timer never disabled. */ 0123 kFLEXIO_TimerDisableOnPreTimerDisable = 0x1U, /*!< Timer disabled on Timer N-1 disable. */ 0124 kFLEXIO_TimerDisableOnTimerCompare = 0x2U, /*!< Timer disabled on Timer compare. */ 0125 kFLEXIO_TimerDisableOnTimerCompareTriggerLow = 0x3U, /*!< Timer disabled on Timer compare and Trigger Low. */ 0126 kFLEXIO_TimerDisableOnPinBothEdge = 0x4U, /*!< Timer disabled on Pin rising or falling edge. */ 0127 kFLEXIO_TimerDisableOnPinBothEdgeTriggerHigh = 0x5U, /*!< Timer disabled on Pin rising or falling edge provided 0128 Trigger is high. */ 0129 kFLEXIO_TimerDisableOnTriggerFallingEdge = 0x6U, /*!< Timer disabled on Trigger falling edge. */ 0130 } flexio_timer_disable_condition_t; 0131 0132 /*! @brief Define type of timer enable condition.*/ 0133 typedef enum _flexio_timer_enable_condition 0134 { 0135 kFLEXIO_TimerEnabledAlways = 0x0U, /*!< Timer always enabled. */ 0136 kFLEXIO_TimerEnableOnPrevTimerEnable = 0x1U, /*!< Timer enabled on Timer N-1 enable. */ 0137 kFLEXIO_TimerEnableOnTriggerHigh = 0x2U, /*!< Timer enabled on Trigger high. */ 0138 kFLEXIO_TimerEnableOnTriggerHighPinHigh = 0x3U, /*!< Timer enabled on Trigger high and Pin high. */ 0139 kFLEXIO_TimerEnableOnPinRisingEdge = 0x4U, /*!< Timer enabled on Pin rising edge. */ 0140 kFLEXIO_TimerEnableOnPinRisingEdgeTriggerHigh = 0x5U, /*!< Timer enabled on Pin rising edge and Trigger high. */ 0141 kFLEXIO_TimerEnableOnTriggerRisingEdge = 0x6U, /*!< Timer enabled on Trigger rising edge. */ 0142 kFLEXIO_TimerEnableOnTriggerBothEdge = 0x7U, /*!< Timer enabled on Trigger rising or falling edge. */ 0143 } flexio_timer_enable_condition_t; 0144 0145 /*! @brief Define type of timer stop bit generate condition.*/ 0146 typedef enum _flexio_timer_stop_bit_condition 0147 { 0148 kFLEXIO_TimerStopBitDisabled = 0x0U, /*!< Stop bit disabled. */ 0149 kFLEXIO_TimerStopBitEnableOnTimerCompare = 0x1U, /*!< Stop bit is enabled on timer compare. */ 0150 kFLEXIO_TimerStopBitEnableOnTimerDisable = 0x2U, /*!< Stop bit is enabled on timer disable. */ 0151 kFLEXIO_TimerStopBitEnableOnTimerCompareDisable = 0x3U, /*!< Stop bit is enabled on timer compare and timer 0152 disable. */ 0153 } flexio_timer_stop_bit_condition_t; 0154 0155 /*! @brief Define type of timer start bit generate condition.*/ 0156 typedef enum _flexio_timer_start_bit_condition 0157 { 0158 kFLEXIO_TimerStartBitDisabled = 0x0U, /*!< Start bit disabled. */ 0159 kFLEXIO_TimerStartBitEnabled = 0x1U, /*!< Start bit enabled. */ 0160 } flexio_timer_start_bit_condition_t; 0161 0162 /*! @brief FlexIO as PWM channel output state */ 0163 typedef enum _flexio_timer_output_state 0164 { 0165 kFLEXIO_PwmLow = 0, /*!< The output state of PWM channel is low */ 0166 kFLEXIO_PwmHigh, /*!< The output state of PWM channel is high */ 0167 } flexio_timer_output_state_t; 0168 0169 /*! @brief Define type of timer polarity for shifter control. */ 0170 typedef enum _flexio_shifter_timer_polarity 0171 { 0172 kFLEXIO_ShifterTimerPolarityOnPositive = 0x0U, /*!< Shift on positive edge of shift clock. */ 0173 kFLEXIO_ShifterTimerPolarityOnNegitive = 0x1U, /*!< Shift on negative edge of shift clock. */ 0174 } flexio_shifter_timer_polarity_t; 0175 0176 /*! @brief Define type of shifter working mode.*/ 0177 typedef enum _flexio_shifter_mode 0178 { 0179 kFLEXIO_ShifterDisabled = 0x0U, /*!< Shifter is disabled. */ 0180 kFLEXIO_ShifterModeReceive = 0x1U, /*!< Receive mode. */ 0181 kFLEXIO_ShifterModeTransmit = 0x2U, /*!< Transmit mode. */ 0182 kFLEXIO_ShifterModeMatchStore = 0x4U, /*!< Match store mode. */ 0183 kFLEXIO_ShifterModeMatchContinuous = 0x5U, /*!< Match continuous mode. */ 0184 #if FSL_FEATURE_FLEXIO_HAS_STATE_MODE 0185 kFLEXIO_ShifterModeState = 0x6U, /*!< SHIFTBUF contents are used for storing 0186 programmable state attributes. */ 0187 #endif /* FSL_FEATURE_FLEXIO_HAS_STATE_MODE */ 0188 #if FSL_FEATURE_FLEXIO_HAS_LOGIC_MODE 0189 kFLEXIO_ShifterModeLogic = 0x7U, /*!< SHIFTBUF contents are used for implementing 0190 programmable logic look up table. */ 0191 #endif /* FSL_FEATURE_FLEXIO_HAS_LOGIC_MODE */ 0192 } flexio_shifter_mode_t; 0193 0194 /*! @brief Define type of shifter input source.*/ 0195 typedef enum _flexio_shifter_input_source 0196 { 0197 kFLEXIO_ShifterInputFromPin = 0x0U, /*!< Shifter input from pin. */ 0198 kFLEXIO_ShifterInputFromNextShifterOutput = 0x1U, /*!< Shifter input from Shifter N+1. */ 0199 } flexio_shifter_input_source_t; 0200 0201 /*! @brief Define of STOP bit configuration.*/ 0202 typedef enum _flexio_shifter_stop_bit 0203 { 0204 kFLEXIO_ShifterStopBitDisable = 0x0U, /*!< Disable shifter stop bit. */ 0205 kFLEXIO_ShifterStopBitLow = 0x2U, /*!< Set shifter stop bit to logic low level. */ 0206 kFLEXIO_ShifterStopBitHigh = 0x3U, /*!< Set shifter stop bit to logic high level. */ 0207 } flexio_shifter_stop_bit_t; 0208 0209 /*! @brief Define type of START bit configuration.*/ 0210 typedef enum _flexio_shifter_start_bit 0211 { 0212 kFLEXIO_ShifterStartBitDisabledLoadDataOnEnable = 0x0U, /*!< Disable shifter start bit, transmitter loads 0213 data on enable. */ 0214 kFLEXIO_ShifterStartBitDisabledLoadDataOnShift = 0x1U, /*!< Disable shifter start bit, transmitter loads 0215 data on first shift. */ 0216 kFLEXIO_ShifterStartBitLow = 0x2U, /*!< Set shifter start bit to logic low level. */ 0217 kFLEXIO_ShifterStartBitHigh = 0x3U, /*!< Set shifter start bit to logic high level. */ 0218 } flexio_shifter_start_bit_t; 0219 0220 /*! @brief Define FlexIO shifter buffer type*/ 0221 typedef enum _flexio_shifter_buffer_type 0222 { 0223 kFLEXIO_ShifterBuffer = 0x0U, /*!< Shifter Buffer N Register. */ 0224 kFLEXIO_ShifterBufferBitSwapped = 0x1U, /*!< Shifter Buffer N Bit Byte Swapped Register. */ 0225 kFLEXIO_ShifterBufferByteSwapped = 0x2U, /*!< Shifter Buffer N Byte Swapped Register. */ 0226 kFLEXIO_ShifterBufferBitByteSwapped = 0x3U, /*!< Shifter Buffer N Bit Swapped Register. */ 0227 #if defined(FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_NIBBLE_BYTE_SWAP) && FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_NIBBLE_BYTE_SWAP 0228 kFLEXIO_ShifterBufferNibbleByteSwapped = 0x4U, /*!< Shifter Buffer N Nibble Byte Swapped Register. */ 0229 #endif /*FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_NIBBLE_BYTE_SWAP*/ 0230 #if defined(FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_HALF_WORD_SWAP) && FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_HALF_WORD_SWAP 0231 kFLEXIO_ShifterBufferHalfWordSwapped = 0x5U, /*!< Shifter Buffer N Half Word Swapped Register. */ 0232 #endif 0233 #if defined(FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_NIBBLE_SWAP) && FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_NIBBLE_SWAP 0234 kFLEXIO_ShifterBufferNibbleSwapped = 0x6U, /*!< Shifter Buffer N Nibble Swapped Register. */ 0235 #endif 0236 } flexio_shifter_buffer_type_t; 0237 0238 /*! @brief Define FlexIO user configuration structure. */ 0239 typedef struct _flexio_config_ 0240 { 0241 bool enableFlexio; /*!< Enable/disable FlexIO module */ 0242 bool enableInDoze; /*!< Enable/disable FlexIO operation in doze mode */ 0243 bool enableInDebug; /*!< Enable/disable FlexIO operation in debug mode */ 0244 bool enableFastAccess; /*!< Enable/disable fast access to FlexIO registers, fast access requires 0245 the FlexIO clock to be at least twice the frequency of the bus clock. */ 0246 } flexio_config_t; 0247 0248 /*! @brief Define FlexIO timer configuration structure. */ 0249 typedef struct _flexio_timer_config 0250 { 0251 /* Trigger. */ 0252 uint32_t triggerSelect; /*!< The internal trigger selection number using MACROs. */ 0253 flexio_timer_trigger_polarity_t triggerPolarity; /*!< Trigger Polarity. */ 0254 flexio_timer_trigger_source_t triggerSource; /*!< Trigger Source, internal (see 'trgsel') or external. */ 0255 /* Pin. */ 0256 flexio_pin_config_t pinConfig; /*!< Timer Pin Configuration. */ 0257 uint32_t pinSelect; /*!< Timer Pin number Select. */ 0258 flexio_pin_polarity_t pinPolarity; /*!< Timer Pin Polarity. */ 0259 /* Timer. */ 0260 flexio_timer_mode_t timerMode; /*!< Timer work Mode. */ 0261 flexio_timer_output_t timerOutput; /*!< Configures the initial state of the Timer Output and 0262 whether it is affected by the Timer reset. */ 0263 flexio_timer_decrement_source_t timerDecrement; /*!< Configures the source of the Timer decrement and the 0264 source of the Shift clock. */ 0265 flexio_timer_reset_condition_t timerReset; /*!< Configures the condition that causes the timer counter 0266 (and optionally the timer output) to be reset. */ 0267 flexio_timer_disable_condition_t timerDisable; /*!< Configures the condition that causes the Timer to be 0268 disabled and stop decrementing. */ 0269 flexio_timer_enable_condition_t timerEnable; /*!< Configures the condition that causes the Timer to be 0270 enabled and start decrementing. */ 0271 flexio_timer_stop_bit_condition_t timerStop; /*!< Timer STOP Bit generation. */ 0272 flexio_timer_start_bit_condition_t timerStart; /*!< Timer STRAT Bit generation. */ 0273 uint32_t timerCompare; /*!< Value for Timer Compare N Register. */ 0274 } flexio_timer_config_t; 0275 0276 /*! @brief Define FlexIO shifter configuration structure. */ 0277 typedef struct _flexio_shifter_config 0278 { 0279 /* Timer. */ 0280 uint32_t timerSelect; /*!< Selects which Timer is used for controlling the 0281 logic/shift register and generating the Shift clock. */ 0282 flexio_shifter_timer_polarity_t timerPolarity; /*!< Timer Polarity. */ 0283 /* Pin. */ 0284 flexio_pin_config_t pinConfig; /*!< Shifter Pin Configuration. */ 0285 uint32_t pinSelect; /*!< Shifter Pin number Select. */ 0286 flexio_pin_polarity_t pinPolarity; /*!< Shifter Pin Polarity. */ 0287 /* Shifter. */ 0288 flexio_shifter_mode_t shifterMode; /*!< Configures the mode of the Shifter. */ 0289 #if FSL_FEATURE_FLEXIO_HAS_PARALLEL_WIDTH 0290 uint32_t parallelWidth; /*!< Configures the parallel width when using parallel mode.*/ 0291 #endif /* FSL_FEATURE_FLEXIO_HAS_PARALLEL_WIDTH */ 0292 flexio_shifter_input_source_t inputSource; /*!< Selects the input source for the shifter. */ 0293 flexio_shifter_stop_bit_t shifterStop; /*!< Shifter STOP bit. */ 0294 flexio_shifter_start_bit_t shifterStart; /*!< Shifter START bit. */ 0295 } flexio_shifter_config_t; 0296 0297 /*! @brief typedef for FlexIO simulated driver interrupt handler.*/ 0298 typedef void (*flexio_isr_t)(void *base, void *handle); 0299 0300 /******************************************************************************* 0301 * Variables 0302 ******************************************************************************/ 0303 /*! @brief Pointers to flexio bases for each instance. */ 0304 extern FLEXIO_Type *const s_flexioBases[]; 0305 0306 #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) 0307 /*! @brief Pointers to flexio clocks for each instance. */ 0308 extern const clock_ip_name_t s_flexioClocks[]; 0309 #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */ 0310 /******************************************************************************* 0311 * API 0312 ******************************************************************************/ 0313 0314 #if defined(__cplusplus) 0315 extern "C" { 0316 #endif /*_cplusplus*/ 0317 0318 /*! 0319 * @name FlexIO Initialization and De-initialization 0320 * @{ 0321 */ 0322 0323 /*! 0324 * @brief Gets the default configuration to configure the FlexIO module. The configuration 0325 * can used directly to call the FLEXIO_Configure(). 0326 * 0327 * Example: 0328 @code 0329 flexio_config_t config; 0330 FLEXIO_GetDefaultConfig(&config); 0331 @endcode 0332 * 0333 * @param userConfig pointer to flexio_config_t structure 0334 */ 0335 void FLEXIO_GetDefaultConfig(flexio_config_t *userConfig); 0336 0337 /*! 0338 * @brief Configures the FlexIO with a FlexIO configuration. The configuration structure 0339 * can be filled by the user or be set with default values by FLEXIO_GetDefaultConfig(). 0340 * 0341 * Example 0342 @code 0343 flexio_config_t config = { 0344 .enableFlexio = true, 0345 .enableInDoze = false, 0346 .enableInDebug = true, 0347 .enableFastAccess = false 0348 }; 0349 FLEXIO_Configure(base, &config); 0350 @endcode 0351 * 0352 * @param base FlexIO peripheral base address 0353 * @param userConfig pointer to flexio_config_t structure 0354 */ 0355 void FLEXIO_Init(FLEXIO_Type *base, const flexio_config_t *userConfig); 0356 0357 /*! 0358 * @brief Gates the FlexIO clock. Call this API to stop the FlexIO clock. 0359 * 0360 * @note After calling this API, call the FLEXO_Init to use the FlexIO module. 0361 * 0362 * @param base FlexIO peripheral base address 0363 */ 0364 void FLEXIO_Deinit(FLEXIO_Type *base); 0365 0366 /*! 0367 * @brief Get instance number for FLEXIO module. 0368 * 0369 * @param base FLEXIO peripheral base address. 0370 */ 0371 uint32_t FLEXIO_GetInstance(FLEXIO_Type *base); 0372 0373 /* @} */ 0374 0375 /*! 0376 * @name FlexIO Basic Operation 0377 * @{ 0378 */ 0379 0380 /*! 0381 * @brief Resets the FlexIO module. 0382 * 0383 * @param base FlexIO peripheral base address 0384 */ 0385 void FLEXIO_Reset(FLEXIO_Type *base); 0386 0387 /*! 0388 * @brief Enables the FlexIO module operation. 0389 * 0390 * @param base FlexIO peripheral base address 0391 * @param enable true to enable, false to disable. 0392 */ 0393 static inline void FLEXIO_Enable(FLEXIO_Type *base, bool enable) 0394 { 0395 if (enable) 0396 { 0397 base->CTRL |= FLEXIO_CTRL_FLEXEN_MASK; 0398 } 0399 else 0400 { 0401 base->CTRL &= ~FLEXIO_CTRL_FLEXEN_MASK; 0402 } 0403 } 0404 0405 #if defined(FSL_FEATURE_FLEXIO_HAS_PIN_STATUS) && FSL_FEATURE_FLEXIO_HAS_PIN_STATUS 0406 /*! 0407 * @brief Reads the input data on each of the FlexIO pins. 0408 * 0409 * @param base FlexIO peripheral base address 0410 * @return FlexIO pin input data 0411 */ 0412 static inline uint32_t FLEXIO_ReadPinInput(FLEXIO_Type *base) 0413 { 0414 return base->PIN; 0415 } 0416 #endif /*FSL_FEATURE_FLEXIO_HAS_PIN_STATUS*/ 0417 0418 #if defined(FSL_FEATURE_FLEXIO_HAS_STATE_MODE) && FSL_FEATURE_FLEXIO_HAS_STATE_MODE 0419 /*! 0420 * @brief Gets the current state pointer for state mode use. 0421 * 0422 * @param base FlexIO peripheral base address 0423 * @return current State pointer 0424 */ 0425 static inline uint8_t FLEXIO_GetShifterState(FLEXIO_Type *base) 0426 { 0427 return ((uint8_t)(base->SHIFTSTATE) & FLEXIO_SHIFTSTATE_STATE_MASK); 0428 } 0429 #endif /*FSL_FEATURE_FLEXIO_HAS_STATE_MODE*/ 0430 0431 /*! 0432 * @brief Configures the shifter with the shifter configuration. The configuration structure 0433 * covers both the SHIFTCTL and SHIFTCFG registers. To configure the shifter to the proper 0434 * mode, select which timer controls the shifter to shift, whether to generate start bit/stop 0435 * bit, and the polarity of start bit and stop bit. 0436 * 0437 * Example 0438 @code 0439 flexio_shifter_config_t config = { 0440 .timerSelect = 0, 0441 .timerPolarity = kFLEXIO_ShifterTimerPolarityOnPositive, 0442 .pinConfig = kFLEXIO_PinConfigOpenDrainOrBidirection, 0443 .pinPolarity = kFLEXIO_PinActiveLow, 0444 .shifterMode = kFLEXIO_ShifterModeTransmit, 0445 .inputSource = kFLEXIO_ShifterInputFromPin, 0446 .shifterStop = kFLEXIO_ShifterStopBitHigh, 0447 .shifterStart = kFLEXIO_ShifterStartBitLow 0448 }; 0449 FLEXIO_SetShifterConfig(base, &config); 0450 @endcode 0451 * 0452 * @param base FlexIO peripheral base address 0453 * @param index Shifter index 0454 * @param shifterConfig Pointer to flexio_shifter_config_t structure 0455 */ 0456 void FLEXIO_SetShifterConfig(FLEXIO_Type *base, uint8_t index, const flexio_shifter_config_t *shifterConfig); 0457 /*! 0458 * @brief Configures the timer with the timer configuration. The configuration structure 0459 * covers both the TIMCTL and TIMCFG registers. To configure the timer to the proper 0460 * mode, select trigger source for timer and the timer pin output and the timing for timer. 0461 * 0462 * Example 0463 @code 0464 flexio_timer_config_t config = { 0465 .triggerSelect = FLEXIO_TIMER_TRIGGER_SEL_SHIFTnSTAT(0), 0466 .triggerPolarity = kFLEXIO_TimerTriggerPolarityActiveLow, 0467 .triggerSource = kFLEXIO_TimerTriggerSourceInternal, 0468 .pinConfig = kFLEXIO_PinConfigOpenDrainOrBidirection, 0469 .pinSelect = 0, 0470 .pinPolarity = kFLEXIO_PinActiveHigh, 0471 .timerMode = kFLEXIO_TimerModeDual8BitBaudBit, 0472 .timerOutput = kFLEXIO_TimerOutputZeroNotAffectedByReset, 0473 .timerDecrement = kFLEXIO_TimerDecSrcOnFlexIOClockShiftTimerOutput, 0474 .timerReset = kFLEXIO_TimerResetOnTimerPinEqualToTimerOutput, 0475 .timerDisable = kFLEXIO_TimerDisableOnTimerCompare, 0476 .timerEnable = kFLEXIO_TimerEnableOnTriggerHigh, 0477 .timerStop = kFLEXIO_TimerStopBitEnableOnTimerDisable, 0478 .timerStart = kFLEXIO_TimerStartBitEnabled 0479 }; 0480 FLEXIO_SetTimerConfig(base, &config); 0481 @endcode 0482 * 0483 * @param base FlexIO peripheral base address 0484 * @param index Timer index 0485 * @param timerConfig Pointer to the flexio_timer_config_t structure 0486 */ 0487 void FLEXIO_SetTimerConfig(FLEXIO_Type *base, uint8_t index, const flexio_timer_config_t *timerConfig); 0488 0489 /*! 0490 * @brief This function set the value of the prescaler on flexio channels 0491 * 0492 * @param base Pointer to the FlexIO simulated peripheral type. 0493 * @param clocksource Set clock value 0494 */ 0495 static inline void FLEXIO_SetClockMode(FLEXIO_Type *base, uint8_t index, flexio_timer_decrement_source_t clocksource) 0496 { 0497 uint32_t reg = base->TIMCFG[index]; 0498 0499 reg &= ~FLEXIO_TIMCFG_TIMDEC_MASK; 0500 0501 reg |= FLEXIO_TIMCFG_TIMDEC(clocksource); 0502 0503 base->TIMCFG[index] = reg; 0504 } 0505 0506 /* @} */ 0507 0508 /*! 0509 * @name FlexIO Interrupt Operation 0510 * @{ 0511 */ 0512 0513 /*! 0514 * @brief Enables the shifter status interrupt. The interrupt generates when the corresponding SSF is set. 0515 * 0516 * @param base FlexIO peripheral base address 0517 * @param mask The shifter status mask which can be calculated by (1 << shifter index) 0518 * @note For multiple shifter status interrupt enable, for example, two shifter status enable, can calculate 0519 * the mask by using ((1 << shifter index0) | (1 << shifter index1)) 0520 */ 0521 static inline void FLEXIO_EnableShifterStatusInterrupts(FLEXIO_Type *base, uint32_t mask) 0522 { 0523 base->SHIFTSIEN |= mask; 0524 } 0525 0526 /*! 0527 * @brief Disables the shifter status interrupt. The interrupt won't generate when the corresponding SSF is set. 0528 * 0529 * @param base FlexIO peripheral base address 0530 * @param mask The shifter status mask which can be calculated by (1 << shifter index) 0531 * @note For multiple shifter status interrupt enable, for example, two shifter status enable, can calculate 0532 * the mask by using ((1 << shifter index0) | (1 << shifter index1)) 0533 */ 0534 static inline void FLEXIO_DisableShifterStatusInterrupts(FLEXIO_Type *base, uint32_t mask) 0535 { 0536 base->SHIFTSIEN &= ~mask; 0537 } 0538 0539 /*! 0540 * @brief Enables the shifter error interrupt. The interrupt generates when the corresponding SEF is set. 0541 * 0542 * @param base FlexIO peripheral base address 0543 * @param mask The shifter error mask which can be calculated by (1 << shifter index) 0544 * @note For multiple shifter error interrupt enable, for example, two shifter error enable, can calculate 0545 * the mask by using ((1 << shifter index0) | (1 << shifter index1)) 0546 */ 0547 static inline void FLEXIO_EnableShifterErrorInterrupts(FLEXIO_Type *base, uint32_t mask) 0548 { 0549 base->SHIFTEIEN |= mask; 0550 } 0551 0552 /*! 0553 * @brief Disables the shifter error interrupt. The interrupt won't generate when the corresponding SEF is set. 0554 * 0555 * @param base FlexIO peripheral base address 0556 * @param mask The shifter error mask which can be calculated by (1 << shifter index) 0557 * @note For multiple shifter error interrupt enable, for example, two shifter error enable, can calculate 0558 * the mask by using ((1 << shifter index0) | (1 << shifter index1)) 0559 */ 0560 static inline void FLEXIO_DisableShifterErrorInterrupts(FLEXIO_Type *base, uint32_t mask) 0561 { 0562 base->SHIFTEIEN &= ~mask; 0563 } 0564 0565 /*! 0566 * @brief Enables the timer status interrupt. The interrupt generates when the corresponding SSF is set. 0567 * 0568 * @param base FlexIO peripheral base address 0569 * @param mask The timer status mask which can be calculated by (1 << timer index) 0570 * @note For multiple timer status interrupt enable, for example, two timer status enable, can calculate 0571 * the mask by using ((1 << timer index0) | (1 << timer index1)) 0572 */ 0573 static inline void FLEXIO_EnableTimerStatusInterrupts(FLEXIO_Type *base, uint32_t mask) 0574 { 0575 base->TIMIEN |= mask; 0576 } 0577 0578 /*! 0579 * @brief Disables the timer status interrupt. The interrupt won't generate when the corresponding SSF is set. 0580 * 0581 * @param base FlexIO peripheral base address 0582 * @param mask The timer status mask which can be calculated by (1 << timer index) 0583 * @note For multiple timer status interrupt enable, for example, two timer status enable, can calculate 0584 * the mask by using ((1 << timer index0) | (1 << timer index1)) 0585 */ 0586 static inline void FLEXIO_DisableTimerStatusInterrupts(FLEXIO_Type *base, uint32_t mask) 0587 { 0588 base->TIMIEN &= ~mask; 0589 } 0590 0591 /* @} */ 0592 0593 /*! 0594 * @name FlexIO Status Operation 0595 * @{ 0596 */ 0597 0598 /*! 0599 * @brief Gets the shifter status flags. 0600 * 0601 * @param base FlexIO peripheral base address 0602 * @return Shifter status flags 0603 */ 0604 static inline uint32_t FLEXIO_GetShifterStatusFlags(FLEXIO_Type *base) 0605 { 0606 return ((base->SHIFTSTAT) & FLEXIO_SHIFTSTAT_SSF_MASK); 0607 } 0608 0609 /*! 0610 * @brief Clears the shifter status flags. 0611 * 0612 * @param base FlexIO peripheral base address 0613 * @param mask The shifter status mask which can be calculated by (1 << shifter index) 0614 * @note For clearing multiple shifter status flags, for example, two shifter status flags, can calculate 0615 * the mask by using ((1 << shifter index0) | (1 << shifter index1)) 0616 */ 0617 static inline void FLEXIO_ClearShifterStatusFlags(FLEXIO_Type *base, uint32_t mask) 0618 { 0619 base->SHIFTSTAT = mask; 0620 } 0621 0622 /*! 0623 * @brief Gets the shifter error flags. 0624 * 0625 * @param base FlexIO peripheral base address 0626 * @return Shifter error flags 0627 */ 0628 static inline uint32_t FLEXIO_GetShifterErrorFlags(FLEXIO_Type *base) 0629 { 0630 return ((base->SHIFTERR) & FLEXIO_SHIFTERR_SEF_MASK); 0631 } 0632 0633 /*! 0634 * @brief Clears the shifter error flags. 0635 * 0636 * @param base FlexIO peripheral base address 0637 * @param mask The shifter error mask which can be calculated by (1 << shifter index) 0638 * @note For clearing multiple shifter error flags, for example, two shifter error flags, can calculate 0639 * the mask by using ((1 << shifter index0) | (1 << shifter index1)) 0640 */ 0641 static inline void FLEXIO_ClearShifterErrorFlags(FLEXIO_Type *base, uint32_t mask) 0642 { 0643 base->SHIFTERR = mask; 0644 } 0645 0646 /*! 0647 * @brief Gets the timer status flags. 0648 * 0649 * @param base FlexIO peripheral base address 0650 * @return Timer status flags 0651 */ 0652 static inline uint32_t FLEXIO_GetTimerStatusFlags(FLEXIO_Type *base) 0653 { 0654 return ((base->TIMSTAT) & FLEXIO_TIMSTAT_TSF_MASK); 0655 } 0656 0657 /*! 0658 * @brief Clears the timer status flags. 0659 * 0660 * @param base FlexIO peripheral base address 0661 * @param mask The timer status mask which can be calculated by (1 << timer index) 0662 * @note For clearing multiple timer status flags, for example, two timer status flags, can calculate 0663 * the mask by using ((1 << timer index0) | (1 << timer index1)) 0664 */ 0665 static inline void FLEXIO_ClearTimerStatusFlags(FLEXIO_Type *base, uint32_t mask) 0666 { 0667 base->TIMSTAT = mask; 0668 } 0669 0670 /* @} */ 0671 0672 /*! 0673 * @name FlexIO DMA Operation 0674 * @{ 0675 */ 0676 0677 /*! 0678 * @brief Enables/disables the shifter status DMA. The DMA request generates when the corresponding SSF is set. 0679 * 0680 * @note For multiple shifter status DMA enables, for example, calculate 0681 * the mask by using ((1 << shifter index0) | (1 << shifter index1)) 0682 * 0683 * @param base FlexIO peripheral base address 0684 * @param mask The shifter status mask which can be calculated by (1 << shifter index) 0685 * @param enable True to enable, false to disable. 0686 */ 0687 static inline void FLEXIO_EnableShifterStatusDMA(FLEXIO_Type *base, uint32_t mask, bool enable) 0688 { 0689 if (enable) 0690 { 0691 base->SHIFTSDEN |= mask; 0692 } 0693 else 0694 { 0695 base->SHIFTSDEN &= ~mask; 0696 } 0697 } 0698 0699 /*! 0700 * @brief Gets the shifter buffer address for the DMA transfer usage. 0701 * 0702 * @param base FlexIO peripheral base address 0703 * @param type Shifter type of flexio_shifter_buffer_type_t 0704 * @param index Shifter index 0705 * @return Corresponding shifter buffer index 0706 */ 0707 uint32_t FLEXIO_GetShifterBufferAddress(FLEXIO_Type *base, flexio_shifter_buffer_type_t type, uint8_t index); 0708 0709 /*! 0710 * @brief Registers the handle and the interrupt handler for the FlexIO-simulated peripheral. 0711 * 0712 * @param base Pointer to the FlexIO simulated peripheral type. 0713 * @param handle Pointer to the handler for FlexIO simulated peripheral. 0714 * @param isr FlexIO simulated peripheral interrupt handler. 0715 * @retval kStatus_Success Successfully create the handle. 0716 * @retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. 0717 */ 0718 status_t FLEXIO_RegisterHandleIRQ(void *base, void *handle, flexio_isr_t isr); 0719 0720 /*! 0721 * @brief Unregisters the handle and the interrupt handler for the FlexIO-simulated peripheral. 0722 * 0723 * @param base Pointer to the FlexIO simulated peripheral type. 0724 * @retval kStatus_Success Successfully create the handle. 0725 * @retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. 0726 */ 0727 status_t FLEXIO_UnregisterHandleIRQ(void *base); 0728 /* @} */ 0729 0730 #if defined(__cplusplus) 0731 } 0732 #endif /*_cplusplus*/ 0733 /*@}*/ 0734 0735 #endif /*_FSL_FLEXIO_H_*/
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |