1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #10771 from Carton32/netopt_last_ed_level

drivers/mrf24j40 : support of NETOPT_LAST_ED_LEVEL
This commit is contained in:
Peter Kietzmann 2019-05-28 20:44:23 +02:00 committed by GitHub
commit da5f108479
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 5 deletions

View File

@ -169,14 +169,15 @@ void mrf24j40_setup(mrf24j40_t *dev, const mrf24j40_params_t *params);
void mrf24j40_reset(mrf24j40_t *dev);
/**
* @brief Trigger a clear channel assessment
* @brief Trigger a clear channel assessment & retrieve RSSI
*
* @param[in] dev device to use
* @param[in] rssi RSSI value from register in dBm
*
* @return true if channel is clear
* @return false if channel is busy
*/
bool mrf24j40_cca(mrf24j40_t *dev);
bool mrf24j40_cca(mrf24j40_t *dev, int8_t *rssi);
/**
* @brief Get the short address of the given device

View File

@ -336,6 +336,17 @@ extern "C" {
#define MRF24J40_GPIO_3 (0x08)
#define MRF24J40_GPIO_4 (0x10)
#define MRF24J40_GPIO_5 (0x20)
/**
* @name Bitfield definitions for the TRISGPIO register (0x34)
* @{
*/
#define MRF24J40_TRISGPIO_TRISGP5 (0x20)
#define MRF24J40_TRISGPIO_TRISGP4 (0x10)
#define MRF24J40_TRISGPIO_TRISGP3 (0x08)
#define MRF24J40_TRISGPIO_TRISGP2 (0x04)
#define MRF24J40_TRISGPIO_TRISGP1 (0x02)
#define MRF24J40_TRISGPIO_TRISGP0 (0x01)
/** @} */
/**

View File

@ -74,7 +74,7 @@ void mrf24j40_reset(mrf24j40_t *dev)
DEBUG("mrf24j40_reset(): reset complete.\n");
}
bool mrf24j40_cca(mrf24j40_t *dev)
bool mrf24j40_cca(mrf24j40_t *dev, int8_t *rssi)
{
uint8_t tmp_ccaedth;
uint8_t status;
@ -94,6 +94,9 @@ bool mrf24j40_cca(mrf24j40_t *dev)
/* return according to measurement */
tmp_ccaedth = mrf24j40_reg_read_short(dev, MRF24J40_REG_CCAEDTH); /* Energy detection threshold */
tmp_rssi = mrf24j40_reg_read_long(dev, MRF24J40_REG_RSSI);
if (rssi != NULL) {
*rssi = mrf24j40_dbm_from_reg(tmp_rssi);
}
mrf24j40_enable_auto_pa_lna(dev);

View File

@ -407,7 +407,6 @@ void mrf24j40_set_option(mrf24j40_t *dev, uint16_t option, bool state)
}
}
void mrf24j40_set_state(mrf24j40_t *dev, uint8_t state)
{
uint8_t old_state;

View File

@ -279,7 +279,7 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
break;
case NETOPT_IS_CHANNEL_CLR:
if (mrf24j40_cca(dev)) {
if (mrf24j40_cca(dev, NULL)) {
*((netopt_enable_t *)val) = NETOPT_ENABLE;
}
else {
@ -288,6 +288,16 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
res = sizeof(netopt_enable_t);
break;
case NETOPT_LAST_ED_LEVEL:
if (max_len < sizeof(int8_t)) {
res = -EOVERFLOW;
}
else {
mrf24j40_cca(dev, (int8_t *)val);
res = sizeof(int8_t);
}
break;
case NETOPT_CSMA_RETRIES:
if (max_len < sizeof(uint8_t)) {
res = -EOVERFLOW;
@ -307,6 +317,7 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
res = sizeof(int8_t);
}
break;
case NETOPT_TX_RETRIES_NEEDED:
if (max_len < sizeof(uint8_t)) {
res = -EOVERFLOW;