| PDL for FM0+ Version1.0 Peripheral Driverl Library for FM0+

- Main Page
- Modules
- Data Structures
- Files

Data Structures | Defines | Typedefs | Enumerations | Functions | Variables
Quadrature Position/Revolution Counter (QPRC)

## Data Structures
struct | stc_qprc_int_sel
| Enumeration to define QPRC interrupt selection. More...
struct | stc_qprc_int_cb
| Enumeration to define QPRC interrupt callback function. More...
struct | stc_qprc_filter
| Structure to configuration QPRC filter. More...
struct | stc_qprc_config
| Structure to configuration QPRC. More...
struct | stc_qprc_intern_data
| Structure of QPRC internal data. More...
struct | stc_qprc_instance_data
| Structure of QPRC instance data. More...
## Defines
#define | stc_qprcn_t FM0P_QPRC_TypeDef
#define | stc_qprc_nfn_t FM0P_QPRC_NF_TypeDef
#define | QPRC0 (*((volatile stc_qprcn_t *) FM0P_QPRC0_BASE))
#define | QPRC1 (*((volatile stc_qprcn_t *) FM0P_QPRC1_BASE))
#define | QPRC2 (*((volatile stc_qprcn_t *) FM0P_QPRC2_BASE))
#define | QPRC3 (*((volatile stc_qprcn_t *) FM0P_QPRC3_BASE))
#define | QPRCNF0 (*((volatile stc_qprc_nfn_t *) FM0P_QPRC0_NF_BASE))
#define | QPRCNF1 (*((volatile stc_qprc_nfn_t *) FM0P_QPRC1_NF_BASE))
#define | QPRCNF2 (*((volatile stc_qprc_nfn_t *) FM0P_QPRC2_NF_BASE))
#define | QPRCNF3 (*((volatile stc_qprc_nfn_t *) FM0P_QPRC3_NF_BASE))
#define | QPRC_INSTANCE_COUNT
#define | QPRC_PC_OVERFLOW_INT 0
#define | QPRC_PC_UNDERFLOW_INT 1
#define | QPRC_PC_ZERO_INDEX_INT 2
## Typedefs
typedef enum en_qprc_instance_index | en_qprc_instance_index_t
| Enumeration to define an index for each QPRC instance.
typedef enum en_qprc_pcmode | en_qprc_pcmode_t
| Enumeration to define position counter mode.
typedef enum en_qprc_rcmode | en_qprc_rcmode_t
| Enumeration to define revolution counter mode.
typedef enum en_qprc_zinedge | en_qprc_zinedge_t
| Enumeration to define ZIN valid edge.
typedef enum en_qprc_binedge | en_qprc_binedge_t
| Enumeration to define BIN valid edge.
typedef enum en_qprc_ainedge | en_qprc_ainedge_t
| Enumeration to define AIN valid edge.
typedef enum en_qprc_pcresetmask | en_qprc_pcresetmask_t
| Enumeration to define reset mask times of position counter.
typedef enum en_qprc_compmode | en_qprc_compmode_t
| Enumeration to define compare object of QPRCR register.
typedef enum en_qprc_int | en_qprc_int_t
| Enumeration to define QPRC interrupt type.
typedef struct stc_qprc_int_sel | stc_qprc_int_sel_t
| Enumeration to define QPRC interrupt selection.
typedef struct stc_qprc_int_cb | stc_qprc_int_cb_t
| Enumeration to define QPRC interrupt callback function.
typedef enum en_qprc_filter_width | en_qprc_filter_width_t
| Enumeration to define QPRC filter width.
typedef struct stc_qprc_filter | stc_qprc_filter_t
| Structure to configuration QPRC filter.
typedef struct stc_qprc_config | stc_qprc_config_t
| Structure to configuration QPRC.
typedef struct stc_qprc_intern_data | stc_qprc_intern_data_t
| Structure of QPRC internal data.
typedef struct stc_qprc_instance_data | stc_qprc_instance_data_t
| Structure of QPRC instance data.
## Enumerations
enum | en_qprc_instance_index { QprcInstanceIndexQprc0 = 0, QprcInstanceIndexQprc1, QprcInstanceIndexQprc2 }
| Enumeration to define an index for each QPRC instance. More...
enum | en_qprc_pcmode { QprcPcMode0 = 0, QprcPcMode1 = 1, QprcPcMode2 = 2, QprcPcMode3 = 3 }
| Enumeration to define position counter mode. More...
enum | en_qprc_rcmode { QprcRcMode0 = 0, QprcRcMode1 = 1, QprcRcMode2 = 2, QprcRcMode3 = 3 }
| Enumeration to define revolution counter mode. More...
enum | en_qprc_zinedge { QprcZinDisable = 0, QprcZinFallingEdge = 1, QprcZinRisingEdge = 2, QprcZinBothEdges = 3, QprcZinLowLevel = 4, QprcZinHighLevel = 5 }
| Enumeration to define ZIN valid edge. More...
enum | en_qprc_binedge { QprcBinDisable = 0, QprcBinFallingEdge = 1, QprcBinRisingEdge = 2, QprcBinBothEdges = 3 }
| Enumeration to define BIN valid edge. More...
enum | en_qprc_ainedge { QprcAinDisable = 0, QprcAinFallingEdge = 1, QprcAinRisingEdge = 2, QprcAinBothEdges = 3 }
| Enumeration to define AIN valid edge. More...
enum | en_qprc_pcresetmask { QprcResetMaskDisable = 0, QprcResetMask2Times = 1, QprcResetMask4Times = 2, QprcResetMask8Times = 3 }
| Enumeration to define reset mask times of position counter. More...
enum | en_qprc_compmode { QprcComapreWithPosition = 0, QprcComapreWithRevolution = 1 }
| Enumeration to define compare object of QPRCR register. More...
enum | en_qprc_int { QprcPcOfUfZeroInt = 0, QprcPcMatchInt, QprcPcRcMatchInt, QprcPcMatchRcMatchInt, QprcPcCountInvertInt, QprcRcOutrangeInt }
| Enumeration to define QPRC interrupt type. More...
enum | en_qprc_filter_width { QprcNoFilter = 0, QprcFilterWidth4Pclk, QprcFilterWidth8Pclk, QprcFilterWidth16Pclk, QprcFilterWidth32Pclk, QprcFilterWidth64Pclk, QprcFilterWidth128Pclk, QprcFilterWidth256Pclk }
| Enumeration to define QPRC filter width. More...
## Functions
static en_result_t | QprcIsValidQprcnPtr (volatile FM0P_QPRC_TypeDef *pstcQprc)
| A certain QPRC instance is valid?
static volatile FM0P_QPRC_NF_TypeDef * | QprcGetNoisFilterPtr (volatile FM0P_QPRC_TypeDef *pstcQprc)
| Get the noise filter for a certain QPRC instance.
static stc_qprc_intern_data_t * | QprcGetInternDataPtr (volatile FM0P_QPRC_TypeDef *pstcQprc)
| Get the internal data for a certain QPRC instance.
static void | Qprc_InitNvic (volatile FM0P_QPRC_TypeDef *pstcQprc)
| Set NVIC Interrupt depending on QPRC instance.
static void | Qprc_DeInitNvic (volatile FM0P_QPRC_TypeDef *pstcQprc)
| Clear NVIC Interrupt depending on QPRC instance.
void | Qprc_IrqHandler (volatile FM0P_QPRC_TypeDef *pstcQprc, stc_qprc_intern_data_t *pstcQprcInternData)
| QPRC instance interrupt service routine.
en_result_t | Qprc_Init (volatile FM0P_QPRC_TypeDef *pstcQprc, stc_qprc_config_t *pstcConfig)
| Initialize QPRC.
en_result_t | Qprc_StopPcCount (volatile FM0P_QPRC_TypeDef *pstcQprc)
| Stop Position Counter.
en_result_t | Qprc_RestartPcCount (volatile FM0P_QPRC_TypeDef *pstcQprc)
| Restart Position Counter from stop status.
en_result_t | Qprc_SetPcCount (volatile FM0P_QPRC_TypeDef *pstcQprc, uint16_t u16PcValue)
| Set count value of Position counter.
uint16_t | Qprc_GetPcCount (volatile FM0P_QPRC_TypeDef *pstcQprc)
| Get count value of Position counter.
en_result_t | Qprc_SetRcCount (volatile FM0P_QPRC_TypeDef *pstcQprc, uint16_t u16RcValue)
| Set count value of Revolution Counter.
uint16_t | Qprc_GetRcCount (volatile FM0P_QPRC_TypeDef *pstcQprc)
| Get count value of Revolution Counter.
en_result_t | Qprc_SetPcMaxValue (volatile FM0P_QPRC_TypeDef *pstcQprc, uint16_t u16PcMaxValue)
| Set maximum count value of Position Counter.
uint16_t | Qprc_GetPcMaxValue (volatile FM0P_QPRC_TypeDef *pstcQprc)
| Get maximum count value of Position Counter.
en_result_t | Qprc_SetPcCompareValue (volatile FM0P_QPRC_TypeDef *pstcQprc, uint16_t u16PcValue)
| Set compare value of Position counter.
uint16_t | Qprc_GetPcCompareValue (volatile FM0P_QPRC_TypeDef *pstcQprc)
| Get compare value of Position counter.
en_result_t | Qprc_SetPcRcCompareValue (volatile FM0P_QPRC_TypeDef *pstcQprc, uint16_t u16PcRcValue)
| Set compare value of Position and Revolution Counter.
uint16_t | Qprc_GetPcRcCompareValue (volatile FM0P_QPRC_TypeDef *pstcQprc)
| Get compare value of Position and Revolution Counter.
en_result_t | Qprc_ConfigPcMode (volatile FM0P_QPRC_TypeDef *pstcQprc, en_qprc_pcmode_t enMode)
| Set Position Counter mode.
en_result_t | Qprc_ConfigRcMode (volatile FM0P_QPRC_TypeDef *pstcQprc, en_qprc_rcmode_t enMode)
| Set Revolution Counter mode.
en_result_t | Qprc_EnableInt (volatile FM0P_QPRC_TypeDef *pstcQprc, stc_qprc_int_sel_t *pstcIntSel, stc_qprc_int_cb_t *pstcIntCallback)
| Enable QPRC interrupts.
en_result_t | Qprc_DisableInt (volatile FM0P_QPRC_TypeDef *pstcQprc, stc_qprc_int_sel_t *pstcIntSel)
| Disable PC match interrupt.
en_int_flag_t | Qprc_GetIntFlag (volatile FM0P_QPRC_TypeDef *pstcQprc, en_qprc_int_t enIntType)
| Get interrupt flag of QPRC.
en_result_t | Qprc_ClrIntFlag (volatile FM0P_QPRC_TypeDef *pstcQprc, en_qprc_int_t enIntType)
| Clear interrupt flag of QPRC.
en_stat_flag_t | Qprc_GetPcOfUfDir (volatile FM0P_QPRC_TypeDef *pstcQprc)
| Get last position counter flow direction.
en_stat_flag_t | Qprc_GetPcDir (volatile FM0P_QPRC_TypeDef *pstcQprc)
| Get last position counter direction.
## Variables
stc_qprc_instance_data_t | m_astcQprcInstanceDataLut [(PDL_PERIPHERAL_ENABLE_QPRC0==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_QPRC1==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_QPRC2==PDL_ON?1:0)]
| Look-up table for all enabled ADC instances and their internal data.
stc_qprc_instance_data_t | m_astcQprcInstanceDataLut [(PDL_PERIPHERAL_ENABLE_QPRC0==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_QPRC1==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_QPRC2==PDL_ON?1:0)]
| Look-up table for all enabled MFS instances and their internal data.

