#define PAYLOAD_SIZE 16 /* number of payload bytes, 0 to 32 bytes */
#define CHANNEL_NO 44 /* communication channel *
//static const uint8_t TADDR[5] = {0x0F, 0x0F, 0x0F, 0x0F, 0xD2}; /* device address */
static const uint8_t TADDR[5] = {0x0F, 0x0F, 0x0F, 0x0F, 0xE1}; /* device address */
static uint8_t payload[PAYLOAD_SIZE]; /* buffer for payload */
void APP_Run(void) {
int i, cntr;
uint8_t status;
WAIT1_Waitms(100); /* give device time to power up */
RF_Init(); /* set CE and CSN to initialization value */
RF_WriteRegister(RF24_RF_SETUP, RF24_RF_SETUP_RF_PWR_0|RF24_RF_SETUP_RF_DR_1000);
RF_WriteRegister(RF24_RX_PW_P0, PAYLOAD_SIZE); /* number of payload bytes we want to send and receive */
RF_WriteRegister(RF24_RF_CH, CHANNEL_NO); /* set channel */
/* Set RADDR and TADDR as the transmit address since we also enable auto acknowledgment */
RF_WriteRegisterData(RF24_RX_ADDR_P0, (uint8_t*)TADDR, sizeof(TADDR));
RF_WriteRegisterData(RF24_TX_ADDR, (uint8_t*)TADDR, sizeof(TADDR));
/* Enable RX_ADDR_P0 address matching */
RF_WriteRegister(RF24_EN_RXADDR, RF24_EN_RXADDR_ERX_P0); /* hoping that P0 is enabled */
/* clear interrupt flags */
RF_ResetStatusIRQ(RF24_STATUS_RX_DR|RF24_STATUS_TX_DS|RF24_STATUS_MAX_RT);
RF_WriteRegister(RF24_EN_AA, RF24_EN_AA_ENAA_P0); /* enable auto acknowledge. RX_ADDR_P0 needs to be equal to TX_ADDR! */
RF_WriteRegister(RF24_SETUP_RETR, RF24_SETUP_RETR_ARD_1500|RF24_SETUP_RETR_ARC_15); /* Important: need 750 us delay between every retry */
RF_WriteRegister(RF24_CONFIG, RF24_EN_CRC|RF24_CRCO|RF24_PWR_UP|RF24_PRIM_TX); /* enable 1 byte CRC, power up and set as PTX */ /* Power up in transmitting mode */
CE_ClrVal(); /* Will pulse this later to send data */
cntr = 0;
for(;;) { // while(true)
cntr++;
if (cntr == 3000) { /* send data every 3000 ms */
cntr = 0;
RED_LED_SetVal();
for(i = 0; i < PAYLOAD_SIZE; i++) { // populate payload
payload[i] = i + 1;
}
RF_TxPayload(payload, sizeof(payload)); /* send data */
RED_LED_ClrVal();
}
if (isrFlag) { /* check if we have received an interrupt */
//APP_BlinkNTimesEachTMS(1, 400, 0);
isrFlag = FALSE; /* reset interrupt flag */
status = RF_GetStatus();
if (status&RF24_STATUS_RX_DR) { /* data received interrupt */
RF_ResetStatusIRQ(RF24_STATUS_RX_DR); /* clear bit */
}
if (status&RF24_STATUS_TX_DS) { /* data sent interrupt */
cntr = 0; /* reset timeout counter */
RED_LED_ClrVal(); /* indicate data has been sent */
RF_ResetStatusIRQ(RF24_STATUS_TX_DS); /* clear bit */
}
if (status&RF24_STATUS_MAX_RT) { /* retry timeout interrupt */
RF_ResetStatusIRQ(RF24_STATUS_MAX_RT); /* clear bit */
}
}
WAIT1_Waitms(1);
}
}
if (status&RF24_STATUS_MAX_RT) { /* retry timeout interrupt */
I dont really know what I'm doing wrong.