void KeyscanTask(void const * argument){
int8_t key;
int8_t sem_value;
BaseType_t err;
for(;;){
key = KEY_Scan(0);
if(CountingSemHandle != NULL){
switch(key){
case KEY_UP_PRES:
err = xSemaphoreTake(CountingSemHandle,portMAX_DELAY);
if(err == pdFALSE)
printf("Semaphore Take failed!\r\n");
else{
sem_value = uxSemaphoreGetCount(CountingSemHandle);
printf("Semaphore Take successed, Semvalue = %d\r\n",sem_value);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_0,GPIO_PIN_RESET);
}
break;
case KEY_DOWN_PRES:
err = xSemaphoreGive(CountingSemHandle);
if(err == pdFALSE)
printf("Semaphore Give failed!\r\n");
else{
sem_value = uxSemaphoreGetCount(CountingSemHandle);
printf("Semaphore Give successed, Semvalue = %d\r\n",sem_value);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_0,GPIO_PIN_SET);
}
break;
}
}
osDelay(10);
}
}