EQEP外设

1.static inline void EQEP_enableModule(uint32_t base);

function Function: This function is used to enable the Enhanced Quadrature Encoder Pulse (eQEP) module. The module must be configured before it is enabled Parameter Description Input parameter: base is the base address of the eQEP module Return parameter: none

2.static inline void EQEP_disableModule(uint32_t base);

function Function: This function is used to disable the Enhanced Quadrature Encoder Pulse (eQEP) module Parameter Description Input parameter: base is the base address of the eQEP module Return parameter: none

3.static inline void EQEP_setDecoderConfig(uint32_t base, uint16_t config);

function: Parameter Description Input parameter: base is the base address of the eQEP module config为eQEP 模块解码器单元的配置 return parameter: none

4.static inline void EQEP_setPositionCounterConfig
(uint32_t base, EQEP_PositionResetMode mode, uint32_t maxPosition);

function function: This function is used to configure the position counter of the eQEP module. The parameter mode determines when the position counter is restarted. Restarts can occur when the counter reaches four values: EQEP _ POSITION _ RESET _ IDX, EQEP _ POSITION _ RESET _ MAX _ POS, EQEP _ POSITION _ RESET _ 1ST _ IDX, The EQEP _ POSITION _ RESET _ UNIT _ TIME _ OUTmaxPosition is the maximum value of the counter and is used to reset the value of the position capture when the steering is reversed. Parameter description Input parameter: base is the base address of the eQEP module mode为eQEP 位置计数器的配置maxPosition为最大位置值 return parameter: none

5.static inline uint32_t EQEP_getPosition(uint32_t base);

function function: This function is used to obtain the current position of the encoder. Depending on the configuration of the encoder and whether an index pulse has occurred, this value may or may not contain the expected data (that is, in index reset mode, if the index pulse has not been encountered, the position counter has not been aligned with the index pulse) Parameter Description Input Parameters: base is the base address of the eQEP module Return Parameters: The current position of the encoder

6.static inline void EQEP_setPosition(uint32_t base, uint32_t position);

function function: This function is used to set the current position of the encoder, and then measure the position of the encoder relative to this value. Parameter description Input parameter: base is the base address of the eQEP module. position为编码器的新位置 return parameter: none

7.static inline int16_t EQEP_getDirection(uint32_t base);

function function: This function is used to obtain the direction of the current rotation. In this case, the current refers to the most recent direction detected by the encoder; it may not be currently moving, but this is the last direction it moved before it stopped. Parameter description Input parameter: base is the base address of eQEP module Return parameter: 1 is forward, -1 is reverse

8.static inline void EQEP_enableInterrupt(uint32_t base, uint16_t intFlags);

function: This function is used to enable each interrupt source of the eQEP module. The interrupt sources are as follows: EQEP_INT_POS_CNT_ERROR - 位置计数器错误EQEP_INT_PHASE_ERROR -正交相位错误EQEP_INT_DIR_CHANGE - 正交方向改变EQEP_INT_WATCHDOG - 看门狗超时EQEP_INT_UNDERFLOW -位置计数器下溢EQEP_INT_OVERFLOW - 位置计数器上溢EQEP_INT_POS_COMP_READY -位置比较准备EQEP_INT_POS_COMP_MATCH -位置比较匹配EQEP_INT_STROBE_EVNT_LATCH - 触发事件锁存EQEP_INT_INDEX_EVNT_LATCH - 索引事件锁存EQEP_INT_UNIT_TIME_OUT -单位时间超时EQEP_INT_QMA_ERROR - QMA错误 parameter description Input parameter: base is the base address of the eQEP module intFlags为要启用的中断源的位掩码 return parameter: none

9.static inline void EQEP_disableInterrupt(uint32_t base, uint16_t intFlags);

function: This function is used to disable each interrupt source of the eQEP module. The interrupt sources are as follows: EQEP_INT_POS_CNT_ERROR - 位置计数器错误EQEP_INT_PHASE_ERROR -正交相位错误EQEP_INT_DIR_CHANGE - 正交方向改变EQEP_INT_WATCHDOG - 看门狗超时EQEP_INT_UNDERFLOW -位置计数器下溢EQEP_INT_OVERFLOW - 位置计数器上溢EQEP_INT_POS_COMP_READY -位置比较准备EQEP_INT_POS_COMP_MATCH -位置比较匹配EQEP_INT_STROBE_EVNT_LATCH - 触发事件锁存EQEP_INT_INDEX_EVNT_LATCH - 索引事件锁存EQEP_INT_UNIT_TIME_OUT -单位时间超时EQEP_INT_QMA_ERROR - QMA错误 parameter description Input parameter: base is the base address of the eQEP module intFlags为要启用的中断源的位掩码 return parameter: none

10.static inline uint16_t EQEP_getInterruptStatus(uint32_t base);

function function: This function is used to obtain the existing state of each interrupt of the eQEP module, enumerated by the bit field of the following values: EQEP_INT_GLOBAL - 全局中断标志EQEP_INT_POS_CNT_ERROR - 位置计数器错误EQEP_INT_PHASE_ERROR -正交相位错误EQEP_INT_DIR_CHANGE - 正交方向改变EQEP_INT_WATCHDOG - 看门狗超时EQEP_INT_UNDERFLOW -位置计数器下溢EQEP_INT_OVERFLOW - 位置计数器上溢EQEP_INT_POS_COMP_READY -位置比较准备EQEP_INT_POS_COMP_MATCH -位置比较匹配EQEP_INT_STROBE_EVNT_LATCH - 触发事件锁存EQEP_INT_INDEX_EVNT_LATCH - 索引事件锁存EQEP_INT_UNIT_TIME_OUT -单位时间超时EQEP_INT_QMA_ERROR - QMA错误 parameter description Input parameter: base is the base address of eQEP module Return parameter: current status of each interrupt of eQEP module

11.static inline void EQEP_clearInterruptStatus(uint32_t base, uint16_t intFlags);

function: This function is used to clear the interrupt of the eQEP module, including: EQEP_INT_GLOBAL - 全局中断标志EQEP_INT_POS_CNT_ERROR - 位置计数器错误EQEP_INT_PHASE_ERROR -正交相位错误EQEP_INT_DIR_CHANGE - 正交方向改变EQEP_INT_WATCHDOG - 看门狗超时EQEP_INT_UNDERFLOW -位置计数器下溢EQEP_INT_OVERFLOW - 位置计数器上溢EQEP_INT_POS_COMP_READY -位置比较准备EQEP_INT_POS_COMP_MATCH -位置比较匹配EQEP_INT_STROBE_EVNT_LATCH - 触发事件锁存EQEP_INT_INDEX_EVNT_LATCH - 索引事件锁存EQEP_INT_UNIT_TIME_OUT -单位时间超时EQEP_INT_QMA_ERROR - QMA错误注意:EQEP_INT_GLOBAL为全局中断标志,必须被清空 parameter description Input parameter: base is the base address of the eQEP module intFlags为要被清理中断的一位掩码 return parameter: none

12.static inline void EQEP_forceInterrupt(uint32_t base, uint16_t intFlags);

function function: This function is used to force the interrupt of the eQEP module, including: EQEP_INT_GLOBAL - 全局中断标志EQEP_INT_POS_CNT_ERROR - 位置计数器错误EQEP_INT_PHASE_ERROR -正交相位错误EQEP_INT_DIR_CHANGE - 正交方向改变EQEP_INT_WATCHDOG - 看门狗超时EQEP_INT_UNDERFLOW -位置计数器下溢EQEP_INT_OVERFLOW - 位置计数器上溢EQEP_INT_POS_COMP_READY -位置比较准备EQEP_INT_POS_COMP_MATCH -位置比较匹配EQEP_INT_STROBE_EVNT_LATCH - 触发事件锁存EQEP_INT_INDEX_EVNT_LATCH - 索引事件锁存EQEP_INT_UNIT_TIME_OUT -单位时间超时EQEP_INT_QMA_ERROR - QMA错误注意:EQEP_INT_GLOBAL为全局中断标志,必须被清空 parameter description Input parameter: base is the base address of the eQEP module intFlags为要被强制执行中断的一位掩码 return parameter: none

