MT2523 API Reference  LinkIt SDK v4
hal_gpt.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 
36 #ifndef __HAL_GPT_H__
37 #define __HAL_GPT_H__
38 #include "hal_platform.h"
39 
40 #ifdef HAL_GPT_MODULE_ENABLED
41 
76 #ifdef HAL_GPT_FEATURE_US_TIMER
77 
89 #else
90 
106 #endif
107 
108 #ifdef HAL_GPT_SW_GPT_FEATURE
109 
122 #endif
123 
175 #ifdef HAL_GPT_FEATURE_US_TIMER
176 
186 #endif
187 
287 #ifdef HAL_GPT_FEATURE_US_TIMER
288 
300 #endif
301 
302 #ifdef HAL_GPT_SW_GPT_FEATURE
303 
349 #endif
350 
358 #ifdef __cplusplus
359 extern "C" {
360 #endif
361 
371 typedef void(* hal_gpt_callback_t)(void *user_data);
372 
380 typedef enum {
384 
385 
387 typedef enum {
394 
395 
397 typedef enum {
401 
402 
415 
416 
426 
427 
436 
437 
451 
460 
461 
471 hal_gpt_status_t hal_gpt_start_timer_ms(hal_gpt_port_t gpt_port, uint32_t timeout_time_ms, hal_gpt_timer_type_t timer_type);
472 
473 
482 
483 
484 #ifdef HAL_GPT_FEATURE_US_TIMER
485 
494 hal_gpt_status_t hal_gpt_start_timer_us(hal_gpt_port_t gpt_port, uint32_t timeout_time_us, hal_gpt_timer_type_t timer_type);
495 #endif
496 
497 
506 
514 
524 hal_gpt_status_t hal_gpt_get_duration_count(uint32_t start_count, uint32_t end_count, uint32_t *duration_count);
525 
526 #ifdef HAL_GPT_SW_GPT_FEATURE
527 
533 hal_gpt_status_t hal_gpt_sw_get_timer(uint32_t *handle);
534 
542 hal_gpt_status_t hal_gpt_sw_free_timer(uint32_t handle);
543 
555 hal_gpt_status_t hal_gpt_sw_start_timer_ms(uint32_t handle, uint32_t timeout_time_ms, hal_gpt_callback_t callback, void *user_data);
556 
565 
574 hal_gpt_status_t hal_gpt_sw_get_remaining_time_ms(uint32_t handle, uint32_t *remaing_time);
575 
576 #endif
577 
578 #ifdef __cplusplus
579 }
580 #endif
581 
586 #endif /*HAL_GPT_MODULE_ENABLED*/
587 #endif /* __HAL_GPT_H__ */
588 
589 
hal_gpt_clock_source_t
GPT clock source.
Definition: hal_platform.h:816
GPT function error occurred.
Definition: hal_gpt.h:389
hal_gpt_status_t hal_gpt_delay_us(uint32_t us)
This function sets delay time in microseconds.
hal_gpt_status_t hal_gpt_sw_free_timer(uint32_t handle)
This function frees timer.
hal_gpt_status_t hal_gpt_get_duration_count(uint32_t start_count, uint32_t end_count, uint32_t *duration_count)
This function calculates the count duration.
hal_gpt_status_t hal_gpt_sw_stop_timer_ms(uint32_t handle)
This function stops the specified software timer.
hal_gpt_status_t hal_gpt_get_free_run_count(hal_gpt_clock_source_t clock_source, uint32_t *count)
This function gets the current count of timer in the free run mode.
hal_gpt_status_t hal_gpt_deinit(hal_gpt_port_t gpt_port)
This function de-initializes the GPT timer.
hal_gpt_status_t hal_gpt_get_running_status(hal_gpt_port_t gpt_port, hal_gpt_running_status_t *running_status)
This function gets the running status of the port as specified.
hal_gpt_status_t hal_gpt_delay_ms(uint32_t ms)
This function sets the delay time in milliseconds.
No error occurred during the function call.
Definition: hal_gpt.h:392
hal_gpt_status_t hal_gpt_init(hal_gpt_port_t gpt_port)
This function initializes the GPT base enironment.
The GPT is running.
Definition: hal_gpt.h:399
void(* hal_gpt_callback_t)(void *user_data)
Register a callback function when using GPT oneshot or repeat modes.
Definition: hal_gpt.h:371
Set the GPT oneshot mode.
Definition: hal_gpt.h:381
The GPT has stopped.
Definition: hal_gpt.h:398
An invalid parameter.
Definition: hal_gpt.h:391
Set the GPT repeat mode.
Definition: hal_gpt.h:382
hal_gpt_status_t hal_gpt_start_timer_us(hal_gpt_port_t gpt_port, uint32_t timeout_time_us, hal_gpt_timer_type_t timer_type)
This function sets the expiration time in microseconds and the timer mode, then starts the timer...
hal_gpt_running_status_t
This enum defines the GPT running status.
Definition: hal_gpt.h:397
hal_gpt_status_t hal_gpt_sw_get_remaining_time_ms(uint32_t handle, uint32_t *remaing_time)
This function gets the remaining timeout value of the specified software timer.
hal_gpt_status_t hal_gpt_register_callback(hal_gpt_port_t gpt_port, hal_gpt_callback_t callback, void *user_data)
This function registers a callback function with the timer specified at the port. ...
hal_gpt_timer_type_t
This enum defines the GPT timer type.
Definition: hal_gpt.h:380
hal_gpt_status_t hal_gpt_start_timer_ms(hal_gpt_port_t gpt_port, uint32_t timeout_time_ms, hal_gpt_timer_type_t timer_type)
This function sets the expiration time in milliseconds and the timer mode, then starts the timer...
hal_gpt_status_t hal_gpt_sw_start_timer_ms(uint32_t handle, uint32_t timeout_time_ms, hal_gpt_callback_t callback, void *user_data)
This function starts the software timer.
hal_gpt_status_t
This enum defines the GPT status.
Definition: hal_gpt.h:387
hal_gpt_port_t
GPT port.
Definition: hal_platform.h:805
hal_gpt_status_t hal_gpt_sw_get_timer(uint32_t *handle)
This function allocates timer handle.
hal_gpt_status_t hal_gpt_stop_timer(hal_gpt_port_t gpt_port)
This function stops the timer only for oneshot mode and repeat mode.
A wrong GPT port is set.
Definition: hal_gpt.h:390
The timer has beed used.
Definition: hal_gpt.h:388