This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

使用蓝牙1.3.2协议KeyFobDemo中的CMA3000d中的SPI读写函数,不能读取数据,求解?

Other Parts Discussed in Thread: CC2540

近来,将蓝牙1.3.2协议栈中中的KeyFobDemo例程中的CMA3000d传感器的读写SPI函数脱离出来,现在写数据正常,但是读数据不能读取,请教一下这个是什么原因呢,SPI的操作代码如下:

void spiInit(void)

{

     PERCFG |= 0x02;//USE SPI1

     P1SEL |= 0xE0;

     P1SEL &= (1<<4);//P1_4 is GPIO

     P1DIR |= 0x10;

     U1UR = 0x80;

     U1CSR = 0x00;

     U1GCR = 0x2F;

     U1BAUD = 0x00;

}

void spiWriteByte(unsigned char byte)

{

    U1CSR &= ~0x02;

    U1DBUF = byte;

    while(!(U1CSR & 0x02));

}

unsigned char spiReadByte(void)

{

   U1CSR &= ~0x02;

   U1DBUF = 0xff;

   while(!(U1CSR & 0x02));

  return U1DBUF;

}

现在写SPI是正常的,但是读取SPI不能读取到数据,我有一个疑问,为什么在读取数据之前要先向SPI中发送一个0xff,请使用过CC2540 SPI的大神指导一下。