dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_semaphore.h
Go to the documentation of this file.
1 
11 /*
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20  * for more details.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with this program; if not, see <http://www.gnu.org/licenses/>
24  */
25 
26 
27 #ifndef PIOS_SEMAPHORE_H_
28 #define PIOS_SEMAPHORE_H_
29 
30 #define PIOS_SEMAPHORE_TIMEOUT_MAX 0xffffffff
31 
32 #include <stdint.h>
33 #include <stdbool.h>
34 
35 struct pios_semaphore;
36 
37 /*
38  * The following functions implement the concept of a binary semaphore usable
39  * with PIOS_INCLUDE_CHIBIOS or PIOS_INCLUDE_IRQ.
40  *
41  * Note that this is not the same as:
42  * - counting semaphore
43  * - mutex
44  * - recursive mutex
45  *
46  * see FreeRTOS documentation for details: http://www.freertos.org/a00113.html
47  * see ChibiOS documentation for details: http://chibios.sourceforge.net/html/group__synchronization.html
48  */
49 
51 bool PIOS_Semaphore_Take(struct pios_semaphore *sema, uint32_t timeout_ms);
52 bool PIOS_Semaphore_Give(struct pios_semaphore *sema);
53 
54 bool PIOS_Semaphore_Take_FromISR(struct pios_semaphore *sema, bool *woken);
55 bool PIOS_Semaphore_Give_FromISR(struct pios_semaphore *sema, bool *woken);
56 
57 #endif /* PIOS_SEMAPHORE_H_ */
58 
bool PIOS_Semaphore_Give_FromISR(struct pios_semaphore *sema, bool *woken)
struct pios_semaphore * PIOS_Semaphore_Create(void)
Creates a binary semaphore.
bool PIOS_Semaphore_Take_FromISR(struct pios_semaphore *sema, bool *woken)
bool PIOS_Semaphore_Give(struct pios_semaphore *sema)
Gives binary semaphore.
bool PIOS_Semaphore_Take(struct pios_semaphore *sema, uint32_t timeout_ms)
Takes binary semaphore.