Topic : Releasing a semaphore with FreeRTOS

Forum : Ride IDE

Original Post
Post Information Post
July 11, 2011 - 5:26pm
Guest

We are working and sharing code alongside another company which is using the IAR IDE. We are providing functions for the other company to use by providing an .elf file. This .elf file contains functions they are going to use and it is generated in Ride7. We've also given them absolute addresses of our functions so they can call our functions from our .elf file inside their code. In their code, they are using FreeRTOS and a semaphore which will be used as a flag to symbolize that an AtoD conversion has been completed. Because we handle the AtoD conversion in one of our functions, it is up to us to release the semaphore at the end of the conversion. However, the semaphore is property of their OS. Is it possible to access and release their semaphore from inside of our code? I know I can release the semaphore using the following command:
------------------------------------------------------------------------------------------
// DMA ISR triggered after all ADC done
void DMAChannel1_IRQHandler(void){

portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
if(DMA_GetITStatus(DMA1_IT_TC1) != RESET)
{
xSemaphoreGiveFromISR(xADC1Semaphore,&xHigherPriorityTaskWoken); // DMA ADC task completion flag to second task...
}
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
}
-------------------------------------------------------------------------------------------
which initiates the following in their code:
-------------------------------------------------------------------------------------------
// This task is run next after xADC1Semaphore is given from DMA ISR
void prvADC2_DsrTask( void *pvParameters )
{

( void ) pvParameters;

for( ;; )
{
xSemaphoreTake(xADC1Semaphore, portMAX_DELAY);
// Add Post ADC collection process here...
}
}
----------------------------------------------------------------------------------------------

So how do we access their semaphore?

Thanks,
-Aaron

Replies
Post Information Post
+1
0
-1
July 12, 2011 - 11:59am
Raisonance Support Team

Aaron,

The semaphore can be shared as a RAM object, then you can declare it as extern in your library and release it as usual.
Also the xSemaphoreGiveFromISR() function will have to be shared if necessary -but the best may perhaps be to just copy the source from FreeRTOS and plug it in your library source, so that you do not have any linker name collision).
There should not be any specific trick once you manage to share RAM objects between IAR and GCC.

I hope this helps.