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

Macros | Functions
ECAP Exported Functions
Standard Driver » ECAP Driver

## Macros
#define | ECAP_SET_NOISE_FILTER_CLKDIV(ecap, u32ClkSel)
| This macro is used to select noise filter clock pre-divide number. More...
#define | ECAP_NOISE_FILTER_DISABLE(ecap)
| This macro is used to disable noise filter. More...
#define | ECAP_NOISE_FILTER_ENABLE(ecap, u32ClkSel)
| This macro is used to enable noise filter. More...
#define | ECAP_ENABLE_INPUT_CHANNEL(ecap, u32Mask)
| This macro is used to enable input channel unit. More...
#define | ECAP_DISABLE_INPUT_CHANNEL(ecap, u32Mask)
| This macro is used to disable input channel unit. More...
#define | ECAP_SEL_INPUT_SRC(ecap, u32Index, u32Src)
| This macro is used to select input channel source. More...
#define | ECAP_ENABLE_INT(ecap, u32Mask)
| This macro is used to enable input channel interrupt. More...
#define | ECAP_DISABLE_INT(ecap, u32Mask)
| This macro is used to disable input channel interrupt. More...
#define | ECAP_ENABLE_OVF_INT(ecap)
| This macro is used to enable input channel overflow interrupt. More...
#define | ECAP_DISABLE_OVF_INT(ecap)
| This macro is used to disable input channel overflow interrupt. More...
#define | ECAP_ENABLE_CMP_MATCH_INT(ecap)
| This macro is used to enable input channel compare-match interrupt. More...
#define | ECAP_DISABLE_CMP_MATCH_INT(ecap)
| This macro is used to disable input channel compare-match interrupt. More...
#define | ECAP_CNT_START(ecap)
| This macro is used to start capture counter. More...
#define | ECAP_CNT_STOP(ecap)
| This macro is used to stop capture counter. More...
#define | ECAP_SET_CNT_CLEAR_EVENT(ecap, u32Event)
| This macro is used to set event to clear capture counter. More...
#define | ECAP_ENABLE_CMP(ecap)
| This macro is used to enable compare function. More...
#define | ECAP_DISABLE_CMP(ecap)
| This macro is used to disable compare function. More...
#define | ECAP_ENABLE_CNT(ecap)
| This macro is used to enable input capture function. More...
#define | ECAP_DISABLE_CNT(ecap)
| This macro is used to disable input capture function. More...
#define | ECAP_SEL_CAPTURE_EDGE(ecap, u32Index, u32Edge)
| This macro is used to select input channel edge detection. More...
#define | ECAP_SEL_RELOAD_TRIG_SRC(ecap, u32TrigSrc)
| This macro is used to select ECAP counter reload trigger source. More...
#define | ECAP_SEL_TIMER_CLK_DIV(ecap, u32Clkdiv)
| This macro is used to select capture timer clock divide. More...
#define | ECAP_SEL_TIMER_CLK_SRC(ecap, u32ClkSrc)
| This macro is used to select capture timer/counter clock source. More...
#define | ECAP_GET_INT_STATUS(ecap)
| This macro is used to read input capture status. More...
#define | ECAP_GET_CAPTURE_FLAG(ecap, u32Mask)
| This macro is used to get input channel interrupt flag. More...
#define | ECAP_CLR_CAPTURE_FLAG(ecap, u32Mask)
| This macro is used to clear input channel interrupt flag. More...
#define | ECAP_SET_CNT_VALUE(ecap, u32Val)
| This macro is used to set input capture counter value. More...
#define | ECAP_GET_CNT_VALUE(ecap)
| This macro is used to get input capture counter value. More...
#define | ECAP_GET_CNT_HOLD_VALUE(ecap, u32Index)
| This macro is used to get input capture counter hold value. More...
#define | ECAP_SET_CNT_CMP(ecap, u32Val)
| This macro is used to set input capture counter compare value. More...

## Functions
void | ECAP_Open (ECAP_T *ecap, uint32_t u32FuncMask)
| Enable ECAP function. More...
void | ECAP_Close (ECAP_T *ecap)
| Disable ECAP function. More...
void | ECAP_EnableINT (ECAP_T *ecap, uint32_t u32Mask)
| This macro is used to enable input channel interrupt. More...
void | ECAP_DisableINT (ECAP_T *ecap, uint32_t u32Mask)
| This macro is used to disable input channel interrupt. More...

## Detailed Description

## Macro Definition Documentation

## ◆ ECAP_CLR_CAPTURE_FLAG

#define ECAP_CLR_CAPTURE_FLAG | ( |  | ecap,
|  |  | u32Mask
| ) |  |

This macro is used to clear input channel interrupt flag.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32Mask | The input channel mask ECAP_STATUS_CAPTF0_Msk ECAP_STATUS_CAPTF1_Msk ECAP_STATUS_CAPTF2_Msk ECAP_STATUS_CAPOVF_Msk ECAP_STATUS_CAPCMPF_Msk

Returns
  None

This macro will write 1 to clear the input channel_n interrupt flag.

Definition at line 398 of file ecap.h.

## ◆ ECAP_CNT_START

#define ECAP_CNT_START | ( |  | ecap | ) |

This macro is used to start capture counter.

Parameters

  [in] | ecap | Specify ECAP port

Returns
  None

This macro will start capture counter up-counting.

Definition at line 229 of file ecap.h.

## ◆ ECAP_CNT_STOP

#define ECAP_CNT_STOP | ( |  | ecap | ) |

This macro is used to stop capture counter.

Parameters

  [in] | ecap | Specify ECAP port

Returns
  None

This macro will stop capture counter up-counting.

Definition at line 238 of file ecap.h.

## ◆ ECAP_DISABLE_CMP

#define ECAP_DISABLE_CMP | ( |  | ecap | ) |

This macro is used to disable compare function.

Parameters

  [in] | ecap | Specify ECAP port

Returns
  None

This macro will disable the compare function.

Definition at line 278 of file ecap.h.

## ◆ ECAP_DISABLE_CMP_MATCH_INT

#define ECAP_DISABLE_CMP_MATCH_INT | ( |  | ecap | ) |

This macro is used to disable input channel compare-match interrupt.

Parameters

  [in] | ecap | Specify ECAP port

Returns
  None

This macro will disable the input channel compare-match interrupt.

Definition at line 220 of file ecap.h.

## ◆ ECAP_DISABLE_CNT

#define ECAP_DISABLE_CNT | ( |  | ecap | ) |

This macro is used to disable input capture function.

Parameters

  [in] | ecap | Specify ECAP port

Returns
  None

This macro will disable input capture timer/counter.

Definition at line 296 of file ecap.h.

## ◆ ECAP_DISABLE_INPUT_CHANNEL

#define ECAP_DISABLE_INPUT_CHANNEL | ( |  | ecap,
|  |  | u32Mask
| ) |  |

This macro is used to disable input channel unit.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32Mask | The input channel mask ECAP_CTL0_IC0EN_Msk ECAP_CTL0_IC1EN_Msk ECAP_CTL0_IC2EN_Msk

Returns
  None

This macro will disable the input channel_n to input capture.

Definition at line 142 of file ecap.h.

## ◆ ECAP_DISABLE_INT

#define ECAP_DISABLE_INT | ( |  | ecap,
|  |  | u32Mask
| ) |  |

This macro is used to disable input channel interrupt.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32Mask | The input channel mask ECAP_IC0 ECAP_IC1 ECAP_IC2

Returns
  None

This macro will disable the input channel_n interrupt.

Definition at line 184 of file ecap.h.

## ◆ ECAP_DISABLE_OVF_INT

#define ECAP_DISABLE_OVF_INT | ( |  | ecap | ) |

This macro is used to disable input channel overflow interrupt.

Parameters

  [in] | ecap | Specify ECAP port

Returns
  None

This macro will disable the input channel overflow interrupt.

Definition at line 202 of file ecap.h.

## ◆ ECAP_ENABLE_CMP

#define ECAP_ENABLE_CMP | ( |  | ecap | ) |

This macro is used to enable compare function.

Parameters

  [in] | ecap | Specify ECAP port

Returns
  None

This macro will enable the compare function.

Definition at line 269 of file ecap.h.

## ◆ ECAP_ENABLE_CMP_MATCH_INT

