Compare commits
33 Commits
backport-9
...
backport-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84662f9781 | ||
|
|
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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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, \
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -245,7 +245,11 @@ struct zvfs_pollfd {
|
||||
__syscall int zvfs_poll(struct zvfs_pollfd *fds, int nfds, int poll_timeout);
|
||||
|
||||
struct zvfs_fd_set {
|
||||
#ifdef ZVFS_OPEN_SIZE
|
||||
uint32_t bitset[DIV_ROUND_UP(ZVFS_OPEN_SIZE, 32)];
|
||||
#else
|
||||
uint32_t bitset[1];
|
||||
#endif
|
||||
};
|
||||
|
||||
/** @brief Number of file descriptors which can be added @ref zvfs_fd_set */
|
||||
|
||||
@@ -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; };
|
||||
|
||||
|
||||
@@ -13,35 +13,37 @@ zephyr_sources(
|
||||
thread_entry.c
|
||||
)
|
||||
|
||||
if(CONFIG_ZVFS_OPEN_IGNORE_MIN)
|
||||
set(final_fd_size ${CONFIG_ZVFS_OPEN_MAX})
|
||||
else()
|
||||
# Import all custom ZVFS_OPEN_ size requirements
|
||||
import_kconfig(CONFIG_ZVFS_OPEN_ADD_SIZE_ ${DOTCONFIG} add_size_keys)
|
||||
|
||||
# Calculate the sum of all "ADD_SIZE" requirements
|
||||
set(add_size_sum 0)
|
||||
foreach(add_size ${add_size_keys})
|
||||
math(EXPR add_size_sum "${add_size_sum} + ${${add_size}}")
|
||||
endforeach()
|
||||
|
||||
if(CONFIG_ZVFS_OPEN_MAX LESS "${add_size_sum}")
|
||||
# Only warn if default value 0 has been modified
|
||||
if(NOT CONFIG_ZVFS_OPEN_MAX EQUAL 0)
|
||||
message(WARNING "
|
||||
CONFIG_ZVFS_OPEN_MAX is less than requested minimum:
|
||||
${CONFIG_ZVFS_OPEN_MAX} < ${add_size_sum}
|
||||
Setting the file descriptor size to ${add_size_sum}")
|
||||
endif()
|
||||
|
||||
set(final_fd_size ${add_size_sum})
|
||||
else()
|
||||
# CONFIG_ZVFS_OPEN_MAX was greater than the sum of the requirements
|
||||
if(CONFIG_ZVFS)
|
||||
if(CONFIG_ZVFS_OPEN_IGNORE_MIN)
|
||||
set(final_fd_size ${CONFIG_ZVFS_OPEN_MAX})
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
# Import all custom ZVFS_OPEN_ size requirements
|
||||
import_kconfig(CONFIG_ZVFS_OPEN_ADD_SIZE_ ${DOTCONFIG} add_size_keys)
|
||||
|
||||
zephyr_compile_definitions(ZVFS_OPEN_SIZE=${final_fd_size})
|
||||
# Calculate the sum of all "ADD_SIZE" requirements
|
||||
set(add_size_sum 0)
|
||||
foreach(add_size ${add_size_keys})
|
||||
math(EXPR add_size_sum "${add_size_sum} + ${${add_size}}")
|
||||
endforeach()
|
||||
|
||||
if(CONFIG_ZVFS_OPEN_MAX LESS "${add_size_sum}")
|
||||
# Only warn if default value 0 has been modified
|
||||
if(NOT CONFIG_ZVFS_OPEN_MAX EQUAL 0)
|
||||
message(WARNING "
|
||||
CONFIG_ZVFS_OPEN_MAX is less than requested minimum:
|
||||
${CONFIG_ZVFS_OPEN_MAX} < ${add_size_sum}
|
||||
Setting the file descriptor size to ${add_size_sum}")
|
||||
endif()
|
||||
|
||||
set(final_fd_size ${add_size_sum})
|
||||
else()
|
||||
# CONFIG_ZVFS_OPEN_MAX was greater than the sum of the requirements
|
||||
set(final_fd_size ${CONFIG_ZVFS_OPEN_MAX})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
zephyr_compile_definitions(ZVFS_OPEN_SIZE=${final_fd_size})
|
||||
endif()
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_FDTABLE fdtable.c)
|
||||
zephyr_syscall_header_ifdef(CONFIG_FDTABLE
|
||||
|
||||
@@ -12,6 +12,7 @@ config FDTABLE
|
||||
|
||||
config ZVFS_OPEN_MAX
|
||||
int "Maximum number of open file descriptors"
|
||||
depends on ZVFS
|
||||
default 0
|
||||
help
|
||||
Maximum number of open file descriptors, this includes
|
||||
|
||||
@@ -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";
|
||||
};
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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