basugouda wrote on Friday, May 31, 2019:
Thank you for your reply
I was trying to unblock two tasks which are using one semaphore,
Both the tasks are ISR based. I am not sure whether this is right way to do using a single semaphore for two ISR based tasks.
void uart_data(void *p){
while(1){
xSemaphoreTake( xBinarySemaphore,portMAX_DELAY );
MAP_UART_transmitData(EUSCI_A0_BASE, MAP_UART_receiveData(EUSCI_A0_BASE));
}
}
void led_t(void *p){
while(1){
xSemaphoreTake( xBinarySemaphore,portMAX_DELAY );
MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P2,GPIO_PIN1);
}
}
void EUSCIA0_IRQHandler(void)
{
BaseType_t checkIfYieldRequired = pdFALSE;
uint32_t status = MAP_UART_getEnabledInterruptStatus(EUSCI_A0_BASE);
MAP_UART_clearInterruptFlag(EUSCI_A0_BASE, status);
if(status & EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG)
{
xSemaphoreGiveFromISR( xBinarySemaphore, &checkIfYieldRequired );
portYIELD_FROM_ISR(checkIfYieldRequired);
}
}
void PORT1_IRQHandler(void)
{
BaseType_t checkIfYieldRequired1 = pdFALSE;
uint32_t status = MAP_GPIO_getEnabledInterruptStatus(GPIO_PORT_P1);
MAP_GPIO_clearInterruptFlag(GPIO_PORT_P1, status);
if(status & GPIO_PIN1)
{
xSemaphoreGiveFromISR( xBinarySemaphore, &checkIfYieldRequired1 );
portYIELD_FROM_ISR(checkIfYieldRequired1);
}
}
int main(void){
//xBinarySemaphore=xSemaphoreCreateBinary();
xBinarySemaphore=xSemaphoreCreateCounting;
hw_init();
xTaskCreate(toggle_led_red,“toggle_led”,20,(void *)0,tskIDLE_PRIORITY,&led_red);
if(xBinarySemaphore!=NULL){
xTaskCreate(uart_data,“UART”,200,(void *)0,tskIDLE_PRIORITY,&UART);
xTaskCreate(led_t,“LED”,200,(void *)0,tskIDLE_PRIORITY,&led);
vTaskStartScheduler();
}
while(1){}
}