Skip to content

Commit 40509f3

Browse files
sumitbatra-nxpmmahadevan108
authored andcommitted
mcux: Enable flexio hal driver to support flexio IP on S32 SoCs
Flexio IP functions in mcux and S32 SoCs are quite similar This commit enables the existing flexio driver to support Flexio IP on S32 SoCs by adding PIN Operations and NO DOZE mode. Signed-off-by: Sumit Batra <[email protected]>
1 parent a8aac90 commit 40509f3

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

mcux/mcux-sdk-ng/README

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ Patch List:
4646
- drivers/adc12/fsl_adc12.c: add guards to avoid compilation warnings when building
4747
with SDK clock control driver disabled.
4848
- drivers: irqsteer: adjust CHn_MASK index computation
49-
- drivers: flexio lcd: Pass a parameter to the GPIO callback functions
49+
- drivers: flexio: lcd: Pass a parameter to the GPIO callback functions
50+
- drivers: flexio: Enable flexio hal driver to support flexio IP on S32 SoCs

mcux/mcux-sdk-ng/drivers/flexio/fsl_flexio.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,19 @@ void FLEXIO_Init(FLEXIO_Type *base, const flexio_config_t *userConfig)
114114
FLEXIO_Reset(base);
115115

116116
ctrlReg = base->CTRL;
117+
#if !(defined(FSL_FEATURE_FLEXIO_HAS_DOZE_MODE_SUPPORT) && (FSL_FEATURE_FLEXIO_HAS_DOZE_MODE_SUPPORT == 0))
117118
ctrlReg &= ~(FLEXIO_CTRL_DOZEN_MASK | FLEXIO_CTRL_DBGE_MASK | FLEXIO_CTRL_FASTACC_MASK | FLEXIO_CTRL_FLEXEN_MASK);
119+
#else
120+
ctrlReg &= ~(FLEXIO_CTRL_DBGE_MASK | FLEXIO_CTRL_FASTACC_MASK | FLEXIO_CTRL_FLEXEN_MASK);
121+
#endif
118122
ctrlReg |= (FLEXIO_CTRL_DBGE(userConfig->enableInDebug) | FLEXIO_CTRL_FASTACC(userConfig->enableFastAccess) |
119123
FLEXIO_CTRL_FLEXEN(userConfig->enableFlexio));
124+
#if !(defined(FSL_FEATURE_FLEXIO_HAS_DOZE_MODE_SUPPORT) && (FSL_FEATURE_FLEXIO_HAS_DOZE_MODE_SUPPORT == 0))
120125
if (!userConfig->enableInDoze)
121126
{
122127
ctrlReg |= FLEXIO_CTRL_DOZEN_MASK;
123128
}
129+
#endif
124130

125131
base->CTRL = ctrlReg;
126132
}
@@ -160,7 +166,9 @@ void FLEXIO_GetDefaultConfig(flexio_config_t *userConfig)
160166
(void)memset(userConfig, 0, sizeof(*userConfig));
161167

162168
userConfig->enableFlexio = true;
169+
#if !(defined(FSL_FEATURE_FLEXIO_HAS_DOZE_MODE_SUPPORT) && (FSL_FEATURE_FLEXIO_HAS_DOZE_MODE_SUPPORT == 0))
163170
userConfig->enableInDoze = false;
171+
#endif
164172
userConfig->enableInDebug = true;
165173
userConfig->enableFastAccess = false;
166174
}

mcux/mcux-sdk-ng/drivers/flexio/fsl_flexio.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ typedef enum _flexio_timer_mode
6767
kFLEXIO_TimerModeDual8BitBaudBit = 0x1U, /*!< Dual 8-bit counters baud/bit mode. */
6868
kFLEXIO_TimerModeDual8BitPWM = 0x2U, /*!< Dual 8-bit counters PWM mode. */
6969
kFLEXIO_TimerModeSingle16Bit = 0x3U, /*!< Single 16-bit counter mode. */
70+
kFLEXIO_TimerModeDual8BitPWMLow = 0x6U, /*!< Dual 8-bit counters PWM Low mode. */
7071
} flexio_timer_mode_t;
7172

7273
/*! @brief Define type of timer initial output or timer reset condition.*/
@@ -239,7 +240,9 @@ typedef enum _flexio_shifter_buffer_type
239240
typedef struct _flexio_config_
240241
{
241242
bool enableFlexio; /*!< Enable/disable FlexIO module */
243+
#if !(defined(FSL_FEATURE_FLEXIO_HAS_DOZE_MODE_SUPPORT) && (FSL_FEATURE_FLEXIO_HAS_DOZE_MODE_SUPPORT == 0))
242244
bool enableInDoze; /*!< Enable/disable FlexIO operation in doze mode */
245+
#endif
243246
bool enableInDebug; /*!< Enable/disable FlexIO operation in debug mode */
244247
bool enableFastAccess; /*!< Enable/disable fast access to FlexIO registers, fast access requires
245248
the FlexIO clock to be at least twice the frequency of the bus clock. */
@@ -895,6 +898,50 @@ static inline uint32_t FLEXIO_GetPinStatus(FLEXIO_Type *base, uint32_t pin)
895898
return (((base->PINSTAT) >> pin) & 0x01U);
896899
}
897900

901+
/*!
902+
* @brief Sets the FLEXIO output pin level.
903+
*
904+
* @param base FlexIO peripheral base address
905+
* @param pin FlexIO pin number.
906+
* @param level FlexIO output pin level to set, can be either 0 or 1.
907+
*/
908+
static inline void FLEXIO_SetPinLevel(FLEXIO_Type *base, uint8_t pin, bool level)
909+
{
910+
base->PINOUTD =
911+
(base->PINOUTD & ~((uint32_t)((uint32_t)1U << pin))) |
912+
(FLEXIO_PINOUTD_OUTD((uint32_t)((true == level)
913+
? (uint32_t)0x1U : (uint32_t)0x0U) << pin));
914+
}
915+
916+
/*!
917+
* @brief Gets the enabled status of a FLEXIO output pin.
918+
*
919+
* @param base FlexIO peripheral base address
920+
* @param pin FlexIO pin number.
921+
* @retval FlexIO port enabled status
922+
* - 0: corresponding output pin is in disabled state.
923+
* - 1: corresponding output pin is in enabled state.
924+
*/
925+
static inline bool FLEXIO_GetPinOverride(const FLEXIO_Type *const base, uint8_t pin)
926+
{
927+
return ((base->PINOUTE & (uint32_t)((uint32_t)1U << pin)) != 0UL);
928+
}
929+
930+
/*!
931+
* @brief Enables or disables a FLEXIO output pin.
932+
*
933+
* @param base FlexIO peripheral base address
934+
* @param pin Flexio pin number.
935+
* @param enabled Enable or disable the FlexIO pin.
936+
*/
937+
static inline void FLEXIO_ConfigPinOverride(FLEXIO_Type *base, uint8_t pin, bool enabled)
938+
{
939+
base->PINOUTE =
940+
(base->PINOUTE & ~((uint32_t)((uint32_t)1U << pin))) |
941+
FLEXIO_PINOUTE_OUTE((uint32_t)((true == enabled)
942+
? (uint32_t)0x1U : (uint32_t)0x0U) << pin);
943+
}
944+
898945
/*!
899946
* @brief Clears the multiple FLEXIO input pins status.
900947
*

0 commit comments

Comments
 (0)