Skip to content

Commit

Permalink
[nrf fromtree] drivers: ieee802154: New API for modulated carrier wav…
Browse files Browse the repository at this point in the history
…e transmission.

Added new API function to start modulated carrier wave transmission

Signed-off-by: Przemyslaw Bida <[email protected]>
(cherry picked from commit e0f94f882309679c6e8133fdcf25fa8878748ecc)
  • Loading branch information
canisLupus1313 committed Dec 4, 2024
1 parent 147a0a1 commit 3cbaf38
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 4 deletions.
5 changes: 5 additions & 0 deletions drivers/ieee802154/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ config IEEE802154_SELECTIVE_TXCHANNEL
this Kconfig option is enabled. If the Kconfig option is disabled the drivers
MUST NOT have the capability.

config IEEE802154_CARRIER_FUNCTIONS
bool "Support for carrier functions"
help
Enable support for functions such as modulated carrier and continuous carrier.

module = IEEE802154_DRIVER
module-str = IEEE 802.15.4 driver
module-help = Sets log level for IEEE 802.15.4 Device Drivers.
Expand Down
24 changes: 21 additions & 3 deletions drivers/ieee802154/ieee802154_nrf5.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ static int nrf5_stop(const struct device *dev)
return 0;
}

#if defined(CONFIG_NRF_802154_CARRIER_FUNCTIONS)
#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
static int nrf5_continuous_carrier(const struct device *dev)
{
ARG_UNUSED(dev);
Expand All @@ -737,6 +737,23 @@ static int nrf5_continuous_carrier(const struct device *dev)

return 0;
}

static int nrf_modulated_carrier(const struct device *dev, const uint8_t *data)
{
ARG_UNUSED(dev);

nrf_802154_tx_power_set(nrf5_data.txpwr);

if (!nrf_802154_modulated_carrier(data)) {
LOG_ERR("Failed to enter modulated carrier state");
return -EIO;
}

LOG_DBG("Modulated carrier wave transmission started (channel: %d)",
nrf_802154_channel_get());

return 0;
}
#endif

#if !defined(CONFIG_IEEE802154_NRF5_EXT_IRQ_MGMT)
Expand Down Expand Up @@ -1244,15 +1261,16 @@ static const struct ieee802154_radio_api nrf5_radio_api = {
.set_txpower = nrf5_set_txpower,
.start = nrf5_start,
.stop = nrf5_stop,
#if defined(CONFIG_NRF_802154_CARRIER_FUNCTIONS)
#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
.continuous_carrier = nrf5_continuous_carrier,
.modulated_carrier = nrf_modulated_carrier,
#endif
.tx = nrf5_tx,
.ed_scan = nrf5_energy_scan_start,
.get_time = nrf5_get_time,
.get_sch_acc = nrf5_get_acc,
.configure = nrf5_configure,
.attr_get = nrf5_attr_get
.attr_get = nrf5_attr_get,
};

#if defined(CONFIG_NET_L2_IEEE802154)
Expand Down
25 changes: 25 additions & 0 deletions include/zephyr/net/ieee802154_radio.h
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,7 @@ struct ieee802154_radio_api {
*/
int (*stop)(const struct device *dev);

#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
/**
* @brief Start continuous carrier wave transmission.
*
Expand All @@ -1786,6 +1787,30 @@ struct ieee802154_radio_api {
*/
int (*continuous_carrier)(const struct device *dev);

/**
* @brief Start modulated carrier wave transmission.
*
* @details When the radio is emitting modulated carrier signals, it
* blocks all transmissions on the selected channel.
* This function is to be called only during radio
* tests. Do not use it during normal device operation.
*
* @note Implementations MAY **sleep** and will usually NOT be
* **isr-ok**. MAY be called in any interface state once the driver is
* fully initialized ("ready").
*
* @param dev pointer to IEEE 802.15.4 driver device
* @param data Pointer to a buffer to modulate the carrier with.
* The first byte is the data length.
*
* @retval 0 modulated carrier wave transmission started
* @retval -EALREADY The driver was already in "TESTING" state and
* emitting a modulated carrier.
* @retval -EIO not started
*/
int (*modulated_carrier)(const struct device *dev, const uint8_t *data);
#endif /* CONFIG_IEEE802154_CARRIER_FUNCTIONS */

/**
* @brief Set or update driver configuration.
*
Expand Down
2 changes: 1 addition & 1 deletion modules/hal_nordic/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ config NRF_802154_SECURITY_KEY_STORAGE_SIZE

config NRF_802154_CARRIER_FUNCTIONS
bool "nRF 802.15.4 carrier functions"
default y if OPENTHREAD_DIAG
default y if (OPENTHREAD_DIAG || IEEE802154_CARRIER_FUNCTIONS)
help
This option enables functions such as modulated carrier and continuous carrier.
If this option is modified on a multicore SoC, its remote counterpart must be set to the exact same value.
Expand Down
1 change: 1 addition & 0 deletions modules/openthread/Kconfig.features
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ config OPENTHREAD_DHCP6_SERVER

config OPENTHREAD_DIAG
bool "Diagnostic functions support"
depends on IEEE802154_CARRIER_FUNCTIONS
help
Enable OpenThread CLI diagnostic commands

Expand Down
2 changes: 2 additions & 0 deletions modules/openthread/platform/diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ void otPlatDiagRadioReceived(otInstance *aInstance,
ARG_UNUSED(aError);
}

#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
otError otPlatDiagRadioTransmitCarrier(otInstance *aInstance, bool aEnable)
{
if (!otPlatDiagModeGet()) {
Expand All @@ -94,6 +95,7 @@ otError otPlatDiagRadioTransmitCarrier(otInstance *aInstance, bool aEnable)

return platformRadioTransmitCarrier(aInstance, aEnable);
}
#endif /* CONFIG_IEEE802154_CARRIER_FUNCTIONS */

void otPlatDiagAlarmCallback(otInstance *aInstance)
{
Expand Down
2 changes: 2 additions & 0 deletions modules/openthread/platform/platform-zephyr.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ void platformUartPanic(void);
*/
uint16_t platformRadioChannelGet(otInstance *aInstance);

#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
/**
* Start/stop continuous carrier wave transmission.
*/
otError platformRadioTransmitCarrier(otInstance *aInstance, bool aEnable);
#endif /* CONFIG_IEEE802154_CARRIER_FUNCTIONS */

/**
* This function initializes the random number service used by OpenThread.
Expand Down
2 changes: 2 additions & 0 deletions modules/openthread/platform/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ otError otPlatRadioReceiveAt(otInstance *aInstance, uint8_t aChannel,
}
#endif

#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
otError platformRadioTransmitCarrier(otInstance *aInstance, bool aEnable)
{
if (radio_api->continuous_carrier == NULL) {
Expand All @@ -831,6 +832,7 @@ otError platformRadioTransmitCarrier(otInstance *aInstance, bool aEnable)

return OT_ERROR_NONE;
}
#endif /* CONFIG_IEEE802154_CARRIER_FUNCTIONS */

otRadioState otPlatRadioGetState(otInstance *aInstance)
{
Expand Down

0 comments on commit 3cbaf38

Please sign in to comment.