Skip to content

Commit

Permalink
ieee802154/submac: implement MR-OFDM timings
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed May 25, 2023
1 parent 8b491b3 commit 5377f37
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
19 changes: 19 additions & 0 deletions sys/include/net/ieee802154.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ extern "C" {
*/
#define IEEE802154_ACK_TIMEOUT_SYMS (54)

/**
* @brief Symbol time for IEEE 802.15.4 MR-OFDM in µs
*/
#define IEEE802154_MR_OFDM_SYMBOL_TIME_US (120)

/**
* @brief value of measured power when RSSI is zero.
*
Expand Down Expand Up @@ -282,6 +287,20 @@ extern const uint8_t ieee802154_addr_bcast[IEEE802154_ADDR_BCAST_LEN];
#define CONFIG_IEEE802154_MR_OQPSK_DEFAULT_RATE (2U)
#endif

/**
* @brief IEEE802.15.4 MR-OFDM default modulation option
*/
#ifndef CONFIG_IEEE802154_MR_OFDM_DEFAULT_OPTION
#define CONFIG_IEEE802154_MR_OFDM_DEFAULT_OPTION (2U)
#endif

/**
* @brief IEEE802.15.4 MR-OFDM default Modulation & Coding Scheme
*/
#ifndef CONFIG_IEEE802154_MR_OFDM_DEFAULT_SCHEME
#define CONFIG_IEEE802154_MR_OFDM_DEFAULT_SCHEME (2U)
#endif

/**
* @brief IEEE802.15.4 default PANID
*/
Expand Down
9 changes: 9 additions & 0 deletions sys/include/net/ieee802154/radio.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,15 @@ typedef struct {
uint8_t rate_mode; /**< rate mode */
} ieee802154_mr_oqpks_conf_t;

/**
* @brief extension for IEEE 802.15.4g MR-ODFM PHY
*/
typedef struct {
ieee802154_phy_conf_t super; /**< common settings */
uint8_t option; /**< OFDM Option */
uint8_t scheme; /**< Modulation & Coding Scheme */
} ieee802154_mr_odmf_conf_t;

/**
* @brief IEEE 802.15.4 radio operations
*/
Expand Down
49 changes: 49 additions & 0 deletions sys/net/link_layer/ieee802154/submac.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,40 @@ static inline uint16_t _mr_oqpsk_csma_backoff_period_us(const ieee802154_mr_oqpk
+ IEEE802154G_ATURNAROUNDTIME_US;
}

/*
* MR-OFDM timing calculations
*/

static unsigned _mr_ofdm_frame_duration(uint8_t option, uint8_t scheme, uint8_t bytes)
{
/* Table 150 - phySymbolsPerOctet values for MR-OFDM PHY, IEEE 802.15.4g-2012 */
static const uint8_t quot[] = { 3, 3, 6, 12, 18, 24, 36 };

--option;
/* phyMaxFrameDuration = phySHRDuration + phyPHRDuration + ceiling [(aMaxPHYPacketSize + 1) x phySymbolsPerOctet] */
const unsigned phySHRDuration = 6;
const unsigned phyPHRDuration = option ? 6 : 3;
const unsigned phyPDUDuration = ((bytes + 1) * (1 << option) + quot[scheme] - 1)
/ quot[scheme];

return (phySHRDuration + phyPHRDuration + phyPDUDuration) * IEEE802154_MR_OFDM_SYMBOL_TIME_US;
}

static inline uint16_t _mr_ofdm_csma_backoff_period_us(const ieee802154_mr_odmf_conf_t *conf)
{
(void)conf;

return IEEE802154_CCA_DURATION_IN_SYMBOLS * IEEE802154_MR_OFDM_SYMBOL_TIME_US
+ IEEE802154G_ATURNAROUNDTIME_US;
}

static inline uint16_t _mr_ofdm_ack_timeout_us(const ieee802154_mr_odmf_conf_t *conf)
{
return _mr_ofdm_csma_backoff_period_us(conf)
+ IEEE802154G_ATURNAROUNDTIME_US
+ _mr_ofdm_frame_duration(conf->option, conf->scheme, IEEE802154_ACK_FRAME_LEN);
}

static int ieee802154_submac_config_phy(ieee802154_submac_t *submac,
const ieee802154_phy_conf_t *conf)
{
Expand All @@ -527,6 +561,12 @@ static int ieee802154_submac_config_phy(ieee802154_submac_t *submac,
submac->ack_timeout_us = _mr_oqpsk_ack_timeout_us((void *)conf);
submac->csma_backoff_us = _mr_oqpsk_csma_backoff_period_us((void *)conf);
break;
#endif
#ifdef MODULE_NETDEV_IEEE802154_MR_OFDM
case IEEE802154_PHY_MR_OFDM:
submac->ack_timeout_us = _mr_ofdm_ack_timeout_us((void *)conf);
submac->csma_backoff_us = _mr_ofdm_csma_backoff_period_us((void *)conf);
break;
#endif
case IEEE802154_PHY_NO_OP:
break;
Expand Down Expand Up @@ -609,6 +649,9 @@ int ieee802154_submac_init(ieee802154_submac_t *submac, const network_uint16_t *
ieee802154_phy_conf_t super;
#ifdef MODULE_NETDEV_IEEE802154_MR_OQPSK
ieee802154_mr_oqpks_conf_t mr_oqpsk;
#endif
#ifdef MODULE_NETDEV_IEEE802154_MR_OFDM
ieee802154_mr_odmf_conf_t mr_ofdm;
#endif
} conf;

Expand All @@ -618,6 +661,12 @@ int ieee802154_submac_init(ieee802154_submac_t *submac, const network_uint16_t *
conf.mr_oqpsk.rate_mode = CONFIG_IEEE802154_MR_OQPSK_DEFAULT_RATE;
}
#endif
#ifdef MODULE_NETDEV_IEEE802154_MR_OFDM
if (submac->phy_mode == IEEE802154_PHY_MR_OFDM) {
conf.mr_ofdm.option = CONFIG_IEEE802154_MR_OFDM_DEFAULT_OPTION;
conf.mr_ofdm.scheme = CONFIG_IEEE802154_MR_OFDM_DEFAULT_SCHEME;
}
#endif

conf.super.phy_mode = submac->phy_mode;
conf.super.channel = submac->channel_num;
Expand Down

0 comments on commit 5377f37

Please sign in to comment.