13.static inline bool EQEP_getError(uint32_t base);

function function: This function is used as an error indicator for the eQEP module. This is considered an error when the two signals of the quadrature input change simultaneously. Parameter description Input parameter: base is the base address of the eQEP module Return parameter: return true if there is an error, otherwise return false

14.static inline uint16_t EQEP_getStatus(uint32_t base);

function function: This function is used to obtain the value of eQEP register, and the returned value is the bitwise or of the following values: EQEP_STS_UNIT_POS_EVNT - 被检测的单位位置事件EQEP_STS_DIR_ON_1ST_IDX - 如果设置,则表示在第一个索引事件上发生了顺时针旋转(向前运动)EQEP_STS_DIR_FLAG - 如果设置,则为顺时针旋转EQEP_STS_DIR_LATCH -如果设置,则表示在上一个索引事件标记上发生了顺时针旋转EQEP_STS_CAP_OVRFLW_ERROR -eQEP 捕获定时器发生了溢出EQEP_STS_CAP_DIR_ERROR - 在位置捕获事件之间发生了方向变化EQEP_STS_1ST_IDX_FLAG - 由第一个索引脉冲的发生设置EQEP_STS_POS_CNT_ERROR - 位置计数器发生错误 parameter description Input parameter: base is the base address of the eQEP module Return parameter: the value of the eQEP status register

15.static inline void EQEP_clearStatus(uint32_t base, uint16_t statusFlags);

this function clears the selected field of the eQEP module status register, which is determined by the logical or of statusFlags and EQEP_STS_UNIT_POS_EVNT - 被检测的单位位置事件EQEP_STS_CAP_OVRFLW_ERROR -eQEP 捕获定时器发生了溢出EQEP_STS_CAP_DIR_ERROR - 在位置捕获事件之间发生了方向变化EQEP_STS_1ST_IDX_FLAG - 由第一个索引脉冲的发生设置注意:只有以上能被清空,其他的为只读 parameter description Input parameter: base is the base address of the eQEP module statusFlags是要清除的状态标志位掩码 return parameter: value of eQEP status register

16.static inline void EQEP_setCaptureConfig
(uint32_t base, EQEP_CAPCLKPrescale capPrescale, EQEP_UPEVNTPrescale evntPrescale);

function function: This function configures the operation of the edge capture unit of the eQEP module. The parameter \ e capPrescale provides the configuration of the eQEP capture timer clock rate. It determines how many powers of two SYSCLKOUT is divisible by, between 1 and 128 inclusive. The macro format for this argument is a EQEP _ CAPTURE _ CLK _ DIV _ X, where X is the division value. For example, B EQEP _ CAPTURE _ CLK _ DIV _ 32 will provide a capture timer clock rate of SYSCLKOUT/32. The parameter evntPrescale determines how often the unit position event occurs. The format of the macro that can be passed to this parameter is EQEP _ UNIT _ POS _ EVNT _ DIV _ X, where X is the number of quadrature clock cycles between unit position events. For example, a \ B EQEP _ UNIT _ POS _ EVNT _ DIV _ of 16 would result in a unit position event frequency of QCLK/16 Parameter Description Input Parameters: base is the base address of the eQEP module capPrescale 是 eQEP 捕获定时器时钟的预分频设置evntPrescale 是单位位置事件频率的预分频设置 return parameter: none

17.static inline void EQEP_enableCapture(uint32_t base);

function Function: This function is used to enable the edge capture unit Parameter Description Input parameter: base is the base address of the eQEP module Return parameter: none

18.static inline void EQEP_disableCapture(uint32_t base);

function Function: This function is used to disable the edge capture unit Parameter Description Input parameter: base is the base address of the eQEP module Return parameter: none

19.static inline uint16_t EQEP_getCapturePeriod(uint32_t base);

function Function: This function is used to obtain the encoder capture cycle parameter Description Input parameter: base is the base address of the eQEP module Return parameter: the cycle count value between the last consecutive eQEP position events

