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

mrf24j40: Add tx_retries_needed netopt

This commit is contained in:
Koen Zandberg 2017-08-03 00:27:39 +02:00
parent 23f4f9be73
commit a2d790c924
3 changed files with 19 additions and 0 deletions

View File

@ -139,6 +139,7 @@ typedef struct {
uint8_t header_len; /**< length of the header */
uint8_t pending; /**< Flags for pending tasks */
uint8_t irq_flag; /**< Flags for IRQs */
uint8_t tx_retries; /**< Number of retries needed for last transmission */
} mrf24j40_t;
/**

View File

@ -267,6 +267,14 @@ extern "C" {
#define MRF24J40_TXSTAT_TXNSTAT (0x01)
/** @} */
/**
* @name Shift offsets for TXSTAT register (0x24)
* @{
*/
#define MRF24J40_TXSTAT_MAX_FRAME_RETRIES_SHIFT (6U)
#define MRF24J40_TXSTAT_CCAFAIL_SHIFT (5U)
/** @} */
/**
* @name Bitfield definitions for the SOFTRST register (0x2A)
* @{

View File

@ -319,6 +319,15 @@ 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;
}
else {
*((uint8_t *)val) = dev->tx_retries;
res = sizeof(int8_t);
}
break;
default:
/* try netdev settings */
@ -538,6 +547,7 @@ static void _isr(netdev_t *netdev)
#ifdef MODULE_NETSTATS_L2
if (netdev->event_callback && (dev->netdev.flags & MRF24J40_OPT_TELL_TX_END)) {
uint8_t txstat = mrf24j40_reg_read_short(dev, MRF24J40_REG_TXSTAT);
dev->tx_retries = (txstat >> MRF24J40_TXSTAT_MAX_FRAME_RETRIES_SHIFT);
/* transmision failed */
if (txstat & MRF24J40_TXSTAT_TXNSTAT) {
/* TX_NOACK - CCAFAIL */