| M480 BSP V3.05.001 The Board Support Package for M480 Series

Macros | Functions
QEI Exported Functions
Standard Driver » QEI Driver

## Macros
#define | QEI_DISABLE_CNT_CMP(qei)
| Disable QEI compare function. More...
#define | QEI_ENABLE_CNT_CMP(qei)
| Enable QEI compare function. More...
#define | QEI_DISABLE_INDEX_LATCH(qei)
| Disable QEI index latch function. More...
#define | QEI_ENABLE_INDEX_LATCH(qei)
| Enable QEI index latch function. More...
#define | QEI_DISABLE_INDEX_RELOAD(qei)
| Disable QEI index reload function. More...
#define | QEI_ENABLE_INDEX_RELOAD(qei)
| Enable QEI index reload function. More...
#define | QEI_DISABLE_INPUT(qei, u32InputType)
| Disable QEI input. More...
#define | QEI_ENABLE_INPUT(qei, u32InputType)
| Enable QEI input. More...
#define | QEI_DISABLE_INPUT_INV(qei, u32InputType)
| Disable inverted input polarity. More...
#define | QEI_ENABLE_INPUT_INV(qei, u32InputType)
| Enable inverted input polarity. More...
#define | QEI_DISABLE_INT(qei, u32IntSel)
| Disable QEI interrupt. More...
#define | QEI_ENABLE_INT(qei, u32IntSel)
| Enable QEI interrupt. More...
#define | QEI_DISABLE_NOISE_FILTER(qei)
| Disable QEI noise filter. More...
#define | QEI_ENABLE_NOISE_FILTER(qei, u32ClkSel)
| Enable QEI noise filter. More...
#define | QEI_GET_CNT_VALUE(qei)
| Get QEI counter value. More...
#define | QEI_GET_DIR(qei)
| Get QEI counting direction. More...
#define | QEI_GET_HOLD_VALUE(qei)
| Get QEI counter hold value. More...
#define | QEI_GET_INDEX_LATCH_VALUE(qei)
| Get QEI counter index latch value. More...
#define | QEI_SET_INDEX_LATCH_VALUE(qei, u32Val)
| Set QEI counter index latch value. More...
#define | QEI_GET_INT_FLAG(qei, u32IntSel)
| Get QEI interrupt flag status. More...
#define | QEI_CLR_INT_FLAG(qei, u32IntSel)
| Clear QEI interrupt flag. More...
#define | QEI_SET_CNT_CMP(qei, u32Value)
| Set QEI counter compare value. More...
#define | QEI_SET_CNT_VALUE(qei, u32Value)
| Set QEI counter value. More...
#define | QEI_ENABLE_HOLD_TRG_SRC(qei, u32Type)
| Enable QEI counter hold mode. More...
#define | QEI_DISABLE_HOLD_TRG_SRC(qei, u32Type)
| Disable QEI counter hold mode. More...
#define | QEI_SET_CNT_MAX(qei, u32Value)
| Set QEI maximum count value. More...
#define | QEI_SET_CNT_MODE(qei, u32Mode)
| Set QEI counting mode. More...

## Functions
void | QEI_Close (QEI_T *qei)
| Close QEI function. More...
void | QEI_DisableInt (QEI_T *qei, uint32_t u32IntSel)
| Disable QEI interrupt. More...
void | QEI_EnableInt (QEI_T *qei, uint32_t u32IntSel)
| Enable QEI interrupt. More...
void | QEI_Open (QEI_T *qei, uint32_t u32Mode, uint32_t u32Value)
| Open QEI in specified mode and enable input. More...
void | QEI_Start (QEI_T *qei)
| Start QEI function. More...
void | QEI_Stop (QEI_T *qei)
| Stop QEI function. More...

## Detailed Description

## Macro Definition Documentation

## ◆ QEI_CLR_INT_FLAG

#define QEI_CLR_INT_FLAG | ( |  | qei,
|  |  | u32IntSel
| ) |  |

Clear QEI interrupt flag.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32IntSel | Interrupt type selection. QEI_STATUS_DIRCHGF_Msk : Direction change flag QEI_STATUS_OVUNF_Msk : Counter overflow or underflow flag QEI_STATUS_CMPF_Msk : Compare-match flag QEI_STATUS_IDXF_Msk : Index detected flag

Returns
  None

This macro clear QEI specified interrupt flag.

Definition at line 293 of file qei.h.

## ◆ QEI_DISABLE_CNT_CMP

#define QEI_DISABLE_CNT_CMP | ( |  | qei | ) |

Disable QEI compare function.

Parameters

  [in] | qei | The pointer of the specified QEI module.

Returns
  None

This macro disable QEI counter compare function.

Definition at line 65 of file qei.h.

## ◆ QEI_DISABLE_HOLD_TRG_SRC

#define QEI_DISABLE_HOLD_TRG_SRC | ( |  | qei,
|  |  | u32Type
| ) |  |

Disable QEI counter hold mode.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32Type | The triggered type. QEI_CTL_HOLDCNT_Msk : Hold QEI_CNT control QEI_CTL_HOLDTMR0_Msk : Hold QEI_CNT by Timer0 QEI_CTL_HOLDTMR1_Msk : Hold QEI_CNT by Timer1 QEI_CTL_HOLDTMR2_Msk : Hold QEI_CNT by Timer2 QEI_CTL_HOLDTMR3_Msk : Hold QEI_CNT by Timer3

Returns
  None

This macro disable QEI counter hold mode.

Definition at line 343 of file qei.h.

## ◆ QEI_DISABLE_INDEX_LATCH

#define QEI_DISABLE_INDEX_LATCH | ( |  | qei | ) |

Disable QEI index latch function.

Parameters

  [in] | qei | The pointer of the specified QEI module.

Returns
  None

This macro disable QEI index trigger counter latch function.

Definition at line 83 of file qei.h.

## ◆ QEI_DISABLE_INDEX_RELOAD

#define QEI_DISABLE_INDEX_RELOAD | ( |  | qei | ) |

Disable QEI index reload function.

Parameters

  [in] | qei | The pointer of the specified QEI module.

Returns
  None

This macro disable QEI index trigger counter reload function.

Definition at line 101 of file qei.h.

## ◆ QEI_DISABLE_INPUT

#define QEI_DISABLE_INPUT | ( |  | qei,
|  |  | u32InputType
| ) |  |

Disable QEI input.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32InputType | Input signal type. QEI_CTL_CHAEN_Msk : QEA input QEI_CTL_CHAEN_Msk : QEB input QEI_CTL_IDXEN_Msk : IDX input

Returns
  None

This macro disable specified QEI signal input.

Definition at line 123 of file qei.h.

## ◆ QEI_DISABLE_INPUT_INV

#define QEI_DISABLE_INPUT_INV | ( |  | qei,
|  |  | u32InputType
| ) |  |

Disable inverted input polarity.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32InputType | Input signal type . QEI_CTL_CHAINV_Msk : QEA Input QEI_CTL_CHBINV_Msk : QEB Input QEI_CTL_IDXINV_Msk : IDX Input

Returns
  None

This macro disable specified QEI signal inverted input polarity.

Definition at line 149 of file qei.h.

## ◆ QEI_DISABLE_INT

#define QEI_DISABLE_INT | ( |  | qei,
|  |  | u32IntSel
| ) |  |

Disable QEI interrupt.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32IntSel | Interrupt type selection. QEI_CTL_DIRIEN_Msk : Direction change interrupt QEI_CTL_OVUNIEN_Msk : Counter overflow or underflow interrupt QEI_CTL_CMPIEN_Msk : Compare-match interrupt QEI_CTL_IDXIEN_Msk : Index detected interrupt

Returns
  None

This macro disable specified QEI interrupt.

