123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726 |
- #ifndef _FSL_FLEXIO_H_
- #define _FSL_FLEXIO_H_
- #include "fsl_common.h"
- #define FSL_FLEXIO_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
- #define FLEXIO_TIMER_TRIGGER_SEL_PININPUT(x) ((uint32_t)(x) << 1U)
- #define FLEXIO_TIMER_TRIGGER_SEL_SHIFTnSTAT(x) (((uint32_t)(x) << 2U) | 0x1U)
- #define FLEXIO_TIMER_TRIGGER_SEL_TIMn(x) (((uint32_t)(x) << 2U) | 0x3U)
- typedef enum _flexio_timer_trigger_polarity
- {
- kFLEXIO_TimerTriggerPolarityActiveHigh = 0x0U,
- kFLEXIO_TimerTriggerPolarityActiveLow = 0x1U,
- } flexio_timer_trigger_polarity_t;
- typedef enum _flexio_timer_trigger_source
- {
- kFLEXIO_TimerTriggerSourceExternal = 0x0U,
- kFLEXIO_TimerTriggerSourceInternal = 0x1U,
- } flexio_timer_trigger_source_t;
- typedef enum _flexio_pin_config
- {
- kFLEXIO_PinConfigOutputDisabled = 0x0U,
- kFLEXIO_PinConfigOpenDrainOrBidirection = 0x1U,
- kFLEXIO_PinConfigBidirectionOutputData = 0x2U,
- kFLEXIO_PinConfigOutput = 0x3U,
- } flexio_pin_config_t;
- typedef enum _flexio_pin_polarity
- {
- kFLEXIO_PinActiveHigh = 0x0U,
- kFLEXIO_PinActiveLow = 0x1U,
- } flexio_pin_polarity_t;
- typedef enum _flexio_timer_mode
- {
- kFLEXIO_TimerModeDisabled = 0x0U,
- kFLEXIO_TimerModeDual8BitBaudBit = 0x1U,
- kFLEXIO_TimerModeDual8BitPWM = 0x2U,
- kFLEXIO_TimerModeSingle16Bit = 0x3U,
- } flexio_timer_mode_t;
- typedef enum _flexio_timer_output
- {
- kFLEXIO_TimerOutputOneNotAffectedByReset = 0x0U,
- kFLEXIO_TimerOutputZeroNotAffectedByReset = 0x1U,
- kFLEXIO_TimerOutputOneAffectedByReset = 0x2U,
- kFLEXIO_TimerOutputZeroAffectedByReset = 0x3U,
- } flexio_timer_output_t;
- typedef enum _flexio_timer_decrement_source
- {
- kFLEXIO_TimerDecSrcOnFlexIOClockShiftTimerOutput = 0x0U,
- kFLEXIO_TimerDecSrcOnTriggerInputShiftTimerOutput = 0x1U,
- kFLEXIO_TimerDecSrcOnPinInputShiftPinInput = 0x2U,
- kFLEXIO_TimerDecSrcOnTriggerInputShiftTriggerInput = 0x3U,
- } flexio_timer_decrement_source_t;
- typedef enum _flexio_timer_reset_condition
- {
- kFLEXIO_TimerResetNever = 0x0U,
- kFLEXIO_TimerResetOnTimerPinEqualToTimerOutput = 0x2U,
- kFLEXIO_TimerResetOnTimerTriggerEqualToTimerOutput = 0x3U,
- kFLEXIO_TimerResetOnTimerPinRisingEdge = 0x4U,
- kFLEXIO_TimerResetOnTimerTriggerRisingEdge = 0x6U,
- kFLEXIO_TimerResetOnTimerTriggerBothEdge = 0x7U,
- } flexio_timer_reset_condition_t;
- typedef enum _flexio_timer_disable_condition
- {
- kFLEXIO_TimerDisableNever = 0x0U,
- kFLEXIO_TimerDisableOnPreTimerDisable = 0x1U,
- kFLEXIO_TimerDisableOnTimerCompare = 0x2U,
- kFLEXIO_TimerDisableOnTimerCompareTriggerLow = 0x3U,
- kFLEXIO_TimerDisableOnPinBothEdge = 0x4U,
- kFLEXIO_TimerDisableOnPinBothEdgeTriggerHigh = 0x5U,
- kFLEXIO_TimerDisableOnTriggerFallingEdge = 0x6U,
- } flexio_timer_disable_condition_t;
- typedef enum _flexio_timer_enable_condition
- {
- kFLEXIO_TimerEnabledAlways = 0x0U,
- kFLEXIO_TimerEnableOnPrevTimerEnable = 0x1U,
- kFLEXIO_TimerEnableOnTriggerHigh = 0x2U,
- kFLEXIO_TimerEnableOnTriggerHighPinHigh = 0x3U,
- kFLEXIO_TimerEnableOnPinRisingEdge = 0x4U,
- kFLEXIO_TimerEnableOnPinRisingEdgeTriggerHigh = 0x5U,
- kFLEXIO_TimerEnableOnTriggerRisingEdge = 0x6U,
- kFLEXIO_TimerEnableOnTriggerBothEdge = 0x7U,
- } flexio_timer_enable_condition_t;
- typedef enum _flexio_timer_stop_bit_condition
- {
- kFLEXIO_TimerStopBitDisabled = 0x0U,
- kFLEXIO_TimerStopBitEnableOnTimerCompare = 0x1U,
- kFLEXIO_TimerStopBitEnableOnTimerDisable = 0x2U,
- kFLEXIO_TimerStopBitEnableOnTimerCompareDisable = 0x3U,
- } flexio_timer_stop_bit_condition_t;
- typedef enum _flexio_timer_start_bit_condition
- {
- kFLEXIO_TimerStartBitDisabled = 0x0U,
- kFLEXIO_TimerStartBitEnabled = 0x1U,
- } flexio_timer_start_bit_condition_t;
- typedef enum _flexio_shifter_timer_polarity
- {
- kFLEXIO_ShifterTimerPolarityOnPositive = 0x0U,
- kFLEXIO_ShifterTimerPolarityOnNegitive = 0x1U,
- } flexio_shifter_timer_polarity_t;
- typedef enum _flexio_shifter_mode
- {
- kFLEXIO_ShifterDisabled = 0x0U,
- kFLEXIO_ShifterModeReceive = 0x1U,
- kFLEXIO_ShifterModeTransmit = 0x2U,
- kFLEXIO_ShifterModeMatchStore = 0x4U,
- kFLEXIO_ShifterModeMatchContinuous = 0x5U,
- #if FSL_FEATURE_FLEXIO_HAS_STATE_MODE
- kFLEXIO_ShifterModeState = 0x6U,
- #endif
- #if FSL_FEATURE_FLEXIO_HAS_LOGIC_MODE
- kFLEXIO_ShifterModeLogic = 0x7U,
- #endif
- } flexio_shifter_mode_t;
- typedef enum _flexio_shifter_input_source
- {
- kFLEXIO_ShifterInputFromPin = 0x0U,
- kFLEXIO_ShifterInputFromNextShifterOutput = 0x1U,
- } flexio_shifter_input_source_t;
- typedef enum _flexio_shifter_stop_bit
- {
- kFLEXIO_ShifterStopBitDisable = 0x0U,
- kFLEXIO_ShifterStopBitLow = 0x2U,
- kFLEXIO_ShifterStopBitHigh = 0x3U,
- } flexio_shifter_stop_bit_t;
- typedef enum _flexio_shifter_start_bit
- {
- kFLEXIO_ShifterStartBitDisabledLoadDataOnEnable = 0x0U,
- kFLEXIO_ShifterStartBitDisabledLoadDataOnShift = 0x1U,
- kFLEXIO_ShifterStartBitLow = 0x2U,
- kFLEXIO_ShifterStartBitHigh = 0x3U,
- } flexio_shifter_start_bit_t;
- typedef enum _flexio_shifter_buffer_type
- {
- kFLEXIO_ShifterBuffer = 0x0U,
- kFLEXIO_ShifterBufferBitSwapped = 0x1U,
- kFLEXIO_ShifterBufferByteSwapped = 0x2U,
- kFLEXIO_ShifterBufferBitByteSwapped = 0x3U,
- #if defined(FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_NIBBLE_BYTE_SWAP) && FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_NIBBLE_BYTE_SWAP
- kFLEXIO_ShifterBufferNibbleByteSwapped = 0x4U,
- #endif
- #if defined(FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_HALF_WORD_SWAP) && FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_HALF_WORD_SWAP
- kFLEXIO_ShifterBufferHalfWordSwapped = 0x5U,
- #endif
- #if defined(FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_NIBBLE_SWAP) && FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_NIBBLE_SWAP
- kFLEXIO_ShifterBufferNibbleSwapped = 0x6U,
- #endif
- } flexio_shifter_buffer_type_t;
- typedef struct _flexio_config_
- {
- bool enableFlexio;
- bool enableInDoze;
- bool enableInDebug;
- bool enableFastAccess;
- } flexio_config_t;
- typedef struct _flexio_timer_config
- {
-
- uint32_t triggerSelect;
- flexio_timer_trigger_polarity_t triggerPolarity;
- flexio_timer_trigger_source_t triggerSource;
-
- flexio_pin_config_t pinConfig;
- uint32_t pinSelect;
- flexio_pin_polarity_t pinPolarity;
-
- flexio_timer_mode_t timerMode;
- flexio_timer_output_t timerOutput;
- flexio_timer_decrement_source_t timerDecrement;
- flexio_timer_reset_condition_t timerReset;
- flexio_timer_disable_condition_t timerDisable;
- flexio_timer_enable_condition_t timerEnable;
- flexio_timer_stop_bit_condition_t timerStop;
- flexio_timer_start_bit_condition_t timerStart;
- uint32_t timerCompare;
- } flexio_timer_config_t;
- typedef struct _flexio_shifter_config
- {
-
- uint32_t timerSelect;
- flexio_shifter_timer_polarity_t timerPolarity;
-
- flexio_pin_config_t pinConfig;
- uint32_t pinSelect;
- flexio_pin_polarity_t pinPolarity;
-
- flexio_shifter_mode_t shifterMode;
- #if FSL_FEATURE_FLEXIO_HAS_PARALLEL_WIDTH
- uint32_t parallelWidth;
- #endif
- flexio_shifter_input_source_t inputSource;
- flexio_shifter_stop_bit_t shifterStop;
- flexio_shifter_start_bit_t shifterStart;
- } flexio_shifter_config_t;
- typedef void (*flexio_isr_t)(void *base, void *handle);
- extern FLEXIO_Type *const s_flexioBases[];
- #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
- extern const clock_ip_name_t s_flexioClocks[];
- #endif
- #if defined(__cplusplus)
- extern "C" {
- #endif
- void FLEXIO_GetDefaultConfig(flexio_config_t *userConfig);
- void FLEXIO_Init(FLEXIO_Type *base, const flexio_config_t *userConfig);
- void FLEXIO_Deinit(FLEXIO_Type *base);
- uint32_t FLEXIO_GetInstance(FLEXIO_Type *base);
- void FLEXIO_Reset(FLEXIO_Type *base);
- static inline void FLEXIO_Enable(FLEXIO_Type *base, bool enable)
- {
- if (enable)
- {
- base->CTRL |= FLEXIO_CTRL_FLEXEN_MASK;
- }
- else
- {
- base->CTRL &= ~FLEXIO_CTRL_FLEXEN_MASK;
- }
- }
- #if defined(FSL_FEATURE_FLEXIO_HAS_PIN_STATUS) && FSL_FEATURE_FLEXIO_HAS_PIN_STATUS
- static inline uint32_t FLEXIO_ReadPinInput(FLEXIO_Type *base)
- {
- return base->PIN;
- }
- #endif
- #if defined(FSL_FEATURE_FLEXIO_HAS_STATE_MODE) && FSL_FEATURE_FLEXIO_HAS_STATE_MODE
- static inline uint8_t FLEXIO_GetShifterState(FLEXIO_Type *base)
- {
- return ((base->SHIFTSTATE) & FLEXIO_SHIFTSTATE_STATE_MASK);
- }
- #endif
- void FLEXIO_SetShifterConfig(FLEXIO_Type *base, uint8_t index, const flexio_shifter_config_t *shifterConfig);
- void FLEXIO_SetTimerConfig(FLEXIO_Type *base, uint8_t index, const flexio_timer_config_t *timerConfig);
- static inline void FLEXIO_EnableShifterStatusInterrupts(FLEXIO_Type *base, uint32_t mask)
- {
- base->SHIFTSIEN |= mask;
- }
- static inline void FLEXIO_DisableShifterStatusInterrupts(FLEXIO_Type *base, uint32_t mask)
- {
- base->SHIFTSIEN &= ~mask;
- }
- static inline void FLEXIO_EnableShifterErrorInterrupts(FLEXIO_Type *base, uint32_t mask)
- {
- base->SHIFTEIEN |= mask;
- }
- static inline void FLEXIO_DisableShifterErrorInterrupts(FLEXIO_Type *base, uint32_t mask)
- {
- base->SHIFTEIEN &= ~mask;
- }
- static inline void FLEXIO_EnableTimerStatusInterrupts(FLEXIO_Type *base, uint32_t mask)
- {
- base->TIMIEN |= mask;
- }
- static inline void FLEXIO_DisableTimerStatusInterrupts(FLEXIO_Type *base, uint32_t mask)
- {
- base->TIMIEN &= ~mask;
- }
- static inline uint32_t FLEXIO_GetShifterStatusFlags(FLEXIO_Type *base)
- {
- return ((base->SHIFTSTAT) & FLEXIO_SHIFTSTAT_SSF_MASK);
- }
- static inline void FLEXIO_ClearShifterStatusFlags(FLEXIO_Type *base, uint32_t mask)
- {
- base->SHIFTSTAT = mask;
- }
- static inline uint32_t FLEXIO_GetShifterErrorFlags(FLEXIO_Type *base)
- {
- return ((base->SHIFTERR) & FLEXIO_SHIFTERR_SEF_MASK);
- }
- static inline void FLEXIO_ClearShifterErrorFlags(FLEXIO_Type *base, uint32_t mask)
- {
- base->SHIFTERR = mask;
- }
- static inline uint32_t FLEXIO_GetTimerStatusFlags(FLEXIO_Type *base)
- {
- return ((base->TIMSTAT) & FLEXIO_TIMSTAT_TSF_MASK);
- }
- static inline void FLEXIO_ClearTimerStatusFlags(FLEXIO_Type *base, uint32_t mask)
- {
- base->TIMSTAT = mask;
- }
- static inline void FLEXIO_EnableShifterStatusDMA(FLEXIO_Type *base, uint32_t mask, bool enable)
- {
- if (enable)
- {
- base->SHIFTSDEN |= mask;
- }
- else
- {
- base->SHIFTSDEN &= ~mask;
- }
- }
- uint32_t FLEXIO_GetShifterBufferAddress(FLEXIO_Type *base, flexio_shifter_buffer_type_t type, uint8_t index);
- status_t FLEXIO_RegisterHandleIRQ(void *base, void *handle, flexio_isr_t isr);
- status_t FLEXIO_UnregisterHandleIRQ(void *base);
- #if defined(__cplusplus)
- }
- #endif
- #endif
|