20.static inline uint16_t EQEP_getCaptureTimer(uint32_t base);

function Function: This function is used to obtain the encoder capture time value Parameter Description Input parameter: base is the base address of the eQEP module Return parameter: capture time value

21.static inline void EQEP_enableCompare(uint32_t base);

function: This function is used to enable the location comparison unit Parameter Description Input parameter: base is the base address of the eQEP module Return parameter: none

22.static inline void EQEP_disableCompare(uint32_t base);

function Function: This function is used to disable the location comparison unit Parameter Description Input parameter: base is the base address of the eQEP module Return parameter: none

23.static inline void EQEP_setComparePulseWidth(uint32_t base, uint16_t cycles);

function: This function is used to configure the synchronous output pulse width of the position comparison unit. The pulse width will be * 4 the width of one SYSCLKOUT cycle. The maximum width is 4096 * 4 sYSCLKOUT cycles. Parameter description Input parameter: base is the base address of the eQEP module cycles为在位置比较事件上可以生成的脉冲宽度。它以4个SYSCLKOUT周期为单位。 return parameter: none

24.static inline void EQEP_loadUnitTimer(uint32_t base, uint32_t period);

function Function: This function is used to load the eQEP module unit timer cycle as SYSCLK cycle number Parameter Description Input parameter: base is the base address of the eQEP module period 为设置单元超时中断的周期值 return parameter: none

25.static inline void EQEP_enableUnitTimer(uint32_t base, uint32_t period);

function function: This function is used to enable the eQEP peripheral unit timer parameter description Input parameter: base is the base address of the eQEP module Return parameter: none

26.static inline void EQEP_disableUnitTimer(uint32_t base);

function Function: This function is used to disable the eQEP peripheral unit Timer Parameter Description Input parameter: base is the base address of the eQEP module Return parameter: none

27.static inline void EQEP_enableWatchdog(uint32_t base, uint16_t period);

function Function: This function is used to enable the watchdog unit Parameter Description Input parameter: base is the base address of the eQEP module Return parameter: none

28.static inline void EQEP_disableWatchdog(uint32_t base);

function Function: This function is used to disable the watchdog unit Parameter Description Input parameter: base is the base address of the eQEP module Return parameter: none

29.static inline void EQEP_setWatchdogTimerValue(uint32_t base, uint16_t value);

function: This function sets the value of the watchdog unit timer of the eQEP module Parameter Description Input parameter: base is the base address of the eQEP module value为要设置的值 return parameter: none

30.static inline uint16_t EQEP_getWatchdogTimerValue(uint32_t base);

function Function: This function obtains the value of the watchdog unit timer of the eQEP module Parameter Description Input parameter: base is the base address of the eQEP module Return parameter: none

31.static inline void EQEP_setPositionInitMode(uint32_t base, uint16_t initMode);

function function: This function configures the event that can initialize the position count. The parameter initMode provides the mode, which can be a EQEP _ INIT _ DO _ NOTHING (no action is configured), or one of the following strobe events, index events, or the logical or of the strobe event and index event. EQEP_INIT_RISING_STROBE 或 EQEP_INIT_EDGE_DIR_STROBE 指定了哪个 strobe 事件将初始化位置计数器。EQEP_INIT_RISING_INDEX 或 \b EQEP_INIT_FALLING_INDEX 指定了哪个 index 事件将初始化位置计数器。

use the EQEP _ setSWPositionInit () for software initialization and the EQEP _ setInitialPosition () to set the value that is loaded into the position counter during initialization. Parameter description Input parameter: base is the base address of the eQEP module initMode 用于初始化位置计数的配置的模式 return parameter: none

32.static inline void EQEP_setSWPositionInit(uint32_t base, bool initialize);

function function: When the initialize parameter is true, this function performs software initialization on the position counter. When false, the QEPC TL [SWI] bit is cleared and no action is taken.

