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:
parent
23f4f9be73
commit
a2d790c924
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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)
|
||||
* @{
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user