Hi Sarfraz,
You should NOT use the HplRF230C.SpiResource interface, because that
is used internally by the RF230 driver which automatically releases it
if it does not need it. You need your own SpiInterface with your own
ID, so you can properly share the SPI bus (via the resource
allocation) with the RF230 driver: So use:
SpiResource = SpiC.Resource[unique("Atm128SpiC.Resource")];
This interface will arbitrate access to the SPI bus for you. Once
access is granted, you need to toggle the slave select line for the
RF230 chip and use the SpiByte interface to read/write data. For this
you can use the SELN and SpiByte interfaces provided by the HplRF230C,
since those can be safely shared between clients (no events). The
HplRF230 interface is a faster SpiByte interface, you can use that one
as well. Then your register access would become:
inline uint8_t readRegister(uint8_t reg)
{
ASSERT( call SpiResource.isOwner() );
ASSERT( reg == (reg & RF230_CMD_REGISTER_MASK) );
call SELN.clr();
call HplRF230.spiSplitWrite(RF230_CMD_REGISTER_READ | reg);
call HplRF230.spiSplitReadWrite(0);
reg = call HplRF230.spiSplitRead();
call SELN.set();
return reg;
}
By the way, which register do you want to access?
Miklos
On Mon, May 19, 2008 at 5:44 AM, Sarfraz Nawaz <[EMAIL PROTECTED]> wrote:
> Hello everyone,
>
> I am trying to use the SPI bus of Atm1281 to peek into some of the registers
> of RF230 radio chip from one of my components. I am using the SpiResource
> provided by HplRF230C to request access to the SPI bus. The
> SpiResource.granted event is signaled but it seems that the SPI bus is not
> initialized. The SpiResource.isOwner method also returns false. See the code
> snippets at the end of this email.
>
> My question is that, why is the SPI bus not properly initialized and why
> does the SpiResource.isOwner return false even though the
> SpiResource.granted event has been signaled? Do I need to initialize the SPI
> bus myself? I think the resource arbiter should initialize the bus. Any help
> or pointers would be much appreciated.
>
>
> Regards
>
>
>
> In my application configuration I have
>
> App.SpiResource -> HplRF230C.SpiResource;
>
> and in the module implementation I have
>
> module TestRF230SpiM {
> uses {
> interface Boot;
> interface Leds;
> interface Resource as SpiResource;
> interface SplitControl as RadioControl;
> interface Atm128Spi as SpiBus;
> }
> }
>
>
> event void RadioControl.startDone(error_t error) {
> if(error==SUCCESS)
> call SpiResource.request();
> else
> call RadioControl.start();
> }
>
> event void SpiResource.granted() {
> if( call SpiResource.isOwner() ){
> call Leds.led1On();
>
> if( call SpiBus.isSpiEnabled() )
> call Leds.led2On();
> }
> else{
> call Leds.led0On();
> call SpiResource.immediateRequest();
> }
> }
>
> I can see the led0 go on but not the others.
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help