This section introduces the General Purpose Counter(GPC) APIs including terms and acronyms, supported features, software architecture, details on how to use this driver, GPC function groups, enums, structures and functions.
More...
This section introduces the General Purpose Counter(GPC) APIs including terms and acronyms, supported features, software architecture, details on how to use this driver, GPC function groups, enums, structures and functions.
Terms and acronyms
| Terms | Details |
| GPC | General Purpose Counter(GPC) captures pulses using raising or falling edge, and counts the number of pulses. |
| GPIO | For an introduction to General Purpose Inputs-Outputs, please refer to the GPIO module in HAL. |
| NVIC | The Nested Vectored Interrupt Controller (NVIC) is the interrupt controller of ARM Cortex-M. For more details, please refer to NVIC introduction in ARM Cortex-M4 Processor Technical Reference Manual . |
Supported features
This module is a generic design to capture the number of pulse waveforms. The GPC is to record pulses number. Compared with the EINT to capture pulses, the EINT will generate interrupt, and it occupies the cpu resource. They are two different scenarios.
- Support normal mode.
In this mode, there is no interrupt, and the register configuration is the default parameter of driver, user cannot modify it. This mode is usually used for non-urgent pulse-counting. Call hal_gpc_get_and_clear_count() function to check the counter values, when the GPC module is enabled.
How to use this driver
- Using GPC normal mode.
To use the GPC driver in a normal mode, look up GPIO datasheet to decide which GPIOs should be selected to pinmux to GPC pin, then call hal_pinmux_set_function to select the pinmux function. After the pinmux setting, hal_gpc_get_running_status() must be called to check the GPC status. If the status is HAL_GPC_STATUS_BUSY, user should wait till the status becomes HAL_GPC_STATUS_IDLE. Once the pulses are captured, always call hal_gpc_deinit() to release the GPC resource, to enable other users to use the GPC module.
- Use GPC with normal mode.
Get the current count value, then clear count register to 0.
- Parameters
-
| [in] | gpc_port | is the port number. |
| [out] | count | is a pointer that to get count value. |
- Returns
- HAL_GPC_STATUS_OK, if OK.
HAL_GPC_STATUS_ERROR_PORT, the gpc_port value is wrong.