mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/nrf24l01p: change API and fix initial setup
This commit is contained in:
parent
bccc2e5d43
commit
e56b821774
@ -417,7 +417,7 @@ int nrf24l01p_get_status(nrf24l01p_t *dev);
|
||||
* @return 1 on success.
|
||||
* @return -1 on error.
|
||||
*/
|
||||
int nrf24l01p_set_power(nrf24l01p_t *dev, int *pwr);
|
||||
int nrf24l01p_set_power(nrf24l01p_t *dev, int pwr);
|
||||
|
||||
/**
|
||||
* @brief Get the transmit power for the nrf24l01+ transceiver device.
|
||||
|
@ -29,6 +29,7 @@ extern "C" {
|
||||
#define INITIAL_ADDRESS_WIDTH 5
|
||||
#define NRF24L01P_MAX_DATA_LENGTH 32
|
||||
#define INITIAL_RF_CHANNEL 5
|
||||
#define INITIAL_RX_POWER_0dB 0
|
||||
|
||||
#define DELAY_CS_TOGGLE_TICKS 2
|
||||
#define DELAY_AFTER_FUNC_TICKS 2
|
||||
|
@ -110,7 +110,7 @@ int nrf24l01p_init(nrf24l01p_t *dev, spi_t spi, gpio_t ce, gpio_t cs, gpio_t irq
|
||||
}
|
||||
|
||||
/* Flush RX FIFIO */
|
||||
status = nrf24l01p_flush_tx_fifo(dev);
|
||||
status = nrf24l01p_flush_rx_fifo(dev);
|
||||
|
||||
if (status < 0) {
|
||||
return status;
|
||||
@ -138,7 +138,7 @@ int nrf24l01p_init(nrf24l01p_t *dev, spi_t spi, gpio_t ce, gpio_t cs, gpio_t irq
|
||||
}
|
||||
|
||||
/* Set RF power */
|
||||
status = nrf24l01p_set_power(dev, 0);
|
||||
status = nrf24l01p_set_power(dev, INITIAL_RX_POWER_0dB);
|
||||
|
||||
if (status < 0) {
|
||||
return status;
|
||||
@ -647,32 +647,28 @@ int nrf24l01p_get_status(nrf24l01p_t *dev)
|
||||
return (int)status;
|
||||
}
|
||||
|
||||
int nrf24l01p_set_power(nrf24l01p_t *dev, int *pwr)
|
||||
int nrf24l01p_set_power(nrf24l01p_t *dev, int pwr)
|
||||
{
|
||||
char rf_setup;
|
||||
|
||||
nrf24l01p_read_reg(dev, REG_RF_SETUP, &rf_setup);
|
||||
|
||||
if (pwr == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (*pwr >= -3) {
|
||||
if (pwr >= -3) {
|
||||
rf_setup &= ~(3 << 1);
|
||||
rf_setup |= (NRF24L01P_PWR_0DBM << 1);
|
||||
}
|
||||
|
||||
if (*pwr < -3) {
|
||||
if (pwr < -3) {
|
||||
rf_setup &= ~(3 << 1);
|
||||
rf_setup |= (NRF24L01P_PWR_N6DBM << 1);
|
||||
}
|
||||
|
||||
if (*pwr < -9) {
|
||||
if (pwr < -9) {
|
||||
rf_setup &= ~(3 << 1);
|
||||
rf_setup |= (NRF24L01P_PWR_N12DBM << 1);
|
||||
}
|
||||
|
||||
if (*pwr < -15) {
|
||||
if (pwr < -15) {
|
||||
rf_setup &= ~(3 << 1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user