#define ECAP_ENABLE_CMP_MATCH_INT | ( |  | ecap | ) |

This macro is used to enable input channel compare-match interrupt.

Parameters

  [in] | ecap | Specify ECAP port

Returns
  None

This macro will enable the input channel compare-match interrupt.

Definition at line 211 of file ecap.h.

## ◆ ECAP_ENABLE_CNT

#define ECAP_ENABLE_CNT | ( |  | ecap | ) |

This macro is used to enable input capture function.

Parameters

  [in] | ecap | Specify ECAP port

Returns
  None

This macro will enable input capture timer/counter.

Definition at line 287 of file ecap.h.

## ◆ ECAP_ENABLE_INPUT_CHANNEL

#define ECAP_ENABLE_INPUT_CHANNEL | ( |  | ecap,
|  |  | u32Mask
| ) |  |

This macro is used to enable input channel unit.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32Mask | The input channel mask ECAP_CTL0_IC0EN_Msk ECAP_CTL0_IC1EN_Msk ECAP_CTL0_IC2EN_Msk

Returns
  None

This macro will enable the input channel_n to input capture.

Definition at line 129 of file ecap.h.

## ◆ ECAP_ENABLE_INT

#define ECAP_ENABLE_INT | ( |  | ecap,
|  |  | u32Mask
| ) |  |

This macro is used to enable input channel interrupt.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32Mask | The input channel mask ECAP_CTL0_CAPIEN0_Msk ECAP_CTL0_CAPIEN1_Msk ECAP_CTL0_CAPIEN2_Msk

Returns
  None

This macro will enable the input channel_n interrupt.

Definition at line 171 of file ecap.h.

## ◆ ECAP_ENABLE_OVF_INT

#define ECAP_ENABLE_OVF_INT | ( |  | ecap | ) |

This macro is used to enable input channel overflow interrupt.

Parameters

  [in] | ecap | Specify ECAP port

Returns
  None

This macro will enable the input channel overflow interrupt.

Definition at line 193 of file ecap.h.

## ◆ ECAP_GET_CAPTURE_FLAG

#define ECAP_GET_CAPTURE_FLAG | ( |  | ecap,
|  |  | u32Mask
| ) |  |

This macro is used to get input channel interrupt flag.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32Mask | The input channel mask ECAP_STATUS_CAPTF0_Msk ECAP_STATUS_CAPTF1_Msk ECAP_STATUS_CAPTF2_Msk ECAP_STATUS_CAPOVF_Msk ECAP_STATUS_CAPCMPF_Msk

Returns
  None

This macro will write 1 to get the input channel_n interrupt flag.

Definition at line 383 of file ecap.h.

## ◆ ECAP_GET_CNT_HOLD_VALUE

#define ECAP_GET_CNT_HOLD_VALUE | ( |  | ecap,
|  |  | u32Index
| ) |  |

This macro is used to get input capture counter hold value.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32Index | The input channel number ECAP_IC0 ECAP_IC1 ECAP_IC2

Returns
  Capture counter hold value

This macro will get a hold value of input capture channel_n.

Definition at line 430 of file ecap.h.

## ◆ ECAP_GET_CNT_VALUE

#define ECAP_GET_CNT_VALUE | ( |  | ecap | ) |

This macro is used to get input capture counter value.

Parameters

  [in] | ecap | Specify ECAP port

Returns
  Capture counter value

This macro will get a counter value of input capture.

Definition at line 417 of file ecap.h.

## ◆ ECAP_GET_INT_STATUS

#define ECAP_GET_INT_STATUS | ( |  | ecap | ) |

This macro is used to read input capture status.

Parameters

  [in] | ecap | Specify ECAP port

Returns
  Input capture status flags

This macro will get the input capture interrupt status.

Definition at line 368 of file ecap.h.

## ◆ ECAP_NOISE_FILTER_DISABLE

#define ECAP_NOISE_FILTER_DISABLE | ( |  | ecap | ) |

This macro is used to disable noise filter.

Parameters

  [in] | ecap | Specify ECAP port

Returns
  None

This macro will disable the noise filter of input capture.

Definition at line 100 of file ecap.h.

## ◆ ECAP_NOISE_FILTER_ENABLE

