Hi, I have a nanopi neo based on allwinner h3 chipset. I am trying to use an SPIDEV based driver for RF2401L (2.4 Ghz wireless module). I have used npi-config to enable the /dev/spidev0.0 device. However, when I try to use it to read status register of my module, I get wrong values.
My SPI settings are
Speed: 10kHz
Bits: 8
Mode: 0 (CPOL=0, CPHA=0)
To debug the issue I used a logic analyzer and found the clock signal rising up just before the MISO/MOSI activity. It shouldn't do that. When CPOL = 0, clock should be idle at 0.

I am setting the SPI mode to 0. Here is the code
Please help me out!
My SPI settings are
Speed: 10kHz
Bits: 8
Mode: 0 (CPOL=0, CPHA=0)
To debug the issue I used a logic analyzer and found the clock signal rising up just before the MISO/MOSI activity. It shouldn't do that. When CPOL = 0, clock should be idle at 0.

I am setting the SPI mode to 0. Here is the code
Code: Select all
void SPI::init()
{
uint8_t bits = RF24_SPIDEV_BITS;
uint32_t speed = RF24_SPIDEV_SPEED;
uint8_t mode = 0;
int ret;
/*
* spi mode
*/
ret = ioctl(this->fd, SPI_IOC_WR_MODE, &mode);
if (ret == -1)
{
perror("can't set spi mode");
abort();
}
ret = ioctl(this->fd, SPI_IOC_RD_MODE, &mode);
if (ret == -1)
{
perror("can't set spi mode");
abort();
}
/*
* bits per word
*/
ret = ioctl(this->fd, SPI_IOC_WR_BITS_PER_WORD, &bits);
if (ret == -1)
{
perror("can't set bits per word");
abort();
}
ret = ioctl(this->fd, SPI_IOC_RD_BITS_PER_WORD, &bits);
if (ret == -1)
{
perror("can't set bits per word");
abort();
}
/*
* max speed hz
*/
ret = ioctl(this->fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed);
if (ret == -1)
{
perror("can't set max speed hz");
abort();
}
ret = ioctl(this->fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed);
if (ret == -1)
{
perror("can't set max speed hz");
abort();
}
}
Please help me out!