xSemaphore scope question SAM7_EMAC
In the lwIP 1.30 port with SAM7X, there are files:
"SAM7_EMAC.c"
"SAM7_EMAC_ISR.c"
There is the same variable defined local in both files: xSemaphore
/* The semaphore used by the EMAC ISR to wake the EMAC task. */
static xSemaphoreHandle xSemaphore = NULL;
It seems like this variable is suppose to handle the communication between the ISR and regular code. But since the variable is called out local in both, I don’t quite see how that could happen. Code from either module is going to access different variables.
Is this actually correct? If so I would recommend naming the two variables different to avoid confusion.
Chris.
xSemaphore scope question SAM7_EMAC
The semaphore is created in one file, then its value is passed into the other file during the initialization. Although there are two variables, they both hold the same value which is just a pointer to the semaphore structure.
xSemaphore scope question SAM7_EMAC
Thanks for the explanation. Seems like an odd way of doing things. In my port I think I will change this to declare the var global in emac.c, then extern in emac_isr.c, and eliminate the copy function. It wastes RAM to save 2 copies of the same var, and it wastes ROM on the copy function.
xSemaphore scope question SAM7_EMAC
I’m with you there. I think this code results from an anal aversion to using global variables.