TaskP.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022-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  */
55 #ifndef ti_dpl_TaskP__include
56 #define ti_dpl_TaskP__include
57 
58 #include <stdint.h>
59 #include <stdbool.h>
60 #include <stddef.h>
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65 
73 #if defined(__GNUC__)
74  #define TaskP_STRUCT_SIZE (340)
75 #else
76  #define TaskP_STRUCT_SIZE (104)
77 #endif
78 
83 #define TaskP_DEFAULT_STACK_SIZE (512)
84 
90 typedef union TaskP_Struct
91 {
92  uint32_t dummy;
94 } TaskP_Struct;
95 
99 typedef enum
100 {
113 } TaskP_State;
114 
121 
122 typedef struct
123 {
125  char *name;
127  void *arg;
129  int priority;
131  size_t stackSize;
135  void *stack;
136 } TaskP_Params;
137 
143 typedef void (*TaskP_Function)(void *);
144 
163 extern TaskP_Handle TaskP_create(TaskP_Function fxn, const TaskP_Params *params);
164 
176 extern void TaskP_delete(TaskP_Handle task);
177 
194 extern TaskP_Handle TaskP_construct(TaskP_Struct *obj, TaskP_Function fxn, const TaskP_Params *params);
195 
203 extern void TaskP_destruct(TaskP_Struct *obj);
204 
228 extern TaskP_State TaskP_getState(TaskP_Handle task);
229 
240 extern TaskP_Handle TaskP_getCurrentTask(void);
241 
261 extern uintptr_t TaskP_disableScheduler(void);
262 
272 extern void TaskP_restoreScheduler(uintptr_t key);
273 
281 extern void TaskP_yield(void);
282 
292 
293 #ifdef __cplusplus
294 }
295 #endif
296 
297 #endif /* ti_dpl_TaskP__include */
ADC_Params params
Definition: Driver_Init.h:11
Definition: TaskP.h:106
uint32_t dummy
Definition: TaskP.h:92
char * name
Definition: TaskP.h:125
TaskP_Struct * TaskP_Handle
Opaque client reference to an instance of a TaskP.
Definition: TaskP.h:120
size_t stackSize
Definition: TaskP.h:131
void TaskP_restoreScheduler(uintptr_t key)
Function to re-enable task scheduling.
Definition: TaskP.h:112
Definition: TaskP.h:102
int priority
Definition: TaskP.h:129
Definition: TaskP.h:104
Definition: TaskP.h:122
TaskP_Handle TaskP_construct(TaskP_Struct *obj, TaskP_Function fxn, const TaskP_Params *params)
Construct a TaskP from statically allocated memory.
uint8_t data[(104)]
Definition: TaskP.h:93
TaskP_State TaskP_getState(TaskP_Handle task)
Get the current state of a task handle.
void TaskP_delete(TaskP_Handle task)
Delete a TaskP.
TaskP_State
Enum returned from TaskP_getState().
Definition: TaskP.h:99
void TaskP_destruct(TaskP_Struct *obj)
Destruct a TaskP.
void TaskP_yield(void)
Create a scheduler point, yielding to equal priority tasks.
TaskP_Handle TaskP_getCurrentTask(void)
Get the currently executing task handle.
void * arg
Definition: TaskP.h:127
Definition: TaskP.h:110
union TaskP_Struct TaskP_Struct
TaskP structure.
TaskP structure.
Definition: TaskP.h:90
void TaskP_Params_init(TaskP_Params *params)
Initialize params structure to default values.
TaskP_Handle TaskP_create(TaskP_Function fxn, const TaskP_Params *params)
Create a TaskP, allocating memory on the heap.
uintptr_t TaskP_disableScheduler(void)
Function to disable task scheduling.
Definition: TaskP.h:108
void(* TaskP_Function)(void *)
Task function definition, passed to create and construct.
Definition: TaskP.h:143
void * stack
Task stack pointer. NULL should be used when calling TaskP_create. A pointer to a current stack shoul...
Definition: TaskP.h:135
#define TaskP_STRUCT_SIZE
Number of bytes greater than or equal to the size of any RTOS Task object.
Definition: TaskP.h:76
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale