Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
cascoda_os.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, Cascoda
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 are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
43 #ifndef BAREMETAL_CASCODA_BM_DRIVER_INCLUDE_CASCODA_BM_CASCODA_OS_H_
44 #define BAREMETAL_CASCODA_BM_DRIVER_INCLUDE_CASCODA_BM_CASCODA_OS_H_
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
53 typedef void *ca_mutex;
54 
59 void CA_OS_Init(void);
60 
64 void CA_OS_Yield(void);
65 
71 
78 void CA_OS_MutexLock(ca_mutex *aMutex);
79 
85 void CA_OS_MutexUnlock(ca_mutex *aMutex);
86 
94 void CA_OS_SchedulerSuspend(void);
95 
100 void CA_OS_SchedulerResume(void);
101 
108 void CA_OS_LockAPI(void);
109 
114 void CA_OS_UnlockAPI(void);
115 
119 #define CA_OS_LOCKED(x) \
120  do \
121  { \
122  CA_OS_LockAPI(); \
123  x; \
124  CA_OS_UnlockAPI(); \
125  } while (0)
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
135 #endif /* BAREMETAL_CASCODA_BM_DRIVER_INCLUDE_CASCODA_BM_CASCODA_OS_H_ */
ca_mutex CA_OS_MutexInit(void)
Initialise a mutex for inter-thread control in an OS-independent manner.
Definition: cascoda_os.c:73
void CA_OS_LockAPI(void)
Lock the Cascoda API thread, for safely calling Cascoda API functions.
Definition: cascoda_os.c:57
void CA_OS_Yield(void)
Yield the CPU to a different task.
Definition: cascoda_os.c:69
void CA_OS_UnlockAPI(void)
Release the Cascoda API lock.
Definition: cascoda_os.c:63
void CA_OS_MutexLock(ca_mutex *aMutex)
Claim a mutex, blocking until it is taken Mutex must be initialised with CA_OS_MutexInit Counterpart ...
Definition: cascoda_os.c:79
void CA_OS_MutexUnlock(ca_mutex *aMutex)
Unlock a claimed mutex Counterpart is CA_OS_MutexLock.
Definition: cascoda_os.c:85
void * ca_mutex
Generic mutex type.
Definition: cascoda_os.h:53
void CA_OS_Init(void)
Initialise the CA_OS subsystem.
Definition: cascoda_os.c:53
void CA_OS_SchedulerResume(void)
Resume the scheduler so pre-emption begins again.
Definition: cascoda_os.c:97
void CA_OS_SchedulerSuspend(void)
Suspend the scheduler so that it will not pre-emptively context switch to another task.
Definition: cascoda_os.c:91