Bluetooth: controller: Refactor time calculation for LL DLE procedure
Refactor the PKT_US macro to show more clearly where the different fields come from Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
This commit is contained in:
parent
3b135bd075
commit
44daa9f15c
1 changed files with 41 additions and 7 deletions
|
@ -7,15 +7,49 @@
|
||||||
/* Macro to convert time in us to connection interval units */
|
/* Macro to convert time in us to connection interval units */
|
||||||
#define RADIO_CONN_EVENTS(x, y) ((u16_t)(((x) + (y) - 1) / (y)))
|
#define RADIO_CONN_EVENTS(x, y) ((u16_t)(((x) + (y) - 1) / (y)))
|
||||||
|
|
||||||
/* Macro to return PDU time */
|
/*
|
||||||
|
* Macros to return correct Data Channel PDU time
|
||||||
|
* Note: formula is valid for 1M, 2M and Coded S8
|
||||||
|
* see BT spec Version 5.1 Vol 6. Part B, chapters 2.1 and 2.2
|
||||||
|
* for packet formats and thus lengths
|
||||||
|
*
|
||||||
|
* Payload overhead size is the Data Channel PDU Header + the MIC
|
||||||
|
*/
|
||||||
|
#define PAYLOAD_OVERHEAD_SIZE (2 + 4)
|
||||||
|
|
||||||
#if defined(CONFIG_BT_CTLR_PHY_CODED)
|
#if defined(CONFIG_BT_CTLR_PHY_CODED)
|
||||||
#define PKT_US(octets, phy) \
|
#define CODED_PHY_PREAMBLE_TIME_US (80)
|
||||||
(((phy) & BIT(2)) ? \
|
#define CODED_PHY_ACCESS_ADDRESS_TIME_US (256)
|
||||||
(80 + 256 + 16 + 24 + ((((2 + (octets) + 4) * 8) + 24 + 3) * 8)) : \
|
#define CODED_PHY_CI_TIME_US (16)
|
||||||
(((octets) + 14) * 8 / BIT(((phy) & 0x03) >> 1)))
|
#define CODED_PHY_TERM1_TIME_US (24)
|
||||||
|
#define CODED_PHY_CRC_SIZE (24)
|
||||||
|
#define CODED_PHY_TERM2_SIZE (3)
|
||||||
|
|
||||||
|
#define FEC_BLOCK1_TIME_US (CODED_PHY_ACCESS_ADDRESS_TIME_US + \
|
||||||
|
CODED_PHY_CI_TIME_US + \
|
||||||
|
CODED_PHY_TERM1_TIME_US)
|
||||||
|
#define FEC_BLOCK2_TIME_US(octets) ((((PAYLOAD_OVERHEAD_SIZE + \
|
||||||
|
(octets)) * 8) + \
|
||||||
|
CODED_PHY_CRC_SIZE + \
|
||||||
|
CODED_PHY_TERM2_SIZE) * 8)
|
||||||
|
|
||||||
|
#define PKT_US(octets, phy) (((phy) & BIT(2)) ? \
|
||||||
|
(CODED_PHY_PREAMBLE_TIME_US + \
|
||||||
|
FEC_BLOCK1_TIME_US + \
|
||||||
|
FEC_BLOCK2_TIME_US(octets)) : \
|
||||||
|
(((PREAMBLE_SIZE(1) + \
|
||||||
|
ACCESS_ADDR_SIZE + \
|
||||||
|
PAYLOAD_OVERHEAD_SIZE + \
|
||||||
|
(octets) + \
|
||||||
|
CRC_SIZE) * 8) / \
|
||||||
|
BIT(((phy) & 0x03) >> 1)))
|
||||||
#else /* !CONFIG_BT_CTLR_PHY_CODED */
|
#else /* !CONFIG_BT_CTLR_PHY_CODED */
|
||||||
#define PKT_US(octets, phy) \
|
#define PKT_US(octets, phy) (((PREAMBLE_SIZE(1) + \
|
||||||
(((octets) + 14) * 8 / BIT(((phy) & 0x03) >> 1))
|
ACCESS_ADDR_SIZE + \
|
||||||
|
PAYLOAD_OVERHEAD_SIZE + \
|
||||||
|
(octets) + \
|
||||||
|
CRC_SIZE) * 8) / \
|
||||||
|
BIT(((phy) & 0x03) >> 1))
|
||||||
#endif /* !CONFIG_BT_CTLR_PHY_CODED */
|
#endif /* !CONFIG_BT_CTLR_PHY_CODED */
|
||||||
|
|
||||||
struct ll_conn *ll_conn_acquire(void);
|
struct ll_conn *ll_conn_acquire(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue