1 /*
2  * ==========================================================
3  *
4  *    Copyright (C) 2020 QuickLogic Corporation
5  *    Licensed under the Apache License, Version 2.0 (the "License");
6  *    you may not use this file except in compliance with the License.
7  *    You may obtain a copy of the License at
8  * 		http://www.apache.org/licenses/LICENSE-2.0
9  *    Unless required by applicable law or agreed to in writing, software
10  *    distributed under the License is distributed on an "AS IS" BASIS,
11  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  *    See the License for the specific language governing permissions and
13  *    limitations under the License.
14  *
15  *    File      : eoss3_hal_timer.h
16  *    Purpose   : This file contains macros and APIs for
17  *             M4 peripheral timer
18  *
19  *
20  * ===========================================================
21  *
22  */
23 
24 #ifndef HAL_INC_EOSS3_HAL_TIMER_H_
25 #define HAL_INC_EOSS3_HAL_TIMER_H_
26 
27 #include <stdint.h>
28 #include <stddef.h>
29 
30 #include "test_types.h"
31 #include "eoss3_hal_def.h"
32 
33 typedef struct __Timer_HandleTypeDef
34 {
35      UINT32_t	ulClkFreq;
36      UINT32_t   ulReload_val;
37 
38 }Timer_HandleTypeDef;
39 
40 /* Ctrl register bit definition */
41 #define TIMER_INT_ENABLE	(UINT32_t)(1 << BYTE_IDX_3)
42 #define SEL_EXTINT_AS_CLK	(UINT32_t)(1 << BYTE_IDX_2)
43 #define SEL_EXTINT_AS_EN	(UINT32_t)(1 << BYTE_IDX_1)
44 #define TIMER_ENABLE		(UINT32_t)(1 << BYTE_IDX_0)
45 
46 #define HAL_TIMER_ONESHOT	(1 << 1)
47 #define HAL_TIMER_PERIODIC	(1 << 0)
48 
49 typedef void (*HAL_TimerCallback_t)(void *);
50 struct HAL_Timer_t;
51 typedef struct HAL_Timer_t* HAL_Timer_t;
52 
53 HAL_StatusTypeDef HAL_Delay_Init(void);
54 void HAL_DelayUSec(uint32_t usecs);
55 
56 HAL_StatusTypeDef HAL_TimerCreate(HAL_Timer_t *Timer, uint32_t USecs,
57 				  uint32_t Flags, HAL_TimerCallback_t CallBack,
58 				  void *Cookie);
59 HAL_StatusTypeDef HAL_TimerStart(HAL_Timer_t Timer);
60 HAL_StatusTypeDef HAL_TimerStop(HAL_Timer_t Timer);
61 HAL_StatusTypeDef HAL_TimerDelete(HAL_Timer_t Timer);
62 
63 HAL_StatusTypeDef HAL_Timer_Enable( );                          // to remove warnings
64 HAL_StatusTypeDef HAL_Timer_Disable( );							// function declarations
65 
66 
67 #endif /* HAL_INC_EOSS3_HAL_TIMER_H_ */
68