## Detailed Description

Provided functions of QPRC module:

- Qprc_Init()
- Qprc_StopPcCount()
- Qprc_RestartPcCount()
- Qprc_SetPcCount()
- Qprc_GetPcCount()
- Qprc_SetRcCount()
- Qprc_GetRcCount()
- Qprc_SetPcCompareValue()
- Qprc_GetPcCompareValue()
- Qprc_SetPcRcCompareValue()
- Qprc_GetPcRcCompareValue()
- Qprc_ConfigPcMode()
- Qprc_ConfigRcMode()
- Qprc_EnableInt()
- Qprc_DisableInt()
- Qprc_GetIntFlag()
- Qprc_ClrIntFlag()
- Qprc_GetPcOfUfDir()
- Qprc_GetPcDir()
- Qprc_IrqHandler()

How to use Position Count (PC) and Revolution Counter (RC)?

Qprc_Init() must be used for configuration of a QPRC channel with a structure of the type stc_qprc_config_t.

A QPRC interrupt can be enabled by the function Qprc_EnableInt(). This function can set callback function for each channel too.

With Qprc_SetPcCompareValue() the PC compare value is set to the value given in the parameter Qprc_SetPcCompareValue::u16PcValue. And PC compare value is read by Qprc_GetPcCompareValue().

