This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

cc2538 z-stack code critical section

Other Parts Discussed in Thread: Z-STACK

hi....i am using ti z-stack for home automation for my project purpose. while tracing out the sample switch program available with the stack, i came across the below code

#define HAL_ENTER_CRITICAL_SECTION(x) \
do { (x) = !IntMasterDisable(); } while (0)

in the sample code, the 'x' is declared as 'intstate' and has not been initialized. what will be the output of the above piece of code?? what is the significance of  "do-while" statement??

 

  • Hi,

    The do-while(0) statement is typically added to ensure that the code is not optimized out.

    IntMasterDisable() disables all interrupts. If I remember correctly, the return value reflects whether interrupts were initially disabled (returns true if interrupts were initially disabled and false if interrupts were initially enabled).

    Hope this helps.

    Br,
    TIABO

  • thank you for the reply!!!

    what does 

    events = (tasksArr[idx])( idx, events );

    mean??? i dont understand the syntax...

  • I don't know the z-stack code, but it looks like the tasksArr array contains function pointers, and the function signature takes two arguments (idx and events).

    So, events = tasksArr[idx]( idx, events); calls the function located in index idx of the tasksArr array. The function arguments are the idx, and events variables. The value returned by the function is stored in the events variable.

    Hope this helps!

    Br,
    TIABO