you can use the EQEP _ setInitialPosition () to set the initial value to be loaded into the position counter. Additional initialization reasons can also be configured using the EQEP _ setPosition InitMode (). Parameter description Input parameter: base is the base address of the eQEP module initialize 是一个标志,用于指定是否启用位置计数器的软件初始化 return parameter: none

33.static inline void EQEP_setInitialPosition(uint32_t base, uint32_t position);

function function: This function sets the initial value of the encoder position. Refer to the EQEP _ setPosition InitMode () to set the reason for initialization, or the EQEP _ setSWPositionInit () to perform software initialization Parameter Description Enter parameters: base is the base address of the eQEP module position 是在初始化时写入位置计数器的值 return parameter: none

34.static inline void EQEP_setLatchMode(uint32_t base, uint32_t latchMode);

function function: This function is configured to latch the events of the position count and several other registers. The parameter latchMode provides a logical or pattern of several values. The EQEP _ LATCH _ CNT _ READ _ BY _ CPU or the \ B EQEP _ LATCH _ UNIT _ TIME _ OUT specifies the event for the latch position count. This latch register can be read using the EQEP _ getPositionLatch (). Based on this setting, the capture timer and capture period are also latched and can be read using the EQEP _ getCaptureTimerLatch () and EQEP _ getCapturePeriodLatch (). The EQEP _ LATCH _ RISING _ STROBE or the \ B EQEP _ LATCH _ EDGE _ DIR _ STROBE specifies which strobe event latches the position count into the strobe position latch register. This register can be read using the EQEP _ getStrobePositionLatch (). The EQEP _ LATCH _ RISING _ INDEX, EQEP _ LATCH _ FALLING _ INDEX, or EQEP _ LATCH _ SW _ INDEX _ MARKER specifies which index event latches the position count into the index position latch register. This register can be read using the EQEP _ getIndexPosition Latch () Parameter Description Input Parameters: base is the base address of the eQEP module latchMode 是用于锁存位置计数和其他寄存器的配置 return parameter: none

35.static inline uint32_t EQEP_getIndexPositionLatch(uint32_t base);

function function: This function returns the value in the latch register at the index location. The position counter is latched into this register at a rising index edge, a falling index edge, or a software index mark. This is configured using the EQEP _ setLatchMode (). Parameter description Input parameter: base is the base address of the eQEP module Return parameter: index the position count latched on the event

36.static inline uint32_t EQEP_getStrobePositionLatch(uint32_t base);

function function: This function returns the value in the strobe position latch register. The position counter can be configured to latch into this register only on a rising strobe edge, or on a rising strobe edge when moving clockwise and a falling strobe edge when moving counterclockwise. This is a parameter description configured using the EQEP _ setLatchMode () Input parameters: base is the base address of the eQEP module Return parameters: count of the location latched on the strobe event

37.static inline uint32_t EQEP_getPositionLatch(uint32_t base);

function function: This function returns the value in the position latch register. The position counter is latched into this register on a unit timeout event Parameter Description Input parameter: base is the base address of the eQEP module Return parameter: the value of the position count latch register

38.static inline uint16_t EQEP_getCaptureTimerLatch(uint32_t base);

function function: This function returns the value in the capture timer latch register. The capture timer value is latched into this register on a unit timeout event or when the CPU reads the eQEP position counter. This is a description of the parameters configured using the EQEP _ setLatchMode () Input parameters: base is the base address of the eQEP module Return parameters: Edge Capture Timer Latch Value

39.static inline uint16_t EQEP_getCapturePeriodLatch(uint32_t base);

function function: This function returns the value in the capture period latch. The capture cycle value is latched into this register on a unit timeout event or when the CPU reads the eQEP position counter. This is configured using the EQEP _ setLatchMode (). Parameter description Input parameter: base is the base address of the eQEP module Return parameter: edge capture cycle latch value

40.static inline void EQEP_setQMAModuleMode
(uint32_t base, EQEP_QMAMode qmaMode)

function function: This function sets the mode of the QMA module. The possible modes are passed to the function through the parameter qmaMode, which can take the value EQEP _ QMA _ MODE _ BYPASS, EQEP _ QMA _ MODE _ 1, or EQEP _ QMA _ MODE _ 2. To use the QMA module, you must first place the eQEP module in Directional Count mode (EQEP _ CONFIG _ CLOCK _ DIR), using EQEP _ setConfig (). Parameter description Input parameter: base is the base address of the eQEP module qmaMode 是 QMA 模块将操作的模式 return parameter: none

41.static inline void EQEP_setStrobeSource
(uint32_t base, EQEP_StrobeSource strobeSrc)

function: This function sets the source of the strobe signal of the eQEP module. The possible values for the parameter strobeSrc are: EQEP_STROBE_FROM_GPIO - 经过极性选择逻辑后,strobe 信号原样使用EQEP_STROBE_OR_ADCSOCA - 经过极性选择逻辑后,strobe 信号与 ADCSOCA 信号进行 OR 操作EQEP_STROBE_OR_ADCSOCB - 经过极性选择逻辑后,strobe 信号与 ADCSOCB 信号进行 OR 操作 parameter description Input parameter: base is the base address of the eQEP module strobeSrc 是 strobe 信号的源 return parameter: none

42.static inline void EQEP_setEmulationMode
(uint32_t base, EQEP_EmulationMode emuMode)

function: This function sets the simulation mode of the eQEP module. This mode determines how the timer affects when the simulation is suspended. Valid values for the emuMode parameter are as follows: EQEP_EMULATIONMODE_STOPIMMEDIATELY - 位置计数器、看门狗计数器、单元定时器和捕获计时器立即停止EQEP_EMULATIONMODE_STOPATROLLOVER - 位置计数器、看门狗计数器、单元定时器一直计数直到周期溢出。捕获计时器计数直到下一个单元周期事件 EQEP_EMULATIONMODE_RUNFREE - 位置计数器、看门狗计数器、单元定时器和捕获计时器在仿真挂起时不受影响 parameter description Input parameter: base is the base address of the eQEP module emuMode 是在仿真挂起时的模式操作 return parameter: none

43.extern void EQEP_setCompareConfig
(uint32_t base, uint16_t config, uint32_t compareValue, uint16_t cycles);

function function: This function configures the operation of the location comparison unit of the eQEP module. The parameter config provides the configuration of the location comparison unit and is the logical or of several values: EQEP_COMPARE_NO_SYNC_OUT、 EQEP_COMPARE_IDX_SYNC_OUT 或 EQEP_COMPARE_STROBE_SYNC_OUT 指定是否有同步输出脉冲以及应使用哪个引脚EQEP_COMPARE_NO_SHADOW、EQEP_COMPARE_LOAD_ON_ZERO 或 EQEP_COMPARE_LOAD_ON_MATCH 指定是否启用阴影以及何时应执行加载 即QPOSCNT = 0 或 QPOSCNT = QPOSCOMP参数 cycles 用于选择同步输出脉冲的宽度。生成脉冲的宽度将为cycles * 4 * 一个 SYSCLKOUT 周期的宽度。最大宽度为 4096 * 4 * SYSCLKOUT 周期注意:可以使用 EQEP_setComparePulseWidth() 函数独立设置同步脉冲宽度 parameter description Input parameter: base is the base address of the eQEP module. config 为 eQEP 模块位置比较单元的配置compareValue 为与位置计数值进行比较以进行位置比较事件的值cycles 为在位置比较事件上可以生成的脉冲宽度。它以 4 个 SYSCLKOUT 周期为单位 return parameter: none

44.extern void EQEP_setInputPolarity
(uint32_t base, bool invertQEPA, bool invertQEPB, bool invertIndex, 
bool invertStrobe);

function function: This function configures the polarity of the input signal to the eQEP module. To invert the polarity of any input signal, pass true into the corresponding argument in the function. Pass false to keep it as it is. Parameter description Input parameter: base is the base address of the eQEP module. invertQEPA 为取反 QEPA 输入的标志invertQEPB 为取反 QEPB 输入的标志invertIndex 为取反索引输入的标志invertStrobe 为取反 strobe 输入的标志 return parameter: none