示例#1
0
文件: nRF24.c 项目: aczid/jxd393_dev
// Write new value to register
// input:
//   reg - register number
//   value - new value
// output: nRF24L01 status
uint8_t nRF24_RWReg(uint8_t reg, uint8_t value) {
    uint8_t status;

    CSN_L();
    status = nRF24_ReadWrite(reg); // Select register
    nRF24_ReadWrite(value); // Write value to register
    CSN_H();

    return status;
}
示例#2
0
文件: nRF24.c 项目: aczid/jxd393_dev
// Send buffer to nRF24L01
// input:
//   reg - register number
//   pBuf - pointer to buffer
//   count - bytes count
// output: nRF24L01 status
uint8_t nRF24_WriteBuf(uint8_t reg, uint8_t *pBuf, uint8_t count) {
    uint8_t status,i;

    CSN_L();
    status = nRF24_ReadWrite(reg);
    for (i = 0; i < count; i++) nRF24_ReadWrite(*pBuf++);
    CSN_H();

    return status;
}
示例#3
0
文件: nRF24.c 项目: aczid/jxd393_dev
// Read nRF24L01 register
// input:
//   reg - register number
// output: register value
uint8_t nRF24_ReadReg(uint8_t reg) {
    uint8_t value;

    CSN_L();
    nRF24_ReadWrite(reg);
    value = nRF24_ReadWrite(0);
    CSN_H();

    return value;
}
示例#4
0
文件: nRF24.c 项目: aczid/jxd393_dev
// Get data from nRF24L01 into buffer
// input:
//   reg - register number
//   pBuf - pointer to buffer
//   count - bytes count
// output: nRF24L01 status
uint8_t nRF24_ReadBuf(uint8_t reg, uint8_t *pBuf, uint8_t count) {
    uint8_t status,i;

    CSN_L();
    status = nRF24_ReadWrite(reg);
    for (i = 0; i < count; i++) pBuf[i] = nRF24_ReadWrite(0);
    CSN_L();

    return status;
}
示例#5
0
uint8_t nRF24_RXPacket(uint8_t* pBuf, uint8_t RX_PAYLOAD) {
	uint8_t status;

    status = nRF24_ReadReg(nRF24_REG_STATUS); // Read status register
    if (status & nRF24_MASK_RX_DR) {
    	if ((status & 0x0E) == 0) {
    		// pipe 0
    		nRF24_ReadBuf(nRF24_CMD_R_RX_PAYLOAD,pBuf,RX_PAYLOAD); // read received payload from RX FIFO buffer
    	}
		nRF24_ReadWrite(nRF24_CMD_FLUSH_RX); // Flush RX FIFO buffer
		nRF24_RWReg(nRF24_CMD_WREG | nRF24_REG_STATUS,status | 0x70); // Clear RX_DR, TX_DS, MAX_RT flags
	    //return nRF24_MASK_RX_DR;
	    return status;
    }

    // Some banana happens
	nRF24_ReadWrite(nRF24_CMD_FLUSH_RX); // Flush RX FIFO buffer
	nRF24_RWReg(nRF24_CMD_WREG | nRF24_REG_STATUS,status | 0x70); // Clear RX_DR, TX_DS, MAX_RT flags
    return status;
}