1 /*
2  * Copyright (c) 2015, Freescale Semiconductor, Inc.
3  * Copyright 2016-2021, 2023 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef FSL_ENC_H_
10 #define FSL_ENC_H_
11 
12 #include "fsl_common.h"
13 
14 /*!
15  * @addtogroup enc
16  * @{
17  */
18 /*******************************************************************************
19  * Definitions
20  ******************************************************************************/
21 #define FSL_ENC_DRIVER_VERSION (MAKE_VERSION(2, 2, 1))
22 
23 /*!
24  * @brief Interrupt enable/disable mask.
25  */
26 enum _enc_interrupt_enable
27 {
28     kENC_HOMETransitionInterruptEnable  = (1U << 0U), /*!< HOME interrupt enable. */
29     kENC_INDEXPulseInterruptEnable      = (1U << 1U), /*!< INDEX pulse interrupt enable. */
30     kENC_WatchdogTimeoutInterruptEnable = (1U << 2U), /*!< Watchdog timeout interrupt enable. */
31     kENC_PositionCompareInerruptEnable  = (1U << 3U), /*!< Position compare interrupt enable. */
32 #if !(defined(FSL_FEATURE_ENC_HAS_NO_CTRL2_SAB_INT) && FSL_FEATURE_ENC_HAS_NO_CTRL2_SAB_INT)
33     kENC_SimultBothPhaseChangeInterruptEnable =
34         (1U << 4U), /*!< Simultaneous PHASEA and PHASEB change interrupt enable. */
35 #endif
36     kENC_PositionRollOverInterruptEnable  = (1U << 5U), /*!< Roll-over interrupt enable. */
37     kENC_PositionRollUnderInterruptEnable = (1U << 6U), /*!< Roll-under interrupt enable. */
38 };
39 
40 /*!
41  * @brief Status flag mask.
42  *
43  * These flags indicate the counter's events.
44  */
45 enum _enc_status_flags
46 {
47     kENC_HOMETransitionFlag  = (1U << 0U), /*!< HOME signal transition interrupt request. */
48     kENC_INDEXPulseFlag      = (1U << 1U), /*!< INDEX Pulse Interrupt Request. */
49     kENC_WatchdogTimeoutFlag = (1U << 2U), /*!< Watchdog timeout interrupt request. */
50     kENC_PositionCompareFlag = (1U << 3U), /*!< Position compare interrupt request. */
51 #if !(defined(FSL_FEATURE_ENC_HAS_NO_CTRL2_SAB_INT) && FSL_FEATURE_ENC_HAS_NO_CTRL2_SAB_INT)
52     kENC_SimultBothPhaseChangeFlag = (1U << 4U), /*!< Simultaneous PHASEA and PHASEB change interrupt request. */
53 #endif
54     kENC_PositionRollOverFlag   = (1U << 5U), /*!< Roll-over interrupt request. */
55     kENC_PositionRollUnderFlag  = (1U << 6U), /*!< Roll-under interrupt request. */
56     kENC_LastCountDirectionFlag = (1U << 7U), /*!< Last count was in the up direction, or the down direction. */
57 };
58 
59 /*!
60  * @brief Signal status flag mask.
61  *
62  * These flags indicate the counter's signal.
63  */
64 enum _enc_signal_status_flags
65 {
66     kENC_RawHOMEStatusFlag       = ENC_IMR_HOME_MASK,  /*!< Raw HOME input. */
67     kENC_RawINDEXStatusFlag      = ENC_IMR_INDEX_MASK, /*!< Raw INDEX input. */
68     kENC_RawPHBStatusFlag        = ENC_IMR_PHB_MASK,   /*!< Raw PHASEB input. */
69     kENC_RawPHAEXStatusFlag      = ENC_IMR_PHA_MASK,   /*!< Raw PHASEA input. */
70     kENC_FilteredHOMEStatusFlag  = ENC_IMR_FHOM_MASK,  /*!< The filtered version of HOME input. */
71     kENC_FilteredINDEXStatusFlag = ENC_IMR_FIND_MASK,  /*!< The filtered version of INDEX input. */
72     kENC_FilteredPHBStatusFlag   = ENC_IMR_FPHB_MASK,  /*!< The filtered version of PHASEB input. */
73     kENC_FilteredPHAStatusFlag   = ENC_IMR_FPHA_MASK,  /*!< The filtered version of PHASEA input. */
74 };
75 
76 /*!
77  * @brief Define HOME signal's trigger mode.
78  *
79  * The ENC would count the trigger from HOME signal line.
80  */
81 typedef enum _enc_home_trigger_mode
82 {
83     kENC_HOMETriggerDisabled = 0U, /*!< HOME signal's trigger is disabled. */
84     kENC_HOMETriggerOnRisingEdge,  /*!< Use positive going edge-to-trigger initialization of position counters. */
85     kENC_HOMETriggerOnFallingEdge, /*!< Use negative going edge-to-trigger initialization of position counters. */
86 } enc_home_trigger_mode_t;
87 
88 /*!
89  * @brief Define INDEX signal's trigger mode.
90  *
91  * The ENC would count the trigger from INDEX signal line.
92  */
93 typedef enum _enc_index_trigger_mode
94 {
95     kENC_INDEXTriggerDisabled = 0U, /*!< INDEX signal's trigger is disabled. */
96     kENC_INDEXTriggerOnRisingEdge,  /*!< Use positive going edge-to-trigger initialization of position counters. */
97     kENC_INDEXTriggerOnFallingEdge, /*!< Use negative going edge-to-trigger initialization of position counters. */
98 } enc_index_trigger_mode_t;
99 
100 /*!
101  * @brief Define type for decoder work mode.
102  *
103  * The normal work mode uses the standard quadrature decoder with PHASEA and PHASEB. When in signal phase count mode,
104  * a positive transition of the PHASEA input generates a count signal while the PHASEB input and the reverse direction
105  * control the counter direction. If the reverse direction is not enabled, PHASEB = 0 means counting up and PHASEB = 1
106  * means counting down. Otherwise, the direction is reversed.
107  */
108 typedef enum _enc_decoder_work_mode
109 {
110     kENC_DecoderWorkAsNormalMode = 0U,      /*!< Use standard quadrature decoder with PHASEA and PHASEB. */
111     kENC_DecoderWorkAsSignalPhaseCountMode, /*!< PHASEA input generates a count signal while PHASEB input control the
112                                                direction. */
113 } enc_decoder_work_mode_t;
114 
115 /*!
116  * @brief Define type for the condition of POSMATCH pulses.
117  */
118 typedef enum _enc_position_match_mode
119 {
120     kENC_POSMATCHOnPositionCounterEqualToComapreValue = 0U, /*!< POSMATCH pulses when a match occurs between the
121                                                                position counters (POS) and the compare value (COMP). */
122     kENC_POSMATCHOnReadingAnyPositionCounter, /*!< POSMATCH pulses when any position counter register is read. */
123 } enc_position_match_mode_t;
124 
125 /*!
126  * @brief Define type for determining how the revolution counter (REV) is incremented/decremented.
127  */
128 typedef enum _enc_revolution_count_condition
129 {
130     kENC_RevolutionCountOnINDEXPulse = 0U, /*!< Use INDEX pulse to increment/decrement revolution counter. */
131     kENC_RevolutionCountOnRollOverModulus, /*!< Use modulus counting roll-over/under to increment/decrement revolution
132                                               counter. */
133 } enc_revolution_count_condition_t;
134 
135 /*!
136  * @brief Define type for direction of self test generated signal.
137  */
138 typedef enum _enc_self_test_direction
139 {
140     kENC_SelfTestDirectionPositive = 0U, /*!< Self test generates the signal in positive direction. */
141     kENC_SelfTestDirectionNegative,      /*!< Self test generates the signal in negative direction. */
142 } enc_self_test_direction_t;
143 
144 #if (defined(FSL_FEATURE_ENC_HAS_CTRL3) && FSL_FEATURE_ENC_HAS_CTRL3)
145 /*!
146  * @brief Define prescaler value for clock in CTRL3.
147  *
148  * The clock is prescaled by a value of 2^PRSC which means that the prescaler logic
149  * can divide the clock by a minimum of 1 and a maximum of 32,768.
150  */
151 typedef enum _enc_prescaler
152 {
153     kENC_ClockDiv1     = 0,
154     kENC_ClockDiv2     = 1,
155     kENC_ClockDiv4     = 2,
156     kENC_ClockDiv8     = 3,
157     kENC_ClockDiv16    = 4,
158     kENC_ClockDiv32    = 5,
159     kENC_ClockDiv64    = 6,
160     kENC_ClockDiv128   = 7,
161     kENC_ClockDiv256   = 8,
162     kENC_ClockDiv512   = 9,
163     kENC_ClockDiv1024  = 10,
164     kENC_ClockDiv2048  = 11,
165     kENC_ClockDiv4096  = 12,
166     kENC_ClockDiv8192  = 13,
167     kENC_ClockDiv16384 = 14,
168     kENC_ClockDiv32768 = 15,
169 } enc_prescaler_t;
170 #endif
171 
172 #if (defined(FSL_FEATURE_ENC_HAS_FILT_PRSC) && FSL_FEATURE_ENC_HAS_FILT_PRSC)
173 /*!
174  * @brief Define input filter prescaler value.
175  *
176  * The input filter prescaler value is to prescale the IPBus clock.
177  * (Frequency of FILT clock) = (Frequency of IPBus clock) / 2^FILT_PRSC.
178  */
179 typedef enum _enc_filter_prescaler
180 {
181     kENC_FilterPrescalerDiv1   = 0U, /*!< Input filter prescaler is 1. */
182     kENC_FilterPrescalerDiv2   = 1U, /*!< Input filter prescaler is 2. */
183     kENC_FilterPrescalerDiv4   = 2U, /*!< Input filter prescaler is 4. */
184     kENC_FilterPrescalerDiv8   = 3U, /*!< Input filter prescaler is 8. */
185     kENC_FilterPrescalerDiv16  = 4U, /*!< Input filter prescaler is 16. */
186     kENC_FilterPrescalerDiv32  = 5U, /*!< Input filter prescaler is 32. */
187     kENC_FilterPrescalerDiv64  = 6U, /*!< Input filter prescaler is 64. */
188     kENC_FilterPrescalerDiv128 = 7U, /*!< Input filter prescaler is 128. */
189 } enc_filter_prescaler_t;
190 #endif
191 
192 /*!
193  * @brief Define user configuration structure for ENC module.
194  */
195 typedef struct _enc_config
196 {
197     /* Basic counter. */
198     bool enableReverseDirection;             /*!< Enable reverse direction counting. */
199     enc_decoder_work_mode_t decoderWorkMode; /*!< Enable signal phase count mode. */
200 
201     /* Signal detection. */
202     enc_home_trigger_mode_t HOMETriggerMode;   /*!< Enable HOME to initialize position counters. */
203     enc_index_trigger_mode_t INDEXTriggerMode; /*!< Enable INDEX to initialize position counters. */
204     bool enableTRIGGERClearPositionCounter;    /*!< Clear POSD, REV, UPOS and LPOS on rising edge of TRIGGER, or not. */
205     bool enableTRIGGERClearHoldPositionCounter; /*!< Enable update of hold registers on rising edge of TRIGGER, or not.
206                                                  */
207 
208     /* Watchdog. */
209     bool enableWatchdog;           /*!< Enable the watchdog to detect if the target is moving or not. */
210     uint16_t watchdogTimeoutValue; /*!< Watchdog timeout count value. It stores the timeout count for the quadrature
211                                         decoder module watchdog timer. This field is only available when
212                                         "enableWatchdog" = true. The available value is a 16-bit unsigned number.*/
213 
214 #if (defined(FSL_FEATURE_ENC_HAS_FILT_PRSC) && FSL_FEATURE_ENC_HAS_FILT_PRSC)
215     enc_filter_prescaler_t filterPrescaler; /*!< Input filter prescaler. */
216 #endif
217 
218     /* Filter for PHASEA, PHASEB, INDEX and HOME. */
219     uint16_t filterCount; /*!< Input Filter Sample Count. This value should be chosen to reduce the probability of
220                                noisy samples causing an incorrect transition to be recognized. The value represent the
221                                number of consecutive samples that must agree prior to the input filter accepting an
222                                input transition. A value of 0x0 represents 3 samples. A value of 0x7 represents 10
223                                samples. The Available range is 0 - 7.*/
224     uint16_t filterSamplePeriod; /*!< Input Filter Sample Period. This value should be set such that the sampling period
225                                       is larger than the period of the expected noise. This value represents the
226                                       sampling period (in IPBus clock cycles) of the decoder input signals.
227                                       The available range is 0 - 255. */
228 
229     /* Position compare. */
230     enc_position_match_mode_t positionMatchMode; /*!< The condition of POSMATCH pulses. */
231     uint32_t positionCompareValue;               /*!< Position compare value. The available value is a 32-bit number.*/
232 
233     /* Modulus counting. */
234     enc_revolution_count_condition_t revolutionCountCondition; /*!< Revolution Counter Modulus Enable. */
235     bool enableModuloCountMode;                                /*!< Enable Modulo Counting. */
236     uint32_t positionModulusValue; /*!< Position modulus value. This value would be available only when
237                                         "enableModuloCountMode" = true. The available value is a 32-bit number. */
238     uint32_t positionInitialValue; /*!< Position initial value. The available value is a 32-bit number. */
239 
240 #if (defined(FSL_FEATURE_ENC_HAS_CTRL3) && FSL_FEATURE_ENC_HAS_CTRL3)
241     /* Prescaler. */
242     bool enablePeriodMeasurementFunction; /*!< Enable period measurement function. */
243     enc_prescaler_t prescalerValue;       /*!< The value of prescaler. */
244 #endif
245 } enc_config_t;
246 
247 /*!
248  * @brief Define configuration structure for self test module.
249  *
250  * The self test module provides a quadrature test signal to the inputs of the quadrature decoder module.
251  * This is a factory test feature. It is also useful to customers' software development and testing.
252  */
253 typedef struct _enc_self_test_config
254 {
255     enc_self_test_direction_t signalDirection; /*!< Direction of self test generated signal. */
256     uint16_t signalCount;  /*!< Hold the number of quadrature advances to generate. The available range is 0 - 255.*/
257     uint16_t signalPeriod; /*!< Hold the period of quadrature phase in IPBus clock cycles.
258                                 The available range is 0 - 31. */
259 } enc_self_test_config_t;
260 
261 #if defined(__cplusplus)
262 extern "C" {
263 #endif
264 
265 /*******************************************************************************
266  * API
267  ******************************************************************************/
268 
269 /*!
270  * @name Initialization and De-initialization
271  * @{
272  */
273 
274 /*!
275  * @brief Initialization for the ENC module.
276  *
277  * This function is to make the initialization for the ENC module. It should be called firstly before any operation to
278  * the ENC with the operations like:
279  *  - Enable the clock for ENC module.
280  *  - Configure the ENC's working attributes.
281  *
282  * @param base   ENC peripheral base address.
283  * @param config Pointer to configuration structure. See to "enc_config_t".
284  */
285 void ENC_Init(ENC_Type *base, const enc_config_t *config);
286 
287 /*!
288  * @brief De-initialization for the ENC module.
289  *
290  * This function is to make the de-initialization for the ENC module. It could be called when ENC is no longer used with
291  * the operations like:
292  *  - Disable the clock for ENC module.
293  *
294  * @param base ENC peripheral base address.
295  */
296 void ENC_Deinit(ENC_Type *base);
297 
298 /*!
299  * @brief Get an available pre-defined settings for ENC's configuration.
300  *
301  * This function initializes the ENC configuration structure with an available settings, the default value are:
302  * @code
303  *   config->enableReverseDirection                = false;
304  *   config->decoderWorkMode                       = kENC_DecoderWorkAsNormalMode;
305  *   config->HOMETriggerMode                       = kENC_HOMETriggerDisabled;
306  *   config->INDEXTriggerMode                      = kENC_INDEXTriggerDisabled;
307  *   config->enableTRIGGERClearPositionCounter     = false;
308  *   config->enableTRIGGERClearHoldPositionCounter = false;
309  *   config->enableWatchdog                        = false;
310  *   config->watchdogTimeoutValue                  = 0U;
311  *   config->filterCount                           = 0U;
312  *   config->filterSamplePeriod                    = 0U;
313  *   config->positionMatchMode                     = kENC_POSMATCHOnPositionCounterEqualToComapreValue;
314  *   config->positionCompareValue                  = 0xFFFFFFFFU;
315  *   config->revolutionCountCondition              = kENC_RevolutionCountOnINDEXPulse;
316  *   config->enableModuloCountMode                 = false;
317  *   config->positionModulusValue                  = 0U;
318  *   config->positionInitialValue                  = 0U;
319  *   config->prescalerValue                        = kENC_ClockDiv1;
320  *   config->enablePeriodMeasurementFunction       = true;
321  * @endcode
322  * @param config Pointer to a variable of configuration structure. See to "enc_config_t".
323  */
324 void ENC_GetDefaultConfig(enc_config_t *config);
325 
326 /*!
327  * @brief Load the initial position value to position counter.
328  *
329  * This function is to transfer the initial position value (UINIT and LINIT) contents to position counter (UPOS and
330  * LPOS), so that to provide the consistent operation the position counter registers.
331  *
332  * @param base ENC peripheral base address.
333  */
334 void ENC_DoSoftwareLoadInitialPositionValue(ENC_Type *base);
335 
336 /*!
337  * @brief Enable and configure the self test function.
338  *
339  * This function is to enable and configuration the self test function. It controls and sets the frequency of a
340  * quadrature signal generator. It provides a quadrature test signal to the inputs of the quadrature decoder module.
341  * It is a factory test feature; however, it may be useful to customers' software development and testing.
342  *
343  * @param base   ENC peripheral base address.
344  * @param config Pointer to configuration structure. See to "enc_self_test_config_t". Pass "NULL" to disable.
345  */
346 void ENC_SetSelfTestConfig(ENC_Type *base, const enc_self_test_config_t *config);
347 
348 /*!
349  * @brief Enable watchdog for ENC module.
350  *
351  * @param base ENC peripheral base address
352  * @param enable Enables or disables the watchdog
353  */
354 void ENC_EnableWatchdog(ENC_Type *base, bool enable);
355 
356 /*!
357  * @brief Set initial position value for ENC module.
358  *
359  * @param base ENC peripheral base address
360  * @param value Positive initial value
361  */
362 void ENC_SetInitialPositionValue(ENC_Type *base, uint32_t value);
363 
364 /*! @} */
365 
366 /*!
367  * @name Status
368  * @{
369  */
370 /*!
371  * @brief  Get the status flags.
372  *
373  * @param  base ENC peripheral base address.
374  *
375  * @return      Mask value of status flags. For available mask, see to "_enc_status_flags".
376  */
377 uint32_t ENC_GetStatusFlags(ENC_Type *base);
378 
379 /*!
380  * @brief Clear the status flags.
381  *
382  * @param base ENC peripheral base address.
383  * @param mask Mask value of status flags to be cleared. For available mask, see to "_enc_status_flags".
384  */
385 void ENC_ClearStatusFlags(ENC_Type *base, uint32_t mask);
386 
387 /*!
388  * @brief  Get the signals' real-time status.
389  *
390  * @param  base ENC peripheral base address.
391  *
392  * @return      Mask value of signals' real-time status. For available mask, see to "_enc_signal_status_flags"
393  */
ENC_GetSignalStatusFlags(ENC_Type * base)394 static inline uint16_t ENC_GetSignalStatusFlags(ENC_Type *base)
395 {
396     return base->IMR;
397 }
398 /*! @} */
399 
400 /*!
401  * @name Interrupts
402  * @{
403  */
404 
405 /*!
406  * @brief Enable the interrupts.
407  *
408  * @param base ENC peripheral base address.
409  * @param mask Mask value of interrupts to be enabled. For available mask, see to "_enc_interrupt_enable".
410  */
411 void ENC_EnableInterrupts(ENC_Type *base, uint32_t mask);
412 
413 /*!
414  * @brief Disable the interrupts.
415  *
416  * @param base ENC peripheral base address.
417  * @param mask Mask value of interrupts to be disabled. For available mask, see to "_enc_interrupt_enable".
418  */
419 void ENC_DisableInterrupts(ENC_Type *base, uint32_t mask);
420 
421 /*!
422  * @brief  Get the enabled interrupts' flags.
423  *
424  * @param  base ENC peripheral base address.
425  *
426  * @return      Mask value of enabled interrupts.
427  */
428 uint32_t ENC_GetEnabledInterrupts(ENC_Type *base);
429 
430 /*! @} */
431 
432 /*!
433  * @name Value Operation
434  * @{
435  */
436 
437 /*!
438  * @brief  Get the current position counter's value.
439  *
440  * @param  base ENC peripheral base address.
441  *
442  * @return     Current position counter's value.
443  */
444 uint32_t ENC_GetPositionValue(ENC_Type *base);
445 
446 /*!
447  * @brief  Get the hold position counter's value.
448  *
449  * When any of the counter registers is read, the contents of each counter register is written to the corresponding hold
450  * register. Taking a snapshot of the counters' values provides a consistent view of a system position and a velocity to
451  * be attained.
452  *
453  * @param  base ENC peripheral base address.
454  *
455  * @return      Hold position counter's value.
456  */
457 uint32_t ENC_GetHoldPositionValue(ENC_Type *base);
458 
459 /*!
460  * @brief  Get the position difference counter's value.
461  *
462  * @param  base ENC peripheral base address.
463  *
464  * @return     The position difference counter's value.
465  */
ENC_GetPositionDifferenceValue(ENC_Type * base)466 static inline uint16_t ENC_GetPositionDifferenceValue(ENC_Type *base)
467 {
468     return base->POSD;
469 }
470 
471 /*!
472  * @brief  Get the hold position difference counter's value.
473  *
474  * When any of the counter registers is read, the contents of each counter register is written to the corresponding hold
475  * register. Taking a snapshot of the counters' values provides a consistent view of a system position and a velocity to
476  * be attained.
477  *
478  * @param  base ENC peripheral base address.
479  *
480  * @return      Hold position difference counter's value.
481  */
ENC_GetHoldPositionDifferenceValue(ENC_Type * base)482 static inline uint16_t ENC_GetHoldPositionDifferenceValue(ENC_Type *base)
483 {
484     return base->POSDH;
485 }
486 
487 /*!
488  * @brief  Get the position revolution counter's value.
489  *
490  * @param  base ENC peripheral base address.
491  *
492  * @return     The position revolution counter's value.
493  */
ENC_GetRevolutionValue(ENC_Type * base)494 static inline uint16_t ENC_GetRevolutionValue(ENC_Type *base)
495 {
496     return base->REV;
497 }
498 
499 /*!
500  * @brief  Get the hold position revolution counter's value.
501  *
502  * When any of the counter registers is read, the contents of each counter register is written to the corresponding hold
503  * register. Taking a snapshot of the counters' values provides a consistent view of a system position and a velocity to
504  * be attained.
505  *
506  * @param  base ENC peripheral base address.
507  *
508  * @return      Hold position revolution counter's value.
509  */
ENC_GetHoldRevolutionValue(ENC_Type * base)510 static inline uint16_t ENC_GetHoldRevolutionValue(ENC_Type *base)
511 {
512     return base->REVH;
513 }
514 
515 #if (defined(FSL_FEATURE_ENC_HAS_LASTEDGE) && FSL_FEATURE_ENC_HAS_LASTEDGE)
516 /*!
517  * @brief  Get the last edge time value.
518  *
519  * @param  base ENC peripheral base address.
520  *
521  * @return     The last edge time hold value.
522  */
ENC_GetLastEdgeTimeValue(ENC_Type * base)523 static inline uint16_t ENC_GetLastEdgeTimeValue(ENC_Type *base)
524 {
525     return base->LASTEDGE;
526 }
527 
528 /*!
529  * @brief  Get the last edge time hold value.
530  *
531  * @param  base ENC peripheral base address.
532  *
533  * @return     The last edge time hold value.
534  */
ENC_GetHoldLastEdgeTimeValue(ENC_Type * base)535 static inline uint16_t ENC_GetHoldLastEdgeTimeValue(ENC_Type *base)
536 {
537     return base->LASTEDGEH;
538 }
539 #endif
540 
541 #if (defined(FSL_FEATURE_ENC_HAS_POSDPER) && FSL_FEATURE_ENC_HAS_POSDPER)
542 /*!
543  * @brief  Get the position difference period value.
544  *
545  * @param  base ENC peripheral base address.
546  *
547  * @return     The position difference period hold value.
548  */
ENC_GetPositionDifferencePeriodValue(ENC_Type * base)549 static inline uint16_t ENC_GetPositionDifferencePeriodValue(ENC_Type *base)
550 {
551     return base->POSDPER;
552 }
553 
554 /*!
555  * @brief  Get the position difference period buffer value.
556  *
557  * @param  base ENC peripheral base address.
558  *
559  * @return     The position difference period hold value.
560  */
ENC_GetPositionDifferencePeriodBufferValue(ENC_Type * base)561 static inline uint16_t ENC_GetPositionDifferencePeriodBufferValue(ENC_Type *base)
562 {
563     return base->POSDPERBFR;
564 }
565 
566 /*!
567  * @brief  Get the position difference period hold value.
568  *
569  * @param  base ENC peripheral base address.
570  *
571  * @return     The position difference period hold value.
572  */
ENC_GetHoldPositionDifferencePeriodValue(ENC_Type * base)573 static inline uint16_t ENC_GetHoldPositionDifferencePeriodValue(ENC_Type *base)
574 {
575     return base->POSDPERH;
576 }
577 #endif
578 /*! @} */
579 
580 #if defined(__cplusplus)
581 }
582 #endif
583 
584 /*! @} */
585 
586 #endif /* FSL_ENC_H_ */
587