Statistics
| Branch: | Revision:

urtware / urt_types.h @ 42470f0a

History | View | Annotate | Download (4.467 KB)

1
/*
2
µRtWare is a lightweight publish/subscribe middleware for real-time
3
applications. It was developed as part of the software habitat for the
4
Autonomous Mini Robot [1] (AMiRo) but can be used for other purposes as well.
5

6
Copyright (C) 2018..2018  Thomas Schöpping et al.
7

8
This program is free software: you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation, either version 3 of the License, or
11
(at your option) any later version.
12

13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
GNU General Public License for more details.
17

18
You should have received a copy of the GNU General Public License
19
along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
*/
21

    
22
#ifndef _URT_TYPES_H_
23
#define _URT_TYPES_H_
24

    
25
#include <urtwareconf.h>
26
#include <stdint.h>
27

    
28
/*============================================================================*/
29
/* PRIMTIVES                                                                  */
30
/*============================================================================*/
31

    
32
/**
33
 * @brief   Type for representing temporal delays in microseconds.
34
 */
35
#if (URT_CFG_DELAY_WIDTH == 32) || defined (__DOXYGEN__)
36
typedef uint32_t urt_delay_t;
37
#elif (URT_CFG_DELAY_WIDTH == 64)
38
typedef uint64_t urt_delay_t;
39
#else
40
#error "URT_CFG_DELAY_WIDTH set to invalid value"
41
#endif
42

    
43
/**
44
 * @brief   Type representing topic IDs.
45
 */
46
#if (URT_CFG_TOPICID_WIDTH == 8) || defined(__DOXYGEN__)
47
typedef uint8_t urt_topicid_t;
48
#elif (URT_CFG_TOPICID_WIDTH == 16)
49
typedef uint16_t urt_topicid_t;
50
#elif (URT_CFG_TOPICID_WIDTH == 32)
51
typedef uint32_t urt_topicid_t;
52
#elif (URT_CFG_TOPICID_WIDTH == 64)
53
typedef uint64_t urt_topicid_t;
54
#else
55
#error "URT_CFG_TOPICID_WIDTH set to invalid value"
56
#endif
57

    
58
/**
59
 * @brief   Type representing node execution stages.
60
 */
61
#if (URT_CFG_NODESTAGE_WIDTH == 8) || defined(__DOXYGEN__)
62
typedef uint8_t urt_nodestage_t;
63
#elif (URT_CFG_NODESTAGE_WIDTH == 16)
64
typedef uint16_t urt_nodestage_t;
65
#elif (URT_CFG_NODESTAGE_WIDTH == 32)
66
typedef uint32_t urt_nodestage_t;
67
#elif (URT_CFG_NODESTAGE_WIDTH == 64)
68
typedef uint64_t urt_nodestage_t;
69
#else
70
#error "URT_CFG_NODESTAGE_WIDTH set to invalid value"
71
#endif
72

    
73
/**
74
 * @brief   µRtWare error codes.
75
 */
76
typedef enum {
77
  URT_STATUS_OK       = 0,  /**< No error occurred. */
78
  URT_STATUS_WARNING  = 1,  /**< A warning occurred. */
79
  URT_STATUS_ERROR    = -1, /**< An error occurred. */
80
} urt_status_t;
81

    
82
/*============================================================================*/
83
/* URT-OSAL                                                                   */
84
/*============================================================================*/
85

    
86
/**
87
 * @brief   µRtWare OSAL timer callback function type.
88
 */
89
typedef void (*urt_osTimerCallback)(void* parameter);
90

    
91
/**
92
 * @brief   Condition variable status.
93
 */
94
typedef enum {
95
  URT_CONDVAR_STATUS_SIGNAL     = 0,  /**< The condition variable has been signaled individually. */
96
  URT_CONDVAR_STATUS_BROADCAST  = 1,  /**< The condition variable has been signaled via broadcast. */
97
  URT_CONDVAR_STATUS_TIMEOUT    = 2,  /**< The condition variable timed out. */
98
} urt_condvarStatus_t;
99

    
100
/**
101
 * @brief   µRtWare OSAL thread function type.
102
 */
103
typedef void (*urt_osThreadFunction_t)(void* arg);
104

    
105
/**
106
 * @brief   Thread execution state.
107
 */
108
typedef enum {
109
  URT_THREAD_STATE_RUNNING    = 0,  /**< Thread is currently running. */
110
  URT_THREAD_STATE_READY      = 1,  /**< Thread is ready and wating to be scheduled. */
111
  URT_THREAD_STATE_SLEEPING   = 2,  /**< Thread is currently sleeping. */
112
  URT_THREAD_STATE_SUSPENDED  = 3,  /**< Thread is suspended. */
113
  URT_THREAD_STATE_WAITING    = 4,  /**< Thread is waiting for event. */
114
  URT_THREAD_STATE_TERMINATED = 5,  /**< Thread has been terminated. */
115
} urt_osThreadState_t;
116

    
117
/**
118
 * @brief   Thread terminate request flags.
119
 */
120
typedef enum {
121
  URT_THREAD_TERMINATE_REQEUST  = 15, /**< Request thread to terminate. */
122
  URT_THREAD_TERMINATE_KILL     = 9,  /**< Kill thread immediately. */
123
} urt_osThreadTerminateSignal_t;
124

    
125
/**
126
 * @brief   Specifier for waiting for events.
127
 */
128
typedef enum {
129
  URT_EVENT_WAIT_ONE  = 0,  /**< Wait for exactly one event to occur. */
130
  URT_EVENT_WAIT_ANY  = 1,  /**< Wait for any combination of events to occur. */
131
  URT_EVENT_WAIT_ALL  = 2,  /**< Wait for all specified events to have occurred. */
132
} urt_osEventWaitType_t;
133

    
134
#endif /* _URT_TYPES_H_ */