sbit TRW_24G_CLK = P1^1;
sbit TRW_24G_DATA = P1^6;
sbit TRW_24G_CS = P1^2;
sbit TRW_24G_CE = P1^3;
sbit TRW_24G_DR1 = P1^4;
/* --------------------------------------------------------------------
Features: TRW-24G is written a BYTE (includes write the word with configuration information sent a BYTE)
------------------------------------------------------------------ */
void Write_TRW_24G_BYTE(x)
{
char i;
for(i=0;i<8;i++)
{
TRW_24G_CLK = 0; if(x&0x80) TRW_24G_DATA= 1;
else
TRW_24G_DATA= 0; x<<=1; TRW_24G_CLK = 1; TRW_24G_CLK = 1; TRW_24G_CLK = 1;
}
}
/* --------------------------------------------------------------------
Features: Reading a BYTE information from TRW-24G
----------------------------------------------------------------------*/
char Read_TRW_24G_BYTE(void)
{
char i,x;
for(i=0;i<8;i++)
{
TRW_24G_CLK = 0; TRW_24G_CLK = 0; TRW_24G_CLK = 0; TRW_24G_CLK = 1; x<<=1;
if(TRW_24G_DATA)
x|=0x01;
else
x|=0x00; } return(x);
}
/* --------------------------------------------------------------------
Features: TRW-24G configuration
-------------------------------------------------------------------- */
void Config_TRW_24G(void)
{
unsigned char i;
P1MDOUT |= 0x4E;
TRW_24G_CE = 0;
TRW_24G_CS = 1;
for(i=0;i<18;i++)
Write_TRW_24G_BYTE(RF_Buffer);
TRW_24G_CS = 0; if(RF_Status[0]&&(RF_Status[6]==1)) {
P1MDOUT &= 0xBD; P1 |= 0x42; TRW_24G_CE = 1;
}
}
/*--------------------------------------------------------------------
Function: The TRW-24G send a packet.
--------------------------------------------------------------------*/
void Send_TRW_24G(char x)
{
unsigned char i;
TRW_24G_CS = 0;
TRW_24G_CE = 1;
Write_TRW_24G_BYTE(0xF0);
Write_TRW_24G_BYTE(0xF0);
for(i=0;i<28;i++)
Write_TRW_24G_BYTE(x);
TRW_24G_CE = 0;
}
/* --------------------------------------------------------------------
Function: TRW-24G read out a packet
-------------------------------------------------------------------- */
char Receive_TRW_24G(void)
{
unsigned char i=0,RF_Data[30];
TRW_24G_CE = 1;
P1MDOUT &= 0xBF;
P1 |= 0x40;
TRW_24G_CLK = 0;
if(TRW_24G_DR1)
{
for(i=0;i<28;i++) RF_Data = Read_TRW_24G_BYTE();
i= RF_Data[4]; } return(i);
}
/////////////////////////////////////////////////////////
this is the sample code i googled from **broken link removed**
if u have any doubts regarding this u can get it from the above data sheet