ZestCode
 
Loading...
Searching...
No Matches
rtos.h
Go to the documentation of this file.
1
21
22#ifndef _PROS_RTOS_H_
23#define _PROS_RTOS_H_
24
25#include <stdbool.h>
26#include <stdint.h>
27
28#ifdef __cplusplus
29extern "C" {
30namespace pros {
31#endif
32
34
37
40
47#define TASK_PRIORITY_MAX 16
48
55#define TASK_PRIORITY_MIN 1
56
63#define TASK_PRIORITY_DEFAULT 8
64
72#define TASK_STACK_DEPTH_DEFAULT 0x2000
73
79#define TASK_STACK_DEPTH_MIN 0x200
80
84#define TASK_NAME_MAX_LEN 32
85
89#define TIMEOUT_MAX ((uint32_t)0xffffffffUL)
90
92
95
100typedef void* task_t;
101
108typedef void (*task_fn_t)(void*);
109
111
112
115
127
138
140
143
144#ifdef PROS_USE_SIMPLE_NAMES
145#ifdef __cplusplus
146#define TASK_STATE_RUNNING pros::E_TASK_STATE_RUNNING
147#define TASK_STATE_READY pros::E_TASK_STATE_READY
148#define TASK_STATE_BLOCKED pros::E_TASK_STATE_BLOCKED
149#define TASK_STATE_SUSPENDED pros::E_TASK_STATE_SUSPENDED
150#define TASK_STATE_DELETED pros::E_TASK_STATE_DELETED
151#define TASK_STATE_INVALID pros::E_TASK_STATE_INVALID
152#define NOTIFY_ACTION_NONE pros::E_NOTIFY_ACTION_NONE
153#define NOTIFY_ACTION_BITS pros::E_NOTIFY_ACTION_BITS
154#define NOTIFY_ACTION_INCR pros::E_NOTIFY_ACTION_INCR
155#define NOTIFY_ACTION_OWRITE pros::E_NOTIFY_ACTION_OWRITE
156#define NOTIFY_ACTION_NO_OWRITE pros::E_NOTIFY_ACTION_NO_OWRITE
157#else
158#define TASK_STATE_RUNNING E_TASK_STATE_RUNNING
159#define TASK_STATE_READY E_TASK_STATE_READY
160#define TASK_STATE_BLOCKED E_TASK_STATE_BLOCKED
161#define TASK_STATE_SUSPENDED E_TASK_STATE_SUSPENDED
162#define TASK_STATE_DELETED E_TASK_STATE_DELETED
163#define TASK_STATE_INVALID E_TASK_STATE_INVALID
164#define NOTIFY_ACTION_NONE E_NOTIFY_ACTION_NONE
165#define NOTIFY_ACTION_BITS E_NOTIFY_ACTION_BITS
166#define NOTIFY_ACTION_INCR E_NOTIFY_ACTION_INCR
167#define NOTIFY_ACTION_OWRITE E_NOTIFY_ACTION_OWRITE
168#define NOTIFY_ACTION_NO_OWRITE E_NOTIFY_ACTION_NO_OWRITE
169#endif
170#endif
171
173
175
184typedef void* mutex_t;
185
187
191#ifdef __cplusplus
192#define CURRENT_TASK ((pros::task_t)NULL)
193#else
194#define CURRENT_TASK ((task_t)NULL)
195#endif
196
198
199#ifdef __cplusplus
200namespace c {
201#endif
202
206
223uint32_t millis(void);
224
241uint64_t micros(void);
242
283task_t task_create(task_fn_t function, void* const parameters, uint32_t prio, const uint16_t stack_depth,
284 const char* const name);
285
313
334void task_delay(const uint32_t milliseconds);
335
356void delay(const uint32_t milliseconds);
357
382void task_delay_until(uint32_t* const prev_time, const uint32_t delta);
383
407
433void task_set_priority(task_t task, uint32_t prio);
434
458
494
535
558uint32_t task_get_count(void);
559
583
609task_t task_get_by_name(const char* name);
610
634
663uint32_t task_notify(task_t task);
664
692void task_join(task_t task);
693
746uint32_t task_notify_ext(task_t task, uint32_t value, notify_action_e_t action, uint32_t* prev_value);
747
784uint32_t task_notify_take(bool clear_on_exit, uint32_t timeout);
785
824
904
992bool mutex_take(mutex_t mutex, uint32_t timeout);
993
1077
1101
1129bool mutex_recursive_take(mutex_t mutex, uint32_t timeout);
1130
1157
1179
1181
1182#ifdef __cplusplus
1183} // namespace c
1184} // namespace pros
1185}
1186#endif
1187
1188#endif // _PROS_RTOS_H_
bool mutex_take(mutex_t mutex, uint32_t timeout)
uint64_t micros(void)
uint32_t task_notify(task_t task)
void * task_t
Definition rtos.h:100
task_state_e_t
Definition rtos.h:119
task_t task_create(task_fn_t function, void *const parameters, uint32_t prio, const uint16_t stack_depth, const char *const name)
void task_delay(const uint32_t milliseconds)
notify_action_e_t
Definition rtos.h:131
mutex_t mutex_create(void)
void task_suspend(task_t task)
void task_resume(task_t task)
task_state_e_t task_get_state(task_t task)
bool mutex_give(mutex_t mutex)
void mutex_delete(mutex_t mutex)
void task_delay_until(uint32_t *const prev_time, const uint32_t delta)
bool mutex_recursive_take(mutex_t mutex, uint32_t timeout)
uint32_t task_get_count(void)
uint32_t task_notify_ext(task_t task, uint32_t value, notify_action_e_t action, uint32_t *prev_value)
uint32_t task_get_priority(task_t task)
void task_set_priority(task_t task, uint32_t prio)
uint32_t task_notify_take(bool clear_on_exit, uint32_t timeout)
task_t task_get_by_name(const char *name)
bool mutex_recursive_give(mutex_t mutex)
void * mutex_t
Definition rtos.h:184
mutex_t mutex_recursive_create(void)
void delay(const uint32_t milliseconds)
char * task_get_name(task_t task)
uint32_t millis(void)
void task_delete(task_t task)
task_t task_get_current()
bool task_notify_clear(task_t task)
void(* task_fn_t)(void *)
Definition rtos.h:108
void task_join(task_t task)
@ E_TASK_STATE_SUSPENDED
Definition rtos.h:123
@ E_TASK_STATE_RUNNING
Definition rtos.h:120
@ E_TASK_STATE_INVALID
Definition rtos.h:125
@ E_TASK_STATE_DELETED
Definition rtos.h:124
@ E_TASK_STATE_READY
Definition rtos.h:121
@ E_TASK_STATE_BLOCKED
Definition rtos.h:122
@ E_NOTIFY_ACTION_OWRITE
Definition rtos.h:135
@ E_NOTIFY_ACTION_NO_OWRITE
Definition rtos.h:136
@ E_NOTIFY_ACTION_NONE
Definition rtos.h:132
@ E_NOTIFY_ACTION_INCR
Definition rtos.h:134
@ E_NOTIFY_ACTION_BITS
Definition rtos.h:133