1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-24 14:03:55 +01:00

Merge pull request #11146 from bergzand/pr/nrf802154/fix_ifs

nrf802154: Fix IFS timings
This commit is contained in:
Semjon Kerner 2019-03-15 14:02:24 +01:00 committed by GitHub
commit 7820a78d42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,7 +68,7 @@ static uint8_t txbuf[IEEE802154_FRAME_LEN_MAX + 3]; /* len PHR + PSDU + LQI */
#define LIFS (40U)
#define SIFS (12U)
#define SIFS_MAXPKTSIZE (18U)
#define TIMER_FREQ (250000UL)
#define TIMER_FREQ (62500UL)
static volatile uint8_t _state;
static mutex_t _txlock;
@ -189,7 +189,6 @@ static void _timer_cb(void *arg, int chan)
(void)chan;
mutex_unlock(&_txlock);
timer_stop(NRF802154_TIMER);
timer_clear(NRF802154_TIMER, 0);
}
static int _init(netdev_t *dev)
@ -199,6 +198,7 @@ static int _init(netdev_t *dev)
int result = timer_init(NRF802154_TIMER, TIMER_FREQ, _timer_cb, NULL);
assert(result >= 0);
(void)result;
timer_stop(NRF802154_TIMER);
/* initialize local variables */
mutex_init(&_txlock);
@ -232,6 +232,9 @@ static int _init(netdev_t *dev)
NRF_RADIO->CRCPOLY = 0x011021;
NRF_RADIO->CRCINIT = 0;
/* Disable the hardware IFS handling */
NRF_RADIO->MODECNF0 |= RADIO_MODECNF0_RU_Msk;
/* assign default addresses */
luid_get(nrf802154_dev.long_addr, IEEE802154_LONG_ADDRESS_LEN);
memcpy(nrf802154_dev.short_addr, &nrf802154_dev.long_addr[6],
@ -285,7 +288,7 @@ static int _send(netdev_t *dev, const iolist_t *iolist)
/* set interframe spacing based on packet size */
unsigned int ifs = (len + IEEE802154_FCS_LEN > SIFS_MAXPKTSIZE) ? LIFS
: SIFS;
timer_set_absolute(NRF802154_TIMER, 0, ifs);
timer_set(NRF802154_TIMER, 0, ifs);
return len;
}