Definition at line 176 of file qei.h.

## ◆ QEI_DISABLE_NOISE_FILTER

#define QEI_DISABLE_NOISE_FILTER | ( |  | qei | ) |

Disable QEI noise filter.

Parameters

  [in] | qei | The pointer of the specified QEI module.

Returns
  None

This macro disable QEI noise filter function.

Definition at line 199 of file qei.h.

## ◆ QEI_ENABLE_CNT_CMP

#define QEI_ENABLE_CNT_CMP | ( |  | qei | ) |

Enable QEI compare function.

Parameters

  [in] | qei | The pointer of the specified QEI module.

Returns
  None

This macro enable QEI counter compare function.

Definition at line 74 of file qei.h.

## ◆ QEI_ENABLE_HOLD_TRG_SRC

#define QEI_ENABLE_HOLD_TRG_SRC | ( |  | qei,
|  |  | u32Type
| ) |  |

Enable QEI counter hold mode.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32Type | The triggered type. QEI_CTL_HOLDCNT_Msk : Hold QEI_CNT control QEI_CTL_HOLDTMR0_Msk : Hold QEI_CNT by Timer0 QEI_CTL_HOLDTMR1_Msk : Hold QEI_CNT by Timer1 QEI_CTL_HOLDTMR2_Msk : Hold QEI_CNT by Timer2 QEI_CTL_HOLDTMR3_Msk : Hold QEI_CNT by Timer3

Returns
  None

This macro enable QEI counter hold mode.

Definition at line 328 of file qei.h.

## ◆ QEI_ENABLE_INDEX_LATCH

#define QEI_ENABLE_INDEX_LATCH | ( |  | qei | ) |

Enable QEI index latch function.

Parameters

  [in] | qei | The pointer of the specified QEI module.

Returns
  None

This macro enable QEI index trigger counter latch function.

Definition at line 92 of file qei.h.

## ◆ QEI_ENABLE_INDEX_RELOAD

#define QEI_ENABLE_INDEX_RELOAD | ( |  | qei | ) |

Enable QEI index reload function.

Parameters

  [in] | qei | The pointer of the specified QEI module.

Returns
  None

This macro enable QEI index trigger counter reload function.

Definition at line 110 of file qei.h.

## ◆ QEI_ENABLE_INPUT

#define QEI_ENABLE_INPUT | ( |  | qei,
|  |  | u32InputType
| ) |  |

Enable QEI input.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32InputType | Input signal type . QEI_CTL_CHAEN_Msk : QEA input QEI_CTL_CHBEN_Msk : QEB input QEI_CTL_IDXEN_Msk : IDX input

Returns
  None

This macro enable specified QEI signal input.

Definition at line 136 of file qei.h.

## ◆ QEI_ENABLE_INPUT_INV

#define QEI_ENABLE_INPUT_INV | ( |  | qei,
|  |  | u32InputType
| ) |  |

Enable inverted input polarity.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32InputType | Input signal type. QEI_CTL_CHAINV_Msk : QEA Input QEI_CTL_CHBINV_Msk : QEB Input QEI_CTL_IDXINV_Msk : IDX Input

Returns
  None

This macro inverse specified QEI signal input polarity.

Definition at line 162 of file qei.h.

## ◆ QEI_ENABLE_INT

#define QEI_ENABLE_INT | ( |  | qei,
|  |  | u32IntSel
| ) |  |

Enable QEI interrupt.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32IntSel | Interrupt type selection. QEI_CTL_DIRIEN_Msk : Direction change interrupt QEI_CTL_OVUNIEN_Msk : Counter overflow or underflow interrupt QEI_CTL_CMPIEN_Msk : Compare-match interrupt QEI_CTL_IDXIEN_Msk : Index detected interrupt

Returns
  None

This macro enable specified QEI interrupt.

Definition at line 190 of file qei.h.

## ◆ QEI_ENABLE_NOISE_FILTER