With Qprc_SetPcRcCompareValue() the PC and RC compare value is set to the value given in the parameter Qprc_SetPcRcCompareValue::u16PcRcValue. And PC and RC compare value is read by Qprc_GetPcRcCompareValue(). Whether PC and RC compare value compares to PC count and RC count depends on the setting in paramter of the Qprc_Init().

The initial PC count value can be set by Qprc_SetPcCount(). And current PC count can be read by Qprc_GetPcCount()

The initial RC count value can be set by Qprc_SetRcCount(). And current RC count can be read by Qprc_GetRcCount()

The maximum PC count value can be set by Qprc_SetPcMaxValue(). And the maximum PC count value can be read by Qprc_GetPcMaxValue(). If PC count exceeds this value, a PC overflow interrupt flag will be set.

After above setting, Qprc_ConfigPcMode() can start PC with following mode:

- Up-down count mode(PC mode 1)
- Phase different count mode (PC mode 2)
- Directional count mode (PC mode 3)

Qprc_ConfigRcMode() can start RC with following mode:

- ZIN trigger mode(RC mode 1)
- PC underflow or overflow detection trigger mode (RC mode 2)
- ZIN or PC underflow or overflow detection trigger mode(RC mode 3)

With interrupt mode, when the interrupt occurs, the interrupt flag will be cleared and run into user interrupt callback function.

With polling mode, user can use Qprc_GetIntFlag() to check if the interrupt occurs, and clear the interrupt flag by Qprc_ClrIntFlag().

Qprc_GetPcOfUfDir() can get the PC direction after a PC overflow or underflow occurs.

Qprc_GetPcDir() can get the current PC direction when PC is counting.

Qprc_StopPcCount() can stop PC when PC is counting. And Qprc_RestartPcCount() will restart PC when PC is in stop status.

When stopping the QPRC, disable PC by using Qprc_ConfigPcMode() to set PC to PC mode0 and disable RC by using Qprc_ConfigRcMode() to set RC to RC mode0. Use QPRC_DisableInt() to disable QPRC interrupt.

## Define Documentation

#define QPRC0 (*((volatile stc_qprcn_t *) FM0P_QPRC0_BASE))

Definition at line 155 of file qprc.h.

Referenced by DT_QPRC_Handler(), Qprc_DeInitNvic(), and Qprc_InitNvic().

#define QPRC1 (*((volatile stc_qprcn_t *) FM0P_QPRC1_BASE))

Definition at line 156 of file qprc.h.

Referenced by DT_QPRC_Handler(), Qprc_DeInitNvic(), and Qprc_InitNvic().

#define QPRC2 (*((volatile stc_qprcn_t *) FM0P_QPRC2_BASE))

Definition at line 157 of file qprc.h.

