drivers: ieee802154_nrf5: Handle RX timestamp
Obtain RX time from the radio driver. Fill the `net_pkt` with a timestamp if `NET_PKT_TIMESTAMP` is enabled. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
ee8a85e38f
commit
a4f704d2ec
2 changed files with 14 additions and 1 deletions
|
@ -110,6 +110,16 @@ static void nrf5_rx_thread(void *arg1, void *arg2, void *arg3)
|
||||||
net_pkt_set_ieee802154_lqi(pkt, rx_frame->lqi);
|
net_pkt_set_ieee802154_lqi(pkt, rx_frame->lqi);
|
||||||
net_pkt_set_ieee802154_rssi(pkt, rx_frame->rssi);
|
net_pkt_set_ieee802154_rssi(pkt, rx_frame->rssi);
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_PKT_TIMESTAMP)
|
||||||
|
struct net_ptp_time timestamp = {
|
||||||
|
.second = rx_frame->time / USEC_PER_SEC,
|
||||||
|
.nanosecond =
|
||||||
|
(rx_frame->time % USEC_PER_SEC) * NSEC_PER_USEC
|
||||||
|
};
|
||||||
|
|
||||||
|
net_pkt_set_timestamp(pkt, ×tamp);
|
||||||
|
#endif
|
||||||
|
|
||||||
LOG_DBG("Caught a packet (%u) (LQI: %u)",
|
LOG_DBG("Caught a packet (%u) (LQI: %u)",
|
||||||
pkt_len, rx_frame->lqi);
|
pkt_len, rx_frame->lqi);
|
||||||
|
|
||||||
|
@ -531,7 +541,8 @@ int nrf5_configure(struct device *dev, enum ieee802154_config_type type,
|
||||||
|
|
||||||
/* nRF5 radio driver callbacks */
|
/* nRF5 radio driver callbacks */
|
||||||
|
|
||||||
void nrf_802154_received_raw(uint8_t *data, int8_t power, uint8_t lqi)
|
void nrf_802154_received_timestamp_raw(uint8_t *data, int8_t power, uint8_t lqi,
|
||||||
|
uint32_t time)
|
||||||
{
|
{
|
||||||
for (u32_t i = 0; i < ARRAY_SIZE(nrf5_data.rx_frames); i++) {
|
for (u32_t i = 0; i < ARRAY_SIZE(nrf5_data.rx_frames); i++) {
|
||||||
if (nrf5_data.rx_frames[i].psdu != NULL) {
|
if (nrf5_data.rx_frames[i].psdu != NULL) {
|
||||||
|
@ -539,6 +550,7 @@ void nrf_802154_received_raw(uint8_t *data, int8_t power, uint8_t lqi)
|
||||||
}
|
}
|
||||||
|
|
||||||
nrf5_data.rx_frames[i].psdu = data;
|
nrf5_data.rx_frames[i].psdu = data;
|
||||||
|
nrf5_data.rx_frames[i].time = time;
|
||||||
nrf5_data.rx_frames[i].rssi = power;
|
nrf5_data.rx_frames[i].rssi = power;
|
||||||
nrf5_data.rx_frames[i].lqi = lqi;
|
nrf5_data.rx_frames[i].lqi = lqi;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
struct nrf5_802154_rx_frame {
|
struct nrf5_802154_rx_frame {
|
||||||
void *fifo_reserved; /* 1st word reserved for use by fifo. */
|
void *fifo_reserved; /* 1st word reserved for use by fifo. */
|
||||||
u8_t *psdu; /* Pointer to a received frame. */
|
u8_t *psdu; /* Pointer to a received frame. */
|
||||||
|
u32_t time; /* RX timestamp. */
|
||||||
u8_t lqi; /* Last received frame LQI value. */
|
u8_t lqi; /* Last received frame LQI value. */
|
||||||
s8_t rssi; /* Last received frame RSSI value. */
|
s8_t rssi; /* Last received frame RSSI value. */
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue