MT7687 API Reference  LinkIt SDK v4
hal_gpc.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2016 MediaTek Inc. All rights reserved.
4  *
5  * This software/firmware and related documentation ("MediaTek Software") are
6  * protected under relevant copyright laws. The information contained herein
7  * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
8  * Without the prior written permission of MediaTek and/or its licensors,
9  * any reproduction, modification, use or disclosure of MediaTek Software,
10  * and information contained herein, in whole or in part, shall be strictly prohibited.
11  * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
12  * if you have agreed to and been bound by the applicable license agreement with
13  * MediaTek ("License Agreement") and been granted explicit permission to do so within
14  * the License Agreement ("Permitted User"). If you are not a Permitted User,
15  * please cease any access or use of MediaTek Software immediately.
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
18  * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
19  * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
21  * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
22  * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
23  * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
24  * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
25  * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
26  * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
27  * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
28  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
29  * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
30  * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
31  * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
32  * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
33  */
34 
35 #ifndef __HAL_GPC_H__
36 #define __HAL_GPC_H__
37 #include "hal_platform.h"
38 
39 #ifdef HAL_GPC_MODULE_ENABLED
40 
70 #ifdef HAL_GPC_FEATURE_ADVANCED_CONFIG
71 
87 #endif
88 
89 
138 #ifdef HAL_GPC_FEATURE_ADVANCED_CONFIG
139 
211 #endif
212 
222 #ifdef __cplusplus
223 extern "C" {
224 #endif
225 
229 #ifdef HAL_GPC_FEATURE_ADVANCED_CONFIG
230 
236 typedef void (*hal_gpc_callback_t)(void *user_data);
237 #endif
238 
246 #ifdef HAL_GPC_FEATURE_ADVANCED_CONFIG
247 
248 typedef enum {
249  HAL_GPC_CLOCK_26MHZ = 0,
250  HAL_GPC_CLOCK_32KHZ = 1,
251 } hal_gpc_clock_t;
252 #endif
253 
254 
256 typedef enum {
260 
262 typedef enum {
268 
270 typedef enum {
283 typedef struct {
286 
287 #ifdef HAL_GPC_FEATURE_ADVANCED_CONFIG
288 
289 typedef struct {
290  hal_gpc_clock_t clock_source;
291  uint32_t debounce;
292  uint32_t threshold;
293 } hal_gpc_advanced_config_t;
294 #endif
295 
308 hal_gpc_status_t hal_gpc_init(hal_gpc_port_t gpc_port, const hal_gpc_config_t *gpc_config);
309 
319 
320 
329 
330 
340 
341 
350 
351 
360 
361 
362 /************************************ HAL_GPC_FEATURE_ADVANCED_CONFIG *********************************/
363 #ifdef HAL_GPC_FEATURE_ADVANCED_CONFIG
364 
371 hal_gpc_status_t hal_gpc_interrupt_enable(hal_gpc_port_t gpc_port);
372 
380 hal_gpc_status_t hal_gpc_interrupt_disable(hal_gpc_port_t gpc_port);
381 
393 hal_gpc_status_t hal_gpc_register_callback(hal_gpc_port_t gpc_port, hal_gpc_callback_t callback, void *user_data);
394 
395 
404 hal_gpc_status_t hal_gpc_set_threshold(hal_gpc_port_t gpc_port, uint32_t *threshold);
405 
413 hal_gpc_status_t hal_gpc_get_threshold(hal_gpc_port_t gpc_port, uint32_t *threshold);
414 
423 hal_gpc_status_t hal_gpc_advanced_config(hal_gpc_port_t gpc_port, const hal_gpc_advanced_config_t *gpc_advanced_config);
424 
425 #endif
426 
427 #ifdef __cplusplus
428 }
429 #endif
430 
435 #endif /*HAL_GPC_MODULE_ENABLED*/
436 #endif /* __HAL_GPC_H__ */
437 
438 
hal_gpc_running_status_t
define GPC busy status
Definition: hal_gpc.h:270
hal_gpc_edge_t edge
Specify GPC capture edge,HAL_GPC_EDGE_RAISING or HAL_GPC_EDGE_FALLING.
Definition: hal_gpc.h:284
The GPC is busy.
Definition: hal_gpc.h:272
The GPC is idle.
Definition: hal_gpc.h:271
No error occurred during the function call.
Definition: hal_gpc.h:266
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.
A wrong GPC port.
Definition: hal_gpc.h:264
An invalid parameter.
Definition: hal_gpc.h:265
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.
hal_gpc_status_t
This enum define GPC function status.
Definition: hal_gpc.h:262
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.
hal_gpc_status_t hal_gpc_deinit(hal_gpc_port_t gpc_port)
Deinitilize the GPC.
This structure defines the initial configuration structure.
Definition: hal_gpc.h:283
hal_gpc_port_t
gpc port
Definition: hal_platform.h:787
A GPC function ERROR occured.
Definition: hal_gpc.h:263
Set the GPC raising edge.
Definition: hal_gpc.h:257
Set the falling edge.
Definition: hal_gpc.h:258
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.
hal_gpc_edge_t
This enum define GPC caputure edge.
Definition: hal_gpc.h:256
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.