Skip to content

Commit a8aac90

Browse files
committed
mcux-sdk: drivers: Add callback parameter to flexio driver
Allow the flexio driver to pass a parameter to the GPIO callback functions. Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent 40899ac commit a8aac90

File tree

3 files changed

+83
-3
lines changed

3 files changed

+83
-3
lines changed

mcux/mcux-sdk-ng/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ 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

mcux/mcux-sdk-ng/drivers/flexio/mculcd/fsl_flexio_mculcd.c

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,13 @@ status_t FLEXIO_MCULCD_Init(FLEXIO_MCULCD_Type *base, flexio_mculcd_config_t *co
6868

6969
if (kStatus_Success == status)
7070
{
71+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
7172
base->setCSPin(true);
7273
base->setRSPin(true);
74+
#else
75+
base->setCSPin(true, base->userData);
76+
base->setRSPin(true, base->userData);
77+
#endif
7378
}
7479

7580
return status;
@@ -751,13 +756,22 @@ void FLEXIO_MCULCD_WriteCommandBlocking(FLEXIO_MCULCD_Type *base, uint32_t comma
751756
{
752757
FLEXIO_Type *flexioBase = base->flexioBase;
753758

759+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
754760
/* De-assert the RS pin. */
755761
base->setRSPin(false);
762+
#else
763+
/* De-assert the RS pin. */
764+
base->setRSPin(false, base->userData);
765+
#endif
756766

757767
/* For 6800, de-assert the RDWR pin. */
758768
if (kFLEXIO_MCULCD_6800 == base->busType)
759769
{
770+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
760771
base->setRDWRPin(false);
772+
#else
773+
base->setRDWRPin(false, base->userData);
774+
#endif
761775
}
762776

763777
/* Configure the timer and TX shifter. */
@@ -774,12 +788,22 @@ void FLEXIO_MCULCD_WriteCommandBlocking(FLEXIO_MCULCD_Type *base, uint32_t comma
774788
/* Stop the timer and TX shifter. */
775789
FLEXIO_MCULCD_ClearSingleBeatWriteConfig(base);
776790

791+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
777792
/* Assert the RS pin. */
778793
base->setRSPin(true);
794+
#else
795+
/* Assert the RS pin. */
796+
base->setRSPin(true, base->userData);
797+
#endif
798+
779799
/* For 6800, assert the RDWR pin. */
780800
if (kFLEXIO_MCULCD_6800 == base->busType)
781801
{
802+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
782803
base->setRDWRPin(true);
804+
#else
805+
base->setRDWRPin(true, base->userData);
806+
#endif
783807
}
784808
}
785809

@@ -804,12 +828,21 @@ void FLEXIO_MCULCD_WriteDataArrayBlocking(FLEXIO_MCULCD_Type *base, const void *
804828
#endif
805829
FLEXIO_Type *flexioBase = base->flexioBase;
806830

831+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
807832
/* Assert the RS pin. */
808833
base->setRSPin(true);
834+
#else
835+
/* Assert the RS pin. */
836+
base->setRSPin(true, base->userData);
837+
#endif
809838
/* For 6800, de-assert the RDWR pin. */
810839
if (kFLEXIO_MCULCD_6800 == base->busType)
811840
{
841+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
812842
base->setRDWRPin(false);
843+
#else
844+
base->setRDWRPin(false, base->userData);
845+
#endif
813846
}
814847

815848
/* Configure the timer and TX shifter. */
@@ -876,12 +909,21 @@ void FLEXIO_MCULCD_ReadDataArrayBlocking(FLEXIO_MCULCD_Type *base, void *data, s
876909
#endif
877910
FLEXIO_Type *flexioBase = base->flexioBase;
878911

912+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
879913
/* Assert the RS pin. */
880914
base->setRSPin(true);
915+
#else
916+
/* Assert the RS pin. */
917+
base->setRSPin(true, base->userData);
918+
#endif
881919
/* For 6800, de-assert the RDWR pin. */
882920
if (kFLEXIO_MCULCD_6800 == base->busType)
883921
{
922+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
884923
base->setRDWRPin(false);
924+
#else
925+
base->setRDWRPin(false, base->userData);
926+
#endif
885927
}
886928

887929
/* Enable the timer and RX shifter. */
@@ -952,12 +994,21 @@ void FLEXIO_MCULCD_WriteSameValueBlocking(FLEXIO_MCULCD_Type *base, uint32_t sam
952994
size /= 2U;
953995
#endif
954996

997+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
955998
/* Assert the RS pin. */
956999
base->setRSPin(true);
1000+
#else
1001+
/* Assert the RS pin. */
1002+
base->setRSPin(true, base->userData);
1003+
#endif
9571004
/* For 6800, de-assert the RDWR pin. */
9581005
if (kFLEXIO_MCULCD_6800 == base->busType)
9591006
{
1007+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
9601008
base->setRDWRPin(false);
1009+
#else
1010+
base->setRDWRPin(false, base->userData);
1011+
#endif
9611012
}
9621013

9631014
/* Configure the timer and TX shifter. */
@@ -1133,7 +1184,11 @@ status_t FLEXIO_MCULCD_TransferNonBlocking(FLEXIO_MCULCD_Type *base,
11331184
/* For 6800, assert the RDWR pin. */
11341185
if (kFLEXIO_MCULCD_6800 == base->busType)
11351186
{
1187+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
11361188
base->setRDWRPin(true);
1189+
#else
1190+
base->setRDWRPin(true, base->userData);
1191+
#endif
11371192
}
11381193
FLEXIO_MCULCD_SetSingleBeatReadConfig(base);
11391194
FLEXIO_MCULCD_EnableInterrupts(base, (uint32_t)kFLEXIO_MCULCD_RxFullInterruptEnable);
@@ -1143,8 +1198,12 @@ status_t FLEXIO_MCULCD_TransferNonBlocking(FLEXIO_MCULCD_Type *base,
11431198
/* For 6800, de-assert the RDWR pin. */
11441199
if (kFLEXIO_MCULCD_6800 == base->busType)
11451200
{
1201+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
11461202
base->setRDWRPin(false);
1147-
}
1203+
#else
1204+
base->setRDWRPin(false, base->userData);
1205+
#endif
1206+
}
11481207
FLEXIO_MCULCD_SetSingleBeatWriteConfig(base);
11491208
FLEXIO_MCULCD_EnableInterrupts(base, (uint32_t)kFLEXIO_MCULCD_TxEmptyInterruptEnable);
11501209
}
@@ -1331,4 +1390,4 @@ void FLEXIO_MCULCD_TransferHandleIRQ(void *base, void *handle)
13311390
statusFlags = FLEXIO_MCULCD_GetStatusFlags(flexioLcdMcuBase);
13321391
}
13331392
}
1334-
}
1393+
}

mcux/mcux-sdk-ng/drivers/flexio/mculcd/fsl_flexio_mculcd.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/*! @name Driver version */
2525
/*! @{ */
2626
/*! @brief FlexIO MCULCD driver version. */
27-
#define FSL_FLEXIO_MCULCD_DRIVER_VERSION (MAKE_VERSION(2, 1, 0))
27+
#define FSL_FLEXIO_MCULCD_DRIVER_VERSION (MAKE_VERSION(2, 2, 0))
2828
/*! @} */
2929

3030
#ifndef FLEXIO_MCULCD_WAIT_COMPLETE_TIME
@@ -97,8 +97,17 @@ enum _flexio_mculcd_dma_enable
9797
kFLEXIO_MCULCD_RxDmaEnable = 0x2U, /*!< Rx DMA request source */
9898
};
9999

100+
#ifndef FLEXIO_MCULCD_LEGACY_GPIO_FUNC
101+
#define FLEXIO_MCULCD_LEGACY_GPIO_FUNC 1
102+
#endif
103+
104+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
100105
/*! @brief Function to set or clear the CS and RS pin. */
101106
typedef void (*flexio_mculcd_pin_func_t)(bool set);
107+
#else
108+
/*! @brief Function to set or clear the CS and RS pin. */
109+
typedef void (*flexio_mculcd_pin_func_t)(bool set, void *userData);
110+
#endif
102111

103112
/*! @brief Define FlexIO MCULCD access structure typedef. */
104113
typedef struct _flexio_mculcd_type
@@ -118,6 +127,9 @@ typedef struct _flexio_mculcd_type
118127
flexio_mculcd_pin_func_t setCSPin; /*!< Function to set or clear the CS pin. */
119128
flexio_mculcd_pin_func_t setRSPin; /*!< Function to set or clear the RS pin. */
120129
flexio_mculcd_pin_func_t setRDWRPin; /*!< Function to set or clear the RD/WR pin, only used in 6800 mode. */
130+
#if !FLEXIO_MCULCD_LEGACY_GPIO_FUNC
131+
void *userData; /*!< Function parameter.*/
132+
#endif
121133
} FLEXIO_MCULCD_Type;
122134

123135
/*! @brief Define FlexIO MCULCD configuration structure. */
@@ -523,7 +535,11 @@ static inline void FLEXIO_MCULCD_WriteData(FLEXIO_MCULCD_Type *base, uint32_t da
523535
*/
524536
static inline void FLEXIO_MCULCD_StartTransfer(FLEXIO_MCULCD_Type *base)
525537
{
538+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
526539
base->setCSPin(false);
540+
#else
541+
base->setCSPin(false, base->userData);
542+
#endif
527543
}
528544

529545
/*!
@@ -533,7 +549,11 @@ static inline void FLEXIO_MCULCD_StartTransfer(FLEXIO_MCULCD_Type *base)
533549
*/
534550
static inline void FLEXIO_MCULCD_StopTransfer(FLEXIO_MCULCD_Type *base)
535551
{
552+
#if FLEXIO_MCULCD_LEGACY_GPIO_FUNC
536553
base->setCSPin(true);
554+
#else
555+
base->setCSPin(true, base->userData);
556+
#endif
537557
}
538558

539559
/*!

0 commit comments

Comments
 (0)