Referenced by DT_QPRC_Handler(), Qprc_DeInitNvic(), and Qprc_InitNvic().

#define QPRC3 (*((volatile stc_qprcn_t *) FM0P_QPRC3_BASE))

Definition at line 158 of file qprc.h.

#define QPRC_INSTANCE_COUNT

Value:

    (PDL_PERIPHERAL_ENABLE_QPRC0 == PDL_ON ? 1 : 0) + \
                                    (PDL_PERIPHERAL_ENABLE_QPRC1 == PDL_ON ? 1 : 0) + \
                                    (PDL_PERIPHERAL_ENABLE_QPRC2 == PDL_ON ? 1 : 0)

Definition at line 165 of file qprc.h.

Referenced by QprcGetInternDataPtr(), QprcGetNoisFilterPtr(), and QprcIsValidQprcnPtr().

#define QPRC_PC_OVERFLOW_INT 0

Definition at line 169 of file qprc.h.

Referenced by Qprc_IrqHandler().

#define QPRC_PC_UNDERFLOW_INT 1

Definition at line 170 of file qprc.h.

Referenced by Qprc_IrqHandler().

#define QPRC_PC_ZERO_INDEX_INT 2

Definition at line 171 of file qprc.h.

Referenced by Qprc_IrqHandler().

#define QPRCNF0 (*((volatile stc_qprc_nfn_t *) FM0P_QPRC0_NF_BASE))

Definition at line 160 of file qprc.h.

#define QPRCNF1 (*((volatile stc_qprc_nfn_t *) FM0P_QPRC1_NF_BASE))

Definition at line 161 of file qprc.h.

#define QPRCNF2 (*((volatile stc_qprc_nfn_t *) FM0P_QPRC2_NF_BASE))

Definition at line 162 of file qprc.h.

#define QPRCNF3 (*((volatile stc_qprc_nfn_t *) FM0P_QPRC3_NF_BASE))

Definition at line 163 of file qprc.h.

#define stc_qprc_nfn_t FM0P_QPRC_NF_TypeDef

Definition at line 153 of file qprc.h.

Referenced by Qprc_Init(), and QprcGetNoisFilterPtr().

#define stc_qprcn_t FM0P_QPRC_TypeDef

Definition at line 152 of file qprc.h.

Referenced by DT_QPRC_Handler(), Qprc_DeInitNvic(), and Qprc_InitNvic().

## Typedef Documentation

typedef enum en_qprc_ainedge en_qprc_ainedge_t

Enumeration to define AIN valid edge.

typedef enum en_qprc_binedge en_qprc_binedge_t

Enumeration to define BIN valid edge.

typedef enum en_qprc_compmode en_qprc_compmode_t

Enumeration to define compare object of QPRCR register.

typedef enum en_qprc_filter_width en_qprc_filter_width_t

Enumeration to define QPRC filter width.

typedef enum en_qprc_instance_index en_qprc_instance_index_t

Enumeration to define an index for each QPRC instance.

typedef enum en_qprc_int en_qprc_int_t

Enumeration to define QPRC interrupt type.

typedef enum en_qprc_pcmode en_qprc_pcmode_t

Enumeration to define position counter mode.

typedef enum en_qprc_pcresetmask en_qprc_pcresetmask_t

Enumeration to define reset mask times of position counter.

typedef enum en_qprc_rcmode en_qprc_rcmode_t

Enumeration to define revolution counter mode.

typedef enum en_qprc_zinedge en_qprc_zinedge_t

Enumeration to define ZIN valid edge.

typedef struct stc_qprc_config stc_qprc_config_t

Structure to configuration QPRC.

typedef struct stc_qprc_filter stc_qprc_filter_t

Structure to configuration QPRC filter.

typedef struct stc_qprc_instance_data stc_qprc_instance_data_t

Structure of QPRC instance data.

typedef struct stc_qprc_int_cb stc_qprc_int_cb_t

Enumeration to define QPRC interrupt callback function.

typedef struct stc_qprc_int_sel stc_qprc_int_sel_t

Enumeration to define QPRC interrupt selection.

typedef struct stc_qprc_intern_data stc_qprc_intern_data_t

Structure of QPRC internal data.

## Enumeration Type Documentation

enum en_qprc_ainedge

Enumeration to define AIN valid edge.

Enumerator:

  QprcAinDisable | Disables edge detection.
  QprcAinFallingEdge | AIN active at falling edge.
  QprcAinRisingEdge | AIN active at rising edge.
  QprcAinBothEdges | AIN active at falling or rising edge.

Definition at line 244 of file qprc.h.

enum en_qprc_binedge

Enumeration to define BIN valid edge.

Enumerator:

  QprcBinDisable | Disables edge detection.
  QprcBinFallingEdge | BIN active at falling edge.
  QprcBinRisingEdge | BIN active at rising edge.
  QprcBinBothEdges | BIN active at falling or rising edge.

Definition at line 232 of file qprc.h.

enum en_qprc_compmode

Enumeration to define compare object of QPRCR register.

Enumerator:

  QprcComapreWithPosition | Compares the value of the QPRC Position and Revolution Counter Compare Register (QPRCR) with that of the position counter.
  QprcComapreWithRevolution | Compares the value of the QPRC Position and Revolution Counter Compare Register (QPRCR) with that of the revolution counter.

Definition at line 268 of file qprc.h.