#define ECAP_NOISE_FILTER_ENABLE | ( |  | ecap,
|  |  | u32ClkSel
| ) |  |

This macro is used to enable noise filter.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32ClkSel | Select noise filter clock divide number ECAP_NOISE_FILTER_CLKDIV_1 ECAP_NOISE_FILTER_CLKDIV_2 ECAP_NOISE_FILTER_CLKDIV_4 ECAP_NOISE_FILTER_CLKDIV_16 ECAP_NOISE_FILTER_CLKDIV_32 ECAP_NOISE_FILTER_CLKDIV_64

Returns
  None

This macro will enable the noise filter of input capture and set noise filter clock divide.

Definition at line 116 of file ecap.h.

## ◆ ECAP_SEL_CAPTURE_EDGE

#define ECAP_SEL_CAPTURE_EDGE | ( |  | ecap,
|  |  | u32Index,
|  |  | u32Edge
| ) |  |

This macro is used to select input channel edge detection.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32Index | The input channel number ECAP_IC0 ECAP_IC1 ECAP_IC2
  [in] | u32Edge | The input source ECAP_RISING_EDGE ECAP_FALLING_EDGE ECAP_RISING_FALLING_EDGE

Returns
  None

This macro will select input capture can detect falling edge, rising edge or either rising or falling edge change.

Definition at line 313 of file ecap.h.

## ◆ ECAP_SEL_INPUT_SRC

#define ECAP_SEL_INPUT_SRC | ( |  | ecap,
|  |  | u32Index,
|  |  | u32Src
| ) |  |

This macro is used to select input channel source.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32Index | The input channel number ECAP_IC0 ECAP_IC1 ECAP_IC2
  [in] | u32Src | The input source ECAP_CAP_INPUT_SRC_FROM_IC ECAP_CAP_INPUT_SRC_FROM_CH

Returns
  None

This macro will select the input source from ICx, CHx.

Definition at line 158 of file ecap.h.

## ◆ ECAP_SEL_RELOAD_TRIG_SRC

#define ECAP_SEL_RELOAD_TRIG_SRC | ( |  | ecap,
|  |  | u32TrigSrc
| ) |  |

This macro is used to select ECAP counter reload trigger source.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32TrigSrc | The input source ECAP_CTL1_CAP0RLDEN_Msk ECAP_CTL1_CAP1RLDEN_Msk ECAP_CTL1_CAP2RLDEN_Msk ECAP_CTL1_OVRLDEN_Msk

Returns
  None

This macro will select capture counter reload trigger source.

Definition at line 327 of file ecap.h.

## ◆ ECAP_SEL_TIMER_CLK_DIV

#define ECAP_SEL_TIMER_CLK_DIV | ( |  | ecap,
|  |  | u32Clkdiv
| ) |  |

This macro is used to select capture timer clock divide.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32Clkdiv | The input source ECAP_CAPTURE_TIMER_CLKDIV_1 ECAP_CAPTURE_TIMER_CLKDIV_4 ECAP_CAPTURE_TIMER_CLKDIV_16 ECAP_CAPTURE_TIMER_CLKDIV_32 ECAP_CAPTURE_TIMER_CLKDIV_64 ECAP_CAPTURE_TIMER_CLKDIV_96 ECAP_CAPTURE_TIMER_CLKDIV_112 ECAP_CAPTURE_TIMER_CLKDIV_128

Returns
  None

This macro will select capture timer clock has a pre-divider with eight divided option.

Definition at line 345 of file ecap.h.

## ◆ ECAP_SEL_TIMER_CLK_SRC

#define ECAP_SEL_TIMER_CLK_SRC | ( |  | ecap,
|  |  | u32ClkSrc
| ) |  |

This macro is used to select capture timer/counter clock source.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32ClkSrc | The input source ECAP_CAPTURE_TIMER_CLK_SRC_CAP_CLK ECAP_CAPTURE_TIMER_CLK_SRC_CAP0 ECAP_CAPTURE_TIMER_CLK_SRC_CAP1 ECAP_CAPTURE_TIMER_CLK_SRC_CAP2

Returns
  None

This macro will select capture timer/clock clock source.

Definition at line 359 of file ecap.h.

