[Tinyos-devel] Re: I2C and SPI sharing

Max CORTIANA max.cortiana at st.com
Fri Oct 27 09:03:26 PDT 2006


Hi all,

after looooot of time, I got the problem.

So. Let's analyze module ArbiterP.nc

we have the command Resource.release.

  async command error_t Resource.release[uint8_t id]() {
    bool released = FALSE;
    //call Leds.led0Toggle();
    atomic {
      if(state == RES_BUSY && resId == id) {
        if(call Queue.isEmpty() == FALSE) {
          reqResId = call Queue.dequeue();
          state = RES_GRANTING;
          post grantedTask();
        }
        else {
          resId = CONTROLLER_ID;
          state = RES_CONTROLLED;
        }
        released = TRUE;
      }
      call Leds.led0On();
    }
    if(released == TRUE) {
      call ResourceConfigure.unconfigure[id]();
      if(resId == CONTROLLER_ID)
        signal ResourceController.granted();
      call Leds.led0Off();
      return SUCCESS;
    }
    call Leds.led0Off();
    return FAIL;
  }

For sake of simplicity, we could rewrite it like:

   async command error_t Resource.release[uint8_t id]() {
    bool released = FALSE;
    atomic {
       ...
       manage the queue
       ...
    }
       ...
       unconfigure the resource
       ...
  }

Suppose a module is using I2C and it release it at the end.
Suppose you are totally unlucky and the radio BackOff timer fires while 
the release is in the atomic session. BackOff procedures will run at the 
end of the atomic block.
When the atomic quits, the BackOff Timer calls the ImmediateRequest command.
ouch, it gets the control even if the resource is unconfigured.

- Max

Philip Levis wrote:
> On Oct 19, 2006, at 10:22 AM, Max CORTIANA wrote:
>
>> After few days, the same problem appears..
>> The line in Msp430SpiNoDmaP.nc:
>> while( !call Usart.isRxIntrPending() );
>> is endless.
>>
>> It happens after a read operation on I2C is finished, Resource is 
>> released and immediatly granted to SPI.
>
> Is there any update on this?
>
> Phil
>



More information about the Tinyos-devel mailing list