enum en_qprc_filter_width

Enumeration to define QPRC filter width.

Enumerator:

  QprcNoFilter | No filter.
  QprcFilterWidth4Pclk | QPRC filter width: 4 PCLK.
  QprcFilterWidth8Pclk | QPRC filter width: 8 PCLK.
  QprcFilterWidth16Pclk | QPRC filter width: 16 PCLK.
  QprcFilterWidth32Pclk | QPRC filter width: 32 PCLK.
  QprcFilterWidth64Pclk | QPRC filter width: 64 PCLK.
  QprcFilterWidth128Pclk | QPRC filter width: 128 PCLK.
  QprcFilterWidth256Pclk | QPRC filter width: 256 PCLK.

Definition at line 323 of file qprc.h.

enum en_qprc_instance_index

Enumeration to define an index for each QPRC instance.

Enumerator:

  QprcInstanceIndexQprc0 | Instance index of QPRC0.
  QprcInstanceIndexQprc1 | Instance index of QPRC1.
  QprcInstanceIndexQprc2 | Instance index of QPRC2.

Definition at line 177 of file qprc.h.

enum en_qprc_int

Enumeration to define QPRC interrupt type.

Enumerator:

  QprcPcOfUfZeroInt | Overflow, underflow, zero match interrupt of position counter.
  QprcPcMatchInt | PC match interrupt of position counter.
  QprcPcRcMatchInt | PC and RC match interrupt.
  QprcPcMatchRcMatchInt | PC match and RC match interrupt.
  QprcPcCountInvertInt | PC invert interrupt.
  QprcRcOutrangeInt | RC outrange interrupt.

Definition at line 278 of file qprc.h.

enum en_qprc_pcmode

Enumeration to define position counter mode.

Enumerator:

  QprcPcMode0 | PC_Mode0: Disable position counter.
  QprcPcMode1 | PC_Mode1: Increments with AIN active edge and decrements with BIN active edge.
  QprcPcMode2 | PC_Mode2: Phase difference count mode: Counts up if AIN is leading BIN, down if BIN leading.
  QprcPcMode3 | PC_Mode3: Directional count mode: Counts up/down with BIN active edge and AIN level.

Definition at line 194 of file qprc.h.

enum en_qprc_pcresetmask

Enumeration to define reset mask times of position counter.

Enumerator:

  QprcResetMaskDisable | No reset mask.
  QprcResetMask2Times | The position counter reset or a revolution counter count-up or -down events are ignored until the position counter changes twice.
  QprcResetMask4Times | The position counter reset or a revolution counter count-up or -down events are ignored until the position counter changes four times.
  QprcResetMask8Times | The position counter reset or a revolution counter count-up or -down events are ignored until the position counter changes eight times.

Definition at line 256 of file qprc.h.

enum en_qprc_rcmode

Enumeration to define revolution counter mode.

Enumerator:

  QprcRcMode0 | RC_Mode0: Disable revolution counter.
  QprcRcMode1 | RC_Mode1: Up/down count of revolution counter with ZIN active edge.
  QprcRcMode2 | RC_Mode2: Up/down count of revolution counter on overflow or underflow in position count match.
  QprcRcMode3 | RC_Mode3: Up/down count of revolution counter on overflow or underflow in position count match and ZIN active edge.

Definition at line 206 of file qprc.h.

enum en_qprc_zinedge

Enumeration to define ZIN valid edge.

Enumerator:

  QprcZinDisable | Disables edge and level detection.
  QprcZinFallingEdge | ZIN active at falling edge.
  QprcZinRisingEdge | ZIN active at rising edge.
  QprcZinBothEdges | ZIN active at falling or rising edge.
  QprcZinLowLevel | ZIN active at low level detected.
  QprcZinHighLevel | ZIN active at high level detected.

Definition at line 218 of file qprc.h.

## Function Documentation

en_result_t Qprc_ClrIntFlag | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc,
|  | en_qprc_int_t | enIntType
| ) |  |

Clear interrupt flag of QPRC.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance
  [in] | enIntType | Interrupt type

Return values:

  Ok | Clear interrupt flag successfully
  ErrorInvalidParameter | If one of following conditions are met: pstcQprc invalid enIntType > QprcRcOutrangeInt Other invalid configuration

Definition at line 1202 of file qprc.c.

References ErrorInvalidParameter, Ok, PdlClr, QprcPcCountInvertInt, QprcPcMatchInt, QprcPcMatchRcMatchInt, QprcPcOfUfZeroInt, QprcPcRcMatchInt, and QprcRcOutrangeInt.

en_result_t Qprc_ConfigPcMode | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc,
|  | en_qprc_pcmode_t | enMode
| ) |  |

Set Position Counter mode.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance
  [in] | enMode | Position Counter mode

Return values:

  Ok | Position Counter mode has been setup
  ErrorInvalidParameter | If one of following conditions are met: pstcQprc == NULL enMode > QprcPcMode3 Other invalid configuration

Definition at line 876 of file qprc.c.

References ErrorInvalidParameter, Ok, QprcPcMode0, QprcPcMode1, QprcPcMode2, and QprcPcMode3.

en_result_t Qprc_ConfigRcMode | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc,
|  | en_qprc_rcmode_t | enMode
| ) |  |

Set Revolution Counter mode.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance
  [in] | enMode | Revolution Counter mode

Return values:

  Ok | Revolution Counter mode has been setup
  ErrorInvalidParameter | If one of following confitions are met: pstcQprc == NULL enMode > QprcRcMode3 Other invalid configuration

< RC_Mode0: Disable revolution counter

Definition at line 931 of file qprc.c.

References ErrorInvalidParameter, Ok, QprcRcMode0, QprcRcMode1, QprcRcMode2, and QprcRcMode3.

static void Qprc_DeInitNvic | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc | ) | `[static]`

Clear NVIC Interrupt depending on QPRC instance.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance

Definition at line 227 of file qprc.c.

References PDL_DEFAULT_INTERRUPT_LEVEL, QPRC0, QPRC1, QPRC2, and stc_qprcn_t.

Referenced by Qprc_DisableInt().

Here is the caller graph for this function:

en_result_t Qprc_DisableInt | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc,
|  | stc_qprc_int_sel_t * | pstcIntSel
| ) |  |

Disable PC match interrupt.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance
  [in] | pstcIntSel | Interrupt selection structure pointer

Return values:

  Ok | PC match interrupt enable bit has been setup
  ErrorInvalidParameter | If one of following conditions are met: pstcQprc invalid Other invalid configuration

Definition at line 1060 of file qprc.c.

References stc_qprc_int_sel::bQprcPcCountInvertInt, stc_qprc_int_sel::bQprcPcMatchInt, stc_qprc_int_sel::bQprcPcMatchRcMatchInt, stc_qprc_int_sel::bQprcPcOfUfZeroInt, stc_qprc_int_sel::bQprcPcRcMatchInt, stc_qprc_int_sel::bQprcRcOutrangeInt, ErrorInvalidParameter, Ok, stc_qprc_intern_data::pfnPcCountInvertCallback, stc_qprc_intern_data::pfnPcMatchCallback, stc_qprc_intern_data::pfnPcMatchRcMatchCallback, stc_qprc_intern_data::pfnPcRcMatchCallback, stc_qprc_intern_data::pfnPcUfOfZeroCallback, stc_qprc_intern_data::pfnRcOutrangeCallback, Qprc_DeInitNvic(), QprcGetInternDataPtr(), and TRUE.

Here is the call graph for this function:

en_result_t Qprc_EnableInt | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc,
|  | stc_qprc_int_sel_t * | pstcIntSel,
|  | stc_qprc_int_cb_t * | pstcIntCallback
| ) |  |

Enable QPRC interrupts.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance
  [in] | pstcIntSel | Interrupt selection structure pointer
  [in] | pstcIntCallback | Interrupt Callback function pointer

Return values:

  Ok | QPRC interrupts has been enabled
  ErrorInvalidParameter | If one of following conditions are met: pstcQprc invalid Other invalid configuration

Definition at line 990 of file qprc.c.

References stc_qprc_int_sel::bQprcPcCountInvertInt, stc_qprc_int_sel::bQprcPcMatchInt, stc_qprc_int_sel::bQprcPcMatchRcMatchInt, stc_qprc_int_sel::bQprcPcOfUfZeroInt, stc_qprc_int_sel::bQprcPcRcMatchInt, stc_qprc_int_sel::bQprcRcOutrangeInt, ErrorInvalidParameter, Ok, stc_qprc_intern_data::pfnPcCountInvertCallback, stc_qprc_int_cb::pfnPcCountInvertIntCallback, stc_qprc_intern_data::pfnPcMatchCallback, stc_qprc_int_cb::pfnPcMatchIntCallback, stc_qprc_intern_data::pfnPcMatchRcMatchCallback, stc_qprc_int_cb::pfnPcMatchRcMatchIntCallback, stc_qprc_int_cb::pfnPcOfUfZeroIntCallback, stc_qprc_intern_data::pfnPcRcMatchCallback, stc_qprc_int_cb::pfnPcRcMatchIntCallback, stc_qprc_intern_data::pfnPcUfOfZeroCallback, stc_qprc_intern_data::pfnRcOutrangeCallback, stc_qprc_int_cb::pfnRcOutrangeIntCallback, Qprc_InitNvic(), QprcGetInternDataPtr(), and TRUE.

Here is the call graph for this function:

en_int_flag_t Qprc_GetIntFlag | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc,
|  | en_qprc_int_t | enIntType
| ) |  |

Get interrupt flag of QPRC.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance
  [in] | enIntType | Interrupt type

Return values:

  PdlClr | Interrupt doesn't occur selected by enIntType
  PdlSet | Interrupt occurs selected by enIntType

Definition at line 1128 of file qprc.c.

References PdlClr, PdlSet, QprcPcCountInvertInt, QprcPcMatchInt, QprcPcMatchRcMatchInt, QprcPcOfUfZeroInt, QprcPcRcMatchInt, and QprcRcOutrangeInt.

uint16_t Qprc_GetPcCompareValue | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc | ) |

Get compare value of Position counter.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance

Return values:

  Count | value

Definition at line 804 of file qprc.c.

References ErrorInvalidParameter.

uint16_t Qprc_GetPcCount | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc | ) |

Get count value of Position counter.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance

Return values:

  Count | value

Note:
  If pstcQprc = NULL, the return value will be 0xFFFF.

Definition at line 676 of file qprc.c.

