You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
41 lines
1.2 KiB
void peredat ()
|
|
{
|
|
static uint8_t payload[NRF_PAYLOAD_LENGTH];
|
|
strcpy((char*)payload, test_data);
|
|
nrf24l01p_write_tx_payload(payload, sizeof(payload));
|
|
|
|
digitalWrite(NRF_CE_PIN, HIGH);
|
|
delay(1);
|
|
digitalWrite(NRF_CE_PIN, LOW);
|
|
|
|
do {} while (!(nrf24l01p_get_irq_flags() & (1 << NRF24L01P_IRQ_TX_DS)));
|
|
nrf24l01p_clear_irq_flag(NRF24L01P_IRQ_TX_DS);
|
|
}
|
|
|
|
void nrf_init(uint8_t *address)
|
|
{
|
|
delay(200);
|
|
|
|
nrf24l01p_get_clear_irq_flags();
|
|
nrf24l01p_close_pipe(NRF24L01P_ALL);
|
|
nrf24l01p_open_pipe(NRF24L01P_TX, false);
|
|
nrf24l01p_set_rx_payload_width(NRF24L01P_PIPE0, NRF_PAYLOAD_LENGTH);
|
|
nrf24l01p_set_crc_mode(NRF24L01P_CRC_16BIT);
|
|
nrf24l01p_set_address_width(NRF24L01P_AW_5BYTES);
|
|
nrf24l01p_set_address(NRF24L01P_TX, address);
|
|
nrf24l01p_set_operation_mode(NRF24L01P_PTX);
|
|
nrf24l01p_set_rf_channel(NRF_CHANNEL);
|
|
|
|
nrf24l01p_set_power_mode(NRF24L01P_PWR_UP);
|
|
delay(NRF_POWER_UP_DELAY);
|
|
}
|
|
|
|
void nrf24l01p_spi_ss(nrf24l01p_spi_ss_level_t level)
|
|
{
|
|
digitalWrite(SPI_SS_PIN, (level == NRF24L01P_SPI_SS_LOW ? LOW : HIGH));
|
|
}
|
|
|
|
uint8_t nrf24l01p_spi_rw(uint8_t value)
|
|
{
|
|
return SPI.transfer(value);
|
|
}
|
|
|