在任务中使用
BaseType_t <b><font color="#64b5f6">xSemaphoreGive</font></b>( SemaphoreHandle_t <b>xSemaphore </b>);<br>
BaseType_t <b><font color="#64b5f6">xSemaphoreTake</font></b>(<br> SemaphoreHandle_t <b>xSemaphore</b>,<br> TickType_t <b>xTicksToWait</b><br> );<br>
ISR中使用
BaseType_t <b><font color="#64b5f6">xSemaphoreGiveFromISR</font></b>(<br> SemaphoreHandle_t <b>xSemaphore</b>,<br> BaseType_t *<b>pxHigherPriorityTaskWoken</b><br> );<br>
BaseType_t <b><font color="#64b5f6">xSemaphoreTakeFromISR</font></b>(<br> SemaphoreHandle_t <b>xSemaphore</b>,<br> BaseType_t *<b>pxHigherPriorityTaskWoken</b><br> );<br><br>
参数 <b><font color="#7b1fa2">pxHigherPriorityTaskWoken </font></b>如果释放信号量导致更高优先级的任务变为了就绪态,则<b><font color="#000000">*pxHigherPriorityTaskWoken = pdTRUE 返回值 </font></b>pdTRUE --> 成功 如果二进制信号量的计数值已经是1,再次调用此函数则返回失败; 如果计数型信号量的计数值已经是最大值,再次调用此函数则返回失败<br>