TaskP.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022, 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 #define TaskP_STRUCT_SIZE (340)
74 
79 #define TaskP_DEFAULT_STACK_SIZE (512)
80 
86 typedef union TaskP_Struct
87 {
88  uint32_t dummy;
90 } TaskP_Struct;
91 
95 typedef enum
96 {
109 } TaskP_State;
110 
117 
118 typedef struct
119 {
121  char *name;
123  void *arg;
125  int priority;
127  size_t stackSize;
131  void *stack;
132 } TaskP_Params;
133 
139 typedef void (*TaskP_Function)(void *);
140 
159 extern TaskP_Handle TaskP_create(TaskP_Function fxn, const TaskP_Params *params);
160 
172 extern void TaskP_delete(TaskP_Handle task);
173 
190 extern TaskP_Handle TaskP_construct(TaskP_Struct *obj, TaskP_Function fxn, const TaskP_Params *params);
191 
199 extern void TaskP_destruct(TaskP_Struct *obj);
200 
224 extern TaskP_State TaskP_getState(TaskP_Handle task);
225 
236 extern TaskP_Handle TaskP_getCurrentTask(void);
237 
257 extern uintptr_t TaskP_disableScheduler(void);
258 
268 extern void TaskP_restoreScheduler(uintptr_t key);
269 
277 extern void TaskP_yield(void);
278 
288 
289 #ifdef __cplusplus
290 }
291 #endif
292 
293 #endif /* ti_dpl_TaskP__include */
ADC_Params params
Definition: Driver_Init.h:11
uint8_t data[(340)]
Definition: TaskP.h:89
Definition: TaskP.h:102
uint32_t dummy
Definition: TaskP.h:88
char * name
Definition: TaskP.h:121
TaskP_Struct * TaskP_Handle
Opaque client reference to an instance of a TaskP.
Definition: TaskP.h:116
size_t stackSize
Definition: TaskP.h:127
void TaskP_restoreScheduler(uintptr_t key)
Function to re-enable task scheduling.
Definition: TaskP.h:108
Definition: TaskP.h:98
int priority
Definition: TaskP.h:125
Definition: TaskP.h:100
Definition: TaskP.h:118
TaskP_Handle TaskP_construct(TaskP_Struct *obj, TaskP_Function fxn, const TaskP_Params *params)
Construct a TaskP from statically allocated memory.
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:95
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:123
Definition: TaskP.h:106
union TaskP_Struct TaskP_Struct
TaskP structure.
TaskP structure.
Definition: TaskP.h:86
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:104
void(* TaskP_Function)(void *)
Task function definition, passed to create and construct.
Definition: TaskP.h:139
void * stack
Task stack pointer. NULL should be used when calling TaskP_create. A pointer to a current stack shoul...
Definition: TaskP.h:131
#define TaskP_STRUCT_SIZE
Number of bytes greater than or equal to the size of any RTOS Task object.
Definition: TaskP.h:73
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale