Choco OS  V.0.16.9.0
Join to the chocolate world
oc_timer.h
Go to the documentation of this file.
1 
28 #ifndef SYSTEM_CORE_INC_DRIVERS_TIMER_OC_TIMER_H_
29 #define SYSTEM_CORE_INC_DRIVERS_TIMER_OC_TIMER_H_
30 
31 #define DRIVER_HEADER
32 #define DRIVER_NAME TIMER
33 
34 #include <oc_driver.h>
35 #include <oc_timer_lld.h>
36 #include <oc_time.h>
37 
38 #undef DRIVER_HEADER
39 #undef DRIVER_NAME
40 
41 
42 typedef struct Context_t * oC_TIMER_Context_t;
43 
44 typedef enum
45 {
46  oC_TIMER_Mode_Periodic = oC_TIMER_LLD_Mode_PeriodicTimer ,
47  oC_TIMER_Mode_InputEdgeCount = oC_TIMER_LLD_Mode_InputEdgeCount ,
48  oC_TIMER_Mode_InputEdgeTime = oC_TIMER_LLD_Mode_InputEdgeTime ,
49  oC_TIMER_Mode_RTC = oC_TIMER_LLD_Mode_RealTimeClock ,
50  oC_TIMER_Mode_PWM = oC_TIMER_LLD_Mode_PWM
51 } oC_TIMER_Mode_t;
52 
53 typedef enum
54 {
55  oC_TIMER_PwmState_Low = oC_TIMER_LLD_PwmState_Low ,
56  oC_TIMER_PwmState_High = oC_TIMER_LLD_PwmState_High ,
57 } oC_TIMER_PwmState_t;
58 
59 typedef enum
60 {
61  oC_TIMER_InputTrigger_RisingEdge = oC_TIMER_LLD_Trigger_RisingEdge ,
62  oC_TIMER_InputTrigger_FallingEdge = oC_TIMER_LLD_Trigger_FallingEdge ,
63  oC_TIMER_InputTrigger_BothEdges = oC_TIMER_LLD_Trigger_Both ,
64 } oC_TIMER_InputTrigger_t;
65 
66 typedef enum
67 {
68  oC_TIMER_CountDirection_DoesntMatter = oC_TIMER_LLD_CountDirection_DoesntMatter ,
69  oC_TIMER_CountDirection_Up = oC_TIMER_LLD_CountDirection_Up ,
70  oC_TIMER_CountDirection_Down = oC_TIMER_LLD_CountDirection_Down
71 } oC_TIMER_CountDirection_t;
72 
73 typedef oC_TIMER_LLD_EventHandler_t oC_TIMER_EventHandler_t;
74 
75 typedef oC_TIMER_LLD_EventFlags_t oC_TIMER_EventFlags_t;
76 
77 typedef struct
78 {
79  oC_TIMER_Mode_t Mode;
80  oC_Time_t MaximumTimeForWait;
81  oC_Frequency_t Frequency;
82  oC_Frequency_t PermissibleDifference;
83  uint64_t MaximumValue;
84  uint64_t MatchValue;
85  oC_TIMER_EventFlags_t EventFlags;
86  oC_TIMER_EventHandler_t EventHandler;
87  oC_Pins_t Pin;
88  oC_TIMER_CountDirection_t CountDirection;
89 
90  union
91  {
92  oC_TIMER_PwmState_t StartPwmState;
93  oC_TIMER_InputTrigger_t InputTrigger;
94  };
96 
97 extern oC_ErrorCode_t oC_TIMER_TurnOn ( void );
98 extern oC_ErrorCode_t oC_TIMER_TurnOff ( void );
99 extern bool oC_TIMER_IsTurnedOn ( void );
100 extern oC_ErrorCode_t oC_TIMER_Configure ( const oC_TIMER_Config_t * Config , oC_TIMER_Context_t * outContext );
101 extern oC_ErrorCode_t oC_TIMER_Unconfigure ( const oC_TIMER_Config_t * Config , oC_TIMER_Context_t * outContext );
102 extern oC_ErrorCode_t oC_TIMER_ReadValue ( oC_TIMER_Context_t Context , uint64_t * outValue );
103 extern oC_ErrorCode_t oC_TIMER_SetValue ( oC_TIMER_Context_t Context , uint64_t Value );
104 extern oC_ErrorCode_t oC_TIMER_ReadMatchValue ( oC_TIMER_Context_t Context , uint64_t * outValue );
105 extern oC_ErrorCode_t oC_TIMER_SetMatchValue ( oC_TIMER_Context_t Context , uint64_t Value );
106 extern oC_ErrorCode_t oC_TIMER_ReadMaxValue ( oC_TIMER_Context_t Context , uint64_t * outValue );
107 extern oC_ErrorCode_t oC_TIMER_SetMaxValue ( oC_TIMER_Context_t Context , uint64_t Value );
108 extern oC_ErrorCode_t oC_TIMER_Start ( oC_TIMER_Context_t Context );
109 extern oC_ErrorCode_t oC_TIMER_Stop ( oC_TIMER_Context_t Context );
110 
111 #endif /* SYSTEM_CORE_INC_DRIVERS_TIMER_OC_TIMER_H_ */
The file with LLD interface for the TIMER driver.
double oC_Frequency_t
type to store frequency
Definition: oc_frequency.h:76
The library with time definitions.
The file with interface for driver creating.
stores ETH context
Definition: oc_eth.c:97