ClockP.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2023, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
54 #ifndef ti_dpl_ClockP__include
55 #define ti_dpl_ClockP__include
56 
57 #include <stdint.h>
58 #include <stdbool.h>
59 #include <stddef.h>
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
73 #define ClockP_STRUCT_SIZE (68)
74 
81 typedef union ClockP_Struct
82 {
83  uint32_t dummy;
86 
90 typedef struct
91 {
92  uint32_t hi;
93  uint32_t lo;
95 
99 typedef enum
100 {
103 } ClockP_Status;
104 
112 typedef void *ClockP_Handle;
113 
114 #define ClockP_handle(x) ((ClockP_Handle)(x))
115 
119 typedef void (*ClockP_Fxn)(uintptr_t arg);
120 
140 typedef struct
141 {
142  bool startFlag;
143  uint32_t period;
144  uintptr_t arg;
145 } ClockP_Params;
146 
160 extern ClockP_Handle ClockP_construct(ClockP_Struct *clockP,
161  ClockP_Fxn clockFxn,
162  uint32_t timeout,
164 
173 extern void ClockP_destruct(ClockP_Struct *clockP);
174 
188 extern ClockP_Handle ClockP_create(ClockP_Fxn clockFxn, uint32_t timeout, ClockP_Params *params);
189 
197 extern void ClockP_delete(ClockP_Handle handle);
198 
204 extern void ClockP_getCpuFreq(ClockP_FreqHz *freq);
205 
211 extern uint32_t ClockP_getSystemTickPeriod(void);
212 
221 extern uint32_t ClockP_getSystemTicks(void);
222 
234 extern uint32_t ClockP_getTicksUntilInterrupt(void);
235 
247 extern uint32_t ClockP_getTimeout(ClockP_Handle handle);
248 
259 extern bool ClockP_isActive(ClockP_Handle handle);
260 
272 
281 extern void ClockP_setTimeout(ClockP_Handle handle, uint32_t timeout);
282 
291 extern void ClockP_setPeriod(ClockP_Handle handle, uint32_t period);
292 
321 extern void ClockP_start(ClockP_Handle handle);
322 
330 extern void ClockP_stop(ClockP_Handle handle);
331 
337 extern void ClockP_usleep(uint32_t usec);
338 
344 extern void ClockP_sleep(uint32_t sec);
345 
346 #ifdef __cplusplus
347 }
348 #endif
349 
350 #endif /* ti_dpl_ClockP__include */
ADC_Params params
Definition: Driver_Init.h:11
bool ClockP_isActive(ClockP_Handle handle)
Determine if a clock object is currently active (i.e., running)
void ClockP_start(ClockP_Handle handle)
Function to start a clock.
uint32_t lo
Definition: ClockP.h:93
void ClockP_setPeriod(ClockP_Handle handle, uint32_t period)
Set the clock period.
uint8_t data[(68)]
Definition: ClockP.h:84
Definition: ClockP.h:102
Basic ClockP Parameters.
Definition: ClockP.h:140
ClockP structure.
Definition: ClockP.h:81
ClockP_Handle ClockP_construct(ClockP_Struct *clockP, ClockP_Fxn clockFxn, uint32_t timeout, ClockP_Params *params)
Function to construct a clock object.
uint32_t ClockP_getSystemTicks(void)
Get the current tick value in number of system ticks.
ClockP_Handle ClockP_create(ClockP_Fxn clockFxn, uint32_t timeout, ClockP_Params *params)
Function to create a clock object.
uint32_t ClockP_getSystemTickPeriod(void)
Get the system tick period in number of micro seconds.
#define ClockP_STRUCT_SIZE
Number of bytes greater than or equal to the size of any RTOS ClockP object.
Definition: ClockP.h:73
Frequency-in-hertz struct.
Definition: ClockP.h:90
union ClockP_Struct ClockP_Struct
ClockP structure.
uint32_t ClockP_getTimeout(ClockP_Handle handle)
Get timeout of clock instance.
uint32_t ClockP_getTicksUntilInterrupt(void)
Get number of ClockP tick periods expected to expire between now and the next interrupt from the time...
bool startFlag
Definition: ClockP.h:142
uint32_t dummy
Definition: ClockP.h:83
Definition: ClockP.h:101
void ClockP_getCpuFreq(ClockP_FreqHz *freq)
Get CPU frequency in Hertz.
uintptr_t arg
Definition: ClockP.h:144
void ClockP_destruct(ClockP_Struct *clockP)
Function to destruct a clock object.
void(* ClockP_Fxn)(uintptr_t arg)
Prototype for a ClockP callback function.
Definition: ClockP.h:119
ClockP_Status
Status codes for ClockP APIs.
Definition: ClockP.h:99
void ClockP_stop(ClockP_Handle handle)
Function to stop a clock.
void ClockP_sleep(uint32_t sec)
Set delay in seconds.
void ClockP_Params_init(ClockP_Params *params)
Initialize params structure to default values.
void ClockP_delete(ClockP_Handle handle)
Function to delete a clock.
uint32_t hi
Definition: ClockP.h:92
void ClockP_setTimeout(ClockP_Handle handle, uint32_t timeout)
Set the initial timeout.
uint32_t period
Definition: ClockP.h:143
void ClockP_usleep(uint32_t usec)
Set delay in micro seconds.
void * ClockP_Handle
Opaque client reference to an instance of a ClockP.
Definition: ClockP.h:112
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale