MT2523 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 {
257  HAL_GPC_EDGE_RAISING = 0,
258  HAL_GPC_EDGE_FALLING = 1,
259 } hal_gpc_edge_t;
260 
262 typedef enum {
263  HAL_GPC_STATUS_ERROR = -3,
264  HAL_GPC_STATUS_ERROR_PORT = -2,
265  HAL_GPC_STATUS_INVALID_PARAMETER = -1,
266  HAL_GPC_STATUS_OK = 0,
267 } hal_gpc_status_t;
268 
270 typedef enum {
271  HAL_GPC_STATUS_IDLE = 0,
272  HAL_GPC_STATUS_BUSY = 1,
273 } hal_gpc_running_status_t;
283 typedef struct {
284  hal_gpc_edge_t edge;
285 } hal_gpc_config_t;
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 
318 hal_gpc_status_t hal_gpc_deinit(hal_gpc_port_t gpc_port);
319 
320 
328 hal_gpc_status_t hal_gpc_enable(hal_gpc_port_t gpc_port);
329 
330 
339 hal_gpc_status_t hal_gpc_disable(hal_gpc_port_t gpc_port);
340 
341 
349 hal_gpc_status_t hal_gpc_get_running_status(hal_gpc_port_t gpc_port, hal_gpc_running_status_t *running_state);
350 
351 
359 hal_gpc_status_t hal_gpc_get_and_clear_count(hal_gpc_port_t gpc_port, uint32_t *count);
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