Skip to content

Commit 5f40089

Browse files
committed
nimble/ll: Introduce Rx end early callback
This adds Rx end early callback that is called before scheduled PHY transition. This allows user to e.g. prepare CCM for next Rx.
1 parent e5ea1fa commit 5f40089

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

nimble/controller/include/controller/ble_ll.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,9 @@ int ble_ll_rx_start(uint8_t *rxbuf, uint8_t chan, struct ble_mbuf_hdr *hdr);
581581
/* Called by the PHY when a packet reception ends */
582582
int ble_ll_rx_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr);
583583

584+
/* Called by the PHY when a packet reception ends */
585+
int ble_ll_rx_early_end(const uint8_t *rxbuf, const struct ble_mbuf_hdr *rxhdr);
586+
584587
/* Helper callback to tx mbuf using ble_phy_tx() */
585588
uint8_t ble_ll_tx_mbuf_pducb(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte);
586589
uint8_t ble_ll_tx_flat_mbuf_pducb(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte);

nimble/controller/src/ble_ll.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,30 @@ ble_ll_rx_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr)
13051305
return rc;
13061306
}
13071307

1308+
/**
1309+
* Early callback called by the PHY when a packet reception has ended.
1310+
*
1311+
* NOTE: Called from interrupt context!
1312+
* Avoid time-consuming operations, such as buffer copying or memory allocation.
1313+
*
1314+
* @param rxbuf Pointer to received PDU data
1315+
* rxhdr Pointer to BLE header of received mbuf
1316+
*
1317+
* @return int
1318+
* < 0: Disable the phy after reception.
1319+
* == 0: Success. Do not disable the PHY.
1320+
* > 0: Do not disable PHY as that has already been done.
1321+
*/
1322+
int
1323+
ble_ll_rx_early_end(const uint8_t *rxbuf, const struct ble_mbuf_hdr *rxhdr)
1324+
{
1325+
int rc = 0;
1326+
1327+
/* TODO */
1328+
1329+
return rc;
1330+
}
1331+
13081332
uint8_t
13091333
ble_ll_tx_mbuf_pducb(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte)
13101334
{

nimble/drivers/nrf5x/src/ble_phy.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,19 @@ ble_phy_rx_end_isr(void)
13591359
#endif
13601360
}
13611361

1362+
/*
1363+
* XXX: This is a horrible ugly hack to deal with the RAM S1 byte
1364+
* that is not sent over the air but is present here. Simply move the
1365+
* data pointer to deal with it. Fix this later.
1366+
*/
1367+
dptr[2] = dptr[1];
1368+
dptr[1] = dptr[0];
1369+
rc = ble_ll_rx_early_end(dptr + 1, ble_hdr);
1370+
if (rc < 0) {
1371+
ble_phy_disable();
1372+
return;
1373+
}
1374+
13621375
/*
13631376
* Let's schedule TX now and we will just cancel it after processing RXed
13641377
* packet if we don't need TX.
@@ -1385,13 +1398,6 @@ ble_phy_rx_end_isr(void)
13851398

13861399
ble_phy_transition_set(BLE_PHY_TRANSITION_NONE, 0);
13871400

1388-
/*
1389-
* XXX: This is a horrible ugly hack to deal with the RAM S1 byte
1390-
* that is not sent over the air but is present here. Simply move the
1391-
* data pointer to deal with it. Fix this later.
1392-
*/
1393-
dptr[2] = dptr[1];
1394-
dptr[1] = dptr[0];
13951401
rc = ble_ll_rx_end(dptr + 1, ble_hdr);
13961402
if (rc < 0) {
13971403
ble_phy_disable();

0 commit comments

Comments
 (0)