SwiP.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-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  */
40 #ifndef ti_dpl_SwiP__include
41 #define ti_dpl_SwiP__include
42 
43 #include <stdint.h>
44 #include <stdbool.h>
45 #include <stddef.h>
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
60 #define SwiP_STRUCT_SIZE (60)
61 
68 typedef union SwiP_Struct
69 {
70  uint32_t dummy;
72 } SwiP_Struct;
73 
79 typedef void *SwiP_Handle;
80 
84 typedef enum
85 {
86  SwiP_OK = 0,
88 } SwiP_Status;
89 
93 typedef void (*SwiP_Fxn)(uintptr_t arg0, uintptr_t arg1);
94 
113 typedef struct
114 {
115  uintptr_t arg0;
116  uintptr_t arg1;
117  uint32_t priority;
118  uint32_t trigger;
119 } SwiP_Params;
120 
133 extern SwiP_Handle SwiP_construct(SwiP_Struct *swiP, SwiP_Fxn swiFxn, SwiP_Params *params);
134 
143 extern void SwiP_destruct(SwiP_Struct *swiP);
144 
153 extern void SwiP_Params_init(SwiP_Params *params);
154 
166 extern SwiP_Handle SwiP_create(SwiP_Fxn swiFxn, SwiP_Params *params);
167 
174 extern void SwiP_delete(SwiP_Handle handle);
175 
191 extern uintptr_t SwiP_disable(void);
192 
197 extern uint32_t SwiP_getTrigger(void);
198 
205 extern void SwiP_andn(SwiP_Handle handle, uint32_t mask);
206 
212 extern void SwiP_dec(SwiP_Handle handle);
213 
219 extern void SwiP_inc(SwiP_Handle handle);
220 
228 extern bool SwiP_inISR(void);
229 
236 extern void SwiP_or(SwiP_Handle handle, uint32_t mask);
237 
243 extern void SwiP_post(SwiP_Handle handle);
244 
250 extern void SwiP_restore(uintptr_t key);
251 
258 extern void SwiP_setPriority(SwiP_Handle handle, uint32_t priority);
259 
260 #ifdef __cplusplus
261 }
262 #endif
263 
264 #endif /* ti_dpl_SwiP__include */
ADC_Params params
Definition: Driver_Init.h:11
SwiP_Status
Status codes for SwiP APIs.
Definition: SwiP.h:84
void * SwiP_Handle
Opaque client reference to an instance of a SwiP.
Definition: SwiP.h:79
void SwiP_delete(SwiP_Handle handle)
Function to delete a software interrupt object.
void SwiP_dec(SwiP_Handle handle)
Decrement SwiP&#39;s trigger value. Post SwiP if trigger becomes 0.
uintptr_t arg0
Definition: SwiP.h:115
SwiP_Handle SwiP_create(SwiP_Fxn swiFxn, SwiP_Params *params)
Function to create a software interrupt object.
Basic SwiP Parameters.
Definition: SwiP.h:113
void SwiP_destruct(SwiP_Struct *swiP)
Function to destruct a software interrupt object.
void(* SwiP_Fxn)(uintptr_t arg0, uintptr_t arg1)
Prototype for the entry function for a hardware interrupt.
Definition: SwiP.h:93
#define SwiP_STRUCT_SIZE
Number of bytes greater than or equal to the size of any RTOS SwiP object.
Definition: SwiP.h:60
Definition: SwiP.h:86
uint8_t data[(60)]
Definition: SwiP.h:71
uint32_t dummy
Definition: SwiP.h:70
void SwiP_Params_init(SwiP_Params *params)
Initialize params structure to default values.
uint32_t trigger
Definition: SwiP.h:118
SwiP_Handle SwiP_construct(SwiP_Struct *swiP, SwiP_Fxn swiFxn, SwiP_Params *params)
Function to construct a software interrupt object.
bool SwiP_inISR(void)
Function to return a status based on whether it is in a software interrupt context.
uintptr_t SwiP_disable(void)
Function to disable software interrupts.
uint32_t SwiP_getTrigger(void)
Function to get the trigger value of the currently running SwiP.
uintptr_t arg1
Definition: SwiP.h:116
void SwiP_inc(SwiP_Handle handle)
Increment the SwiP&#39;s trigger value and post the SwiP.
void SwiP_andn(SwiP_Handle handle, uint32_t mask)
Clear bits in SwiP&#39;s trigger. Post SwiP if trigger becomes 0.
void SwiP_setPriority(SwiP_Handle handle, uint32_t priority)
Function to set the priority of a software interrupt.
Definition: SwiP.h:87
uint32_t priority
Definition: SwiP.h:117
void SwiP_restore(uintptr_t key)
Function to restore software interrupts.
void SwiP_or(SwiP_Handle handle, uint32_t mask)
Or the mask with the SwiP&#39;s trigger value and post the SwiP.
union SwiP_Struct SwiP_Struct
SemaphoreP structure.
SemaphoreP structure.
Definition: SwiP.h:68
void SwiP_post(SwiP_Handle handle)
Unconditionally post a software interrupt.
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale