Skip to content

Commit 87244a9

Browse files
committed
KW41Z: Update SDK TPM driver
Certain instances of the TPM are missing some registers, updated TPM driver handles this variation. This issue was discovered when running the PWMOUT tests using the ci-test-shield Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent d08c819 commit 87244a9

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/device/MKW41Z4_features.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,14 +1680,29 @@
16801680
#define FSL_FEATURE_TPM_HAS_PAUSE_COUNTER_ON_TRIGGER (1)
16811681
/* @brief Has external trigger selection. */
16821682
#define FSL_FEATURE_TPM_HAS_EXTERNAL_TRIGGER_SELECTION (1)
1683-
/* @brief Has TPM_COMBINE. */
1683+
/* @brief Has TPM_COMBINE register. */
16841684
#define FSL_FEATURE_TPM_HAS_COMBINE (1)
1685+
/* @brief Whether COMBINE register has effect. */
1686+
#define FSL_FEATURE_TPM_COMBINE_HAS_EFFECTn(x) \
1687+
((x) == TPM0 ? (0) : \
1688+
((x) == TPM1 ? (1) : \
1689+
((x) == TPM2 ? (1) : (-1))))
16851690
/* @brief Has TPM_POL. */
16861691
#define FSL_FEATURE_TPM_HAS_POL (1)
1687-
/* @brief Has TPM_FILTER. */
1692+
/* @brief Has TPM_FILTER register. */
16881693
#define FSL_FEATURE_TPM_HAS_FILTER (1)
1689-
/* @brief Has TPM_QDCTRL. */
1694+
/* @brief Whether FILTER register has effect. */
1695+
#define FSL_FEATURE_TPM_FILTER_HAS_EFFECTn(x) \
1696+
((x) == TPM0 ? (0) : \
1697+
((x) == TPM1 ? (1) : \
1698+
((x) == TPM2 ? (1) : (-1))))
1699+
/* @brief Has TPM_QDCTRL register. */
16901700
#define FSL_FEATURE_TPM_HAS_QDCTRL (1)
1701+
/* @brief Whether QDCTRL register has effect. */
1702+
#define FSL_FEATURE_TPM_QDCTRL_HAS_EFFECTn(x) \
1703+
((x) == TPM0 ? (0) : \
1704+
((x) == TPM1 ? (1) : \
1705+
((x) == TPM2 ? (1) : (-1))))
16911706

16921707
/* TRNG0 module features */
16931708

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/drivers/fsl_tpm.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,25 @@ status_t TPM_SetupPwm(TPM_Type *base,
162162
assert(pwmFreq_Hz);
163163
assert(numOfChnls);
164164
assert(srcClock_Hz);
165+
#if defined(FSL_FEATURE_TPM_HAS_COMBINE) && FSL_FEATURE_TPM_HAS_COMBINE
166+
if(mode == kTPM_CombinedPwm)
167+
{
168+
assert(FSL_FEATURE_TPM_COMBINE_HAS_EFFECTn(base));
169+
}
170+
#endif
165171

166172
uint32_t mod;
167173
uint32_t tpmClock = (srcClock_Hz / (1U << (base->SC & TPM_SC_PS_MASK)));
168174
uint16_t cnv;
169175
uint8_t i;
170176

171177
#if defined(FSL_FEATURE_TPM_HAS_QDCTRL) && FSL_FEATURE_TPM_HAS_QDCTRL
172-
/* Clear quadrature Decoder mode because in quadrature Decoder mode PWM doesn't operate*/
173-
base->QDCTRL &= ~TPM_QDCTRL_QUADEN_MASK;
178+
/* The TPM's QDCTRL register required to be effective */
179+
if( FSL_FEATURE_TPM_QDCTRL_HAS_EFFECTn(base) )
180+
{
181+
/* Clear quadrature Decoder mode because in quadrature Decoder mode PWM doesn't operate*/
182+
base->QDCTRL &= ~TPM_QDCTRL_QUADEN_MASK;
183+
}
174184
#endif
175185

176186
switch (mode)

0 commit comments

Comments
 (0)