asking
Full Member level 5
- Joined
- Sep 21, 2010
- Messages
- 279
- Helped
- 6
- Reputation
- 12
- Reaction score
- 6
- Trophy points
- 1,298
- Activity points
- 3,377
In the example code given below when i try to compile it i get error "datain = spi_transfer(dataout);" pointer required. Can anyone help whats wrong with this ?
Code:
/* software spi routine */
unsigned short spi_transfer(unsigned short tx)
{
unsigned short i = 0;
short int rs = 0;
nrf24_sck_digitalWrite(LOW);
for(i=0;i<8;i++)
{
if(tx & (1<<(7-i)))
{
nrf24_mosi_digitalWrite(HIGH);
}
else
{
nrf24_mosi_digitalWrite(LOW);
}
nrf24_sck_digitalWrite(HIGH);
rs = rs << 1;
if(nrf24_miso_digitalRead())
{
rs |= 0x01;
}
nrf24_sck_digitalWrite(LOW);
}
return rs;
}
/* send and receive multiple bytes over SPI */
void nrf24_transferSync(unsigned short dataout,unsigned short datain,unsigned short len)
{
unsigned int i;
for(i=0;i<len;i++)
{
[B]datain[i] = spi_transfer(dataout[i]);[/B]
}
}
//send multiple bytes over SPI
void nrf24_transmitSync(unsigned short dataout,unsigned short len)
{
unsigned int i;
for(i=0;i<len;i++)
{
spi_transfer(dataout[i]);
}
}