Stuck with semaphore compiler errors

tcomins wrote on Wednesday, July 08, 2009:

I’m getting two compiler errors due to the use of semaphores that I can’ t figure out - details below.

I’m compiling for an NXP LPC-2103 ARM7-TDMI micro using:

- FreeRTOS V5.3.0
- Eclipse Ganeymeded V3.4.2
- Zylin Embedded CDT V4.6.1
- YAGARTO
     binutils: 2.19.1
     gcc:      4.3.3
     newlib:   1.17.0
     gdb:      6.8.50-20080308-cvs

I’m trying to use semaphores to implement deferred interrupt processing. I have:

- an init function called from main.c that creates the semaphore…

        vSemaphoreCreateBinary( xI2CSemaphore );

- an isr wrapper and an isr
- the isr "gives" the semaphore

        xSemaphoreGiveFromISR(xI2CSemaphore, &xI2CSemaphoreWokeTask);

- a task "takes" the semaphore

        if (xSemaphoreTake(xI2CSemaphore, (portTickType) 1) == pdTRUE) {

I have the init function and the task in a common .c file that includes a global variable definition for the semaphore handle

        xSemaphoreHandle xI2CSemaphore = NULL;

The isr wrapper and isr are in another .c file that includes an external global variable reference

        extern xSemaphoreHandle xI2CSemaphore;

I get the following errors:

PROJECT/i2cISR.c:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘xI2CSemaphore’
PROJECT/i2cISR.c: In function ‘vI2C_ISR’:
PROJECT/i2cISR.c:74: error: ‘xI2CSemaphore’ undeclared (first use in this function)

I’m stuck. Any help is appreciated!

TC

aturowski wrote on Wednesday, July 08, 2009:

Compiler doesn’t understand, what xSemaphoreHandle  means. Propably you forgot to include “semphr.h” file in header, where your

extern xSemaphoreHandle xI2CSemaphore;

is.

Regards,
Adam

tcomins wrote on Wednesday, July 08, 2009:

That was it. I figured I was leaving out something obvious but I just couldn’t figure it out.

Thanks for the help!

TC