mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
nrf52840: adapt to Radio HAL changes
This commit is contained in:
parent
9dce6eba14
commit
4cfe62fc99
@ -91,6 +91,7 @@ static struct {
|
|||||||
bool cca_send : 1; /**< whether the next transmission uses CCA or not */
|
bool cca_send : 1; /**< whether the next transmission uses CCA or not */
|
||||||
bool ack_filter : 1; /**< whether the ACK filter is activated or not */
|
bool ack_filter : 1; /**< whether the ACK filter is activated or not */
|
||||||
bool promisc : 1; /**< whether the device is in promiscuous mode or not */
|
bool promisc : 1; /**< whether the device is in promiscuous mode or not */
|
||||||
|
bool pending : 1; /**< whether there pending bit should be set in the ACK frame or not */
|
||||||
} cfg = {
|
} cfg = {
|
||||||
.cca_send = true,
|
.cca_send = true,
|
||||||
.ack_filter = true,
|
.ack_filter = true,
|
||||||
@ -431,6 +432,11 @@ static void _timer_cb(void *arg, int chan)
|
|||||||
|
|
||||||
if (chan == MAC_TIMER_CHAN_ACK) {
|
if (chan == MAC_TIMER_CHAN_ACK) {
|
||||||
/* Copy sqn */
|
/* Copy sqn */
|
||||||
|
ack[1] = IEEE802154_FCF_TYPE_ACK;
|
||||||
|
if (cfg.pending) {
|
||||||
|
ack[1] |= IEEE802154_FCF_FRAME_PEND;
|
||||||
|
}
|
||||||
|
|
||||||
ack[3] = rxbuf[3];
|
ack[3] = rxbuf[3];
|
||||||
|
|
||||||
NRF_RADIO->PACKETPTR = (uint32_t) &ack;
|
NRF_RADIO->PACKETPTR = (uint32_t) &ack;
|
||||||
@ -517,7 +523,7 @@ void isr_radio(void)
|
|||||||
case STATE_RX:
|
case STATE_RX:
|
||||||
if (NRF_RADIO->CRCSTATUS) {
|
if (NRF_RADIO->CRCSTATUS) {
|
||||||
bool l2filter_passed = _l2filter(rxbuf+1);
|
bool l2filter_passed = _l2filter(rxbuf+1);
|
||||||
bool is_auto_ack_en = ack[1];
|
bool is_auto_ack_en = !IS_ACTIVE(CONFIG_IEEE802154_AUTO_ACK_DISABLE);
|
||||||
bool is_ack = rxbuf[1] & IEEE802154_FCF_TYPE_ACK;
|
bool is_ack = rxbuf[1] & IEEE802154_FCF_TYPE_ACK;
|
||||||
bool ack_req = rxbuf[1] & IEEE802154_FCF_ACK_REQ;
|
bool ack_req = rxbuf[1] & IEEE802154_FCF_ACK_REQ;
|
||||||
|
|
||||||
@ -699,26 +705,41 @@ int _set_cca_mode(ieee802154_dev_t *dev, ieee802154_cca_mode_t mode)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _set_hw_addr_filter(ieee802154_dev_t *dev, const network_uint16_t *short_addr,
|
static int _config_addr_filter(ieee802154_dev_t *dev, ieee802154_af_cmd_t cmd, const void *value)
|
||||||
const eui64_t *ext_addr, const uint16_t *pan_id)
|
|
||||||
{
|
{
|
||||||
(void) dev;
|
(void) dev;
|
||||||
if (short_addr) {
|
const uint16_t *pan_id = value;
|
||||||
memcpy(nrf802154_short_addr, short_addr, IEEE802154_SHORT_ADDRESS_LEN);
|
switch(cmd) {
|
||||||
}
|
case IEEE802154_AF_SHORT_ADDR:
|
||||||
|
memcpy(nrf802154_short_addr, value, IEEE802154_SHORT_ADDRESS_LEN);
|
||||||
if (ext_addr) {
|
break;
|
||||||
memcpy(nrf802154_long_addr, ext_addr, IEEE802154_LONG_ADDRESS_LEN);
|
case IEEE802154_AF_EXT_ADDR:
|
||||||
}
|
memcpy(nrf802154_long_addr, value, IEEE802154_LONG_ADDRESS_LEN);
|
||||||
|
break;
|
||||||
if (pan_id) {
|
case IEEE802154_AF_PANID:
|
||||||
nrf802154_pan_id = *pan_id;
|
nrf802154_pan_id = *pan_id;
|
||||||
|
break;
|
||||||
|
case IEEE802154_AF_PAN_COORD:
|
||||||
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _set_rx_mode(ieee802154_dev_t *dev, ieee802154_rx_mode_t mode)
|
static int _config_src_addr_match(ieee802154_dev_t *dev, ieee802154_src_match_t cmd, const void *value)
|
||||||
|
{
|
||||||
|
(void) dev;
|
||||||
|
switch(cmd) {
|
||||||
|
case IEEE802154_SRC_MATCH_EN:
|
||||||
|
cfg.pending = *((const bool*) value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -ENOTSUP;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _set_frame_filter_mode(ieee802154_dev_t *dev, ieee802154_filter_mode_t mode)
|
||||||
{
|
{
|
||||||
(void) dev;
|
(void) dev;
|
||||||
|
|
||||||
@ -726,21 +747,16 @@ static int _set_rx_mode(ieee802154_dev_t *dev, ieee802154_rx_mode_t mode)
|
|||||||
bool _promisc = false;
|
bool _promisc = false;
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case IEEE802154_RX_AACK_DISABLED:
|
case IEEE802154_FILTER_ACCEPT:
|
||||||
ack[1] = 0;
|
break;
|
||||||
break;
|
case IEEE802154_FILTER_PROMISC:
|
||||||
case IEEE802154_RX_AACK_ENABLED:
|
_promisc = true;
|
||||||
ack[1] = IEEE802154_FCF_TYPE_ACK;
|
break;
|
||||||
break;
|
case IEEE802154_FILTER_ACK_ONLY:
|
||||||
case IEEE802154_RX_AACK_FRAME_PENDING:
|
ackf = false;
|
||||||
ack[1] = IEEE802154_FCF_TYPE_ACK | IEEE802154_FCF_FRAME_PEND;
|
break;
|
||||||
break;
|
default:
|
||||||
case IEEE802154_RX_PROMISC:
|
return -ENOTSUP;
|
||||||
_promisc = true;
|
|
||||||
break;
|
|
||||||
case IEEE802154_RX_WAIT_FOR_ACK:
|
|
||||||
ackf = false;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.ack_filter = ackf;
|
cfg.ack_filter = ackf;
|
||||||
@ -800,7 +816,8 @@ static const ieee802154_radio_ops_t nrf802154_ops = {
|
|||||||
.set_cca_threshold = set_cca_threshold,
|
.set_cca_threshold = set_cca_threshold,
|
||||||
.set_cca_mode = _set_cca_mode,
|
.set_cca_mode = _set_cca_mode,
|
||||||
.config_phy = _config_phy,
|
.config_phy = _config_phy,
|
||||||
.set_hw_addr_filter = _set_hw_addr_filter,
|
|
||||||
.set_csma_params = _set_csma_params,
|
.set_csma_params = _set_csma_params,
|
||||||
.set_rx_mode = _set_rx_mode,
|
.config_addr_filter = _config_addr_filter,
|
||||||
|
.config_src_addr_match = _config_src_addr_match,
|
||||||
|
.set_frame_filter_mode = _set_frame_filter_mode,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user