On Aug 13, 2008, at 7:39 PM, Varun Jain wrote:

> Hi,
>
> I am trying to use Resource interface to arbitrate between CC2420  
> and another SPI slave device. I am doing as follows:
>
>
>
>
>
> /* TestLedScreenC.nc
>
> ** Display messages received from the BaseStation on an SPI enabled  
> LED screen
>
> */
>
> uses interface Timer<TMilli> as Timer1;
>
> uses interface SpiPacket;
>
> uses interface Resource as LedResource;
>
>
>
> uint8_t buff[] = {0xfc, 0x60, 0xda, 0xf2, 0x66, 0xb6}; // Data to  
> be sent over the SPI bus
>
>
>
> /* Request the resource every second */
>
> event void Timer1.fired() {
>
>                 call LedResource.request();
>
>                 call Leds.led2Toggle();
>
>   }
>
>
>
>  /* If the resource is granted then send a Packet over the SPI bus */
>
>   event void LedResource.granted() {
>
>                 call SpiPacket.send(buff, NULL, sizeof(buff));
>
>   }
>
>
>
>   /* Signal ‘senddone’ when the packet is successfully sent */
>
>   async event void SpiPacket.sendDone(uint8_t* txBuffer, uint8_t*  
> rxBuffer, uint16_t length, error_t ok ) {
>
>                 if (ok == SUCCESS) {
>
>                                 call Leds.led0Toggle();
>
>                                 call LedResource.release();
>
>                 }
>
>   }
>
>
>
> enum {
>
>     CLIENT_ID = unique( "LedSpi.Resource" ),
>
> };
>
>
>
> components new TimerMilliC();
>
>   TestLedScreenC.Timer1 -> TimerMilliC;
>
>
>
>   components Atm128SpiC as LedPacket;
>
>   TestLedScreenC.SpiPacket -> LedPacket.SpiPacket;
>
>   TestLedScreenC.LedResource -> LedPacket.Resource[CLIENT_ID];
>
>
>
>
>
> I add the above code to any application which is operating with the  
> CC2420 every few seconds, i.e the nodes are receiving data from the  
> BaseStation every few seonds, for example, TestDissemination. The  
> problem I am facing is that once I add the above code, it does not  
> appear to work correctly, the LEDS start toggling at undefined  
> intervals (indicating the senddone’s being implemented  
> erratically). I am believing its an “arbitration” issue and I am  
> not able to grab the SPI bus at the correct time and it probably  
> interferes with the CC2420 (which is connected via SPI as well). I  
> understand that the SPI bus gets released if the CC2420 is not  
> active so I should be able to grab the SPI bus every second for  
> external device but it appears that I am not able to send anything  
> on Radio at all.
>
>
>
> Am I missing something, do I need to do something more to arbitrate??
>
>
>
> I hope I was able to explain the issues, if not, please mail back  
> and I will try to explain again whatever you do not understand
>

Use the key "Atm128SpiC.Resource" rather than "LedSpi.Resource".

Phil
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to