#define QEI_ENABLE_NOISE_FILTER | ( |  | qei,
|  |  | u32ClkSel
| ) |  |

Enable QEI noise filter.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32ClkSel | The sampling frequency of the noise filter clock. QEI_CTL_NFCLKSEL_DIV1 QEI_CTL_NFCLKSEL_DIV2 QEI_CTL_NFCLKSEL_DIV4 QEI_CTL_NFCLKSEL_DIV16 QEI_CTL_NFCLKSEL_DIV32 QEI_CTL_NFCLKSEL_DIV64

Returns
  None

This macro enable QEI noise filter function and select noise filter clock.

Definition at line 215 of file qei.h.

## ◆ QEI_GET_CNT_VALUE

#define QEI_GET_CNT_VALUE | ( |  | qei | ) |

Get QEI counter value.

Parameters

  [in] | qei | The pointer of the specified QEI module.

Returns
  QEI pulse counter register value.

This macro get QEI pulse counter value.

Definition at line 224 of file qei.h.

## ◆ QEI_GET_DIR

#define QEI_GET_DIR | ( |  | qei | ) |

Get QEI counting direction.

Parameters

  [in] | qei | The pointer of the specified QEI module.

Return values

  0 | QEI counter is in down-counting.
  1 | QEI counter is in up-counting.

This macro get QEI counting direction.

Definition at line 234 of file qei.h.

## ◆ QEI_GET_HOLD_VALUE

#define QEI_GET_HOLD_VALUE | ( |  | qei | ) |

Get QEI counter hold value.

Parameters

  [in] | qei | The pointer of the specified QEI module.

Returns
  QEI pulse counter hold register value.

This macro get QEI pulse counter hold value, which is updated with counter value in hold counter value control.

Definition at line 243 of file qei.h.

## ◆ QEI_GET_INDEX_LATCH_VALUE

#define QEI_GET_INDEX_LATCH_VALUE | ( |  | qei | ) |

Get QEI counter index latch value.

Parameters

  [in] | qei | The pointer of the specified QEI module.

Returns
  QEI pulse counter index latch value

This macro get QEI pulse counter index latch value, which is updated with counter value when the index is detected.

Definition at line 252 of file qei.h.

## ◆ QEI_GET_INT_FLAG

#define QEI_GET_INT_FLAG | ( |  | qei,
|  |  | u32IntSel
| ) |  |

Get QEI interrupt flag status.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32IntSel | Interrupt type selection. QEI_STATUS_DIRF_Msk : Counting direction flag QEI_STATUS_DIRCHGF_Msk : Direction change flag QEI_STATUS_OVUNF_Msk : Counter overflow or underflow flag QEI_STATUS_CMPF_Msk : Compare-match flag QEI_STATUS_IDXF_Msk : Index detected flag

Return values

  0 | QEI specified interrupt flag is not set.
  1 | QEI specified interrupt flag is set.

This macro get QEI specified interrupt flag status.

Definition at line 278 of file qei.h.

## ◆ QEI_SET_CNT_CMP

#define QEI_SET_CNT_CMP | ( |  | qei,
|  |  | u32Value
| ) |  |

Set QEI counter compare value.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32Value | The counter compare value.

Returns
  None

This macro set QEI pulse counter compare value.

Definition at line 303 of file qei.h.

## ◆ QEI_SET_CNT_MAX

#define QEI_SET_CNT_MAX | ( |  | qei,
|  |  | u32Value
| ) |  |

Set QEI maximum count value.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32Value | The counter maximum value.

Returns
  QEI maximum count value

This macro set QEI maximum count value.

Definition at line 353 of file qei.h.

## ◆ QEI_SET_CNT_MODE

#define QEI_SET_CNT_MODE | ( |  | qei,
|  |  | u32Mode
| ) |  |

Set QEI counting mode.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32Mode | QEI counting mode. QEI_CTL_X4_FREE_COUNTING_MODE QEI_CTL_X2_FREE_COUNTING_MODE QEI_CTL_X4_COMPARE_COUNTING_MODE QEI_CTL_X2_COMPARE_COUNTING_MODE

Returns
  None

This macro set QEI counting mode.

Definition at line 367 of file qei.h.

## ◆ QEI_SET_CNT_VALUE

#define QEI_SET_CNT_VALUE | ( |  | qei,
|  |  | u32Value
| ) |  |

Set QEI counter value.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32Value | The counter compare value.

Returns
  None

This macro set QEI pulse counter value.

Definition at line 313 of file qei.h.

## ◆ QEI_SET_INDEX_LATCH_VALUE

#define QEI_SET_INDEX_LATCH_VALUE | ( |  | qei,
|  |  | u32Val
| ) |  |

Set QEI counter index latch value.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32Val | The latch value.

Returns
  QEI pulse counter index latch value

This macro set QEI pulse counter index latch value, which is updated with counter value when the index is detected.

Definition at line 262 of file qei.h.

## Function Documentation

## ◆ QEI_Close()

void QEI_Close | ( | QEI_T * | qei | ) |

Close QEI function.

Parameters

  [in] | qei | The pointer of the specified QEI module.

Returns
  None

This function reset QEI configuration and stop QEI counting.

Definition at line 30 of file qei.c.

## ◆ QEI_DisableInt()

void QEI_DisableInt | ( | QEI_T * | qei,
|  | uint32_t | u32IntSel
| ) |  |

Disable QEI interrupt.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32IntSel | Interrupt type selection. QEI_CTL_DIRIEN_Msk : Direction change interrupt QEI_CTL_OVUNIEN_Msk : Counter overflow or underflow interrupt QEI_CTL_CMPIEN_Msk : Compare-match interrupt QEI_CTL_IDXIEN_Msk : Index detected interrupt

Returns
  None

This function disable QEI specified interrupt.

Definition at line 47 of file qei.c.

## ◆ QEI_EnableInt()

void QEI_EnableInt | ( | QEI_T * | qei,
|  | uint32_t | u32IntSel
| ) |  |

Enable QEI interrupt.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32IntSel | Interrupt type selection. QEI_CTL_DIRIEN_Msk : Direction change interrupt QEI_CTL_OVUNIEN_Msk : Counter overflow or underflow interrupt QEI_CTL_CMPIEN_Msk : Compare-match interrupt QEI_CTL_IDXIEN_Msk : Index detected interrupt

Returns
  None

This function enable QEI specified interrupt.

Definition at line 74 of file qei.c.

## ◆ QEI_Open()

void QEI_Open | ( | QEI_T * | qei,
|  | uint32_t | u32Mode,
|  | uint32_t | u32Value
| ) |  |

Open QEI in specified mode and enable input.

Parameters

  [in] | qei | The pointer of the specified QEI module.
  [in] | u32Mode | QEI counting mode. QEI_CTL_X4_FREE_COUNTING_MODE QEI_CTL_X2_FREE_COUNTING_MODE QEI_CTL_X4_COMPARE_COUNTING_MODE QEI_CTL_X2_COMPARE_COUNTING_MODE
  [in] | u32Value | The counter maximum value in compare-counting mode.

Returns
  None

This function set QEI in specified mode and enable input.

Definition at line 102 of file qei.c.

## ◆ QEI_Start()

void QEI_Start | ( | QEI_T * | qei | ) |

Start QEI function.

Parameters

  [in] | qei | The pointer of the specified QEI module.

Returns
  None

This function enable QEI function and start QEI counting.

Definition at line 119 of file qei.c.

## ◆ QEI_Stop()

void QEI_Stop | ( | QEI_T * | qei | ) |

Stop QEI function.

Parameters

  [in] | qei | The pointer of the specified QEI module.

Returns
  None

This function disable QEI function and stop QEI counting.

Definition at line 131 of file qei.c.