MT7697 API Reference  LinkIt SDK v4
GPC

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...

Overview

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.

How to use this driver

Functions

hal_gpc_status_t hal_gpc_init (hal_gpc_port_t gpc_port, const hal_gpc_config_t *gpc_config)
 This function is used to initialize the GPC base environment. More...
 
hal_gpc_status_t hal_gpc_deinit (hal_gpc_port_t gpc_port)
 Deinitilize the GPC. More...
 
hal_gpc_status_t hal_gpc_enable (hal_gpc_port_t gpc_port)
 Enable the GPC module, after that the GPC can start to capture the pulses. More...
 
hal_gpc_status_t hal_gpc_disable (hal_gpc_port_t gpc_port)
 Disable the GPC module, after that the GPC stop capturing the pulses. More...
 
hal_gpc_status_t hal_gpc_get_running_status (hal_gpc_port_t gpc_port, hal_gpc_running_status_t *running_state)
 To get the port that you specified is idle or busy. More...
 
hal_gpc_status_t hal_gpc_get_and_clear_count (hal_gpc_port_t gpc_port, uint32_t *count)
 Get the current count value, then clear count register to 0. More...
 

Modules

 Enum
 
 Struct
 
 Typedef
 

Function Documentation

hal_gpc_status_t hal_gpc_deinit ( hal_gpc_port_t  gpc_port)

Deinitilize the GPC.

After this function, the callback is cleared, clock power is closed, the GPC module disabled.

Parameters
[in]gpc_portis the port number.
Returns
HAL_GPC_STATUS_OK, if OK.
HAL_GPC_STATUS_ERROR_PORT, the gpc_port value is wrong.
See also
hal_gpc_init()
hal_gpc_status_t hal_gpc_disable ( hal_gpc_port_t  gpc_port)

Disable the GPC module, after that the GPC stop capturing the pulses.

If user do not call hal_gpc_get_and_clear_count(), the value in count register will be kept until clear it.

Parameters
[in]gpc_portis the port number.
Returns
HAL_GPC_STATUS_OK, if OK.
HAL_GPC_STATUS_ERROR_PORT, the gpc_port value is wrong.
See also
hal_gpc_enable().
hal_gpc_status_t hal_gpc_enable ( hal_gpc_port_t  gpc_port)

Enable the GPC module, after that the GPC can start to capture the pulses.

Parameters
[in]gpc_portis the port number.
Returns
HAL_GPC_STATUS_OK, if OK.
HAL_GPC_STATUS_ERROR_PORT, the gpc_port value is wrong.
See also
hal_gpc_disable().
hal_gpc_status_t hal_gpc_get_and_clear_count ( hal_gpc_port_t  gpc_port,
uint32_t *  count 
)

Get the current count value, then clear count register to 0.

Parameters
[in]gpc_portis the port number.
[out]countis 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.
hal_gpc_status_t hal_gpc_get_running_status ( hal_gpc_port_t  gpc_port,
hal_gpc_running_status_t running_state 
)

To get the port that you specified is idle or busy.

Parameters
[in]gpc_portis the port number.
[out]running_stateis a pointer to get status value. For mode details, please refer to hal_gpc_running_status_t.
Returns
HAL_GPC_STATUS_OK, if OK.
HAL_GPC_STATUS_ERROR_PORT, the gpc_port value is wrong.
hal_gpc_status_t hal_gpc_init ( hal_gpc_port_t  gpc_port,
const hal_gpc_config_t gpc_config 
)

This function is used to initialize the GPC base environment.

Parameters
[in]gpc_portis the port number.
[in]gpc_configis the pointer of config. For mode details please, refer to hal_gpc_config_t.
Returns
HAL_GPC_STATUS_OK, if OK.
HAL_GPC_STATUS_ERROR_PORT, the gpc_port value is wrong.
See also
hal_gpc_deinit()