qpcpp/doxygen/snippets/qxk_sema.cpp
2019-01-16 19:31:40 -05:00

24 lines
544 B
C++

QXSemaphore BTN_sema; // semaphore to signal a button press
int main() {
. . .
// initialize the BTN_sema semaphore as binary, signaling semaphore
BTN_sema.init(0U, // initial semaphore count (singaling semaphore)
1U); // maximum semaphore count (binary semaphore)
. . .
}
void main_threadXYZ(QXThread * const me) {
while (1) {
. . .
BTN_sema.wait(QXTHREAD_NO_TIMEOUT); // timeout for waiting
. . .
}
}
void GPIO_Handler(void) {
. . .
BTN_sema.signal();
. . .
}