AM64x MCU+ SDK  10.00.00
cb_tmevent.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Texas Instruments Incorporated
3  * Copyright (c) 2023 Excelfore Corporation (https://excelfore.com)
4  *
5  * All rights reserved not granted herein.
6  * Limited License.
7  *
8  * Texas Instruments Incorporated grants a world-wide, royalty-free,
9  * non-exclusive license under copyrights and patents it now or hereafter
10  * owns or controls to make, have made, use, import, offer to sell and sell ("Utilize")
11  * this software subject to the terms herein. With respect to the foregoing patent
12  * license, such license is granted solely to the extent that any such patent is necessary
13  * to Utilize the software alone. The patent license shall not apply to any combinations which
14  * include this software, other than combinations with devices manufactured by or for TI ("TI Devices").
15  * No hardware patent is licensed hereunder.
16  *
17  * Redistributions must preserve existing copyright notices and reproduce this license (including the
18  * above copyright notice and the disclaimer and (if applicable) source code license limitations below)
19  * in the documentation and/or other materials provided with the distribution
20  *
21  * Redistribution and use in binary form, without modification, are permitted provided that the following
22  * conditions are met:
23  *
24  * * No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any
25  * software provided in binary form.
26  * * any redistribution and use are licensed by TI for use only with TI Devices.
27  * * Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
28  *
29  * If software source code is provided to you, modification and redistribution of the source code are permitted
30  * provided that the following conditions are met:
31  *
32  * * any redistribution and use of the source code, including any resulting derivative works, are licensed by
33  * TI for use only with TI Devices.
34  * * any redistribution and use of any object code compiled from the source code and any resulting derivative
35  * works, are licensed by TI for use only with TI Devices.
36  *
37  * Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or
38  * promote products derived from this software without specific prior written permission.
39  *
40  * DISCLAIMER.
41  *
42  * THIS SOFTWARE IS PROVIDED BY TI AND TI"S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
43  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44  * IN NO EVENT SHALL TI AND TI"S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
45  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
46  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48  * POSSIBILITY OF SUCH DAMAGE.
49 */
59 #ifndef CB_EVENT_H_
60 #define CB_EVENT_H_
61 
62 #ifdef CB_EVENT_NON_POSIX_H
63 /* non-posix platforms need to support necessary POSIX compatible
64  * functions and types which are defined as CB_* macros below.
65  * And provide them in a header file defined as CB_EVENT_NON_POSIX_H */
66 #include CB_EVENT_NON_POSIX_H
67 #else
68 #include <unistd.h>
69 #include <time.h>
70 
74 #define CB_USLEEP(x) usleep(x)
75 
79 #define CB_SLEEP(x) sleep(x)
80 
84 #define CB_MKTIME(x) mktime(x)
85 
89 static inline int cb_nanosleep64(int64_t ts64, int64_t *rts64)
90 {
91  struct timespec ts, rts;
92  int res;
93  UB_NSEC2TS(ts64, ts);
94  res=nanosleep(&ts, &rts);
95  if(rts64!=NULL) {*rts64=(int64_t)(UB_TS2NSEC(rts));}
96  return res;
97 }
98 #endif // CB_EVENT_NON_POSIX_H
99 
106 typedef struct cb_timer_object cb_timer_object_t;
107 
115 typedef enum {
120 
127 
133 
143  uint32_t value_ms, uint32_t interval_ms);
144 
152 
161 
162 
163 #endif
164 
cb_timer_stop
int cb_timer_stop(cb_timer_object_t *mtmo)
timer stop.
cb_timer_start_interval
int cb_timer_start_interval(cb_timer_object_t *mtmo, uint32_t value_ms, uint32_t interval_ms)
start timer interval.
clear
uint8_t clear
Definition: tisci_rm_udmap.h:5
cb_timer_clear_t
cb_timer_clear_t
enumeration used for timer to clear, decrement or no clear. This enumeration has following members:
Definition: cb_tmevent.h:115
CB_TIMER_NO_CLEAR
@ CB_TIMER_NO_CLEAR
Definition: cb_tmevent.h:116
cb_timer_close
void cb_timer_close(cb_timer_object_t *mtmo)
close the timer
cb_nanosleep64
static int cb_nanosleep64(int64_t ts64, int64_t *rts64)
nano second unit sleep
Definition: cb_tmevent.h:89
cb_timer_create
cb_timer_object_t * cb_timer_create(char *tname)
creates timer.
cb_timer_object_t
struct cb_timer_object cb_timer_object_t
handler for cb_timer_object
Definition: cb_tmevent.h:106
CB_TIMER_DECREMENT
@ CB_TIMER_DECREMENT
Definition: cb_tmevent.h:117
cb_timer_expired
bool cb_timer_expired(cb_timer_object_t *mtmo, cb_timer_clear_t clear)
timer expired
UB_NSEC2TS
#define UB_NSEC2TS(ns, ts)
convert nanosec value to 'struct timespec' vaule
Definition: unibase_macros.h:236
UB_TS2NSEC
#define UB_TS2NSEC(ts)
convert 'struct timespec' vaule to nanosecond integer
Definition: unibase_macros.h:218
CB_TIMER_ALL_CLEAR
@ CB_TIMER_ALL_CLEAR
Definition: cb_tmevent.h:118