## ◆ ECAP_SET_CNT_CLEAR_EVENT

#define ECAP_SET_CNT_CLEAR_EVENT | ( |  | ecap,
|  |  | u32Event
| ) |  |

This macro is used to set event to clear capture counter.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32Event | The input channel number ECAP_CTL0_CMPCLREN_Msk ECAP_CTL1_CAP0RLDEN_Msk ECAP_CTL1_CAP1RLDEN_Msk ECAP_CTL1_CAP2RLDEN_Msk ECAP_CTL1_OVRLDEN_Msk

Returns
  None

This macro will enable and select compare or capture event that can clear capture counter.

Definition at line 254 of file ecap.h.

## ◆ ECAP_SET_CNT_CMP

#define ECAP_SET_CNT_CMP | ( |  | ecap,
|  |  | u32Val
| ) |  |

This macro is used to set input capture counter compare value.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32Val | Input capture compare value

Returns
  None

This macro will set a compare value of input capture counter.

Definition at line 440 of file ecap.h.

## ◆ ECAP_SET_CNT_VALUE

#define ECAP_SET_CNT_VALUE | ( |  | ecap,
|  |  | u32Val
| ) |  |

This macro is used to set input capture counter value.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32Val | Counter value

Returns
  None

This macro will set a counter value of input capture.

Definition at line 408 of file ecap.h.

## ◆ ECAP_SET_NOISE_FILTER_CLKDIV

#define ECAP_SET_NOISE_FILTER_CLKDIV | ( |  | ecap,
|  |  | u32ClkSel
| ) |  |

This macro is used to select noise filter clock pre-divide number.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32ClkSel | The noise filter clock divide number ECAP_NOISE_FILTER_CLKDIV_1 ECAP_NOISE_FILTER_CLKDIV_2 ECAP_NOISE_FILTER_CLKDIV_4 ECAP_NOISE_FILTER_CLKDIV_16 ECAP_NOISE_FILTER_CLKDIV_32 ECAP_NOISE_FILTER_CLKDIV_64

Returns
  None

This macro will set the sampling frequency of the noise filter cock.

Definition at line 91 of file ecap.h.

## Function Documentation

## ◆ ECAP_Close()

void ECAP_Close | ( | ECAP_T * | ecap | ) |

Disable ECAP function.

Parameters

  [in] | ecap | The pointer of the specified ECAP module.

Returns
  None

This macro disable input capture function.

Definition at line 50 of file ecap.c.

## ◆ ECAP_DisableINT()

void ECAP_DisableINT | ( | ECAP_T * | ecap,
|  | uint32_t | u32Mask
| ) |  |

This macro is used to disable input channel interrupt.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32Mask | The input channel number ECAP_CTL0_CAPIEN0_Msk ECAP_CTL0_CAPIEN1_Msk ECAP_CTL0_CAPIEN2_Msk ECAP_CTL0_OVIEN_Msk ECAP_CTL0_CMPIEN_Msk

Returns
  None

This macro will disable the input channel_n interrupt.

Definition at line 96 of file ecap.c.

## ◆ ECAP_EnableINT()

void ECAP_EnableINT | ( | ECAP_T * | ecap,
|  | uint32_t | u32Mask
| ) |  |

This macro is used to enable input channel interrupt.

Parameters

  [in] | ecap | Specify ECAP port
  [in] | u32Mask | The input channel Mask ECAP_CTL0_CAPIEN0_Msk ECAP_CTL0_CAPIEN1_Msk ECAP_CTL0_CAPIEN2_Msk ECAP_CTL0_OVIEN_Msk ECAP_CTL0_CMPIEN_Msk

Returns
  None

This macro will enable the input channel_n interrupt.

Definition at line 68 of file ecap.c.

## ◆ ECAP_Open()

void ECAP_Open | ( | ECAP_T * | ecap,
|  | uint32_t | u32FuncMask
| ) |  |

Enable ECAP function.

Parameters

  [in] | ecap | The pointer of the specified ECAP module.
  [in] | u32FuncMask | Input capture function select ECAP_DISABLE_COMPARE ECAP_COMPARE_FUNCTION

Returns
  None

This macro enable input capture function and select compare and reload function.

Definition at line 33 of file ecap.c.