en_stat_flag_t Qprc_GetPcDir | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc | ) |

Get last position counter direction.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance

Return values:

  PdlClr | The position counter was incremented.
  PdlSet | The position counter was decremented.

Definition at line 1290 of file qprc.c.

References PdlClr, and PdlSet.

uint16_t Qprc_GetPcMaxValue | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc | ) |

Get maximum count value of Position Counter.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance

Return values:

  PcMaxValue |

Note:
  If pstcQprc = NULL, the return value will be 0xFFFF.

Definition at line 761 of file qprc.c.

en_stat_flag_t Qprc_GetPcOfUfDir | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc | ) |

Get last position counter flow direction.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance

Return values:

  PdlClr | The position counter was incremented.
  PdlSet | The position counter was decremented.

Definition at line 1268 of file qprc.c.

References PdlClr, and PdlSet.

uint16_t Qprc_GetPcRcCompareValue | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc | ) |

Get compare value of Position and Revolution Counter.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance

Return values:

  Count | value

If pstcQprc = NULL, the return will be 0xFFFF.

Definition at line 852 of file qprc.c.

uint16_t Qprc_GetRcCount | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc | ) |

Get count value of Revolution Counter.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance

Return values:

  Count | value

Note:
  If pstcQprc = NULL, the return value will be 0xFFFF.

Definition at line 719 of file qprc.c.

en_result_t Qprc_Init | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc,
|  | stc_qprc_config_t * | pstcConfig
| ) |  |

Initialize QPRC.

This function initializes an QPRC module and sets up the internal data structures

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance
  [in] | pstcConfig | Pointer to QPRC module configuration

Return values:

  Ok | Internal data has been setup
  ErrorInvalidParameter | If one of following conditions are met: pstcQprc == NULL pstcConfig == NULL Other invalid configuration

Definition at line 410 of file qprc.c.

References stc_qprc_config::b8KValue, stc_qprc_filter::bInputInvert, stc_qprc_filter::bInputMask, stc_qprc_config::bSwapAinBin, stc_qprc_config::enAinEdge, stc_qprc_config::enBinEdge, stc_qprc_config::enComapreMode, stc_qprc_config::enPcResetMask, stc_qprc_filter::enWidth, stc_qprc_config::enZinEdge, ErrorInvalidParameter, FALSE, Ok, QprcAinBothEdges, QprcBinBothEdges, QprcBinDisable, QprcBinFallingEdge, QprcBinRisingEdge, QprcComapreWithRevolution, QprcFilterWidth256Pclk, QprcGetNoisFilterPtr(), QprcIsValidQprcnPtr(), QprcResetMask2Times, QprcResetMask4Times, QprcResetMask8Times, QprcResetMaskDisable, QprcZinBothEdges, QprcZinDisable, QprcZinFallingEdge, QprcZinHighLevel, QprcZinLowLevel, QprcZinRisingEdge, stc_qprc_nfn_t, stc_qprc_config::stcAinFilter, stc_qprc_config::stcBinFilter, stc_qprc_config::stcCinFilter, and TRUE.

Here is the call graph for this function:

static void Qprc_InitNvic | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc | ) | `[static]`

Set NVIC Interrupt depending on QPRC instance.

Parameters:

  pstcQprc | Pointer to QPRC instance

Definition at line 208 of file qprc.c.

References PDL_IRQ_LEVEL_DT_QPRC, QPRC0, QPRC1, QPRC2, and stc_qprcn_t.

Referenced by Qprc_EnableInt().

Here is the caller graph for this function:

void Qprc_IrqHandler | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc,
|  | stc_qprc_intern_data_t * | pstcQprcInternData
| ) |  |

QPRC instance interrupt service routine.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance
  [in] | pstcQprcInternData | Pointer to internal data

Definition at line 308 of file qprc.c.

References PdlClr, PdlSet, stc_qprc_intern_data::pfnPcCountInvertCallback, stc_qprc_intern_data::pfnPcMatchCallback, stc_qprc_intern_data::pfnPcMatchRcMatchCallback, stc_qprc_intern_data::pfnPcRcMatchCallback, stc_qprc_intern_data::pfnPcUfOfZeroCallback, stc_qprc_intern_data::pfnRcOutrangeCallback, QPRC_PC_OVERFLOW_INT, QPRC_PC_UNDERFLOW_INT, and QPRC_PC_ZERO_INDEX_INT.

Referenced by DT_QPRC_Handler().

Here is the caller graph for this function:

en_result_t Qprc_RestartPcCount | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc | ) |

Restart Position Counter from stop status.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance

Return values:

  Ok | Restart Position Counter successfully
  ErrorInvalidParameter | pstcQprc == NULL

Definition at line 632 of file qprc.c.

References ErrorInvalidParameter, and Ok.

en_result_t Qprc_SetPcCompareValue | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc,
|  | uint16_t | u16PcValue
| ) |  |

Set compare value of Position counter.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance
  [in] | u16PcValue | Compare value

Return values:

  Ok | Compare value has been setup
  ErrorInvalidParameter | pstcQprc == NULL

Definition at line 782 of file qprc.c.

References ErrorInvalidParameter, and Ok.

en_result_t Qprc_SetPcCount | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc,
|  | uint16_t | u16PcValue
| ) |  |

