Compare commits
47 Commits
main
...
v4.3-branc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0683aba74 | ||
|
|
53f18035d5 | ||
|
|
26f00561a9 | ||
|
|
5206f493b9 | ||
|
|
06e38d511c | ||
|
|
cbd2cea099 | ||
|
|
316cf05463 | ||
|
|
59e779d9ed | ||
|
|
fd649f17f0 | ||
|
|
e0a24d3471 | ||
|
|
1ff7fbbaa2 | ||
|
|
ee992eb6a8 | ||
|
|
ef1b2dfd56 | ||
|
|
cde22a3191 | ||
|
|
6173a3cb3e | ||
|
|
cffdb1d8cf | ||
|
|
260d76b698 | ||
|
|
7b0ad6bd9d | ||
|
|
fd6cfbd96b | ||
|
|
3ab62f13b8 | ||
|
|
f46be4550e | ||
|
|
c2665034a3 | ||
|
|
ffcda664c7 | ||
|
|
e959c4fc93 | ||
|
|
357d7c91c0 | ||
|
|
6ce17559f9 | ||
|
|
4e0b47a85e | ||
|
|
1b1df572f7 | ||
|
|
cf8801709e | ||
|
|
ab0251d2ca | ||
|
|
baf69fca19 | ||
|
|
7b82586e8c | ||
|
|
769aa4de58 | ||
|
|
fcc1b73a66 | ||
|
|
fca2826e06 | ||
|
|
309a7de5bc | ||
|
|
a65d0578da | ||
|
|
1858e07427 | ||
|
|
81b8d50c91 | ||
|
|
b45a60cb79 | ||
|
|
da9921200c | ||
|
|
fe706b9c61 | ||
|
|
df69f01359 | ||
|
|
dc309b8482 | ||
|
|
38edcafef2 | ||
|
|
98845243a3 | ||
|
|
d66a39f7b5 |
@@ -107,6 +107,18 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
|
||||
#endif /* FP_GUARD_EXTRA_SIZE */
|
||||
#endif /* CONFIG_MPU_STACK_GUARD */
|
||||
|
||||
#if defined(CONFIG_ARM_STORE_EXC_RETURN) || defined(CONFIG_USERSPACE)
|
||||
thread->arch.mode = 0;
|
||||
#if defined(CONFIG_ARM_STORE_EXC_RETURN)
|
||||
thread->arch.mode_exc_return = DEFAULT_EXC_RETURN;
|
||||
#endif
|
||||
#if FP_GUARD_EXTRA_SIZE > 0
|
||||
if ((thread->base.user_options & K_FP_REGS) != 0) {
|
||||
thread->arch.mode |= Z_ARM_MODE_MPU_GUARD_FLOAT_Msk;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
iframe = Z_STACK_PTR_TO_FRAME(struct __basic_sf, stack_ptr);
|
||||
#if defined(CONFIG_USERSPACE)
|
||||
thread->arch.priv_stack_start = 0;
|
||||
@@ -144,17 +156,6 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
|
||||
thread->callee_saved.psp = (uint32_t)iframe;
|
||||
thread->arch.basepri = 0;
|
||||
|
||||
#if defined(CONFIG_ARM_STORE_EXC_RETURN) || defined(CONFIG_USERSPACE)
|
||||
thread->arch.mode = 0;
|
||||
#if defined(CONFIG_ARM_STORE_EXC_RETURN)
|
||||
thread->arch.mode_exc_return = DEFAULT_EXC_RETURN;
|
||||
#endif
|
||||
#if FP_GUARD_EXTRA_SIZE > 0
|
||||
if ((thread->base.user_options & K_FP_REGS) != 0) {
|
||||
thread->arch.mode |= Z_ARM_MODE_MPU_GUARD_FLOAT_Msk;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/*
|
||||
* initial values in all other registers/thread entries are
|
||||
* irrelevant.
|
||||
|
||||
@@ -115,6 +115,18 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, char *sta
|
||||
#endif /* FP_GUARD_EXTRA_SIZE */
|
||||
#endif /* CONFIG_MPU_STACK_GUARD */
|
||||
|
||||
#if defined(CONFIG_ARM_STORE_EXC_RETURN) || defined(CONFIG_USERSPACE)
|
||||
thread->arch.mode = 0;
|
||||
#if defined(CONFIG_ARM_STORE_EXC_RETURN)
|
||||
thread->arch.mode_exc_return = DEFAULT_EXC_RETURN;
|
||||
#endif
|
||||
#if FP_GUARD_EXTRA_SIZE > 0
|
||||
if ((thread->base.user_options & K_FP_REGS) != 0) {
|
||||
thread->arch.mode |= Z_ARM_MODE_MPU_GUARD_FLOAT_Msk;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
iframe = Z_STACK_PTR_TO_FRAME(struct __basic_sf, stack_ptr);
|
||||
#if defined(CONFIG_USERSPACE)
|
||||
thread->arch.priv_stack_start = 0;
|
||||
@@ -141,17 +153,6 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, char *sta
|
||||
thread->callee_saved.psp = (uint32_t)iframe;
|
||||
thread->arch.basepri = 0;
|
||||
|
||||
#if defined(CONFIG_ARM_STORE_EXC_RETURN) || defined(CONFIG_USERSPACE)
|
||||
thread->arch.mode = 0;
|
||||
#if defined(CONFIG_ARM_STORE_EXC_RETURN)
|
||||
thread->arch.mode_exc_return = DEFAULT_EXC_RETURN;
|
||||
#endif
|
||||
#if FP_GUARD_EXTRA_SIZE > 0
|
||||
if ((thread->base.user_options & K_FP_REGS) != 0) {
|
||||
thread->arch.mode |= Z_ARM_MODE_MPU_GUARD_FLOAT_Msk;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#ifdef CONFIG_ARM_PAC_PER_THREAD
|
||||
/* Generate PAC key and save it in thread context to be set later
|
||||
* when the thread is actually switched in
|
||||
|
||||
@@ -207,6 +207,15 @@ FUNC_NORETURN void arch_user_mode_enter(k_thread_entry_t user_entry,
|
||||
int arch_thread_priv_stack_space_get(const struct k_thread *thread, size_t *stack_size,
|
||||
size_t *unused_ptr)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_INIT_STACKS) || !IS_ENABLED(CONFIG_THREAD_STACK_INFO)) {
|
||||
/*
|
||||
* This is needed to ensure that the call to z_stack_space_get() below is properly
|
||||
* dead-stripped when linking using LLVM / lld. For more info, please see issue
|
||||
* #98491.
|
||||
*/
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((thread->base.user_options & K_USER) != K_USER) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -189,6 +189,15 @@ FUNC_NORETURN void arch_user_mode_enter(k_thread_entry_t user_entry,
|
||||
int arch_thread_priv_stack_space_get(const struct k_thread *thread, size_t *stack_size,
|
||||
size_t *unused_ptr)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_INIT_STACKS) || !IS_ENABLED(CONFIG_THREAD_STACK_INFO)) {
|
||||
/*
|
||||
* This is needed to ensure that the call to z_stack_space_get() below is properly
|
||||
* dead-stripped when linking using LLVM / lld. For more info, please see issue
|
||||
* #98491.
|
||||
*/
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct z_x86_thread_stack_header *hdr_stack_obj;
|
||||
|
||||
if ((thread->base.user_options & K_USER) != K_USER) {
|
||||
|
||||
@@ -240,6 +240,15 @@ FUNC_NORETURN void arch_user_mode_enter(k_thread_entry_t user_entry,
|
||||
int arch_thread_priv_stack_space_get(const struct k_thread *thread, size_t *stack_size,
|
||||
size_t *unused_ptr)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_INIT_STACKS) || !IS_ENABLED(CONFIG_THREAD_STACK_INFO)) {
|
||||
/*
|
||||
* This is needed to ensure that the call to z_stack_space_get() below is properly
|
||||
* dead-stripped when linking using LLVM / lld. For more info, please see issue
|
||||
* #98491.
|
||||
*/
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct xtensa_thread_stack_header *hdr_stack_obj;
|
||||
|
||||
if ((thread->base.user_options & K_USER) != K_USER) {
|
||||
|
||||
@@ -7,14 +7,15 @@
|
||||
# Note1: Suggest developers use Secure Provisioning Tool(SPT) to download RT1180 image
|
||||
# SPT can be downloaded on NXP web: https://www.nxp.com/design/design-center/software/development-software/mcuxpresso-software-and-tools-/mcuxpresso-secure-provisioning-tool:MCUXPRESSO-SECURE-PROVISIONING
|
||||
# Details about the usage of SPT on MIMXRT1180-EVK board can be referred on chapter 7 of getting start with Mcuxpresso SDK for MIMXRT1180-EVK doc in SDK package.
|
||||
set(JLINKSCRIPTDIR ${CMAKE_CURRENT_LIST_DIR}/jlinkscript)
|
||||
if(CONFIG_SOC_MIMXRT1189_CM33 OR CONFIG_SECOND_CORE_MCUX)
|
||||
board_runner_args(linkserver "--device=MIMXRT1189xxxxx:MIMXRT1180-EVK")
|
||||
board_runner_args(jlink "--device=MIMXRT1189xxx8_M33" "--reset-after-load" "--tool-opt=-jlinkscriptfile jlinkscript/evkmimxrt1180_cm33.jlinkscript")
|
||||
board_runner_args(jlink "--device=MIMXRT1189xxx8_M33" "--reset-after-load" "--tool-opt=-jlinkscriptfile ${JLINKSCRIPTDIR}/evkmimxrt1180_cm33.jlinkscript")
|
||||
elseif(CONFIG_SOC_MIMXRT1189_CM7)
|
||||
# Note: Only support run cm7 image when debugging due to default boot core on board is cm33 core
|
||||
board_runner_args(linkserver "--device=MIMXRT1189xxxxx:MIMXRT1180-EVK")
|
||||
board_runner_args(linkserver "--core=cm7")
|
||||
board_runner_args(jlink "--device=MIMXRT1189xxx8_M7" "--speed=4000" "--no-reset" "--tool-opt=-jlinkscriptfile jlinkscript/evkmimxrt1180_cm7.jlinkscript" "--tool-opt=-ir")
|
||||
board_runner_args(jlink "--device=MIMXRT1189xxx8_M7" "--speed=4000" "--no-reset" "--tool-opt=-jlinkscriptfile ${JLINKSCRIPTDIR}/evkmimxrt1180_cm7.jlinkscript" "--tool-opt=-ir")
|
||||
endif()
|
||||
|
||||
include(${ZEPHYR_BASE}/boards/common/linkserver.board.cmake)
|
||||
|
||||
@@ -83,7 +83,7 @@ of i.MX NETC.
|
||||
.phy_mode = NETC_PHY_MODE(port), \
|
||||
}; \
|
||||
struct dsa_port_config dsa_##n##_##port##_config = { \
|
||||
.use_random_mac_addr = DT_NODE_HAS_PROP(port, zephyr_random_mac_address), \
|
||||
.use_random_mac_addr = DT_PROP(port, zephyr_random_mac_address), \
|
||||
.mac_addr = DT_PROP_OR(port, local_mac_address, {0}), \
|
||||
.port_idx = DT_REG_ADDR(port), \
|
||||
.phy_dev = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(port, phy_handle)), \
|
||||
|
||||
@@ -136,16 +136,39 @@ Keeping Zephyr updated
|
||||
To update the Zephyr project source code, you need to get the latest
|
||||
changes via ``git``. Afterwards, run ``west update`` as mentioned in
|
||||
the previous paragraph.
|
||||
Additionally, in the case of updated or added Python dependencies, running
|
||||
``west packages pip --install`` will make sure these are up-to-date.
|
||||
Additionally, check for updated or added Python dependencies.
|
||||
|
||||
.. code-block:: console
|
||||
.. tabs::
|
||||
|
||||
# replace zephyrproject with the path you gave west init
|
||||
cd zephyrproject/zephyr
|
||||
git pull
|
||||
west update
|
||||
west packages pip --install
|
||||
.. group-tab:: Linux/macOS
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
# replace zephyrproject with the path you gave west init
|
||||
cd zephyrproject/zephyr
|
||||
git pull
|
||||
west update
|
||||
west packages pip --install
|
||||
|
||||
.. group-tab:: Windows
|
||||
|
||||
.. tabs::
|
||||
|
||||
.. code-tab:: bat
|
||||
|
||||
:: replace zephyrproject with the path you gave west init
|
||||
cd zephyrproject\zephyr
|
||||
git pull
|
||||
west update
|
||||
cmd /c scripts\utils\west-packages-pip-install.cmd
|
||||
|
||||
.. code-tab:: powershell
|
||||
|
||||
# replace zephyrproject with the path you gave west init
|
||||
cd zephyrproject\zephyr
|
||||
git pull
|
||||
west update
|
||||
python -m pip install @((west packages pip) -split ' ')
|
||||
|
||||
Export Zephyr CMake package
|
||||
***************************
|
||||
|
||||
@@ -266,6 +266,10 @@ chosen. You'll also install Zephyr's additional Python dependencies in a
|
||||
|
||||
west packages pip --install
|
||||
|
||||
.. note::
|
||||
|
||||
This could downgrade or upgrade west itself.
|
||||
|
||||
.. group-tab:: macOS
|
||||
|
||||
#. Create a new virtual environment:
|
||||
@@ -317,6 +321,10 @@ chosen. You'll also install Zephyr's additional Python dependencies in a
|
||||
|
||||
west packages pip --install
|
||||
|
||||
.. note::
|
||||
|
||||
This could downgrade or upgrade west itself.
|
||||
|
||||
.. group-tab:: Windows
|
||||
|
||||
#. Open a ``cmd.exe`` or PowerShell terminal window **as a regular user**
|
||||
@@ -389,9 +397,19 @@ chosen. You'll also install Zephyr's additional Python dependencies in a
|
||||
|
||||
#. Install Python dependencies using ``west packages``.
|
||||
|
||||
.. code-block:: bat
|
||||
.. tabs::
|
||||
|
||||
west packages pip --install
|
||||
.. code-tab:: bat
|
||||
|
||||
cmd /c scripts\utils\west-packages-pip-install.cmd
|
||||
|
||||
.. code-tab:: powershell
|
||||
|
||||
python -m pip install @((west packages pip) -split ' ')
|
||||
|
||||
.. note::
|
||||
|
||||
This could downgrade or upgrade west itself.
|
||||
|
||||
Install the Zephyr SDK
|
||||
**********************
|
||||
|
||||
@@ -76,17 +76,16 @@ static int entropy_gecko_trng_get_entropy(const struct device *dev,
|
||||
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
#ifdef CONFIG_CRYPTO_ACC_GECKO_TRNG
|
||||
CMU_ClockEnable(cmuClock_CRYPTOACC, true);
|
||||
#endif
|
||||
|
||||
while (length) {
|
||||
#ifndef CONFIG_CRYPTO_ACC_GECKO_TRNG
|
||||
available = TRNG0->FIFOLEVEL * 4;
|
||||
#else
|
||||
CMU_ClockEnable(cmuClock_CRYPTOACC, true);
|
||||
available = S2_FIFO_LEVEL * 4;
|
||||
#endif
|
||||
if (available == 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
count = SL_MIN(length, available);
|
||||
entropy_gecko_trng_read(buffer, count);
|
||||
buffer += count;
|
||||
|
||||
@@ -451,7 +451,7 @@ static struct dsa_api dsa_netc_api = {
|
||||
.phy_mode = NETC_PHY_MODE(port), \
|
||||
}; \
|
||||
struct dsa_port_config dsa_##n##_##port##_config = { \
|
||||
.use_random_mac_addr = DT_NODE_HAS_PROP(port, zephyr_random_mac_address), \
|
||||
.use_random_mac_addr = DT_PROP(port, zephyr_random_mac_address), \
|
||||
.mac_addr = DT_PROP_OR(port, local_mac_address, {0}), \
|
||||
.port_idx = DT_REG_ADDR(port), \
|
||||
.phy_dev = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(port, phy_handle)), \
|
||||
@@ -482,6 +482,6 @@ static struct dsa_api dsa_netc_api = {
|
||||
POST_KERNEL, \
|
||||
CONFIG_ETH_INIT_PRIORITY, \
|
||||
NULL); \
|
||||
DSA_SWITCH_INST_INIT(n, &dsa_netc_api, &dsa_netc_data_##n, DSA_NETC_PORT_INST_INIT); \
|
||||
DSA_SWITCH_INST_INIT(n, &dsa_netc_api, &dsa_netc_data_##n, DSA_NETC_PORT_INST_INIT);
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(DSA_NETC_DEVICE);
|
||||
|
||||
@@ -1294,6 +1294,11 @@ static int i2c_dw_initialize(const struct device *dev)
|
||||
uint32_t reg_base = get_regs(dev);
|
||||
|
||||
clear_bit_enable_en(reg_base);
|
||||
/*
|
||||
* depending on the IP configuration, we may have to disable block mode in
|
||||
* controller mode
|
||||
*/
|
||||
clear_bit_enable_block(reg_base);
|
||||
|
||||
/* verify that we have a valid DesignWare register first */
|
||||
if (read_comp_type(reg_base) != I2C_DW_MAGIC_KEY) {
|
||||
|
||||
@@ -224,10 +224,12 @@ static int i2c_nrfx_twim_init(const struct device *dev)
|
||||
return i2c_nrfx_twim_common_init(dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEVICE_DEINIT_SUPPORT
|
||||
static int i2c_nrfx_twim_deinit(const struct device *dev)
|
||||
{
|
||||
return i2c_nrfx_twim_common_deinit(dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
static DEVICE_API(i2c, i2c_nrfx_twim_driver_api) = {
|
||||
.configure = i2c_nrfx_twim_configure,
|
||||
|
||||
@@ -151,6 +151,7 @@ int i2c_nrfx_twim_common_init(const struct device *dev)
|
||||
return pm_device_driver_init(dev, twim_nrfx_pm_action);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEVICE_DEINIT_SUPPORT
|
||||
int i2c_nrfx_twim_common_deinit(const struct device *dev)
|
||||
{
|
||||
const struct i2c_nrfx_twim_common_config *config = dev->config;
|
||||
@@ -178,3 +179,4 @@ int i2c_nrfx_twim_common_deinit(const struct device *dev)
|
||||
nrfx_twim_uninit(&config->twim);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -211,10 +211,12 @@ static int i2c_nrfx_twim_rtio_init(const struct device *dev)
|
||||
return i2c_nrfx_twim_common_init(dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEVICE_DEINIT_SUPPORT
|
||||
static int i2c_nrfx_twim_rtio_deinit(const struct device *dev)
|
||||
{
|
||||
return i2c_nrfx_twim_common_deinit(dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define CONCAT_BUF_SIZE(idx) \
|
||||
COND_CODE_1(DT_NODE_HAS_PROP(I2C(idx), zephyr_concat_buf_size), \
|
||||
|
||||
@@ -292,6 +292,7 @@ static int shim_nrf_twis_init(const struct device *dev)
|
||||
return pm_device_driver_init(dev, shim_nrf_twis_pm_action_cb);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEVICE_DEINIT_SUPPORT
|
||||
static int shim_nrf_twis_deinit(const struct device *dev)
|
||||
{
|
||||
const struct shim_nrf_twis_config *dev_config = dev->config;
|
||||
@@ -320,6 +321,7 @@ static int shim_nrf_twis_deinit(const struct device *dev)
|
||||
nrfx_twis_uninit(&dev_config->twis);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define SHIM_NRF_TWIS_NAME(id, name) \
|
||||
_CONCAT_4(shim_nrf_twis_, name, _, id)
|
||||
|
||||
@@ -61,8 +61,7 @@ void esp_ieee802154_receive_done(uint8_t *frame, esp_ieee802154_frame_info_t *fr
|
||||
|
||||
/* The ESP-IDF HAL handles FCS already and drops frames with bad checksum. The checksum at
|
||||
* the end of a valid frame is replaced with RSSI and LQI values.
|
||||
*
|
||||
* ToDo: Check if L2 needs a valid checksum in the frame.
|
||||
* Zephyr L2 expects only valid frames, so checksum is not needed for a re-check.
|
||||
*/
|
||||
if (IS_ENABLED(CONFIG_IEEE802154_L2_PKT_INCL_FCS)) {
|
||||
len = frame[0];
|
||||
@@ -121,7 +120,7 @@ static enum ieee802154_hw_caps esp32_get_capabilities(const struct device *dev)
|
||||
|
||||
/* ToDo: Double-check and extend */
|
||||
return IEEE802154_HW_ENERGY_SCAN | IEEE802154_HW_FILTER | IEEE802154_HW_TX_RX_ACK |
|
||||
IEEE802154_HW_CSMA;
|
||||
IEEE802154_HW_CSMA | IEEE802154_HW_PROMISC | IEEE802154_RX_ON_WHEN_IDLE;
|
||||
}
|
||||
|
||||
/* override weak function in components/ieee802154/esp_ieee802154.c of ESP-IDF */
|
||||
@@ -345,9 +344,6 @@ static int esp32_tx(const struct device *dev, enum ieee802154_tx_mode tx_mode, s
|
||||
|
||||
err = k_sem_take(&data->tx_wait, K_MSEC(IEEE802154_ESP32_TX_TIMEOUT_MS));
|
||||
|
||||
/* set the radio back to RX mode as quickly as possible */
|
||||
ieee802154_receive();
|
||||
|
||||
if (err != 0) {
|
||||
LOG_ERR("TX timeout");
|
||||
} else {
|
||||
@@ -359,36 +355,26 @@ static int esp32_tx(const struct device *dev, enum ieee802154_tx_mode tx_mode, s
|
||||
|
||||
static int esp32_start(const struct device *dev)
|
||||
{
|
||||
struct ieee802154_esp32_data *data = dev->data;
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
if (data->is_started) {
|
||||
return 0;
|
||||
} else if (esp_ieee802154_enable() == 0) {
|
||||
esp_ieee802154_set_promiscuous(false);
|
||||
esp_ieee802154_set_rx_when_idle(true);
|
||||
|
||||
/* ToDo: check if this is necessary */
|
||||
esp_ieee802154_receive();
|
||||
|
||||
data->is_started = true;
|
||||
return 0;
|
||||
if (esp_ieee802154_receive() != 0) {
|
||||
LOG_ERR("Failed to start radio");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return -EIO;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int esp32_stop(const struct device *dev)
|
||||
{
|
||||
struct ieee802154_esp32_data *data = dev->data;
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
if (!data->is_started) {
|
||||
return 0;
|
||||
} else if (esp_ieee802154_disable() == 0) {
|
||||
data->is_started = false;
|
||||
return 0;
|
||||
if (esp_ieee802154_sleep() != 0) {
|
||||
LOG_ERR("Failed to stop radio");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return -EIO;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* override weak function in components/ieee802154/esp_ieee802154.c of ESP-IDF */
|
||||
@@ -404,7 +390,7 @@ void IRAM_ATTR esp_ieee802154_energy_detect_done(int8_t power)
|
||||
callback = esp32_data.energy_scan_done;
|
||||
esp32_data.energy_scan_done = NULL;
|
||||
dev = net_if_get_device(esp32_data.iface);
|
||||
callback(dev, power); /* TODO: check scaling */
|
||||
callback(dev, power);
|
||||
}
|
||||
|
||||
static int esp32_ed_scan(const struct device *dev, uint16_t duration, energy_scan_done_cb_t done_cb)
|
||||
@@ -416,7 +402,7 @@ static int esp32_ed_scan(const struct device *dev, uint16_t duration, energy_sca
|
||||
if (esp32_data.energy_scan_done == NULL) {
|
||||
esp32_data.energy_scan_done = done_cb;
|
||||
|
||||
/* The duration of energy detection, in symbol unit (16 us). TODO: check scaling */
|
||||
/* The duration of energy detection, in symbol unit (16 us) */
|
||||
if (esp_ieee802154_energy_detect(duration * USEC_PER_MSEC / US_PER_SYMBLE) != 0) {
|
||||
esp32_data.energy_scan_done = NULL;
|
||||
err = -EBUSY;
|
||||
@@ -470,6 +456,15 @@ static int esp32_init(const struct device *dev)
|
||||
k_sem_init(&data->cca_wait, 0, 1);
|
||||
k_sem_init(&data->tx_wait, 0, 1);
|
||||
|
||||
if (esp_ieee802154_enable() != 0) {
|
||||
LOG_ERR("IEEE 802154 enabling failed!");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* Default radio settings */
|
||||
esp_ieee802154_set_promiscuous(false);
|
||||
esp_ieee802154_set_rx_when_idle(true);
|
||||
|
||||
LOG_INF("IEEE 802154 radio initialized");
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -24,8 +24,6 @@ struct ieee802154_esp32_data {
|
||||
/* CCA result. Holds information whether channel is free or not. */
|
||||
bool channel_free;
|
||||
|
||||
bool is_started;
|
||||
|
||||
/* TX synchronization semaphore. Unlocked when frame has been
|
||||
* sent or send procedure failed.
|
||||
*/
|
||||
|
||||
@@ -40,6 +40,11 @@ struct stm32_exti_range {
|
||||
#define EXTI_NUM_LINES_TOTAL DT_PROP(EXTI_NODE, num_lines)
|
||||
#define NUM_EXTI_LINES DT_PROP(EXTI_NODE, num_gpio_lines)
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_STM32N6X)
|
||||
/* Index 8 of CR stands for PORTN instead of PORTI */
|
||||
#define STM32_PORT_GAP (STM32_PORTN - STM32_PORTI)
|
||||
#endif
|
||||
|
||||
BUILD_ASSERT(EXTI_NUM_LINES_TOTAL >= NUM_EXTI_LINES,
|
||||
"The total number of EXTI lines must be greater or equal than the number of GPIO lines");
|
||||
|
||||
@@ -284,15 +289,26 @@ void stm32_exti_set_line_src_port(gpio_pin_t line, uint32_t port)
|
||||
{
|
||||
uint32_t ll_line = stm32_exti_linenum_to_src_cfg_line(line);
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_STM32L0X) && defined(LL_SYSCFG_EXTI_PORTH)
|
||||
/*
|
||||
* Ports F and G are not present on some STM32L0 parts, so
|
||||
* for these parts port H external interrupt should be enabled
|
||||
* by writing value 0x5 instead of 0x7.
|
||||
* On some series, or specific parts, it may happen that a discontinuity
|
||||
* exists in the indexes of port used in configuration registers.
|
||||
* Fix those case by case
|
||||
*/
|
||||
#if defined(CONFIG_SOC_SERIES_STM32L0X) && defined(LL_SYSCFG_EXTI_PORTH)
|
||||
if (port == STM32_PORTH) {
|
||||
/* Port H (index 7) uses value 5 */
|
||||
port = LL_SYSCFG_EXTI_PORTH;
|
||||
}
|
||||
#elif defined(CONFIG_SOC_SERIES_STM32MP1X)
|
||||
if (port == STM32_PORTZ) {
|
||||
/* Port Z (index 25) uses value 11 */
|
||||
port = LL_EXTI_CONFIG_PORTZ;
|
||||
}
|
||||
#elif defined(CONFIG_SOC_SERIES_STM32N6X)
|
||||
if (port >= STM32_PORTN) {
|
||||
/* Ports N and above (starting index 13) use value 8 and higher */
|
||||
port = port - STM32_PORT_GAP;
|
||||
}
|
||||
#endif
|
||||
|
||||
z_stm32_hsem_lock(CFG_HW_EXTI_SEMID, HSEM_LOCK_DEFAULT_RETRY);
|
||||
@@ -329,15 +345,26 @@ uint32_t stm32_exti_get_line_src_port(gpio_pin_t line)
|
||||
port = LL_SYSCFG_GetEXTISource(ll_line);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_STM32L0X) && defined(LL_SYSCFG_EXTI_PORTH)
|
||||
/*
|
||||
* Ports F and G are not present on some STM32L0 parts, so
|
||||
* for these parts port H external interrupt is enabled
|
||||
* by writing value 0x5 instead of 0x7.
|
||||
* On some series, or specific parts, it may happen that a discontinuity
|
||||
* exists in the indexes of port used in configuration registers.
|
||||
* Fix those case by case.
|
||||
*/
|
||||
#if defined(CONFIG_SOC_SERIES_STM32L0X) && defined(LL_SYSCFG_EXTI_PORTH)
|
||||
if (port == LL_SYSCFG_EXTI_PORTH) {
|
||||
/* Value 7 is for port H */
|
||||
port = STM32_PORTH;
|
||||
}
|
||||
#elif defined(CONFIG_SOC_SERIES_STM32MP1X)
|
||||
if (port == LL_EXTI_CONFIG_PORTZ) {
|
||||
/* Value 11 is for port Z */
|
||||
port = STM32_PORTZ;
|
||||
}
|
||||
#elif defined(CONFIG_SOC_SERIES_STM32N6X)
|
||||
if (port >= STM32_PORTN) {
|
||||
/* Value 8 and higher are for ports N and above */
|
||||
port = port + STM32_PORT_GAP;
|
||||
}
|
||||
#endif
|
||||
|
||||
return port;
|
||||
|
||||
@@ -108,6 +108,7 @@ struct mcux_flexcomm_data {
|
||||
bool pm_policy_state_lock;
|
||||
struct k_work pm_lock_work;
|
||||
#endif
|
||||
uint32_t usart_intenset;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PM_POLICY_DEVICE_CONSTRAINTS
|
||||
@@ -1205,10 +1206,10 @@ static void mcux_flexcomm_pm_restore_wake(const struct device *dev,
|
||||
}
|
||||
#endif /* FC_UART_IS_WAKEUP */
|
||||
|
||||
static uint32_t usart_intenset;
|
||||
static int mcux_flexcomm_pm_action(const struct device *dev, enum pm_device_action action)
|
||||
{
|
||||
const struct mcux_flexcomm_config *config = dev->config;
|
||||
struct mcux_flexcomm_data *data = dev->data;
|
||||
int ret;
|
||||
|
||||
switch (action) {
|
||||
@@ -1217,14 +1218,14 @@ static int mcux_flexcomm_pm_action(const struct device *dev, enum pm_device_acti
|
||||
case PM_DEVICE_ACTION_SUSPEND:
|
||||
break;
|
||||
case PM_DEVICE_ACTION_TURN_OFF:
|
||||
usart_intenset = USART_GetEnabledInterrupts(config->base);
|
||||
data->usart_intenset = USART_GetEnabledInterrupts(config->base);
|
||||
break;
|
||||
case PM_DEVICE_ACTION_TURN_ON:
|
||||
ret = mcux_flexcomm_init_common(dev);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
USART_EnableInterrupts(config->base, usart_intenset);
|
||||
USART_EnableInterrupts(config->base, data->usart_intenset);
|
||||
break;
|
||||
default:
|
||||
return -ENOTSUP;
|
||||
|
||||
@@ -2412,10 +2412,12 @@ static int uarte_instance_init(const struct device *dev,
|
||||
return pm_device_driver_init(dev, uarte_nrfx_pm_action);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEVICE_DEINIT_SUPPORT
|
||||
static int uarte_instance_deinit(const struct device *dev)
|
||||
{
|
||||
return pm_device_driver_deinit(dev, uarte_nrfx_pm_action);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define UARTE_GET_ISR(idx) \
|
||||
COND_CODE_1(CONFIG_UART_##idx##_ASYNC, (uarte_nrfx_isr_async), (uarte_nrfx_isr_int))
|
||||
|
||||
@@ -659,8 +659,8 @@ static int transceive_dma(const struct device *dev,
|
||||
const struct spi_mcux_config *config = dev->config;
|
||||
struct spi_mcux_data *data = dev->data;
|
||||
SPI_Type *base = config->base;
|
||||
int ret;
|
||||
uint8_t word_size = (uint8_t)SPI_WORD_SIZE_GET(spi_cfg->operation);
|
||||
int ret = 0;
|
||||
|
||||
if (word_size > SPI_MAX_DATA_WIDTH) {
|
||||
LOG_ERR("Word size %d is greater than %d", word_size, SPI_MAX_DATA_WIDTH);
|
||||
@@ -671,6 +671,14 @@ static int transceive_dma(const struct device *dev,
|
||||
|
||||
spi_context_lock(&data->ctx, asynchronous, cb, userdata, spi_cfg);
|
||||
|
||||
spi_context_buffers_setup(&data->ctx, tx_bufs, rx_bufs, 1);
|
||||
|
||||
if ((data->ctx.tx_count + data->ctx.rx_count) == 0) {
|
||||
/* no data to transfer */
|
||||
ret = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
data->word_size_bits = word_size;
|
||||
data->word_size_bytes = (word_size > 8) ? (sizeof(uint16_t)) : (sizeof(uint8_t));
|
||||
ret = spi_mcux_configure(dev, spi_cfg);
|
||||
@@ -678,8 +686,6 @@ static int transceive_dma(const struct device *dev,
|
||||
goto out;
|
||||
}
|
||||
|
||||
spi_context_buffers_setup(&data->ctx, tx_bufs, rx_bufs, 1);
|
||||
|
||||
spi_context_cs_control(&data->ctx, true);
|
||||
|
||||
/* Clear FIFOs and any previous errors before transfer */
|
||||
|
||||
@@ -712,6 +712,7 @@ static int spi_nrfx_init(const struct device *dev)
|
||||
return pm_device_driver_init(dev, spim_nrfx_pm_action);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEVICE_DEINIT_SUPPORT
|
||||
static int spi_nrfx_deinit(const struct device *dev)
|
||||
{
|
||||
#if defined(CONFIG_PM_DEVICE)
|
||||
@@ -732,6 +733,7 @@ static int spi_nrfx_deinit(const struct device *dev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define SPI_NRFX_SPIM_EXTENDED_CONFIG(idx) \
|
||||
IF_ENABLED(NRFX_SPIM_EXTENDED_ENABLED, \
|
||||
|
||||
@@ -196,7 +196,7 @@ static void gop_eagain_retry(int cmd, struct gnttab_map_grant_ref *gref)
|
||||
|
||||
void *gnttab_get_pages(unsigned int npages)
|
||||
{
|
||||
int ret;
|
||||
int ret = 0;
|
||||
void *page_addr;
|
||||
unsigned int removed;
|
||||
xen_pfn_t gfn;
|
||||
|
||||
@@ -88,6 +88,7 @@ current_sense_amplifier_scale_ua_dt(const struct current_sense_amplifier_dt_spec
|
||||
* (INT32_MAX * 1000) * UINT16_MAX <= INT64_MAX
|
||||
* ~2**57 <= 2**63
|
||||
*/
|
||||
temp = temp - 1000 * (int64_t)(spec->zero_current_voltage_mv);
|
||||
int64_t scaled = temp * 1000 * spec->sense_gain_div;
|
||||
/* Perform final divisions */
|
||||
return scaled / spec->sense_gain_mult / spec->sense_milli_ohms;
|
||||
|
||||
@@ -32,12 +32,13 @@ extern "C" {
|
||||
#ifdef CONFIG_RING_BUFFER_LARGE
|
||||
typedef uint32_t ring_buf_idx_t;
|
||||
#define RING_BUFFER_MAX_SIZE (UINT32_MAX / 2)
|
||||
#define RING_BUFFER_SIZE_ASSERT_MSG "Size too big"
|
||||
#else
|
||||
typedef uint16_t ring_buf_idx_t;
|
||||
#define RING_BUFFER_MAX_SIZE (UINT16_MAX / 2)
|
||||
#define RING_BUFFER_SIZE_ASSERT_MSG "Size too big, please enable CONFIG_RING_BUFFER_LARGE"
|
||||
#endif
|
||||
|
||||
#define RING_BUFFER_SIZE_ASSERT_MSG "Size too big"
|
||||
|
||||
struct ring_buf_index { ring_buf_idx_t head, tail, base; };
|
||||
|
||||
|
||||
@@ -15,63 +15,82 @@ extern "C" {
|
||||
|
||||
static inline int isupper(int a)
|
||||
{
|
||||
return (int)(((unsigned)(a)-(unsigned)'A') < 26U);
|
||||
return (('A' <= a) && (a <= 'Z'));
|
||||
}
|
||||
|
||||
static inline int isalpha(int c)
|
||||
{
|
||||
return (int)((((unsigned)c|32u)-(unsigned)'a') < 26U);
|
||||
/* force to lowercase */
|
||||
c |= 32;
|
||||
|
||||
return (('a' <= c) && (c <= 'z'));
|
||||
}
|
||||
|
||||
static inline int isblank(int c)
|
||||
{
|
||||
return ((c == ' ') || (c == '\t'));
|
||||
}
|
||||
|
||||
static inline int isspace(int c)
|
||||
{
|
||||
return (int)(c == (int)' ' || ((unsigned)c-(unsigned)'\t') < 5U);
|
||||
return ((c == ' ') || (('\t' <= c) && (c <= '\r')));
|
||||
}
|
||||
|
||||
static inline int isgraph(int c)
|
||||
{
|
||||
return (int)((((unsigned)c) > ' ') &&
|
||||
(((unsigned)c) <= (unsigned)'~'));
|
||||
return ((' ' < c) && (c <= '~'));
|
||||
}
|
||||
|
||||
static inline int isprint(int c)
|
||||
{
|
||||
return (int)((((unsigned)c) >= ' ') &&
|
||||
(((unsigned)c) <= (unsigned)'~'));
|
||||
return ((' ' <= c) && (c <= '~'));
|
||||
}
|
||||
|
||||
static inline int isdigit(int a)
|
||||
{
|
||||
return (int)(((unsigned)(a)-(unsigned)'0') < 10U);
|
||||
return (('0' <= a) && (a <= '9'));
|
||||
}
|
||||
|
||||
static inline int islower(int c)
|
||||
{
|
||||
return (('a' <= c) && (c <= 'z'));
|
||||
}
|
||||
|
||||
static inline int isxdigit(int a)
|
||||
{
|
||||
unsigned int ua = (unsigned int)a;
|
||||
if (isdigit(a) != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (int)(((ua - (unsigned)'0') < 10U) ||
|
||||
((ua | 32U) - (unsigned)'a' < 6U));
|
||||
/* force to lowercase */
|
||||
a |= 32;
|
||||
|
||||
return (('a' <= a) && (a <= 'f'));
|
||||
}
|
||||
|
||||
static inline int tolower(int chr)
|
||||
{
|
||||
return (chr >= (int)'A' && chr <= (int)'Z') ? (chr + 32) : (chr);
|
||||
return (chr >= 'A' && chr <= 'Z') ? (chr + 32) : (chr);
|
||||
}
|
||||
|
||||
static inline int toupper(int chr)
|
||||
{
|
||||
return (int)((chr >= (int)'a' && chr <=
|
||||
(int)'z') ? (chr - 32) : (chr));
|
||||
return ((chr >= 'a' && chr <= 'z') ? (chr - 32) : (chr));
|
||||
}
|
||||
|
||||
static inline int isalnum(int chr)
|
||||
{
|
||||
return (int)(isalpha(chr) || isdigit(chr));
|
||||
return (isalpha(chr) || isdigit(chr));
|
||||
}
|
||||
|
||||
static inline int ispunct(int c)
|
||||
{
|
||||
return (isgraph(c) && !isalnum(c));
|
||||
}
|
||||
|
||||
static inline int iscntrl(int c)
|
||||
{
|
||||
return (int)((((unsigned int)c) <= 31U) || (((unsigned int)c) == 127U));
|
||||
return ((((unsigned int)c) <= 31U) || (((unsigned int)c) == 127U));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Guido van Rossum.
|
||||
*
|
||||
* Copyright (c) 2011 The FreeBSD Foundation
|
||||
* All rights reserved.
|
||||
* Portions of this software were developed by David Chisnall
|
||||
* under sponsorship from the FreeBSD Foundation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -48,26 +53,121 @@
|
||||
|
||||
#define EOS '\0'
|
||||
|
||||
#ifndef FNM_NORES
|
||||
#define FNM_NORES 3
|
||||
#endif
|
||||
|
||||
#ifndef FNM_LEADING_DIR
|
||||
#define FNM_LEADING_DIR 0x08
|
||||
#endif
|
||||
|
||||
#ifndef FNM_CASEFOLD
|
||||
#define FNM_CASEFOLD 0x10
|
||||
#endif
|
||||
|
||||
#define FOLDCASE(ch, flags) foldcase((unsigned char)(ch), (flags))
|
||||
|
||||
#define RANGE_ERROR (-1)
|
||||
#define RANGE_NOMATCH 1
|
||||
#define RANGE_MATCH 0
|
||||
|
||||
/* POSIX character class matching was missing from the BSD version. This was added in 2025 */
|
||||
static int rangematch_cc(const char **pattern, int ch)
|
||||
{
|
||||
typedef unsigned long long ull;
|
||||
|
||||
/*
|
||||
* [:alnum:] et al are 9 characters. [:xdigits:] is 10.
|
||||
* If we first check for the leading "[:", then we have at most 8 remaining characters to
|
||||
* compare. Rather than using string comparison, encode the 8 characters into an integer and
|
||||
* compare to a precomputed constants. This likely only works for the "C" locale.
|
||||
*/
|
||||
#define FNM_CC5(a, b, c, d, e) \
|
||||
(((ull)(a) << 48) | ((ull)(b) << 40) | ((ull)(c) << 32) | ((ull)(d) << 24) | \
|
||||
((ull)(e) << 16) | ((ull)':' << 8) | ((ull)']' << 0))
|
||||
#define FNM_CC6(a, b, c, d, e, f) \
|
||||
(((ull)(a) << 56) | ((ull)(b) << 48) | ((ull)(c) << 40) | ((ull)(d) << 32) | \
|
||||
((ull)(e) << 24) | ((ull)(f) << 16) | ((ull)':' << 8) | ((ull)']' << 0))
|
||||
|
||||
ull key;
|
||||
int ret;
|
||||
const char *p = *pattern;
|
||||
|
||||
/* check the leading "[:" */
|
||||
if ((p[0] != '[') || (p[1] != ':')) {
|
||||
return RANGE_ERROR;
|
||||
}
|
||||
|
||||
/* encode the remaining characters into a 64-bit integer */
|
||||
for (p += 2, key = 0; *p != EOS; ++p) {
|
||||
if (*(p - 1) == ']') {
|
||||
break;
|
||||
}
|
||||
|
||||
key <<= 8;
|
||||
key |= (unsigned char)(*p);
|
||||
}
|
||||
|
||||
switch (key) {
|
||||
case FNM_CC5('a', 'l', 'n', 'u', 'm'):
|
||||
ret = !isalnum(ch);
|
||||
break;
|
||||
case FNM_CC5('a', 'l', 'p', 'h', 'a'):
|
||||
ret = !isalpha(ch);
|
||||
break;
|
||||
case FNM_CC5('b', 'l', 'a', 'n', 'k'):
|
||||
ret = !isblank(ch);
|
||||
break;
|
||||
case FNM_CC5('c', 'n', 't', 'r', 'l'):
|
||||
ret = !iscntrl(ch);
|
||||
break;
|
||||
case FNM_CC5('d', 'i', 'g', 'i', 't'):
|
||||
ret = !isdigit(ch);
|
||||
break;
|
||||
case FNM_CC5('g', 'r', 'a', 'p', 'h'):
|
||||
ret = !isgraph(ch);
|
||||
break;
|
||||
case FNM_CC5('l', 'o', 'w', 'e', 'r'):
|
||||
ret = !islower(ch);
|
||||
break;
|
||||
case FNM_CC5('p', 'r', 'i', 'n', 't'):
|
||||
ret = !isprint(ch);
|
||||
break;
|
||||
case FNM_CC5('p', 'u', 'n', 'c', 't'):
|
||||
ret = !ispunct(ch);
|
||||
break;
|
||||
case FNM_CC5('s', 'p', 'a', 'c', 'e'):
|
||||
ret = !isspace(ch);
|
||||
break;
|
||||
case FNM_CC5('u', 'p', 'p', 'e', 'r'):
|
||||
ret = !isupper(ch);
|
||||
break;
|
||||
case FNM_CC6('x', 'd', 'i', 'g', 'i', 't'):
|
||||
ret = !isxdigit(ch);
|
||||
break;
|
||||
default:
|
||||
return RANGE_ERROR;
|
||||
}
|
||||
|
||||
*pattern = p;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int foldcase(int ch, int flags)
|
||||
{
|
||||
|
||||
if ((flags & FNM_CASEFOLD) != 0 && isupper(ch)) {
|
||||
if (((flags & FNM_CASEFOLD) != 0) && isupper(ch)) {
|
||||
return tolower(ch);
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
#define FOLDCASE(ch, flags) foldcase((unsigned char)(ch), (flags))
|
||||
|
||||
static const char *rangematch(const char *pattern, int test, int flags)
|
||||
static int rangematch(const char **pattern, char test, int flags)
|
||||
{
|
||||
bool negate, ok, need;
|
||||
char c, c2;
|
||||
|
||||
if (pattern == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
int negate, ok;
|
||||
const char *origpat;
|
||||
const char *pat = *pattern;
|
||||
|
||||
/*
|
||||
* A bracket expression starting with an unquoted circumflex
|
||||
@@ -76,90 +176,113 @@ static const char *rangematch(const char *pattern, int test, int flags)
|
||||
* consistency with the regular expression syntax.
|
||||
* J.T. Conklin (conklin@ngai.kaleida.com)
|
||||
*/
|
||||
negate = *pattern == '!' || *pattern == '^';
|
||||
negate = (*pat == '!' || *pat == '^');
|
||||
if (negate) {
|
||||
++pattern;
|
||||
++pat;
|
||||
}
|
||||
|
||||
for (need = true, ok = false, c = FOLDCASE(*pattern++, flags); c != ']' || need;
|
||||
c = FOLDCASE(*pattern++, flags)) {
|
||||
need = false;
|
||||
test = FOLDCASE(test, flags);
|
||||
|
||||
if (c == '/' && (flags & FNM_PATHNAME)) {
|
||||
return (void *)-1;
|
||||
}
|
||||
|
||||
if (c == '\\' && !(flags & FNM_NOESCAPE)) {
|
||||
if (*pattern != ']' && *pattern != EOS) {
|
||||
c = FOLDCASE(*pattern++, flags);
|
||||
/*
|
||||
* A right bracket shall lose its special meaning and represent
|
||||
* itself in a bracket expression if it occurs first in the list.
|
||||
* -- POSIX.2 2.8.3.2
|
||||
*/
|
||||
ok = 0;
|
||||
origpat = pat;
|
||||
for (;;) {
|
||||
if (*pat == ']' && pat > origpat) {
|
||||
pat++;
|
||||
break;
|
||||
} else if (*pat == '\0') {
|
||||
return RANGE_ERROR;
|
||||
} else if (*pat == '/' && (flags & FNM_PATHNAME)) {
|
||||
return RANGE_NOMATCH;
|
||||
} else if (*pat == '\\' && !(flags & FNM_NOESCAPE)) {
|
||||
pat++;
|
||||
} else {
|
||||
switch (rangematch_cc(&pat, test)) {
|
||||
case RANGE_ERROR:
|
||||
/* not a character class, proceed below */
|
||||
break;
|
||||
case RANGE_MATCH:
|
||||
/* a valid character class that was matched */
|
||||
ok = 1;
|
||||
continue;
|
||||
case RANGE_NOMATCH:
|
||||
/* a valid character class that was not matched */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (c == EOS) {
|
||||
return NULL;
|
||||
}
|
||||
c = FOLDCASE(*pat++, flags);
|
||||
|
||||
if (*pattern == '-') {
|
||||
c2 = FOLDCASE(*(pattern + 1), flags);
|
||||
if (c2 != EOS && c2 != ']') {
|
||||
pattern += 2;
|
||||
if (c2 == '\\' && !(flags & FNM_NOESCAPE)) {
|
||||
c2 = FOLDCASE(*pattern++, flags);
|
||||
if (*pat == '-' && *(pat + 1) != EOS && *(pat + 1) != ']') {
|
||||
if (*++pat == '\\' && !(flags & FNM_NOESCAPE)) {
|
||||
if (*pat != EOS) {
|
||||
pat++;
|
||||
}
|
||||
}
|
||||
c2 = FOLDCASE(*pat, flags);
|
||||
pat++;
|
||||
if (c2 == EOS) {
|
||||
return RANGE_ERROR;
|
||||
}
|
||||
|
||||
if (c2 == EOS) {
|
||||
return NULL;
|
||||
}
|
||||
if (flags & FNM_CASEFOLD) {
|
||||
c2 = tolower((int)c2);
|
||||
}
|
||||
|
||||
if (c <= test && test <= c2) {
|
||||
ok = true;
|
||||
}
|
||||
if (c <= test && test <= c2) {
|
||||
ok = 1;
|
||||
}
|
||||
} else if (c == test) {
|
||||
ok = true;
|
||||
ok = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return ok == negate ? NULL : pattern;
|
||||
if (ok != negate) {
|
||||
*pattern = pat;
|
||||
return RANGE_MATCH;
|
||||
}
|
||||
|
||||
return RANGE_NOMATCH;
|
||||
}
|
||||
|
||||
static int fnmatchx(const char *pattern, const char *string, int flags, size_t recursion)
|
||||
static int fnmatchx(const char *pattern, const char *string, const char *stringstart, int flags,
|
||||
size_t recursion)
|
||||
{
|
||||
const char *stringstart, *r;
|
||||
char c, test;
|
||||
|
||||
if (pattern == NULL || string == NULL) {
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
char c;
|
||||
char pc, sc;
|
||||
|
||||
if (recursion-- == 0) {
|
||||
return FNM_NORES;
|
||||
}
|
||||
|
||||
for (stringstart = string;;) {
|
||||
c = FOLDCASE(*pattern++, flags);
|
||||
switch (c) {
|
||||
while (true) {
|
||||
pc = FOLDCASE(*pattern++, flags);
|
||||
sc = FOLDCASE(*string, flags);
|
||||
switch (pc) {
|
||||
case EOS:
|
||||
if ((flags & FNM_LEADING_DIR) && *string == '/') {
|
||||
if (((flags & FNM_LEADING_DIR) != 0) && (sc == '/')) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return *string == EOS ? 0 : FNM_NOMATCH;
|
||||
if (sc == EOS) {
|
||||
return 0;
|
||||
}
|
||||
return FNM_NOMATCH;
|
||||
case '?':
|
||||
if (*string == EOS) {
|
||||
if (sc == EOS) {
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
if (*string == '/' && (flags & FNM_PATHNAME)) {
|
||||
if ((sc == '/') && ((flags & FNM_PATHNAME) != 0)) {
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
if (*string == '.' && (flags & FNM_PERIOD) &&
|
||||
(string == stringstart ||
|
||||
((flags & FNM_PATHNAME) && *(string - 1) == '/'))) {
|
||||
if ((sc == '.') && ((flags & FNM_PERIOD) != 0) &&
|
||||
((string == stringstart) ||
|
||||
(((flags & FNM_PATHNAME) != 0) && (*(string - 1) == '/')))) {
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
++string;
|
||||
break;
|
||||
case '*':
|
||||
@@ -169,107 +292,85 @@ static int fnmatchx(const char *pattern, const char *string, int flags, size_t r
|
||||
c = FOLDCASE(*++pattern, flags);
|
||||
}
|
||||
|
||||
if (*string == '.' && (flags & FNM_PERIOD) &&
|
||||
(string == stringstart ||
|
||||
((flags & FNM_PATHNAME) && *(string - 1) == '/'))) {
|
||||
if ((sc == '.') && ((flags & FNM_PERIOD) != 0) &&
|
||||
((string == stringstart) ||
|
||||
(((flags & FNM_PATHNAME) != 0) && (*(string - 1) == '/')))) {
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
/* Optimize for pattern with * at end or before /. */
|
||||
if (c == EOS) {
|
||||
if (flags & FNM_PATHNAME) {
|
||||
return (flags & FNM_LEADING_DIR) ||
|
||||
strchr(string, '/') == NULL
|
||||
? 0
|
||||
: FNM_NOMATCH;
|
||||
} else {
|
||||
if ((flags & FNM_PATHNAME) == 0) {
|
||||
return 0;
|
||||
}
|
||||
} else if (c == '/' && flags & FNM_PATHNAME) {
|
||||
|
||||
if (((flags & FNM_LEADING_DIR) != 0) ||
|
||||
(strchr(string, '/') == NULL)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return FNM_NOMATCH;
|
||||
} else if ((c == '/') && ((flags & FNM_PATHNAME) != 0)) {
|
||||
string = strchr(string, '/');
|
||||
if (string == NULL) {
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* General case, use recursion. */
|
||||
do {
|
||||
test = FOLDCASE(*string, flags);
|
||||
if (test == EOS) {
|
||||
while (sc != EOS) {
|
||||
if (fnmatchx(pattern, string, stringstart, flags, recursion) == 0) {
|
||||
return 0;
|
||||
}
|
||||
sc = FOLDCASE(*string, flags);
|
||||
if ((sc == '/') && ((flags & FNM_PATHNAME) != 0)) {
|
||||
break;
|
||||
}
|
||||
|
||||
int e = fnmatchx(pattern, string, flags & ~FNM_PERIOD, recursion);
|
||||
|
||||
if (e != FNM_NOMATCH) {
|
||||
return e;
|
||||
}
|
||||
|
||||
if (test == '/' && flags & FNM_PATHNAME) {
|
||||
break;
|
||||
}
|
||||
|
||||
++string;
|
||||
} while (true);
|
||||
|
||||
}
|
||||
return FNM_NOMATCH;
|
||||
case '[':
|
||||
if (*string == EOS) {
|
||||
if (sc == EOS) {
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
if ((sc == '/') && ((flags & FNM_PATHNAME) != 0)) {
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
if ((sc == '.') && ((flags & FNM_PERIOD) != 0) &&
|
||||
((string == stringstart) ||
|
||||
(((flags & FNM_PATHNAME) != 0) && (*(string - 1) == '/')))) {
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
if (*string == '/' && flags & FNM_PATHNAME) {
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
if (*string == '.' && (flags & FNM_PERIOD) &&
|
||||
(string == stringstart ||
|
||||
((flags & FNM_PATHNAME) && *(string - 1) == '/'))) {
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
r = rangematch(pattern, FOLDCASE(*string, flags), flags);
|
||||
|
||||
if (r == NULL) {
|
||||
if (FOLDCASE('[', flags) != FOLDCASE(*string, flags)) {
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
++string;
|
||||
switch (rangematch(&pattern, sc, flags)) {
|
||||
case RANGE_ERROR:
|
||||
goto norm;
|
||||
case RANGE_MATCH:
|
||||
break;
|
||||
case RANGE_NOMATCH:
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
if (r == (void *)-1) {
|
||||
if (*string != '[') {
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
} else {
|
||||
pattern = r;
|
||||
}
|
||||
|
||||
++string;
|
||||
break;
|
||||
case '\\':
|
||||
if (!(flags & FNM_NOESCAPE)) {
|
||||
c = FOLDCASE(*pattern++, flags);
|
||||
if (c == EOS) {
|
||||
c = '\0';
|
||||
--pattern;
|
||||
}
|
||||
if ((flags & FNM_NOESCAPE) == 0) {
|
||||
pc = FOLDCASE(*pattern++, flags);
|
||||
}
|
||||
__fallthrough;
|
||||
default:
|
||||
if (c != FOLDCASE(*string++, flags)) {
|
||||
norm:
|
||||
if (pc != sc) {
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
++string;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CODE_UNREACHABLE;
|
||||
}
|
||||
|
||||
int fnmatch(const char *pattern, const char *string, int flags)
|
||||
{
|
||||
return fnmatchx(pattern, string, flags, 64);
|
||||
return fnmatchx(pattern, string, string, flags, 64);
|
||||
}
|
||||
|
||||
@@ -57,6 +57,8 @@ static void lvgl_pointer_process_event(struct input_event *evt, void *user_data)
|
||||
data->common_data.pending_event.state =
|
||||
evt->value ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (!evt->sync) {
|
||||
|
||||
@@ -122,6 +122,7 @@ int notify_new_tx_frame(struct net_pkt *pkt);
|
||||
otError infra_if_init(otInstance *instance, struct net_if *ail_iface);
|
||||
otError infra_if_start_icmp6_listener(void);
|
||||
void infra_if_stop_icmp6_listener(void);
|
||||
void udp_plat_init_sockfd(void);
|
||||
otError udp_plat_init(otInstance *ot_instance, struct net_if *ail_iface, struct net_if *ot_iface);
|
||||
void udp_plat_deinit(void);
|
||||
otError mdns_plat_socket_init(otInstance *ot_instance, uint32_t ail_iface_idx);
|
||||
|
||||
@@ -36,6 +36,13 @@ static void udp_receive_handler(struct net_socket_service_event *evt);
|
||||
NET_SOCKET_SERVICE_SYNC_DEFINE_STATIC(handle_udp_receive, udp_receive_handler,
|
||||
CONFIG_OPENTHREAD_ZEPHYR_BORDER_ROUTER_MAX_UDP_SERVICES);
|
||||
|
||||
void udp_plat_init_sockfd(void)
|
||||
{
|
||||
for (uint8_t i = 0; i < CONFIG_OPENTHREAD_ZEPHYR_BORDER_ROUTER_MAX_UDP_SERVICES; i++) {
|
||||
sockfd_udp[i].fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
otError udp_plat_init(otInstance *ot_instance, struct net_if *ail_iface, struct net_if *ot_iface)
|
||||
{
|
||||
ot_instance_ptr = ot_instance;
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
&ieee802154 {
|
||||
status = "okay";
|
||||
};
|
||||
27
scripts/utils/west-packages-pip-install.cmd
Normal file
27
scripts/utils/west-packages-pip-install.cmd
Normal file
@@ -0,0 +1,27 @@
|
||||
:: SPDX-FileCopyrightText: Copyright The Zephyr Project Contributors
|
||||
:: SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
@echo off
|
||||
rem Collect packages from west and install them with a single pip call.
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
set "PACKAGES="
|
||||
|
||||
for /f "usebackq delims=" %%p in (`west packages pip`) do (
|
||||
if defined PACKAGES (
|
||||
set "PACKAGES=!PACKAGES! %%p"
|
||||
) else (
|
||||
set "PACKAGES=%%p"
|
||||
)
|
||||
)
|
||||
|
||||
if not defined PACKAGES (
|
||||
echo west packages pip returned no packages to install.
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
echo Installing packages with: python.exe -m pip install %PACKAGES%
|
||||
python.exe -m pip install %PACKAGES%
|
||||
set "RESULT=%ERRORLEVEL%"
|
||||
|
||||
endlocal & exit /b %RESULT%
|
||||
@@ -4,13 +4,15 @@
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
from itertools import chain
|
||||
from pathlib import Path
|
||||
from pathlib import Path, PureWindowsPath
|
||||
|
||||
from west.commands import WestCommand
|
||||
from west.util import quote_sh_list
|
||||
from zephyr_ext_common import ZEPHYR_BASE
|
||||
|
||||
sys.path.append(os.fspath(Path(__file__).parent.parent))
|
||||
@@ -157,11 +159,38 @@ class Packages(WestCommand):
|
||||
self.die("Running pip install outside of a virtual environment")
|
||||
|
||||
if len(requirements) > 0:
|
||||
subprocess.check_call(
|
||||
[sys.executable, "-m", "pip", "install"]
|
||||
+ list(chain.from_iterable([("-r", r) for r in requirements]))
|
||||
+ manager_args
|
||||
cmd = [sys.executable, "-m", "pip", "install"]
|
||||
cmd += chain.from_iterable([("-r", str(r)) for r in requirements])
|
||||
cmd += manager_args
|
||||
self.dbg(quote_sh_list(cmd))
|
||||
|
||||
# Use os.execv to execute a new program, replacing the current west process,
|
||||
# this unloads all python modules first and allows for pip to update packages safely
|
||||
if platform.system() != 'Windows':
|
||||
os.execv(cmd[0], cmd)
|
||||
|
||||
# Only reachable on Windows systems
|
||||
# Windows does not really support os.execv:
|
||||
# https://github.com/python/cpython/issues/63323
|
||||
# https://github.com/python/cpython/issues/101191
|
||||
# Warn the users about permission errors as those reported in:
|
||||
# https://github.com/zephyrproject-rtos/zephyr/issues/100296
|
||||
cmdscript = (
|
||||
PureWindowsPath(__file__).parents[1] / "utils" / "west-packages-pip-install.cmd"
|
||||
)
|
||||
self.wrn(
|
||||
"Updating packages on Windows with 'west packages pip --install', that are "
|
||||
"currently in use by west, results in permission errors. Leaving your "
|
||||
"environment with conflicting package versions. Recommended is to start with "
|
||||
"a new environment in that case.\n\n"
|
||||
"To avoid this using powershell run the following command instead:\n"
|
||||
f"{sys.executable} -m pip install @((west packages pip) -split ' ')\n\n"
|
||||
"Using cmd.exe execute the helper script:\n"
|
||||
f"cmd /c {cmdscript}\n\n"
|
||||
"Running 'west packages pip --install -- --dry-run' can provide information "
|
||||
"without actually updating the environment."
|
||||
)
|
||||
subprocess.check_call(cmd)
|
||||
else:
|
||||
self.inf("Nothing to install")
|
||||
return
|
||||
|
||||
@@ -7,6 +7,7 @@ config SOC_SERIES_RP2350
|
||||
select HAS_RPI_PICO
|
||||
select HAS_SEGGER_RTT if ZEPHYR_SEGGER_MODULE
|
||||
select SOC_RESET_HOOK
|
||||
imply XIP
|
||||
|
||||
config SOC_RP2350A_HAZARD3
|
||||
select HAS_FLASH_LOAD_OFFSET
|
||||
|
||||
@@ -13,6 +13,22 @@ configdefault SYS_CLOCK_TICKS_PER_SEC
|
||||
configdefault UART_NS16550_DW8250_DW_APB
|
||||
default y
|
||||
|
||||
configdefault ZERO_LATENCY_IRQS
|
||||
default y
|
||||
|
||||
configdefault ZERO_LATENCY_LEVELS
|
||||
default 2
|
||||
|
||||
if PM_DEVICE
|
||||
|
||||
configdefault PM_DEVICE_RUNTIME
|
||||
default y
|
||||
|
||||
configdefault POWER_DOMAIN
|
||||
default y
|
||||
|
||||
endif # PM_DEVICE
|
||||
|
||||
if SILABS_SIWX91X_NWP
|
||||
|
||||
# WiseConnect create threads with realtime priority. Default (10kHz) clock tick
|
||||
|
||||
@@ -311,29 +311,14 @@ void radio_phy_set(uint8_t phy, uint8_t flags)
|
||||
|
||||
void radio_tx_power_set(int8_t power)
|
||||
{
|
||||
#if defined(CONFIG_SOC_COMPATIBLE_NRF54LX)
|
||||
uint32_t value;
|
||||
|
||||
value = hal_radio_tx_power_value(power);
|
||||
NRF_RADIO->TXPOWER = value;
|
||||
|
||||
#elif defined(CONFIG_SOC_COMPATIBLE_NRF5340_CPUNET)
|
||||
uint32_t value;
|
||||
|
||||
/* NOTE: TXPOWER register only accepts upto 0dBm, hence use the HAL
|
||||
* floor value for the TXPOWER register. Permit +3dBm by using high
|
||||
* voltage being set for radio.
|
||||
*/
|
||||
value = hal_radio_tx_power_floor(power);
|
||||
NRF_RADIO->TXPOWER = value;
|
||||
#if defined(CONFIG_SOC_COMPATIBLE_NRF5340_CPUNET)
|
||||
hal_radio_tx_power_high_voltage_set(power);
|
||||
|
||||
#else /* !CONFIG_SOC_COMPATIBLE_NRF5340_CPUNET && !CONFIG_SOC_COMPATIBLE_NRF54LX */
|
||||
|
||||
/* NOTE: valid value range is passed by Kconfig define. */
|
||||
NRF_RADIO->TXPOWER = (uint32_t)power;
|
||||
|
||||
#endif /* !CONFIG_SOC_COMPATIBLE_NRF5340_CPUNET && !CONFIG_SOC_COMPATIBLE_NRF54LX */
|
||||
#endif /* CONFIG_SOC_COMPATIBLE_NRF5340_CPUNET */
|
||||
}
|
||||
|
||||
void radio_tx_power_max_set(void)
|
||||
@@ -346,32 +331,17 @@ void radio_tx_power_max_set(void)
|
||||
|
||||
int8_t radio_tx_power_min_get(void)
|
||||
{
|
||||
return (int8_t)hal_radio_tx_power_min_get();
|
||||
return hal_radio_tx_power_min_get();
|
||||
}
|
||||
|
||||
int8_t radio_tx_power_max_get(void)
|
||||
{
|
||||
#if defined(CONFIG_SOC_COMPATIBLE_NRF5340_CPUNET)
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
|
||||
#else /* !CONFIG_SOC_COMPATIBLE_NRF5340_CPUNET */
|
||||
return (int8_t)hal_radio_tx_power_max_get();
|
||||
|
||||
#endif /* !CONFIG_SOC_COMPATIBLE_NRF5340_CPUNET */
|
||||
return hal_radio_tx_power_max_get();
|
||||
}
|
||||
|
||||
int8_t radio_tx_power_floor(int8_t power)
|
||||
{
|
||||
#if defined(CONFIG_SOC_COMPATIBLE_NRF5340_CPUNET)
|
||||
/* NOTE: TXPOWER register only accepts upto 0dBm, +3dBm permitted by
|
||||
* use of high voltage being set for radio when TXPOWER register is set.
|
||||
*/
|
||||
if (power >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos3dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
}
|
||||
#endif /* CONFIG_SOC_COMPATIBLE_NRF5340_CPUNET */
|
||||
|
||||
return (int8_t)hal_radio_tx_power_floor(power);
|
||||
return hal_radio_tx_power_floor(power);
|
||||
}
|
||||
|
||||
void radio_freq_chan_set(uint32_t chan)
|
||||
|
||||
@@ -67,43 +67,77 @@ static inline uint32_t hal_radio_phy_mode_get(uint8_t phy, uint8_t flags)
|
||||
return mode;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_min_get(void)
|
||||
static inline int8_t hal_radio_tx_power_min_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Neg30dBm;
|
||||
return -30; /* -30 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_max_get(void)
|
||||
static inline int8_t hal_radio_tx_power_max_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
return 4; /* +4 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
static inline int8_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm) {
|
||||
if (tx_power_lvl >= 4) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -4) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -8) {
|
||||
return -8;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -12) {
|
||||
return -12;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -16) {
|
||||
return -16;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -20) {
|
||||
return -20;
|
||||
}
|
||||
|
||||
/* Note: The -30 dBm power level is deprecated so ignore it! */
|
||||
return -40;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_value(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= 4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_0dBm) {
|
||||
if (tx_power_lvl >= 0) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg4dBm) {
|
||||
if (tx_power_lvl >= -4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg8dBm) {
|
||||
if (tx_power_lvl >= -8) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg12dBm) {
|
||||
if (tx_power_lvl >= -12) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg16dBm) {
|
||||
if (tx_power_lvl >= -16) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg20dBm) {
|
||||
if (tx_power_lvl >= -20) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
}
|
||||
|
||||
|
||||
@@ -255,51 +255,88 @@ static inline uint32_t hal_radio_phy_mode_get(uint8_t phy, uint8_t flags)
|
||||
return mode;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_min_get(void)
|
||||
static inline int8_t hal_radio_tx_power_min_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
return -40; /* -40 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_max_get(void)
|
||||
static inline int8_t hal_radio_tx_power_max_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
return 4; /* +4 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
static inline int8_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
if (tx_power_lvl >= 4) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos3dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
if (tx_power_lvl >= 3) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_0dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
if (tx_power_lvl >= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
if (tx_power_lvl >= -4) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg8dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
if (tx_power_lvl >= -8) {
|
||||
return -8;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg12dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
if (tx_power_lvl >= -12) {
|
||||
return -12;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg16dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
if (tx_power_lvl >= -16) {
|
||||
return -16;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg20dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
if (tx_power_lvl >= -20) {
|
||||
return -20;
|
||||
}
|
||||
|
||||
/* Note: The -30 dBm power level is deprecated so ignore it! */
|
||||
return -40;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_value(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= 4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 3) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 0) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -8) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -12) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -16) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -20) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
}
|
||||
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
}
|
||||
|
||||
|
||||
@@ -274,51 +274,88 @@ static inline uint32_t hal_radio_phy_mode_get(uint8_t phy, uint8_t flags)
|
||||
return mode;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_min_get(void)
|
||||
static inline int8_t hal_radio_tx_power_min_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
return -40; /* -40 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_max_get(void)
|
||||
static inline int8_t hal_radio_tx_power_max_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
return 4; /* +4 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
static inline int8_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
if (tx_power_lvl >= 4) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos3dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
if (tx_power_lvl >= 3) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_0dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
if (tx_power_lvl >= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
if (tx_power_lvl >= -4) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg8dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
if (tx_power_lvl >= -8) {
|
||||
return -8;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg12dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
if (tx_power_lvl >= -12) {
|
||||
return -12;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg16dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
if (tx_power_lvl >= -16) {
|
||||
return -16;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg20dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
if (tx_power_lvl >= -20) {
|
||||
return -20;
|
||||
}
|
||||
|
||||
/* Note: The -30 dBm power level is deprecated so ignore it! */
|
||||
return -40;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_value(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= 4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 3) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 0) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -8) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -12) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -16) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -20) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
}
|
||||
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
}
|
||||
|
||||
|
||||
@@ -444,51 +444,88 @@ static inline uint32_t hal_radio_phy_mode_get(uint8_t phy, uint8_t flags)
|
||||
return mode;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_min_get(void)
|
||||
static inline int8_t hal_radio_tx_power_min_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
return -40; /* -40 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_max_get(void)
|
||||
static inline int8_t hal_radio_tx_power_max_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
return 4; /* +4 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
static inline int8_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
if (tx_power_lvl >= 4) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos3dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
if (tx_power_lvl >= 3) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_0dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
if (tx_power_lvl >= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
if (tx_power_lvl >= -4) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg8dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
if (tx_power_lvl >= -8) {
|
||||
return -8;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg12dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
if (tx_power_lvl >= -12) {
|
||||
return -12;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg16dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
if (tx_power_lvl >= -16) {
|
||||
return -16;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg20dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
if (tx_power_lvl >= -20) {
|
||||
return -20;
|
||||
}
|
||||
|
||||
/* Note: The -30 dBm power level is deprecated so ignore it! */
|
||||
return -40;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_value(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= 4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 3) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 0) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -8) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -12) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -16) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -20) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
}
|
||||
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
}
|
||||
|
||||
|
||||
@@ -433,71 +433,128 @@ static inline uint32_t hal_radio_phy_mode_get(uint8_t phy, uint8_t flags)
|
||||
return mode;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_min_get(void)
|
||||
static inline int8_t hal_radio_tx_power_min_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
return -40; /* -40 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_max_get(void)
|
||||
static inline int8_t hal_radio_tx_power_max_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Pos8dBm;
|
||||
return 8; /* +8 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
static inline int8_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos8dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos8dBm;
|
||||
if (tx_power_lvl >= 8) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos7dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos7dBm;
|
||||
if (tx_power_lvl >= 7) {
|
||||
return 7;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos6dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos6dBm;
|
||||
if (tx_power_lvl >= 6) {
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos5dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos5dBm;
|
||||
if (tx_power_lvl >= 5) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
if (tx_power_lvl >= 4) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos3dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
if (tx_power_lvl >= 3) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos2dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos2dBm;
|
||||
if (tx_power_lvl >= 2) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_0dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
if (tx_power_lvl >= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
if (tx_power_lvl >= -4) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg8dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
if (tx_power_lvl >= -8) {
|
||||
return -8;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg12dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
if (tx_power_lvl >= -12) {
|
||||
return -12;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg16dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
if (tx_power_lvl >= -16) {
|
||||
return -16;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg20dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
if (tx_power_lvl >= -20) {
|
||||
return -20;
|
||||
}
|
||||
|
||||
/* Note: The -30 dBm power level is deprecated so ignore it! */
|
||||
return -40;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_value(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= 8) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos8dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 7) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos7dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 6) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos6dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 5) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos5dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 3) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 2) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos2dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 0) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -8) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -12) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -16) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -20) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
}
|
||||
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
}
|
||||
|
||||
|
||||
@@ -272,51 +272,88 @@ static inline uint32_t hal_radio_phy_mode_get(uint8_t phy, uint8_t flags)
|
||||
return mode;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_min_get(void)
|
||||
static inline int8_t hal_radio_tx_power_min_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
return -40; /* -40 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_max_get(void)
|
||||
static inline int8_t hal_radio_tx_power_max_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
return 4; /* +4 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
static inline int8_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
if (tx_power_lvl >= 4) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos3dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
if (tx_power_lvl >= 3) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_0dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
if (tx_power_lvl >= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
if (tx_power_lvl >= -4) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg8dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
if (tx_power_lvl >= -8) {
|
||||
return -8;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg12dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
if (tx_power_lvl >= -12) {
|
||||
return -12;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg16dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
if (tx_power_lvl >= -16) {
|
||||
return -16;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg20dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
if (tx_power_lvl >= -20) {
|
||||
return -20;
|
||||
}
|
||||
|
||||
/* Note: The -30 dBm power level is deprecated so ignore it! */
|
||||
return -40;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_value(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= 4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 3) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 0) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -8) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -12) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -16) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -20) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
}
|
||||
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
}
|
||||
|
||||
|
||||
@@ -443,71 +443,128 @@ static inline uint32_t hal_radio_phy_mode_get(uint8_t phy, uint8_t flags)
|
||||
return mode;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_min_get(void)
|
||||
static inline int8_t hal_radio_tx_power_min_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
return -40; /* -40 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_max_get(void)
|
||||
static inline int8_t hal_radio_tx_power_max_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Pos8dBm;
|
||||
return 8; /* +8 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
static inline int8_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos8dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos8dBm;
|
||||
if (tx_power_lvl >= 8) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos7dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos7dBm;
|
||||
if (tx_power_lvl >= 7) {
|
||||
return 7;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos6dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos6dBm;
|
||||
if (tx_power_lvl >= 6) {
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos5dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos5dBm;
|
||||
if (tx_power_lvl >= 5) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
if (tx_power_lvl >= 4) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos3dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
if (tx_power_lvl >= 3) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos2dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos2dBm;
|
||||
if (tx_power_lvl >= 2) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_0dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
if (tx_power_lvl >= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
if (tx_power_lvl >= -4) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg8dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
if (tx_power_lvl >= -8) {
|
||||
return -8;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg12dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
if (tx_power_lvl >= -12) {
|
||||
return -12;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg16dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
if (tx_power_lvl >= -16) {
|
||||
return -16;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg20dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
if (tx_power_lvl >= -20) {
|
||||
return -20;
|
||||
}
|
||||
|
||||
/* Note: The -30 dBm power level is deprecated so ignore it! */
|
||||
return -40;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_value(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= 8) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos8dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 7) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos7dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 6) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos6dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 5) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos5dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 3) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 2) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos2dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 0) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -8) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -12) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -16) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -20) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
}
|
||||
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
}
|
||||
|
||||
|
||||
@@ -457,71 +457,128 @@ static inline uint32_t hal_radio_phy_mode_get(uint8_t phy, uint8_t flags)
|
||||
return mode;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_min_get(void)
|
||||
static inline int8_t hal_radio_tx_power_min_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
return -40; /* -40 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_max_get(void)
|
||||
static inline int8_t hal_radio_tx_power_max_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Pos8dBm;
|
||||
return 8; /* +8 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
static inline int8_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos8dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos8dBm;
|
||||
if (tx_power_lvl >= 8) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos7dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos7dBm;
|
||||
if (tx_power_lvl >= 7) {
|
||||
return 7;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos6dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos6dBm;
|
||||
if (tx_power_lvl >= 6) {
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos5dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos5dBm;
|
||||
if (tx_power_lvl >= 5) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
if (tx_power_lvl >= 4) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos3dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
if (tx_power_lvl >= 3) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos2dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos2dBm;
|
||||
if (tx_power_lvl >= 2) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_0dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
if (tx_power_lvl >= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
if (tx_power_lvl >= -4) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg8dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
if (tx_power_lvl >= -8) {
|
||||
return -8;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg12dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
if (tx_power_lvl >= -12) {
|
||||
return -12;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg16dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
if (tx_power_lvl >= -16) {
|
||||
return -16;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg20dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
if (tx_power_lvl >= -20) {
|
||||
return -20;
|
||||
}
|
||||
|
||||
/* Note: The -30 dBm power level is deprecated so ignore it! */
|
||||
return -40;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_value(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= 8) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos8dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 7) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos7dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 6) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos6dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 5) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos5dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 3) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 2) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos2dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 0) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -8) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -12) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -16) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -20) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
}
|
||||
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
}
|
||||
|
||||
|
||||
@@ -357,13 +357,6 @@
|
||||
#endif /* !CONFIG_BT_CTLR_TIFS_HW */
|
||||
#endif /* !CONFIG_BT_CTLR_RADIO_ENABLE_FAST */
|
||||
|
||||
/* nRF5340 supports +3dBm Tx Power using high voltage request, define +3dBm
|
||||
* value for Controller use.
|
||||
*/
|
||||
#ifndef RADIO_TXPOWER_TXPOWER_Pos3dBm
|
||||
#define RADIO_TXPOWER_TXPOWER_Pos3dBm (0x03UL)
|
||||
#endif
|
||||
|
||||
/* HAL abstraction of Radio bitfields */
|
||||
#define HAL_NRF_RADIO_EVENT_END NRF_RADIO_EVENT_END
|
||||
#define HAL_RADIO_EVENTS_END EVENTS_END
|
||||
@@ -452,73 +445,130 @@ static inline uint32_t hal_radio_phy_mode_get(uint8_t phy, uint8_t flags)
|
||||
return mode;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_max_get(void)
|
||||
static inline int8_t hal_radio_tx_power_max_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
return 3; /* 3 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_min_get(void)
|
||||
static inline int8_t hal_radio_tx_power_min_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
return -40; /* -40 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
static inline int8_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_0dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
if (tx_power_lvl >= 3) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg1dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg1dBm;
|
||||
if (tx_power_lvl >= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg2dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg2dBm;
|
||||
if (tx_power_lvl >= -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg3dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg3dBm;
|
||||
if (tx_power_lvl >= -2) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
if (tx_power_lvl >= -3) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg5dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg5dBm;
|
||||
if (tx_power_lvl >= -4) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg6dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg6dBm;
|
||||
if (tx_power_lvl >= -5) {
|
||||
return -5;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg7dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg7dBm;
|
||||
if (tx_power_lvl >= -6) {
|
||||
return -6;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg8dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
if (tx_power_lvl >= -7) {
|
||||
return -7;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg12dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
if (tx_power_lvl >= -8) {
|
||||
return -8;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg16dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
if (tx_power_lvl >= -12) {
|
||||
return -12;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg20dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
if (tx_power_lvl >= -16) {
|
||||
return -16;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -20) {
|
||||
return -20;
|
||||
}
|
||||
|
||||
/* Note: The -30 dBm power level is deprecated so ignore it! */
|
||||
return -40;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_value(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= 0) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -1) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg1dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -2) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg2dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -3) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg3dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -5) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg5dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -6) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg6dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -7) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg7dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -8) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -12) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -16) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -20) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
}
|
||||
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
}
|
||||
|
||||
static inline void hal_radio_tx_power_high_voltage_set(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos3dBm) {
|
||||
if (tx_power_lvl >= 3) {
|
||||
nrf_vreqctrl_radio_high_voltage_set(NRF_VREQCTRL, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,63 +5,63 @@
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_TX_PWR_PLUS_10)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos10dBm
|
||||
#define RADIO_TXP_DEFAULT (+10)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_PLUS_9)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos9dBm
|
||||
#define RADIO_TXP_DEFAULT (+9)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_PLUS_8)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos8dBm
|
||||
#define RADIO_TXP_DEFAULT (+8)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_PLUS_7)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos7dBm
|
||||
#define RADIO_TXP_DEFAULT (+7)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_PLUS_6)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos6dBm
|
||||
#define RADIO_TXP_DEFAULT (+6)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_PLUS_5)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos5dBm
|
||||
#define RADIO_TXP_DEFAULT (+5)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_PLUS_4)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos4dBm
|
||||
#define RADIO_TXP_DEFAULT (+4)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_PLUS_3)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos3dBm
|
||||
#define RADIO_TXP_DEFAULT (+3)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_PLUS_2)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos2dBm
|
||||
#define RADIO_TXP_DEFAULT (+2)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_PLUS_1)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos1dBm
|
||||
#define RADIO_TXP_DEFAULT (+1)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_0)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_0dBm
|
||||
#define RADIO_TXP_DEFAULT (0)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_1)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg1dBm
|
||||
#define RADIO_TXP_DEFAULT (-1)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_2)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg2dBm
|
||||
#define RADIO_TXP_DEFAULT (-2)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_3)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg3dBm
|
||||
#define RADIO_TXP_DEFAULT (-3)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_4)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg4dBm
|
||||
#define RADIO_TXP_DEFAULT (-4)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_5)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg5dBm
|
||||
#define RADIO_TXP_DEFAULT (-5)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_6)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg6dBm
|
||||
#define RADIO_TXP_DEFAULT (-6)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_7)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg7dBm
|
||||
#define RADIO_TXP_DEFAULT (-7)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_8)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg8dBm
|
||||
#define RADIO_TXP_DEFAULT (-8)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_9)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg9dBm
|
||||
#define RADIO_TXP_DEFAULT (-9)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_10)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg10dBm
|
||||
#define RADIO_TXP_DEFAULT (-10)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_12)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg12dBm
|
||||
#define RADIO_TXP_DEFAULT (-12)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_14)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg14dBm
|
||||
#define RADIO_TXP_DEFAULT (-14)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_16)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg16dBm
|
||||
#define RADIO_TXP_DEFAULT (-16)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_20)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg20dBm
|
||||
#define RADIO_TXP_DEFAULT (-20)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_26)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg26dBm
|
||||
#define RADIO_TXP_DEFAULT (-26)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_30)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg30dBm
|
||||
#define RADIO_TXP_DEFAULT (-30)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_40)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg40dBm
|
||||
#define RADIO_TXP_DEFAULT (-40)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_46)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg46dBm
|
||||
#define RADIO_TXP_DEFAULT (-46)
|
||||
#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_70)
|
||||
#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg70dBm
|
||||
#define RADIO_TXP_DEFAULT (-70)
|
||||
#endif
|
||||
|
||||
@@ -408,71 +408,128 @@ static inline uint32_t hal_radio_phy_mode_get(uint8_t phy, uint8_t flags)
|
||||
return mode;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_min_get(void)
|
||||
static inline int8_t hal_radio_tx_power_min_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
return -40; /* -40 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_max_get(void)
|
||||
static inline int8_t hal_radio_tx_power_max_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Pos8dBm;
|
||||
return 8; /* +8 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
static inline int8_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos8dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos8dBm;
|
||||
if (tx_power_lvl >= 8) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos7dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos7dBm;
|
||||
if (tx_power_lvl >= 7) {
|
||||
return 7;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos6dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos6dBm;
|
||||
if (tx_power_lvl >= 6) {
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos5dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos5dBm;
|
||||
if (tx_power_lvl >= 5) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
if (tx_power_lvl >= 4) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos3dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
if (tx_power_lvl >= 3) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos2dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos2dBm;
|
||||
if (tx_power_lvl >= 2) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_0dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
if (tx_power_lvl >= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
if (tx_power_lvl >= -4) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg8dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
if (tx_power_lvl >= -8) {
|
||||
return -8;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg12dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
if (tx_power_lvl >= -12) {
|
||||
return -12;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg16dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
if (tx_power_lvl >= -16) {
|
||||
return -16;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg20dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
if (tx_power_lvl >= -20) {
|
||||
return -20;
|
||||
}
|
||||
|
||||
/* Note: The -30 dBm power level is deprecated so ignore it! */
|
||||
return -40;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_value(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= 8) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos8dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 7) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos7dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 6) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos6dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 5) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos5dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 3) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 2) {
|
||||
return RADIO_TXPOWER_TXPOWER_Pos2dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= 0) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -8) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -12) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -16) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -20) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
}
|
||||
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
}
|
||||
|
||||
|
||||
@@ -355,13 +355,6 @@
|
||||
#endif /* !CONFIG_BT_CTLR_TIFS_HW */
|
||||
#endif /* !CONFIG_BT_CTLR_RADIO_ENABLE_FAST */
|
||||
|
||||
/* nRF5340 supports +3dBm Tx Power using high voltage request, define +3dBm
|
||||
* value for Controller use.
|
||||
*/
|
||||
#ifndef RADIO_TXPOWER_TXPOWER_Pos3dBm
|
||||
#define RADIO_TXPOWER_TXPOWER_Pos3dBm (0x03UL)
|
||||
#endif
|
||||
|
||||
/* HAL abstraction of Radio bitfields */
|
||||
#define HAL_NRF_RADIO_EVENT_END NRF_RADIO_EVENT_END
|
||||
#define HAL_RADIO_EVENTS_END EVENTS_END
|
||||
@@ -432,73 +425,130 @@ static inline uint32_t hal_radio_phy_mode_get(uint8_t phy, uint8_t flags)
|
||||
return mode;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_max_get(void)
|
||||
static inline int8_t hal_radio_tx_power_max_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
return 3; /* 3 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_min_get(void)
|
||||
static inline int8_t hal_radio_tx_power_min_get(void)
|
||||
{
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
return -40; /* -40 dBm */
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
static inline int8_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_0dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
if (tx_power_lvl >= 3) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg1dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg1dBm;
|
||||
if (tx_power_lvl >= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg2dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg2dBm;
|
||||
if (tx_power_lvl >= -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg3dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg3dBm;
|
||||
if (tx_power_lvl >= -2) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg4dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
if (tx_power_lvl >= -3) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg5dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg5dBm;
|
||||
if (tx_power_lvl >= -4) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg6dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg6dBm;
|
||||
if (tx_power_lvl >= -5) {
|
||||
return -5;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg7dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg7dBm;
|
||||
if (tx_power_lvl >= -6) {
|
||||
return -6;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg8dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
if (tx_power_lvl >= -7) {
|
||||
return -7;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg12dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
if (tx_power_lvl >= -8) {
|
||||
return -8;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg16dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
if (tx_power_lvl >= -12) {
|
||||
return -12;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg20dBm) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
if (tx_power_lvl >= -16) {
|
||||
return -16;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -20) {
|
||||
return -20;
|
||||
}
|
||||
|
||||
/* Note: The -30 dBm power level is deprecated so ignore it! */
|
||||
return -40;
|
||||
}
|
||||
|
||||
static inline uint32_t hal_radio_tx_power_value(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= 0) {
|
||||
return RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -1) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg1dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -2) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg2dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -3) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg3dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -4) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -5) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg5dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -6) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg6dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -7) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg7dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -8) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -12) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -16) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg16dBm;
|
||||
}
|
||||
|
||||
if (tx_power_lvl >= -20) {
|
||||
return RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
}
|
||||
|
||||
return RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
}
|
||||
|
||||
static inline void hal_radio_tx_power_high_voltage_set(int8_t tx_power_lvl)
|
||||
{
|
||||
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos3dBm) {
|
||||
if (tx_power_lvl >= 3) {
|
||||
nrf_vreqctrl_radio_high_voltage_set(NRF_VREQCTRL, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1856,6 +1856,8 @@ static void le_frame_space_update_complete(struct net_buf *buf)
|
||||
}
|
||||
|
||||
bt_conn_notify_frame_space_update_complete(conn, ¶ms);
|
||||
|
||||
bt_conn_unref(conn);
|
||||
}
|
||||
#endif /* CONFIG_BT_FRAME_SPACE_UPDATE */
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <zephyr/logging/log.h>
|
||||
#include <zephyr/devicetree.h>
|
||||
#include <zephyr/dfu/mcuboot.h>
|
||||
#include <zephyr/dfu/flash_img.h>
|
||||
#include <zephyr/dfu/mcuboot.h>
|
||||
@@ -23,11 +24,16 @@ LOG_MODULE_REGISTER(flash_img, CONFIG_IMG_MANAGER_LOG_LEVEL);
|
||||
#include <bootutil/bootutil_public.h>
|
||||
#endif
|
||||
|
||||
#define FIXED_PARTITION_GET_FLASH_NODE(node_id) \
|
||||
COND_CODE_1(DT_NODE_HAS_COMPAT(DT_PARENT(node_id), fixed_subpartitions), \
|
||||
(DT_PARENT(DT_GPARENT(node_id))), (DT_GPARENT(node_id)))
|
||||
|
||||
#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \
|
||||
DT_SAME_NODE(FIXED_PARTITION_GET_FLASH_NODE(DT_CHOSEN(zephyr_code_partition)), \
|
||||
FIXED_PARTITION_GET_FLASH_NODE(DT_NODELABEL(label))) && \
|
||||
(FIXED_PARTITION_OFFSET(label) <= CONFIG_FLASH_LOAD_OFFSET && \
|
||||
FIXED_PARTITION_OFFSET(label) + FIXED_PARTITION_SIZE(label) > CONFIG_FLASH_LOAD_OFFSET)
|
||||
|
||||
#include <zephyr/devicetree.h>
|
||||
#if defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) && (CONFIG_TFM_MCUBOOT_IMAGE_NUMBER == 2)
|
||||
#define UPLOAD_FLASH_AREA_LABEL slot1_ns_partition
|
||||
#else
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2021 mcumgr authors
|
||||
* Copyright (c) 2022-2024 Nordic Semiconductor ASA
|
||||
* Copyright (c) 2022-2025 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -48,7 +48,13 @@
|
||||
to be able to figure out application running slot.
|
||||
#endif
|
||||
|
||||
#define FIXED_PARTITION_GET_FLASH_NODE(node_id) \
|
||||
COND_CODE_1(DT_NODE_HAS_COMPAT(DT_PARENT(node_id), fixed_subpartitions), \
|
||||
(DT_PARENT(DT_GPARENT(node_id))), (DT_GPARENT(node_id)))
|
||||
|
||||
#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \
|
||||
DT_SAME_NODE(FIXED_PARTITION_GET_FLASH_NODE(DT_CHOSEN(zephyr_code_partition)), \
|
||||
FIXED_PARTITION_GET_FLASH_NODE(DT_NODELABEL(label))) && \
|
||||
(FIXED_PARTITION_OFFSET(label) <= CONFIG_FLASH_LOAD_OFFSET && \
|
||||
FIXED_PARTITION_OFFSET(label) + FIXED_PARTITION_SIZE(label) > CONFIG_FLASH_LOAD_OFFSET)
|
||||
|
||||
|
||||
@@ -361,15 +361,13 @@ img_mgmt_state_any_pending(void)
|
||||
int
|
||||
img_mgmt_slot_in_use(int slot)
|
||||
{
|
||||
#if defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER)
|
||||
return 0;
|
||||
#else
|
||||
int image = img_mgmt_slot_to_image(slot);
|
||||
int active_slot = img_mgmt_active_slot(image);
|
||||
|
||||
#if !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP) && \
|
||||
!defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD) && \
|
||||
!defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD_WITH_REVERT)
|
||||
!defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD_WITH_REVERT) && \
|
||||
!defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER)
|
||||
enum img_mgmt_next_boot_type type = NEXT_BOOT_TYPE_NORMAL;
|
||||
int nbs = img_mgmt_get_next_boot_slot(image, &type);
|
||||
|
||||
@@ -391,7 +389,6 @@ img_mgmt_slot_in_use(int slot)
|
||||
#endif
|
||||
|
||||
return (active_slot == slot);
|
||||
#endif /* !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER) */
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <zcbor_common.h>
|
||||
#include <zcbor_encode.h>
|
||||
@@ -117,8 +118,6 @@ struct datetime_parser {
|
||||
#define RTC_DATETIME_MINUTE_MAX 59
|
||||
#define RTC_DATETIME_SECOND_MIN 0
|
||||
#define RTC_DATETIME_SECOND_MAX 59
|
||||
#define RTC_DATETIME_MILLISECOND_MIN 0
|
||||
#define RTC_DATETIME_MILLISECOND_MAX 999
|
||||
|
||||
/* Size used for datetime creation buffer */
|
||||
#ifdef CONFIG_MCUMGR_GRP_OS_DATETIME_MS
|
||||
@@ -129,7 +128,7 @@ struct datetime_parser {
|
||||
|
||||
/* Minimum/maximum size of a datetime string that a client can provide */
|
||||
#define RTC_DATETIME_MIN_STRING_SIZE 19
|
||||
#define RTC_DATETIME_MAX_STRING_SIZE 26
|
||||
#define RTC_DATETIME_MAX_STRING_SIZE 31
|
||||
#endif
|
||||
|
||||
/* Specifies what the "all" ('a') of info parameter shows */
|
||||
@@ -969,7 +968,7 @@ static int os_mgmt_datetime_write(struct smp_streamer *ctxt)
|
||||
bool ok = true;
|
||||
char *pos;
|
||||
char *new_pos;
|
||||
char date_string[RTC_DATETIME_MAX_STRING_SIZE];
|
||||
char date_string[RTC_DATETIME_MAX_STRING_SIZE + 1];
|
||||
struct rtc_time new_time = {
|
||||
.tm_wday = -1,
|
||||
.tm_yday = -1,
|
||||
@@ -1024,7 +1023,7 @@ static int os_mgmt_datetime_write(struct smp_streamer *ctxt)
|
||||
if (zcbor_map_decode_bulk(zsd, datetime_decode, ARRAY_SIZE(datetime_decode), &decoded)) {
|
||||
return MGMT_ERR_EINVAL;
|
||||
} else if (datetime.len < RTC_DATETIME_MIN_STRING_SIZE ||
|
||||
datetime.len >= RTC_DATETIME_MAX_STRING_SIZE) {
|
||||
datetime.len > RTC_DATETIME_MAX_STRING_SIZE) {
|
||||
return MGMT_ERR_EINVAL;
|
||||
}
|
||||
|
||||
@@ -1060,16 +1059,20 @@ static int os_mgmt_datetime_write(struct smp_streamer *ctxt)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MCUMGR_GRP_OS_DATETIME_MS
|
||||
if (*(pos - 1) == '.' && *pos != '\0') {
|
||||
/* Provided value has a ms value, extract it */
|
||||
new_time.tm_nsec = strtol(pos, &new_pos, RTC_DATETIME_NUMERIC_BASE);
|
||||
if (*(pos - 1) == '.') {
|
||||
uint32_t msec = 0;
|
||||
uint32_t mul = 100; /* first digit: 10^-1 second = 100 ms */
|
||||
|
||||
if (new_time.tm_nsec < RTC_DATETIME_MILLISECOND_MIN ||
|
||||
new_time.tm_nsec > RTC_DATETIME_MILLISECOND_MAX) {
|
||||
return MGMT_ERR_EINVAL;
|
||||
/* Parse up to 3 fractional digits */
|
||||
while (isdigit((unsigned char)*pos) && mul >= 1) {
|
||||
msec += (uint32_t)(*pos - '0') * mul;
|
||||
mul /= 10;
|
||||
pos++;
|
||||
}
|
||||
|
||||
new_time.tm_nsec *= RTC_DATETIME_MS_TO_NS;
|
||||
/* "." without digits yields 0 µs */
|
||||
|
||||
new_time.tm_nsec = msec * RTC_DATETIME_MS_TO_NS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -297,7 +297,8 @@ static void ot_bbr_multicast_listener_handler(void *context,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
struct net_route_entry_mcast *route_to_del = net_route_mcast_lookup(&recv_addr);
|
||||
struct net_route_entry_mcast *route_to_del =
|
||||
net_route_mcast_lookup_by_iface(&recv_addr, ot_context->iface);
|
||||
struct net_if_mcast_addr *addr_to_del;
|
||||
|
||||
addr_to_del = net_if_ipv6_maddr_lookup(&recv_addr, &(ot_context->iface));
|
||||
@@ -307,6 +308,8 @@ static void ot_bbr_multicast_listener_handler(void *context,
|
||||
|
||||
if (addr_to_del != NULL && net_if_ipv6_maddr_is_joined(addr_to_del)) {
|
||||
net_if_ipv6_maddr_leave(ot_context->iface, addr_to_del);
|
||||
net_if_ipv6_maddr_rm(ot_context->iface,
|
||||
(const struct in6_addr *)&recv_addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -325,6 +328,7 @@ void openthread_border_router_init(struct openthread_context *ot_ctx)
|
||||
NET_EVENT_IPV4_ADDR_ADD);
|
||||
net_mgmt_add_event_callback(&ail_net_event_ipv4_addr_cb);
|
||||
#endif /* CONFIG_NET_IPV4 */
|
||||
udp_plat_init_sockfd();
|
||||
openthread_set_bbr_multicast_listener_cb(ot_bbr_multicast_listener_handler, (void *)ot_ctx);
|
||||
(void)infra_if_start_icmp6_listener();
|
||||
}
|
||||
|
||||
@@ -486,7 +486,6 @@ int mdns_unpack_query_header(struct dns_msg_t *msg, uint16_t *src_id)
|
||||
int dns_unpack_name(const uint8_t *msg, int maxlen, const uint8_t *src,
|
||||
struct net_buf *buf, const uint8_t **eol)
|
||||
{
|
||||
int dest_size = net_buf_tailroom(buf);
|
||||
const uint8_t *end_of_label = NULL;
|
||||
const uint8_t *curr_src = src;
|
||||
int loop_check = 0, len = -1;
|
||||
@@ -525,6 +524,8 @@ int dns_unpack_name(const uint8_t *msg, int maxlen, const uint8_t *src,
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
} else {
|
||||
size_t dest_size = net_buf_tailroom(buf);
|
||||
|
||||
/* Max label length is 64 bytes (because 2 bits are
|
||||
* used for pointer)
|
||||
*/
|
||||
@@ -533,8 +534,7 @@ int dns_unpack_name(const uint8_t *msg, int maxlen, const uint8_t *src,
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
if (((buf->data + label_len + 1) >=
|
||||
(buf->data + dest_size)) ||
|
||||
if ((label_len + 1 >= dest_size) ||
|
||||
((curr_src + label_len) >= (msg + maxlen))) {
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
@@ -612,9 +612,14 @@ static int http_server_run(struct http_server_ctx *ctx)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Listening socket error, abort. */
|
||||
LOG_ERR("Listening socket error, aborting.");
|
||||
ret = -sock_error;
|
||||
|
||||
if (ret == -ENETDOWN) {
|
||||
LOG_INF("Network is down");
|
||||
} else {
|
||||
LOG_ERR("Listening socket error, aborting. (%d)", ret);
|
||||
}
|
||||
|
||||
goto closing;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Copyright (c) 2018 Intel Corporation.
|
||||
* Copyright (c) 2021 Nordic Semiconductor ASA.
|
||||
* Copyright (c) 2025 HubbleNetwork.
|
||||
* Copyright (c) 2025 NXP.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -159,16 +160,20 @@ static int get_sync_locked(const struct device *dev)
|
||||
uint32_t flags = pm->base.flags;
|
||||
|
||||
if (pm->base.usage == 0) {
|
||||
if (flags & BIT(PM_DEVICE_FLAG_PD_CLAIMED)) {
|
||||
if ((flags & BIT(PM_DEVICE_FLAG_PD_CLAIMED)) == 0) {
|
||||
const struct device *domain = PM_DOMAIN(&pm->base);
|
||||
|
||||
if (domain->pm_base->flags & BIT(PM_DEVICE_FLAG_ISR_SAFE)) {
|
||||
ret = pm_device_runtime_get(domain);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
if (domain != NULL) {
|
||||
if ((domain->pm_base->flags & BIT(PM_DEVICE_FLAG_ISR_SAFE)) != 0) {
|
||||
ret = pm_device_runtime_get(domain);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
/* Power domain successfully claimed */
|
||||
pm->base.flags |= BIT(PM_DEVICE_FLAG_PD_CLAIMED);
|
||||
} else {
|
||||
return -EWOULDBLOCK;
|
||||
}
|
||||
} else {
|
||||
return -EWOULDBLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,6 +336,7 @@ static int put_sync_locked(const struct device *dev)
|
||||
|
||||
if (domain->pm_base->flags & BIT(PM_DEVICE_FLAG_ISR_SAFE)) {
|
||||
ret = put_sync_locked(domain);
|
||||
pm->base.flags &= ~BIT(PM_DEVICE_FLAG_PD_CLAIMED);
|
||||
} else {
|
||||
ret = -EWOULDBLOCK;
|
||||
}
|
||||
|
||||
@@ -98,6 +98,15 @@ config SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE
|
||||
escape sequences). However, if bulk data is transferred it may be
|
||||
required to increase it.
|
||||
|
||||
config SHELL_BACKEND_SERIAL_NEEDS_LARGE_RING_BUFFER
|
||||
bool
|
||||
default y if SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE > $(INT16_MAX)
|
||||
default y if SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE > $(INT16_MAX)
|
||||
select RING_BUFFER_LARGE
|
||||
help
|
||||
This is a helper Kconfig to select RING_BUFFER_LARGE when the implementation
|
||||
requires a ring buffer of > 32kB.
|
||||
|
||||
if SHELL_BACKEND_SERIAL_API_ASYNC
|
||||
|
||||
config SHELL_BACKEND_SERIAL_ASYNC_RX_TIMEOUT
|
||||
@@ -322,6 +331,14 @@ config SHELL_MQTT_RX_BUF_SIZE
|
||||
help
|
||||
Buffer size for the MQTT data reception.
|
||||
|
||||
config SHELL_MQTT_NEEDS_LARGE_RING_BUFFER
|
||||
bool
|
||||
default y if SHELL_MQTT_RX_BUF_SIZE > $(INT16_MAX)
|
||||
select RING_BUFFER_LARGE
|
||||
help
|
||||
This is a helper Kconfig to select RING_BUFFER_LARGE when the implementation
|
||||
requires a ring buffer of > 32kB.
|
||||
|
||||
config SHELL_MQTT_TX_BUF_SIZE
|
||||
int "TX buffer size"
|
||||
range 32 $(UINT16_MAX)
|
||||
|
||||
@@ -465,6 +465,7 @@ error:
|
||||
static void telnet_server_cb(struct net_socket_service_event *evt)
|
||||
{
|
||||
int sock_error;
|
||||
int ret;
|
||||
socklen_t optlen = sizeof(int);
|
||||
|
||||
if (sh_telnet == NULL) {
|
||||
@@ -475,7 +476,14 @@ static void telnet_server_cb(struct net_socket_service_event *evt)
|
||||
(evt->event.revents & ZSOCK_POLLNVAL)) {
|
||||
(void)zsock_getsockopt(evt->event.fd, SOL_SOCKET,
|
||||
SO_ERROR, &sock_error, &optlen);
|
||||
NET_ERR("Telnet socket %d error (%d)", evt->event.fd, sock_error);
|
||||
|
||||
ret = -sock_error;
|
||||
|
||||
if (ret == -ENETDOWN) {
|
||||
LOG_INF("Network is down");
|
||||
} else {
|
||||
LOG_ERR("Telnet socket %d error (%d)", evt->event.fd, ret);
|
||||
}
|
||||
|
||||
if (evt->event.fd == sh_telnet->fds[SOCK_ID_CLIENT].fd) {
|
||||
telnet_end_client_connection();
|
||||
|
||||
@@ -142,21 +142,66 @@ static const struct gpio_dt_spec cs_loopback_gpio =
|
||||
GPIO_DT_SPEC_GET_OR(DT_PATH(zephyr_user), cs_loopback_gpios, {0});
|
||||
static struct gpio_callback cs_cb_data;
|
||||
atomic_t cs_count;
|
||||
int cs_start;
|
||||
|
||||
static void spi_loopback_gpio_cs_loopback_prepare(void)
|
||||
{
|
||||
/* record start state of CS pin and reset edge counter */
|
||||
cs_start = gpio_pin_get_dt(&cs_loopback_gpio);
|
||||
atomic_set(&cs_count, 0);
|
||||
}
|
||||
|
||||
/* valid expected triggers are 0, 1, or 2, and this function input is not validated */
|
||||
static int spi_loopback_gpio_cs_loopback_check(int expected_triggers)
|
||||
{
|
||||
int actual_triggers = atomic_get(&cs_count);
|
||||
/* 1 should mean CS is asserted, 0 not */
|
||||
int cs_level = gpio_pin_get_dt(&cs_loopback_gpio);
|
||||
|
||||
if (actual_triggers != expected_triggers) {
|
||||
TC_PRINT("Expected %d CS triggers, got %d", expected_triggers, actual_triggers);
|
||||
/* putting this first simplifies a lot of the checks needed below */
|
||||
if (actual_triggers > expected_triggers) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Case should not happen unless test is set up wrong */
|
||||
if (actual_triggers == 0 && cs_level != cs_start) {
|
||||
TC_PRINT("Got 0 triggers but CS changed, GPIO interrupt not working?");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* already handled error case for this */
|
||||
if (expected_triggers == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* all the other cases should get at least one gpio callback */
|
||||
if (actual_triggers == 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* a lot of the following code for cases of expecting 1 and 2 is for
|
||||
* handling race conditions due to gpio interrupt latency, where two edges can happen
|
||||
* before the first one's interrupt is processed
|
||||
*/
|
||||
|
||||
/* expected case is that cs level is opposite of start */
|
||||
if ((expected_triggers == 1) && (cs_level == cs_start)) {
|
||||
/* only possibly case at this point is that the CS triggered twice */
|
||||
actual_triggers = 2;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* expected case is that cs level is same as start */
|
||||
if ((expected_triggers == 2) && (cs_level != cs_start)) {
|
||||
/* only possibly case at this point is that the CS triggered once */
|
||||
actual_triggers = 1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
error:
|
||||
TC_PRINT("Expected %d CS triggers, got %d", expected_triggers, actual_triggers);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void cs_callback(const struct device *port,
|
||||
@@ -167,7 +212,6 @@ static void cs_callback(const struct device *port,
|
||||
ARG_UNUSED(cb);
|
||||
ARG_UNUSED(pins);
|
||||
|
||||
/* Give semaphore to indicate CS triggered */
|
||||
atomic_inc(&cs_count);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_DNS_RESOLVER_LOG_LEVEL);
|
||||
|
||||
#define NET_LOG_ENABLED 1
|
||||
#include "net_private.h"
|
||||
#include "dns_pack.h"
|
||||
|
||||
#if defined(CONFIG_DNS_RESOLVER_LOG_LEVEL_DBG)
|
||||
#define DBG(fmt, ...) printk(fmt, ##__VA_ARGS__)
|
||||
@@ -909,4 +910,143 @@ ZTEST(dns_resolve, test_dns_localhost_resolve_ipv6)
|
||||
0, "not loopback address");
|
||||
}
|
||||
|
||||
NET_BUF_POOL_DEFINE(test_dns_qname_pool, 2, CONFIG_DNS_RESOLVER_MAX_QUERY_LEN,
|
||||
0, NULL);
|
||||
|
||||
ZTEST(dns_resolve, test_dns_unpack_name)
|
||||
{
|
||||
/* NULL string terminator serves a role of a final zero-length label */
|
||||
static const uint8_t *test_records[] = {
|
||||
/* example.com */
|
||||
"\007example\003com",
|
||||
/* www.zephyrproject.org */
|
||||
"\003www\015zephyrproject\003org",
|
||||
/* These records should barely fit (fills up the buffer size limit). */
|
||||
"\077very_long_record_that_has_a_length_of_63_bytes_xxxxxxxxxxxxxxxx"
|
||||
"\077very_long_record_that_has_a_length_of_63_bytes_xxxxxxxxxxxxxxxx"
|
||||
"\077very_long_record_that_has_a_length_of_63_bytes_xxxxxxxxxxxxxxxx"
|
||||
"\076very_long_record_that_has_a_length_of_62_bytes_xxxxxxxxxxxxxxx",
|
||||
};
|
||||
static const uint8_t *expected_names[] = {
|
||||
"example.com",
|
||||
"www.zephyrproject.org",
|
||||
"very_long_record_that_has_a_length_of_63_bytes_xxxxxxxxxxxxxxxx."
|
||||
"very_long_record_that_has_a_length_of_63_bytes_xxxxxxxxxxxxxxxx."
|
||||
"very_long_record_that_has_a_length_of_63_bytes_xxxxxxxxxxxxxxxx."
|
||||
"very_long_record_that_has_a_length_of_62_bytes_xxxxxxxxxxxxxxx",
|
||||
|
||||
};
|
||||
struct net_buf *result;
|
||||
int ret;
|
||||
|
||||
zassert_equal(CONFIG_DNS_RESOLVER_MAX_QUERY_LEN, 255, "Invalid test configuration");
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(test_records); i++) {
|
||||
const uint8_t *end_of_label = NULL;
|
||||
|
||||
result = net_buf_alloc(&test_dns_qname_pool, K_NO_WAIT);
|
||||
zassert_not_null(result, "Failed to allocate buffer");
|
||||
|
||||
/* +1 to include NULL as terminating label */
|
||||
ret = dns_unpack_name(test_records[i], strlen(test_records[i]) + 1,
|
||||
test_records[i], result, &end_of_label);
|
||||
zassert_equal(ret, strlen(expected_names[i]),
|
||||
"Error parsing records (%d)", ret);
|
||||
zassert_str_equal(expected_names[i], result->data,
|
||||
"Parsed wrong name (%s)", result->data);
|
||||
zassert_equal_ptr(test_records[i] + strlen(test_records[i]) + 1,
|
||||
end_of_label, "Wrong end of label");
|
||||
|
||||
net_buf_unref(result);
|
||||
}
|
||||
}
|
||||
|
||||
ZTEST(dns_resolve, test_dns_unpack_name_with_pointer)
|
||||
{
|
||||
static const uint8_t test_records[] = {
|
||||
/* www.example.com followed by ftp.example.com with pointer */
|
||||
"\003www\007example\003com\000\003ftp\300\004" /* Last two bytes are pointer */
|
||||
};
|
||||
static const uint8_t *expected_names[] = {
|
||||
"www.example.com",
|
||||
"ftp.example.com",
|
||||
};
|
||||
const size_t offset_2nd_rec = 17;
|
||||
const uint8_t *end_of_label = NULL;
|
||||
struct net_buf *result;
|
||||
int ret;
|
||||
|
||||
/* First name */
|
||||
result = net_buf_alloc(&test_dns_qname_pool, K_NO_WAIT);
|
||||
zassert_not_null(result, "Failed to allocate buffer");
|
||||
|
||||
ret = dns_unpack_name(test_records, sizeof(test_records),
|
||||
test_records, result, &end_of_label);
|
||||
zassert_equal(ret, strlen(expected_names[0]),
|
||||
"Error parsing records (%d)", ret);
|
||||
zassert_str_equal(expected_names[0], result->data,
|
||||
"Parsed wrong name (%s)", result->data);
|
||||
zassert_equal_ptr(test_records + offset_2nd_rec, end_of_label,
|
||||
"Wrong end of label");
|
||||
|
||||
net_buf_unref(result);
|
||||
|
||||
/* Second name with a pointer within */
|
||||
end_of_label = NULL;
|
||||
|
||||
result = net_buf_alloc(&test_dns_qname_pool, K_NO_WAIT);
|
||||
zassert_not_null(result, "Failed to allocate buffer");
|
||||
|
||||
ret = dns_unpack_name(test_records, sizeof(test_records),
|
||||
test_records + offset_2nd_rec, result, &end_of_label);
|
||||
zassert_equal(ret, strlen(expected_names[1]),
|
||||
"Error parsing records (%d)", ret);
|
||||
zassert_str_equal(expected_names[1], result->data,
|
||||
"Parsed wrong name (%s)", result->data);
|
||||
/* -1 as end_of_label should point to the last byte in the buffer (pointer offset) */
|
||||
zassert_equal_ptr(test_records + sizeof(test_records) - 1, end_of_label,
|
||||
"Wrong end of label");
|
||||
|
||||
net_buf_unref(result);
|
||||
}
|
||||
|
||||
ZTEST(dns_resolve, test_dns_unpack_name_overflow)
|
||||
{
|
||||
static const uint8_t *test_records[] = {
|
||||
/* 4 records 63 bytes (252 bytes) + 3 bytes for dot separators,
|
||||
* no space left for NULL terminator.
|
||||
*/
|
||||
"\077very_long_record_that_has_a_length_of_63_bytes_xxxxxxxxxxxxxxxx"
|
||||
"\077very_long_record_that_has_a_length_of_63_bytes_xxxxxxxxxxxxxxxx"
|
||||
"\077very_long_record_that_has_a_length_of_63_bytes_xxxxxxxxxxxxxxxx"
|
||||
"\077very_long_record_that_has_a_length_of_63_bytes_xxxxxxxxxxxxxxxx",
|
||||
/* 4 records fit (251 bytes), 4 bytes for dot separators, 5th one-byte
|
||||
* record won't fit.
|
||||
*/
|
||||
"\077very_long_record_that_has_a_length_of_63_bytes_xxxxxxxxxxxxxxxx"
|
||||
"\077very_long_record_that_has_a_length_of_63_bytes_xxxxxxxxxxxxxxxx"
|
||||
"\077very_long_record_that_has_a_length_of_63_bytes_xxxxxxxxxxxxxxxx"
|
||||
"\076very_long_record_that_has_a_length_of_62_bytes_xxxxxxxxxxxxxxx"
|
||||
"\001x",
|
||||
/* Single 64 byte record, that's forbidden (max record len is 63). */
|
||||
"\100very_long_record_that_has_a_length_of_64_bytes_that_is_incorrect",
|
||||
};
|
||||
struct net_buf *result;
|
||||
int ret;
|
||||
|
||||
zassert_equal(CONFIG_DNS_RESOLVER_MAX_QUERY_LEN, 255, "Invalid test configuration");
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(test_records); i++) {
|
||||
result = net_buf_alloc(&test_dns_qname_pool, K_NO_WAIT);
|
||||
zassert_not_null(result, "Failed to allocate buffer");
|
||||
|
||||
/* +1 to include NULL as terminating label */
|
||||
ret = dns_unpack_name(test_records[i], strlen(test_records[i]) + 1,
|
||||
test_records[i], result, NULL);
|
||||
zassert_equal(ret, -EMSGSIZE, "Name parsing should've failed");
|
||||
|
||||
net_buf_unref(result);
|
||||
}
|
||||
}
|
||||
|
||||
ZTEST_SUITE(dns_resolve, NULL, test_init, NULL, NULL, NULL);
|
||||
|
||||
@@ -1,20 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Meta
|
||||
* Copyright (c) The Zephyr Project Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <zephyr/posix/fnmatch.h>
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
/*
|
||||
* Note: the \x00 control character is specifically excluded below, since testing for it is
|
||||
* equivalent to reading past the end of a '\0'-terminated string (i.e. can fault).
|
||||
*/
|
||||
#define TEST_BLANK_CHARS " \t"
|
||||
#define TEST_CNTRL_CHARS \
|
||||
"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16" \
|
||||
"\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f"
|
||||
#define TEST_DIGIT_CHARS "0123456789"
|
||||
#define TEST_LOWER_CHARS "abcdefghijklmnopqrstuvwxyz"
|
||||
#define TEST_PUNCT_CHARS "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
|
||||
#define TEST_SPACE_CHARS " \f\n\r\t\v"
|
||||
#define TEST_UPPER_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
#define TEST_XDIGIT_CHARS "0123456789ABCDEFabcdef"
|
||||
|
||||
/*
|
||||
* Adapted from
|
||||
* https://git.musl-libc.org/cgit/libc-testsuite/tree/fnmatch.c
|
||||
*/
|
||||
ZTEST(posix_c_lib_ext, test_fnmatch)
|
||||
{
|
||||
/* Note: commented out lines indicate known problems to be addressed in #55186 */
|
||||
|
||||
zassert_ok(fnmatch("*.c", "foo.c", 0));
|
||||
zassert_ok(fnmatch("*.c", ".c", 0));
|
||||
zassert_equal(fnmatch("*.a", "foo.c", 0), FNM_NOMATCH);
|
||||
@@ -30,8 +45,31 @@ ZTEST(posix_c_lib_ext, test_fnmatch)
|
||||
zassert_equal(fnmatch("a*.c", "a/x.c", FNM_PATHNAME), FNM_NOMATCH);
|
||||
zassert_ok(fnmatch("*/foo", "/foo", FNM_PATHNAME));
|
||||
zassert_ok(fnmatch("-O[01]", "-O1", 0));
|
||||
zassert_ok(fnmatch("[[?*\\]", "\\", 0));
|
||||
zassert_ok(fnmatch("[]?*\\]", "]", 0));
|
||||
/*
|
||||
* '\' in pattern escapes ']'. bracket expression is incomplete. pattern is interpreted as
|
||||
* literal sequence '[[?*\]'. which does not match input '\'
|
||||
*/
|
||||
zassert_equal(fnmatch("[[?*\\]", "\\", 0), FNM_NOMATCH);
|
||||
/* '\' in pattern does not escape ']'. bracket expression complete. '\' matches input '\' */
|
||||
zassert_ok(fnmatch("[[?*\\]", "\\", FNM_NOESCAPE));
|
||||
/* '\' in pattern escapes '\', match '\' */
|
||||
zassert_ok(fnmatch("[[?*\\\\]", "\\", 0));
|
||||
/*
|
||||
* "[]" (empty bracket expression) is an invalid pattern.
|
||||
* > The ( ']' ) shall lose its special meaning and represent itself in a bracket expression
|
||||
* > if it occurs first in the list (after an initial ( '^' ), if any)
|
||||
* https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_05
|
||||
*
|
||||
* So the next test is (again) and incomplete bracket expression and should return error.
|
||||
* The two tests that follow it also require the ']' to be treated as a literal character to
|
||||
* match within the bracket expression.
|
||||
*/
|
||||
zassert_equal(fnmatch("[]?*\\]", "]", 0), FNM_NOMATCH);
|
||||
/* '\' in pattern does not escape. bracket expression complete. ']' matches input ']' */
|
||||
zassert_ok(fnmatch("[]?*\\]", "]", FNM_NOESCAPE));
|
||||
/* '\' in pattern escapes '\'. bracket expression complete. ']' matches input ']' */
|
||||
zassert_ok(fnmatch("[]?*\\\\]", "]", 0));
|
||||
|
||||
zassert_ok(fnmatch("[!]a-]", "b", 0));
|
||||
zassert_ok(fnmatch("[]-_]", "^", 0));
|
||||
zassert_ok(fnmatch("[!]-_]", "X", 0));
|
||||
@@ -73,11 +111,58 @@ ZTEST(posix_c_lib_ext, test_fnmatch)
|
||||
zassert_equal(fnmatch("*/*", "a/.b", FNM_PATHNAME | FNM_PERIOD), FNM_NOMATCH);
|
||||
zassert_ok(fnmatch("*?*/*", "a/.b", FNM_PERIOD));
|
||||
zassert_ok(fnmatch("*[.]/b", "a./b", FNM_PATHNAME | FNM_PERIOD));
|
||||
/* zassert_ok(fnmatch("*[[:alpha:]]/""*[[:alnum:]]", "a/b", FNM_PATHNAME)); */
|
||||
zassert_not_equal(fnmatch("*[![:digit:]]*/[![:d-d]", "a/b", FNM_PATHNAME), 0);
|
||||
zassert_not_equal(fnmatch("*[![:digit:]]*/[[:d-d]", "a/[", FNM_PATHNAME), 0);
|
||||
zassert_not_equal(fnmatch("*[![:digit:]]*/[![:d-d]", "a/[", FNM_PATHNAME), 0);
|
||||
zassert_ok(fnmatch("*[[:alpha:]]/*[[:alnum:]]", "a/b", FNM_PATHNAME));
|
||||
zassert_ok(fnmatch("*[![:digit:]]*/[![:d-d]", "a/b", FNM_PATHNAME), 0);
|
||||
zassert_ok(fnmatch("*[![:digit:]]*/[[:d-d]", "a/[", FNM_PATHNAME), 0);
|
||||
zassert_equal(fnmatch("*[![:digit:]]*/[![:d-d]", "a/[", FNM_PATHNAME), FNM_NOMATCH);
|
||||
zassert_ok(fnmatch("a?b", "a.b", FNM_PATHNAME | FNM_PERIOD));
|
||||
zassert_ok(fnmatch("a*b", "a.b", FNM_PATHNAME | FNM_PERIOD));
|
||||
zassert_ok(fnmatch("a[.]b", "a.b", FNM_PATHNAME | FNM_PERIOD));
|
||||
|
||||
/* Additional test cases for POSIX character classes (C-locale only) */
|
||||
static const struct test_data_s {
|
||||
const char *pattern;
|
||||
const char *match;
|
||||
const char *nomatch;
|
||||
} test_data[] = {
|
||||
{"[[:alnum:]]", TEST_DIGIT_CHARS TEST_UPPER_CHARS TEST_LOWER_CHARS, " "},
|
||||
{"[[:alpha:]]", TEST_UPPER_CHARS TEST_LOWER_CHARS, "0"},
|
||||
{"[[:blank:]]", TEST_BLANK_CHARS, "x"},
|
||||
{"[[:cntrl:]]", TEST_CNTRL_CHARS, "x"},
|
||||
{"[[:digit:]]", TEST_DIGIT_CHARS, "a"},
|
||||
{"[[:graph:]]", TEST_DIGIT_CHARS TEST_UPPER_CHARS TEST_LOWER_CHARS TEST_PUNCT_CHARS,
|
||||
" "},
|
||||
{"[[:lower:]]", TEST_LOWER_CHARS, "X"},
|
||||
{"[[:print:]]",
|
||||
TEST_DIGIT_CHARS TEST_UPPER_CHARS TEST_LOWER_CHARS TEST_PUNCT_CHARS " ", "\t"},
|
||||
{"[[:punct:]]", TEST_PUNCT_CHARS, "x"},
|
||||
{"[[:space:]]", TEST_SPACE_CHARS, "x"},
|
||||
{"[[:upper:]]", TEST_UPPER_CHARS, "x"},
|
||||
{"[[:xdigit:]]", TEST_XDIGIT_CHARS, "h"},
|
||||
};
|
||||
|
||||
ARRAY_FOR_EACH_PTR(test_data, data) {
|
||||
/* ensure that characters in "nomatch" do not match "pattern" */
|
||||
for (size_t j = 0; j < strlen(data->nomatch); j++) {
|
||||
char c = data->nomatch[j];
|
||||
char input[] = {c, '\0'};
|
||||
|
||||
zexpect_equal(fnmatch(data->pattern, input, 0), FNM_NOMATCH,
|
||||
"pattern \"%s\" unexpectedly matched char 0x%02x (%c)",
|
||||
data->pattern, c, isprint(c) ? c : '.');
|
||||
}
|
||||
|
||||
/* ensure that characters in "match" do match "pattern" */
|
||||
for (size_t j = 0; j < strlen(data->match); j++) {
|
||||
char c = data->match[j];
|
||||
char input[] = {c, '\0'};
|
||||
|
||||
zexpect_ok(fnmatch(data->pattern, input, 0),
|
||||
"pattern \"%s\" did not match char 0x%02x (%c)", data->pattern,
|
||||
c, isprint(c) ? c : '.');
|
||||
}
|
||||
}
|
||||
|
||||
/* ensure that an invalid character class generates an error */
|
||||
zassert_equal(fnmatch("[[:foobarbaz:]]", "Z", 0), FNM_NOMATCH);
|
||||
}
|
||||
|
||||
@@ -6,13 +6,20 @@
|
||||
*/
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
#include <zephyr/devicetree.h>
|
||||
#include <zephyr/storage/flash_map.h>
|
||||
#include <zephyr/dfu/flash_img.h>
|
||||
|
||||
#define SLOT0_PARTITION slot0_partition
|
||||
#define SLOT1_PARTITION slot1_partition
|
||||
|
||||
#define FIXED_PARTITION_GET_FLASH_NODE(node_id) \
|
||||
COND_CODE_1(DT_NODE_HAS_COMPAT(DT_PARENT(node_id), fixed_subpartitions), \
|
||||
(DT_PARENT(DT_GPARENT(node_id))), (DT_GPARENT(node_id)))
|
||||
|
||||
#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \
|
||||
DT_SAME_NODE(FIXED_PARTITION_GET_FLASH_NODE(DT_CHOSEN(zephyr_code_partition)), \
|
||||
FIXED_PARTITION_GET_FLASH_NODE(DT_NODELABEL(label))) && \
|
||||
(FIXED_PARTITION_OFFSET(label) <= CONFIG_FLASH_LOAD_OFFSET && \
|
||||
FIXED_PARTITION_OFFSET(label) + FIXED_PARTITION_SIZE(label) > CONFIG_FLASH_LOAD_OFFSET)
|
||||
|
||||
|
||||
8
tests/subsys/pm/power_domain/Kconfig
Normal file
8
tests/subsys/pm/power_domain/Kconfig
Normal file
@@ -0,0 +1,8 @@
|
||||
# Copyright 2025 NXP
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
source "Kconfig.zephyr"
|
||||
|
||||
config TEST_PM_DEVICE_ISR_SAFE
|
||||
bool "Use ISR safe PM for the test"
|
||||
@@ -91,11 +91,14 @@ static int devb_pm_action(const struct device *dev,
|
||||
}
|
||||
|
||||
|
||||
PM_DEVICE_DT_DEFINE(TEST_DOMAIN, domain_pm_action);
|
||||
PM_DEVICE_DT_DEFINE(TEST_DOMAIN, domain_pm_action,
|
||||
COND_CODE_1(CONFIG_TEST_PM_DEVICE_ISR_SAFE, (PM_DEVICE_ISR_SAFE), (0)));
|
||||
|
||||
DEVICE_DT_DEFINE(TEST_DOMAIN, NULL, PM_DEVICE_DT_GET(TEST_DOMAIN),
|
||||
NULL, NULL, POST_KERNEL, 10, NULL);
|
||||
|
||||
PM_DEVICE_DT_DEFINE(TEST_DEVA, deva_pm_action);
|
||||
PM_DEVICE_DT_DEFINE(TEST_DEVA, deva_pm_action,
|
||||
COND_CODE_1(CONFIG_TEST_PM_DEVICE_ISR_SAFE, (PM_DEVICE_ISR_SAFE), (0)));
|
||||
DEVICE_DT_DEFINE(TEST_DEVA, NULL, PM_DEVICE_DT_GET(TEST_DEVA),
|
||||
NULL, NULL, POST_KERNEL, 20, NULL);
|
||||
|
||||
@@ -157,18 +160,22 @@ ZTEST(power_domain_1cpu, test_power_domain_device_runtime)
|
||||
|
||||
pm_device_state_get(deva, &state);
|
||||
zassert_equal(state, PM_DEVICE_STATE_ACTIVE);
|
||||
zassert_true(atomic_test_bit(&deva->pm_base->flags, PM_DEVICE_FLAG_PD_CLAIMED));
|
||||
|
||||
pm_device_state_get(domain, &state);
|
||||
zassert_equal(state, PM_DEVICE_STATE_ACTIVE);
|
||||
|
||||
ret = pm_device_runtime_get(devc);
|
||||
zassert_equal(ret, 0);
|
||||
zassert_true(atomic_test_bit(&devc->pm_base->flags, PM_DEVICE_FLAG_PD_CLAIMED));
|
||||
|
||||
ret = pm_device_runtime_get(devb);
|
||||
zassert_equal(ret, 0);
|
||||
zassert_true(atomic_test_bit(&devb->pm_base->flags, PM_DEVICE_FLAG_PD_CLAIMED));
|
||||
|
||||
ret = pm_device_runtime_put(deva);
|
||||
zassert_equal(ret, 0);
|
||||
zassert_false(atomic_test_bit(&deva->pm_base->flags, PM_DEVICE_FLAG_PD_CLAIMED));
|
||||
|
||||
/*
|
||||
* The domain has to still be active since device B
|
||||
@@ -183,9 +190,11 @@ ZTEST(power_domain_1cpu, test_power_domain_device_runtime)
|
||||
*/
|
||||
ret = pm_device_runtime_put(devb);
|
||||
zassert_equal(ret, 0);
|
||||
zassert_false(atomic_test_bit(&devb->pm_base->flags, PM_DEVICE_FLAG_PD_CLAIMED));
|
||||
|
||||
ret = pm_device_runtime_put(devc);
|
||||
zassert_equal(ret, 0);
|
||||
zassert_false(atomic_test_bit(&devc->pm_base->flags, PM_DEVICE_FLAG_PD_CLAIMED));
|
||||
|
||||
pm_device_state_get(domain, &state);
|
||||
zassert_equal(state, PM_DEVICE_STATE_SUSPENDED);
|
||||
|
||||
@@ -5,3 +5,11 @@ tests:
|
||||
integration_platforms:
|
||||
- native_sim
|
||||
tags: pm
|
||||
pm.power_doamin.isr_safe:
|
||||
platform_allow:
|
||||
- native_sim
|
||||
integration_platforms:
|
||||
- native_sim
|
||||
extra_configs:
|
||||
- CONFIG_TEST_PM_DEVICE_ISR_SAFE=y
|
||||
tags: pm
|
||||
|
||||
Reference in New Issue
Block a user