mirror of
https://github.com/QuantumLeaps/qpcpp.git
synced 2025-01-28 06:02:56 +08:00
24 lines
544 B
C++
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();
|
||
|
. . .
|
||
|
}
|