Set count value of Position counter.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance
  [in] | u16PcValue | Count value

Return values:

  Ok | Count value has been setup
  ErrorInvalidParameter | pstcQprc == NULL

Definition at line 654 of file qprc.c.

References ErrorInvalidParameter, and Ok.

en_result_t Qprc_SetPcMaxValue | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc,
|  | uint16_t | u16PcMaxValue
| ) |  |

Set maximum count value of Position Counter.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance
  [in] | u16PcMaxValue | Maximum count value

Return values:

  Ok | Maximum count value has been setup
  ErrorInvalidParameter | pstcQprc == NULL

Definition at line 739 of file qprc.c.

References ErrorInvalidParameter, and Ok.

en_result_t Qprc_SetPcRcCompareValue | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc,
|  | uint16_t | u16PcRcValue
| ) |  |

Set compare value of Position and Revolution Counter.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance
  [in] | u16PcRcValue | Compare value

Return values:

  Ok | Compare value has been setup
  ErrorInvalidParameter | pstcQprc == NULL

Note:
  the object with which this value is compared depends on the compare mode setting in the Qprc_Init(), plesae refer to the structure type en_qprc_compmode_t.

Definition at line 829 of file qprc.c.

References ErrorInvalidParameter, and Ok.

en_result_t Qprc_SetRcCount | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc,
|  | uint16_t | u16RcValue
| ) |  |

Set count value of Revolution Counter.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance
  [in] | u16RcValue | Count value

Return values:

  Ok | Count value has been setup
  ErrorInvalidParameter | pstcQprc == NULL

Definition at line 696 of file qprc.c.

References ErrorInvalidParameter, and Ok.

en_result_t Qprc_StopPcCount | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc | ) |

Stop Position Counter.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance

Return values:

  Ok | Stop Position Counter counting successfully
  ErrorInvalidParameter | pstcQprc == NULL

Definition at line 611 of file qprc.c.

References ErrorInvalidParameter, and Ok.

static stc_qprc_intern_data_t * QprcGetInternDataPtr | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc | ) | `[static]`

Get the internal data for a certain QPRC instance.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance

Returns:
  Pointer to internal data

Definition at line 186 of file qprc.c.

References QPRC_INSTANCE_COUNT, and stc_qprc_instance_data::stcInternData.

Referenced by Qprc_DisableInt(), and Qprc_EnableInt().

Here is the caller graph for this function:

static volatile FM0P_QPRC_NF_TypeDef * QprcGetNoisFilterPtr | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc | ) | `[static]`

Get the noise filter for a certain QPRC instance.

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance

Returns:
  Pointer to the noise filter

Definition at line 158 of file qprc.c.

References stc_qprc_instance_data::pstcInstanceNf, QPRC_INSTANCE_COUNT, and stc_qprc_nfn_t.

Referenced by Qprc_Init().

Here is the caller graph for this function:

static en_result_t QprcIsValidQprcnPtr | ( | volatile FM0P_QPRC_TypeDef * | pstcQprc | ) | `[static]`

A certain QPRC instance is valid?

Parameters:

  [in] | pstcQprc | Pointer to QPRC instance

Return values:

  Ok | QPRC instance is valid
  ErrorInvalidParameter | If instance is not enabled (or not known)

Definition at line 129 of file qprc.c.

References ErrorInvalidParameter, Ok, and QPRC_INSTANCE_COUNT.

Referenced by Qprc_Init().

Here is the caller graph for this function:

## Variable Documentation

stc_qprc_instance_data_t m_astcQprcInstanceDataLut[(PDL_PERIPHERAL_ENABLE_QPRC0==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_QPRC1==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_QPRC2==PDL_ON?1:0)]

Initial value:

    {

        {
            & (*((volatile  FM0P_QPRC_TypeDef  *) FM0P_QPRC0_BASE)) ,
            & (*((volatile  FM0P_QPRC_NF_TypeDef  *) FM0P_QPRC0_NF_BASE)) ,
            {NULL,NULL,NULL,NULL,NULL,NULL}
        },

        {
            & (*((volatile  FM0P_QPRC_TypeDef  *) FM0P_QPRC1_BASE)) ,
            & (*((volatile  FM0P_QPRC_NF_TypeDef  *) FM0P_QPRC1_NF_BASE)) ,
            {NULL,NULL,NULL,NULL,NULL,NULL}
        },

        {
            & (*((volatile  FM0P_QPRC_TypeDef  *) FM0P_QPRC2_BASE)) ,
            & (*((volatile  FM0P_QPRC_NF_TypeDef  *) FM0P_QPRC2_NF_BASE)) ,
            {NULL,NULL,NULL,NULL,NULL,NULL}
        },

    }

Look-up table for all enabled ADC instances and their internal data.

Look-up table for all enabled MFS instances and their internal data.

Definition at line 93 of file qprc.c.

Referenced by DT_QPRC_Handler().

stc_qprc_instance_data_t m_astcQprcInstanceDataLut[(PDL_PERIPHERAL_ENABLE_QPRC0==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_QPRC1==PDL_ON?1:0)+(PDL_PERIPHERAL_ENABLE_QPRC2==PDL_ON?1:0)]

Look-up table for all enabled MFS instances and their internal data.

Definition at line 93 of file qprc.c.

Referenced by DT_QPRC_Handler().