extern void Nrf24l::getData(uint8_t * data) // Reads payload bytes into data array //读RX 有效数据:1-32 字节。读操作全部从字节0 开始。当读RX //有效数据完成后,FIFO 寄存器中有效数据被清除。 //应用于接收模式下。 { csnLow(); // Pull down chip select spi->transfer( R_RX_PAYLOAD ); // Send cmd to read rx payload transferSync(data,data,payload); // Read payload csnHi(); // Pull up chip select // NVI: per product spec, p 67, note c: // "The RX_DR IRQ is asserted by a new packet arrival event. The procedure // for handling this interrupt should be: 1) read payload through SPI, // 2) clear RX_DR IRQ, 3) read FIFO_STATUS to check if there are more // payloads available in RX FIFO, 4) if there are more data in RX FIFO, // repeat from step 1)." // So if we're going to clear RX_DR here, we need to check the RX FIFO // in the dataReady() function // NVI:每个产品的规格,第67页,注三: //“的RX_DR IRQ是断言一个新的数据包到达事件的过程 //处理这个中断应该是:1)通过SPI读取有效负载, //2)明确RX_DR IRQ,3)读FIFO_STATUS,以检查是否有更多的 //在RX FIFO中可用的有效载荷,4)如果在RX FIFO更多的数据, //重复从步骤1开始)。“ //所以,如果我们要在这里清除RX_DR,我们需要检查RX FIFO //在dataReady()函数 configRegister(STATUS,(1<<RX_DR)); // Reset status register }
void Nrf24l::readRegister(uint8_t reg, uint8_t * value, uint8_t len) // Reads an array of bytes from the given start position in the MiRF registers. { csnLow(); spi->transfer(R_REGISTER | (REGISTER_MASK & reg)); transferSync(value,value,len); csnHi(); }
extern void Nrf24l::getData(uint8_t * data) // Reads payload bytes into data array { csnLow(); // Pull down chip select spi->transfer( R_RX_PAYLOAD ); // Send cmd to read rx payload transferSync(data,data,payload); // Read payload csnHi(); // Pull up chip select // NVI: per product spec, p 67, note c: // "The RX_DR IRQ is asserted by a new packet arrival event. The procedure // for handling this interrupt should be: 1) read payload through SPI, // 2) clear RX_DR IRQ, 3) read FIFO_STATUS to check if there are more // payloads available in RX FIFO, 4) if there are more data in RX FIFO, // repeat from step 1)." // So if we're going to clear RX_DR here, we need to check the RX FIFO // in the dataReady() function configRegister(STATUS,(1<<RX_DR)); // Reset status register }