Skip to content

Commit 3ac6a88

Browse files
Przemyslaw Bidarlubos
authored andcommitted
[nrf fromtree] drivers: ieee802154: New API for modulated carrier wave transmission.
Added new API function to start modulated carrier wave transmission Signed-off-by: Przemyslaw Bida <[email protected]> (cherry picked from commit e0f94f8)
1 parent 314231f commit 3ac6a88

File tree

8 files changed

+59
-4
lines changed

8 files changed

+59
-4
lines changed

drivers/ieee802154/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ config IEEE802154_SELECTIVE_TXCHANNEL
100100
this Kconfig option is enabled. If the Kconfig option is disabled the drivers
101101
MUST NOT have the capability.
102102

103+
config IEEE802154_CARRIER_FUNCTIONS
104+
bool "Support for carrier functions"
105+
help
106+
Enable support for functions such as modulated carrier and continuous carrier.
107+
103108
module = IEEE802154_DRIVER
104109
module-str = IEEE 802.15.4 driver
105110
module-help = Sets log level for IEEE 802.15.4 Device Drivers.

drivers/ieee802154/ieee802154_nrf5.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ static int nrf5_stop(const struct device *dev)
720720
return 0;
721721
}
722722

723-
#if defined(CONFIG_NRF_802154_CARRIER_FUNCTIONS)
723+
#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
724724
static int nrf5_continuous_carrier(const struct device *dev)
725725
{
726726
ARG_UNUSED(dev);
@@ -737,6 +737,23 @@ static int nrf5_continuous_carrier(const struct device *dev)
737737

738738
return 0;
739739
}
740+
741+
static int nrf_modulated_carrier(const struct device *dev, const uint8_t *data)
742+
{
743+
ARG_UNUSED(dev);
744+
745+
nrf_802154_tx_power_set(nrf5_data.txpwr);
746+
747+
if (!nrf_802154_modulated_carrier(data)) {
748+
LOG_ERR("Failed to enter modulated carrier state");
749+
return -EIO;
750+
}
751+
752+
LOG_DBG("Modulated carrier wave transmission started (channel: %d)",
753+
nrf_802154_channel_get());
754+
755+
return 0;
756+
}
740757
#endif
741758

742759
#if !defined(CONFIG_IEEE802154_NRF5_EXT_IRQ_MGMT)
@@ -1244,15 +1261,16 @@ static const struct ieee802154_radio_api nrf5_radio_api = {
12441261
.set_txpower = nrf5_set_txpower,
12451262
.start = nrf5_start,
12461263
.stop = nrf5_stop,
1247-
#if defined(CONFIG_NRF_802154_CARRIER_FUNCTIONS)
1264+
#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
12481265
.continuous_carrier = nrf5_continuous_carrier,
1266+
.modulated_carrier = nrf_modulated_carrier,
12491267
#endif
12501268
.tx = nrf5_tx,
12511269
.ed_scan = nrf5_energy_scan_start,
12521270
.get_time = nrf5_get_time,
12531271
.get_sch_acc = nrf5_get_acc,
12541272
.configure = nrf5_configure,
1255-
.attr_get = nrf5_attr_get
1273+
.attr_get = nrf5_attr_get,
12561274
};
12571275

12581276
#if defined(CONFIG_NET_L2_IEEE802154)

include/zephyr/net/ieee802154_radio.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,7 @@ struct ieee802154_radio_api {
17651765
*/
17661766
int (*stop)(const struct device *dev);
17671767

1768+
#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
17681769
/**
17691770
* @brief Start continuous carrier wave transmission.
17701771
*
@@ -1786,6 +1787,30 @@ struct ieee802154_radio_api {
17861787
*/
17871788
int (*continuous_carrier)(const struct device *dev);
17881789

1790+
/**
1791+
* @brief Start modulated carrier wave transmission.
1792+
*
1793+
* @details When the radio is emitting modulated carrier signals, it
1794+
* blocks all transmissions on the selected channel.
1795+
* This function is to be called only during radio
1796+
* tests. Do not use it during normal device operation.
1797+
*
1798+
* @note Implementations MAY **sleep** and will usually NOT be
1799+
* **isr-ok**. MAY be called in any interface state once the driver is
1800+
* fully initialized ("ready").
1801+
*
1802+
* @param dev pointer to IEEE 802.15.4 driver device
1803+
* @param data Pointer to a buffer to modulate the carrier with.
1804+
* The first byte is the data length.
1805+
*
1806+
* @retval 0 modulated carrier wave transmission started
1807+
* @retval -EALREADY The driver was already in "TESTING" state and
1808+
* emitting a modulated carrier.
1809+
* @retval -EIO not started
1810+
*/
1811+
int (*modulated_carrier)(const struct device *dev, const uint8_t *data);
1812+
#endif /* CONFIG_IEEE802154_CARRIER_FUNCTIONS */
1813+
17891814
/**
17901815
* @brief Set or update driver configuration.
17911816
*

modules/hal_nordic/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ config NRF_802154_SECURITY_KEY_STORAGE_SIZE
204204

205205
config NRF_802154_CARRIER_FUNCTIONS
206206
bool "nRF 802.15.4 carrier functions"
207-
default y if OPENTHREAD_DIAG
207+
default y if (OPENTHREAD_DIAG || IEEE802154_CARRIER_FUNCTIONS)
208208
help
209209
This option enables functions such as modulated carrier and continuous carrier.
210210
If this option is modified on a multicore SoC, its remote counterpart must be set to the exact same value.

modules/openthread/Kconfig.features

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ config OPENTHREAD_DHCP6_SERVER
136136

137137
config OPENTHREAD_DIAG
138138
bool "Diagnostic functions support"
139+
depends on IEEE802154_CARRIER_FUNCTIONS
139140
help
140141
Enable OpenThread CLI diagnostic commands
141142

modules/openthread/platform/diag.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ void otPlatDiagRadioReceived(otInstance *aInstance,
8686
ARG_UNUSED(aError);
8787
}
8888

89+
#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
8990
otError otPlatDiagRadioTransmitCarrier(otInstance *aInstance, bool aEnable)
9091
{
9192
if (!otPlatDiagModeGet()) {
@@ -94,6 +95,7 @@ otError otPlatDiagRadioTransmitCarrier(otInstance *aInstance, bool aEnable)
9495

9596
return platformRadioTransmitCarrier(aInstance, aEnable);
9697
}
98+
#endif /* CONFIG_IEEE802154_CARRIER_FUNCTIONS */
9799

98100
void otPlatDiagAlarmCallback(otInstance *aInstance)
99101
{

modules/openthread/platform/platform-zephyr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ void platformUartPanic(void);
7070
*/
7171
uint16_t platformRadioChannelGet(otInstance *aInstance);
7272

73+
#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
7374
/**
7475
* Start/stop continuous carrier wave transmission.
7576
*/
7677
otError platformRadioTransmitCarrier(otInstance *aInstance, bool aEnable);
78+
#endif /* CONFIG_IEEE802154_CARRIER_FUNCTIONS */
7779

7880
/**
7981
* This function initializes the random number service used by OpenThread.

modules/openthread/platform/radio.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,7 @@ otError otPlatRadioReceiveAt(otInstance *aInstance, uint8_t aChannel,
809809
}
810810
#endif
811811

812+
#if defined(CONFIG_IEEE802154_CARRIER_FUNCTIONS)
812813
otError platformRadioTransmitCarrier(otInstance *aInstance, bool aEnable)
813814
{
814815
if (radio_api->continuous_carrier == NULL) {
@@ -831,6 +832,7 @@ otError platformRadioTransmitCarrier(otInstance *aInstance, bool aEnable)
831832

832833
return OT_ERROR_NONE;
833834
}
835+
#endif /* CONFIG_IEEE802154_CARRIER_FUNCTIONS */
834836

835837
otRadioState otPlatRadioGetState(otInstance *aInstance)
836838
{

0 commit comments

Comments
 (0)