APM:Libraries
libraries
AP_HAL_ChibiOS
Semaphores.h
Go to the documentation of this file.
1
/*
2
* This file is free software: you can redistribute it and/or modify it
3
* under the terms of the GNU General Public License as published by the
4
* Free Software Foundation, either version 3 of the License, or
5
* (at your option) any later version.
6
*
7
* This file is distributed in the hope that it will be useful, but
8
* WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
* See the GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License along
13
* with this program. If not, see <http://www.gnu.org/licenses/>.
14
*
15
* Code by Andrew Tridgell and Siddharth Bharat Purohit
16
*/
17
#pragma once
18
19
#include <
AP_HAL/AP_HAL_Boards.h
>
20
21
#include "
AP_HAL_ChibiOS.h
"
22
23
24
class
ChibiOS::Semaphore
:
public
AP_HAL::Semaphore
{
25
public
:
26
Semaphore
() {
27
#if CH_CFG_USE_MUTEXES == TRUE
28
chMtxObjectInit(&
_lock
);
29
#endif
30
}
31
bool
give
();
32
bool
take
(uint32_t timeout_ms);
33
bool
take_nonblocking
();
34
bool
check_owner
(
void
) {
35
#if CH_CFG_USE_MUTEXES == TRUE
36
return
_lock
.owner == chThdGetSelfX();
37
#else
38
return
true
;
39
#endif
40
}
41
void
assert_owner
(
void
) {
42
osalDbgAssert(
check_owner
(),
"owner"
);
43
}
44
private
:
45
mutex_t
_lock
;
46
};
ChibiOS::Semaphore::give
bool give()
Definition:
Semaphores.cpp:26
ChibiOS::Semaphore::assert_owner
void assert_owner(void)
Definition:
Semaphores.h:41
AP_HAL::Semaphore
Definition:
Semaphores.h:7
ChibiOS::Semaphore
Definition:
Semaphores.h:24
ChibiOS::Semaphore::Semaphore
Semaphore()
Definition:
Semaphores.h:26
ChibiOS::Semaphore::take
bool take(uint32_t timeout_ms)
Definition:
Semaphores.cpp:32
ChibiOS::Semaphore::take_nonblocking
bool take_nonblocking()
Definition:
Semaphores.cpp:51
AP_HAL_ChibiOS.h
ChibiOS::Semaphore::check_owner
bool check_owner(void)
Definition:
Semaphores.h:34
AP_HAL_Boards.h
ChibiOS::Semaphore::_lock
mutex_t _lock
Definition:
Semaphores.h:45
Generated on Sun Jun 17 2018 14:18:48 for APM:Libraries by
1.8.13