diff --git a/drivers/adc/adc_context.h b/drivers/adc/adc_context.h index ec845943fe4..3b4267e0d4c 100644 --- a/drivers/adc/adc_context.h +++ b/drivers/adc/adc_context.h @@ -95,7 +95,7 @@ static inline void adc_context_enable_timer(struct adc_context *ctx) u32_t interval_us = ctx->options.interval_us; u32_t interval_ms = ceiling_fraction(interval_us, 1000UL); - k_timer_start(&ctx->timer, K_NO_WAIT, interval_ms); + k_timer_start(&ctx->timer, K_NO_WAIT, K_MSEC(interval_ms)); } static inline void adc_context_disable_timer(struct adc_context *ctx) diff --git a/drivers/clock_control/nrf_clock_calibration.c b/drivers/clock_control/nrf_clock_calibration.c index 036f9c8bfd6..75934654e1f 100644 --- a/drivers/clock_control/nrf_clock_calibration.c +++ b/drivers/clock_control/nrf_clock_calibration.c @@ -106,7 +106,8 @@ static void start_hw_cal(void) static void start_cycle(void) { k_timer_start(&backoff_timer, - K_MSEC(CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_PERIOD), 0); + K_MSEC(CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_PERIOD), + K_NO_WAIT); hf_release(); lf_release(); cal_process_in_progress = 0; diff --git a/drivers/console/rtt_console.c b/drivers/console/rtt_console.c index fe2d57ac749..555aac130c0 100644 --- a/drivers/console/rtt_console.c +++ b/drivers/console/rtt_console.c @@ -30,7 +30,7 @@ static void wait(void) k_busy_wait(1000*CONFIG_RTT_TX_RETRY_DELAY_MS); } } else { - k_sleep(CONFIG_RTT_TX_RETRY_DELAY_MS); + k_msleep(CONFIG_RTT_TX_RETRY_DELAY_MS); } } diff --git a/drivers/display/ssd16xx.c b/drivers/display/ssd16xx.c index f0c1c9559d2..f332bb8fd33 100644 --- a/drivers/display/ssd16xx.c +++ b/drivers/display/ssd16xx.c @@ -115,7 +115,7 @@ static inline void ssd16xx_busy_wait(struct ssd16xx_data *driver) while (pin > 0) { __ASSERT(pin >= 0, "Failed to get pin level"); - k_sleep(SSD16XX_BUSY_DELAY); + k_msleep(SSD16XX_BUSY_DELAY); pin = gpio_pin_get(driver->busy, SSD16XX_BUSY_PIN); } } @@ -456,9 +456,9 @@ static int ssd16xx_controller_init(struct device *dev) LOG_DBG(""); gpio_pin_set(driver->reset, SSD16XX_RESET_PIN, 1); - k_sleep(SSD16XX_RESET_DELAY); + k_msleep(SSD16XX_RESET_DELAY); gpio_pin_set(driver->reset, SSD16XX_RESET_PIN, 0); - k_sleep(SSD16XX_RESET_DELAY); + k_msleep(SSD16XX_RESET_DELAY); ssd16xx_busy_wait(driver); err = ssd16xx_write_cmd(driver, SSD16XX_CMD_SW_RESET, NULL, 0); diff --git a/drivers/espi/espi_mchp_xec.c b/drivers/espi/espi_mchp_xec.c index 7831d7d8bb0..e036021a238 100644 --- a/drivers/espi/espi_mchp_xec.c +++ b/drivers/espi/espi_mchp_xec.c @@ -440,7 +440,7 @@ static int espi_xec_send_oob(struct device *dev, struct espi_oob_packet pckt) LOG_DBG("%s %d", __func__, ESPI_OOB_REGS->TX_LEN); /* Wait until ISR or timeout */ - ret = k_sem_take(&data->tx_lock, MAX_OOB_TIMEOUT); + ret = k_sem_take(&data->tx_lock, K_MSEC(MAX_OOB_TIMEOUT)); if (ret == -EAGAIN) { return -ETIMEDOUT; } @@ -465,7 +465,7 @@ static int espi_xec_receive_oob(struct device *dev, } /* Wait until ISR or timeout */ - ret = k_sem_take(&data->rx_lock, MAX_OOB_TIMEOUT); + ret = k_sem_take(&data->rx_lock, K_MSEC(MAX_OOB_TIMEOUT)); if (ret == -EAGAIN) { return -ETIMEDOUT; } diff --git a/drivers/flash/flash_stm32.c b/drivers/flash/flash_stm32.c index c3ca8783809..47be03c2a79 100644 --- a/drivers/flash/flash_stm32.c +++ b/drivers/flash/flash_stm32.c @@ -22,31 +22,31 @@ LOG_MODULE_REGISTER(flash_stm32, CONFIG_FLASH_LOG_LEVEL); /* STM32F0: maximum erase time of 40ms for a 2K sector */ #if defined(CONFIG_SOC_SERIES_STM32F0X) -#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(40)) +#define STM32_FLASH_MAX_ERASE_TIME 40 /* STM32F3: maximum erase time of 40ms for a 2K sector */ #elif defined(CONFIG_SOC_SERIES_STM32F1X) -#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(40)) +#define STM32_FLASH_MAX_ERASE_TIME 40 /* STM32F3: maximum erase time of 40ms for a 2K sector */ #elif defined(CONFIG_SOC_SERIES_STM32F3X) -#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(40)) +#define STM32_FLASH_MAX_ERASE_TIME 40 /* STM32F4: maximum erase time of 4s for a 128K sector */ #elif defined(CONFIG_SOC_SERIES_STM32F4X) -#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(4000)) +#define STM32_FLASH_MAX_ERASE_TIME 4000 /* STM32F7: maximum erase time of 4s for a 256K sector */ #elif defined(CONFIG_SOC_SERIES_STM32F7X) -#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(4000)) +#define STM32_FLASH_MAX_ERASE_TIME 4000 /* STM32L4: maximum erase time of 24.47ms for a 2K sector */ #elif defined(CONFIG_SOC_SERIES_STM32L4X) -#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(25)) +#define STM32_FLASH_MAX_ERASE_TIME 25 /* STM32WB: maximum erase time of 24.5ms for a 4K sector */ #elif defined(CONFIG_SOC_SERIES_STM32WBX) -#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(25)) +#define STM32_FLASH_MAX_ERASE_TIME 25 #elif defined(CONFIG_SOC_SERIES_STM32G0X) /* STM32G0: maximum erase time of 40ms for a 2K sector */ -#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(40)) +#define STM32_FLASH_MAX_ERASE_TIME 40 /* STM32G4: maximum erase time of 24.47ms for a 2K sector */ #elif defined(CONFIG_SOC_SERIES_STM32G4X) -#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(25)) +#define STM32_FLASH_MAX_ERASE_TIME 25 #endif /* Let's wait for double the max erase time to be sure that the operation is diff --git a/drivers/i2s/i2s_ll_stm32.c b/drivers/i2s/i2s_ll_stm32.c index 4c780846f91..9f5d915acb8 100644 --- a/drivers/i2s/i2s_ll_stm32.c +++ b/drivers/i2s/i2s_ll_stm32.c @@ -374,7 +374,8 @@ static int i2s_stm32_read(struct device *dev, void **mem_block, size_t *size) } if (dev_data->rx.state != I2S_STATE_ERROR) { - ret = k_sem_take(&dev_data->rx.sem, dev_data->rx.cfg.timeout); + ret = k_sem_take(&dev_data->rx.sem, + K_MSEC(dev_data->rx.cfg.timeout)); if (ret < 0) { return ret; } @@ -400,7 +401,7 @@ static int i2s_stm32_write(struct device *dev, void *mem_block, size_t size) return -EIO; } - ret = k_sem_take(&dev_data->tx.sem, dev_data->tx.cfg.timeout); + ret = k_sem_take(&dev_data->tx.sem, K_MSEC(dev_data->tx.cfg.timeout)); if (ret < 0) { return ret; } diff --git a/drivers/led/ht16k33.c b/drivers/led/ht16k33.c index 0361250e81c..cb812b92a75 100644 --- a/drivers/led/ht16k33.c +++ b/drivers/led/ht16k33.c @@ -272,7 +272,7 @@ static void ht16k33_irq_thread(struct device *dev) do { k_sem_reset(&data->irq_sem); pressed = ht16k33_process_keyscan_data(dev); - k_sleep(CONFIG_HT16K33_KEYSCAN_DEBOUNCE_MSEC); + k_msleep(CONFIG_HT16K33_KEYSCAN_DEBOUNCE_MSEC); } while (pressed); } } @@ -441,7 +441,7 @@ static int ht16k33_init(struct device *dev) /* Setup timer for polling key data */ k_timer_init(&data->timer, ht16k33_timer_callback, NULL); k_timer_start(&data->timer, K_NO_WAIT, - CONFIG_HT16K33_KEYSCAN_POLL_MSEC); + K_MSEC(CONFIG_HT16K33_KEYSCAN_POLL_MSEC)); } k_thread_create(&data->irq_thread, data->irq_thread_stack, diff --git a/drivers/led/lp5562.c b/drivers/led/lp5562.c index a4fae43c5cb..32711188fc5 100644 --- a/drivers/led/lp5562.c +++ b/drivers/led/lp5562.c @@ -70,12 +70,12 @@ LOG_MODULE_REGISTER(lp5562); * therefore (16 * 63) = 1008ms. We round it down to 1000ms to be on the safe * side. */ -#define LP5562_MAX_BLINK_PERIOD K_MSEC(1000) +#define LP5562_MAX_BLINK_PERIOD 1000 /* * The minimum waiting period is 0.49ms with the prescaler set to 0 and one * step. We round up to a full millisecond. */ -#define LP5562_MIN_BLINK_PERIOD K_MSEC(1) +#define LP5562_MIN_BLINK_PERIOD 1 /* Brightness limits in percent */ #define LP5562_MIN_BRIGHTNESS 0 diff --git a/drivers/sensor/ccs811/ccs811.c b/drivers/sensor/ccs811/ccs811.c index 086f4e77c33..630958d91f9 100644 --- a/drivers/sensor/ccs811/ccs811.c +++ b/drivers/sensor/ccs811/ccs811.c @@ -351,7 +351,7 @@ static int switch_to_app_mode(struct device *i2c) return -EIO; } - k_sleep(1); /* t_APP_START */ + k_msleep(1); /* t_APP_START */ status = fetch_status(i2c); if (status < 0) { return -EIO; @@ -462,7 +462,7 @@ static int ccs811_init(struct device *dev) | DT_INST_0_AMS_CCS811_WAKE_GPIOS_FLAGS); set_wake(drv_data, true); - k_sleep(1); + k_msleep(1); #endif #ifdef DT_INST_0_AMS_CCS811_RESET_GPIOS_CONTROLLER drv_data->reset_gpio = device_get_binding(DT_INST_0_AMS_CCS811_RESET_GPIOS_CONTROLLER); @@ -475,7 +475,7 @@ static int ccs811_init(struct device *dev) GPIO_OUTPUT_ACTIVE | DT_INST_0_AMS_CCS811_RESET_GPIOS_FLAGS); - k_sleep(1); + k_msleep(1); #endif #ifdef DT_INST_0_AMS_CCS811_IRQ_GPIOS_CONTROLLER @@ -509,7 +509,7 @@ static int ccs811_init(struct device *dev) } } #endif - k_sleep(20); /* t_START assuming recent power-on */ + k_msleep(20); /* t_START assuming recent power-on */ /* Switch device to application mode */ ret = switch_to_app_mode(drv_data->i2c); diff --git a/drivers/sensor/hp206c/hp206c.c b/drivers/sensor/hp206c/hp206c.c index 8529bff4c98..59159e5e8b9 100644 --- a/drivers/sensor/hp206c/hp206c.c +++ b/drivers/sensor/hp206c/hp206c.c @@ -166,7 +166,7 @@ static int hp206c_wait_dev_ready(struct device *dev, u32_t timeout_ms) struct hp206c_device_data *hp206c = dev->driver_data; u8_t int_src; - k_timer_start(&hp206c->tmr, timeout_ms, K_NO_WAIT); + k_timer_start(&hp206c->tmr, K_MSEC(timeout_ms), K_NO_WAIT); k_timer_status_sync(&hp206c->tmr); if (hp206c_read_reg(dev, HP206C_REG_INT_SRC, &int_src) < 0) { diff --git a/drivers/sensor/lsm6dsl/lsm6dsl_shub.c b/drivers/sensor/lsm6dsl/lsm6dsl_shub.c index 15b19cef731..a753c65eabf 100644 --- a/drivers/sensor/lsm6dsl/lsm6dsl_shub.c +++ b/drivers/sensor/lsm6dsl/lsm6dsl_shub.c @@ -150,7 +150,7 @@ static inline void lsm6dsl_shub_wait_completed(struct lsm6dsl_data *data) u16_t freq; freq = (data->accel_freq == 0U) ? 26 : data->accel_freq; - k_sleep((2000U / freq) + 1); + k_msleep((2000U / freq) + 1); } static inline void lsm6dsl_shub_embedded_en(struct lsm6dsl_data *data, bool on) diff --git a/drivers/sensor/lsm6dso/lsm6dso_shub.c b/drivers/sensor/lsm6dso/lsm6dso_shub.c index a269e44106d..67fe17c7e12 100644 --- a/drivers/sensor/lsm6dso/lsm6dso_shub.c +++ b/drivers/sensor/lsm6dso/lsm6dso_shub.c @@ -420,7 +420,7 @@ static inline void lsm6dso_shub_wait_completed(struct lsm6dso_data *data) u16_t freq; freq = (data->accel_freq == 0) ? 26 : data->accel_freq; - k_sleep((2000U / freq) + 1); + k_msleep((2000U / freq) + 1); } static inline void lsm6dso_shub_embedded_en(struct lsm6dso_data *data, bool on) diff --git a/drivers/sensor/ms5607/ms5607.c b/drivers/sensor/ms5607/ms5607.c index e37410847ab..068192cbeff 100644 --- a/drivers/sensor/ms5607/ms5607.c +++ b/drivers/sensor/ms5607/ms5607.c @@ -97,7 +97,7 @@ static int ms5607_get_measurement(const struct ms5607_data *data, return err; } - k_sleep(delay); + k_msleep(delay); err = data->tf->read_adc(data, val); if (err < 0) { diff --git a/drivers/sensor/ms5837/ms5837.c b/drivers/sensor/ms5837/ms5837.c index 1e674f7bfef..db4966351b0 100644 --- a/drivers/sensor/ms5837/ms5837.c +++ b/drivers/sensor/ms5837/ms5837.c @@ -30,7 +30,7 @@ static int ms5837_get_measurement(struct device *i2c_master, return err; } - k_sleep(delay); + k_msleep(delay); err = i2c_burst_read(i2c_master, i2c_address, adc_read_cmd, ((u8_t *)val) + 1, 3); diff --git a/drivers/sensor/ti_hdc/ti_hdc.c b/drivers/sensor/ti_hdc/ti_hdc.c index 674fef01155..9b5efd8b040 100644 --- a/drivers/sensor/ti_hdc/ti_hdc.c +++ b/drivers/sensor/ti_hdc/ti_hdc.c @@ -57,7 +57,7 @@ static int ti_hdc_sample_fetch(struct device *dev, enum sensor_channel chan) k_sem_take(&drv_data->data_sem, K_FOREVER); #else /* wait for the conversion to finish */ - k_sleep(HDC_CONVERSION_TIME); + k_msleep(HDC_CONVERSION_TIME); #endif if (i2c_read(drv_data->i2c, buf, 4, DT_INST_0_TI_HDC_BASE_ADDRESS) < 0) { diff --git a/drivers/serial/uart_nrfx_uart.c b/drivers/serial/uart_nrfx_uart.c index 6868c348ff4..514ae023c95 100644 --- a/drivers/serial/uart_nrfx_uart.c +++ b/drivers/serial/uart_nrfx_uart.c @@ -278,7 +278,7 @@ static void uart_nrfx_poll_out(struct device *dev, unsigned char c) /* k_sleep allows other threads to execute and finish * their transactions. */ - k_sleep(1); + k_msleep(1); if (--safety_cnt == 0) { return; } diff --git a/drivers/serial/uart_nrfx_uarte.c b/drivers/serial/uart_nrfx_uarte.c index d5af543f8bb..7631c4356cf 100644 --- a/drivers/serial/uart_nrfx_uarte.c +++ b/drivers/serial/uart_nrfx_uarte.c @@ -965,7 +965,7 @@ static void uarte_nrfx_poll_out(struct device *dev, unsigned char c) /* k_sleep allows other threads to execute and finish * their transactions. */ - k_sleep(1); + k_msleep(1); if (--safety_cnt == 0) { return; } diff --git a/include/sys_clock.h b/include/sys_clock.h index 54af11de8da..39f749e219b 100644 --- a/include/sys_clock.h +++ b/include/sys_clock.h @@ -53,6 +53,8 @@ extern void z_enable_sys_clock(void); /* number of nanoseconds per second */ #define NSEC_PER_SEC ((NSEC_PER_USEC) * (USEC_PER_MSEC) * (MSEC_PER_SEC)) +#define k_msleep(ms) k_sleep(ms) +#define K_TIMEOUT_EQ(a, b) ((a) == (b)) /* kernel clocks */ diff --git a/lib/posix/sleep.c b/lib/posix/sleep.c index cf5bc171b8c..b40aa4fc1de 100644 --- a/lib/posix/sleep.c +++ b/lib/posix/sleep.c @@ -27,7 +27,7 @@ int usleep(useconds_t useconds) if (useconds < USEC_PER_MSEC) { k_busy_wait(useconds); } else { - k_sleep(useconds / USEC_PER_MSEC); + k_msleep(useconds / USEC_PER_MSEC); } return 0; diff --git a/lib/posix/timer.c b/lib/posix/timer.c index 5684704dd9f..8d71b4d6f18 100644 --- a/lib/posix/timer.c +++ b/lib/posix/timer.c @@ -174,7 +174,7 @@ int timer_settime(timer_t timerid, int flags, const struct itimerspec *value, } timer->status = ACTIVE; - k_timer_start(&timer->ztimer, duration, timer->reload); + k_timer_start(&timer->ztimer, K_MSEC(duration), K_MSEC(timer->reload)); return 0; } diff --git a/samples/basic/blinky/src/main.c b/samples/basic/blinky/src/main.c index 198ad58ddf4..5ffbe73c731 100644 --- a/samples/basic/blinky/src/main.c +++ b/samples/basic/blinky/src/main.c @@ -51,6 +51,6 @@ void main(void) while (1) { gpio_pin_set(dev, PIN, (int)led_is_on); led_is_on = !led_is_on; - k_sleep(SLEEP_TIME_MS); + k_msleep(SLEEP_TIME_MS); } } diff --git a/samples/basic/button/src/main.c b/samples/basic/button/src/main.c index 6bb893ece3b..3828b161d43 100644 --- a/samples/basic/button/src/main.c +++ b/samples/basic/button/src/main.c @@ -87,7 +87,7 @@ void main(void) val = gpio_pin_get(dev_button, DT_ALIAS_SW0_GPIOS_PIN); gpio_pin_set(dev_led, DT_ALIAS_LED0_GPIOS_PIN, val); - k_sleep(SLEEP_TIME_MS); + k_msleep(SLEEP_TIME_MS); #endif } } diff --git a/samples/basic/threads/src/main.c b/samples/basic/threads/src/main.c index dee446cbc3e..3403bf9c07f 100644 --- a/samples/basic/threads/src/main.c +++ b/samples/basic/threads/src/main.c @@ -70,7 +70,7 @@ void blink(const struct led *led, u32_t sleep_ms, u32_t id) k_fifo_put(&printk_fifo, mem_ptr); - k_sleep(sleep_ms); + k_msleep(sleep_ms); cnt++; } } @@ -109,8 +109,8 @@ void uart_out(void) } K_THREAD_DEFINE(blink1_id, STACKSIZE, blink1, NULL, NULL, NULL, - PRIORITY, 0, K_NO_WAIT); + PRIORITY, 0, 0); K_THREAD_DEFINE(blink2_id, STACKSIZE, blink2, NULL, NULL, NULL, - PRIORITY, 0, K_NO_WAIT); + PRIORITY, 0, 0); K_THREAD_DEFINE(uart_out_id, STACKSIZE, uart_out, NULL, NULL, NULL, - PRIORITY, 0, K_NO_WAIT); + PRIORITY, 0, 0); diff --git a/samples/boards/arc_secure_services/src/main.c b/samples/boards/arc_secure_services/src/main.c index 519da9569ea..3149512f4d6 100644 --- a/samples/boards/arc_secure_services/src/main.c +++ b/samples/boards/arc_secure_services/src/main.c @@ -36,7 +36,7 @@ void threadA(void *dummy1, void *dummy2, void *dummy3) } K_THREAD_DEFINE(thread_a, STACKSIZE, threadA, NULL, NULL, NULL, - PRIORITY, 0, K_NO_WAIT); + PRIORITY, 0, 0); void main(void) @@ -54,6 +54,6 @@ void main(void) while (1) { printk("I am the %s thread in secure world: %d\n", __func__, i++); - k_sleep(SLEEPTIME); + k_msleep(SLEEPTIME); } } diff --git a/samples/boards/mec15xxevb_assy6853/power_management/src/power_mgmt.c b/samples/boards/mec15xxevb_assy6853/power_management/src/power_mgmt.c index 8a794a855ef..6face4d54d2 100644 --- a/samples/boards/mec15xxevb_assy6853/power_management/src/power_mgmt.c +++ b/samples/boards/mec15xxevb_assy6853/power_management/src/power_mgmt.c @@ -106,7 +106,7 @@ static int taskB_init(void) void taskA_thread(void *p1, void *p2, void *p3) { while (true) { - k_sleep(THREAD_A_SLEEP_TIME); + k_msleep(THREAD_A_SLEEP_TIME); printk("A"); } } @@ -114,7 +114,7 @@ void taskA_thread(void *p1, void *p2, void *p3) static void taskB_thread(void *p1, void *p2, void *p3) { while (true) { - k_sleep(THREAD_B_SLEEP_TIME); + k_msleep(THREAD_B_SLEEP_TIME); printk("B"); } } @@ -160,7 +160,7 @@ int test_pwr_mgmt_multithread(bool use_logging, u8_t cycles) pm_exit_marker(); while (cycles-- > 0) { - k_sleep(CONFIG_SYS_PM_MIN_RESIDENCY_SLEEP_1 + 500); + k_msleep(CONFIG_SYS_PM_MIN_RESIDENCY_SLEEP_1 + 500); if (use_logging) { LOG_INF("Wake from Light Sleep\n"); @@ -176,7 +176,7 @@ int test_pwr_mgmt_multithread(bool use_logging, u8_t cycles) /* GPIO toggle to measure latency */ pm_entry_marker(); - k_sleep(CONFIG_SYS_PM_MIN_RESIDENCY_DEEP_SLEEP_1 + 500); + k_msleep(CONFIG_SYS_PM_MIN_RESIDENCY_DEEP_SLEEP_1 + 500); k_busy_wait(3000); @@ -203,7 +203,7 @@ int test_pwr_mgmt_singlethread(bool use_logging, u8_t cycles) while (cycles-- > 0) { /* Trigger Light Sleep 1 state. 48MHz PLL stays on */ - k_sleep(CONFIG_SYS_PM_MIN_RESIDENCY_SLEEP_1 + 500); + k_msleep(CONFIG_SYS_PM_MIN_RESIDENCY_SLEEP_1 + 500); if (use_logging) { LOG_INF("Wake from Light Sleep\n"); @@ -220,7 +220,7 @@ int test_pwr_mgmt_singlethread(bool use_logging, u8_t cycles) /* GPIO toggle to measure latency */ pm_entry_marker(); - k_sleep(CONFIG_SYS_PM_MIN_RESIDENCY_DEEP_SLEEP_1 + 1000); + k_msleep(CONFIG_SYS_PM_MIN_RESIDENCY_DEEP_SLEEP_1 + 1000); k_busy_wait(3000); diff --git a/samples/display/grove_display/src/main.c b/samples/display/grove_display/src/main.c index 518e412b872..d27168792b1 100644 --- a/samples/display/grove_display/src/main.c +++ b/samples/display/grove_display/src/main.c @@ -122,6 +122,6 @@ void main(void) } /* wait a while */ - k_sleep(SLEEPTIME); + k_msleep(SLEEPTIME); } } diff --git a/samples/drivers/display/src/main.c b/samples/drivers/display/src/main.c index 135326bf2e9..06c2bc50d76 100644 --- a/samples/drivers/display/src/main.c +++ b/samples/drivers/display/src/main.c @@ -234,9 +234,9 @@ void main(void) rect_h *= scale; if (capabilities.screen_info & SCREEN_INFO_EPD) { - grey_scale_sleep = K_MSEC(10000); + grey_scale_sleep = 10000; } else { - grey_scale_sleep = K_MSEC(100); + grey_scale_sleep = 100; } buf_size = rect_w * rect_h; @@ -319,7 +319,7 @@ void main(void) fill_buffer_fnc(BOTTOM_LEFT, grey_count, buf, buf_size); display_write(display_dev, x, y, &buf_desc, buf); ++grey_count; - k_sleep(grey_scale_sleep); + k_msleep(grey_scale_sleep); #if CONFIG_TEST if (grey_count >= 1024) { break; diff --git a/samples/drivers/ht16k33/src/main.c b/samples/drivers/ht16k33/src/main.c index e62e5422604..f559e66992b 100644 --- a/samples/drivers/ht16k33/src/main.c +++ b/samples/drivers/ht16k33/src/main.c @@ -74,7 +74,7 @@ void main(void) for (i = 500; i <= 2000; i *= 2) { LOG_INF("Blinking LEDs with a period of %d ms", i); led_blink(led_dev, 0, i / 2, i / 2); - k_sleep(10 * i); + k_msleep(10 * i); } led_blink(led_dev, 0, 0, 0); diff --git a/samples/drivers/lcd_hd44780/src/main.c b/samples/drivers/lcd_hd44780/src/main.c index 7cf5d11d275..36c3d0cb629 100644 --- a/samples/drivers/lcd_hd44780/src/main.c +++ b/samples/drivers/lcd_hd44780/src/main.c @@ -183,11 +183,11 @@ void _set_row_offsets(s8_t row0, s8_t row1, s8_t row2, s8_t row3) void _pi_lcd_toggle_enable(struct device *gpio_dev) { GPIO_PIN_WR(gpio_dev, GPIO_PIN_PC25_E, LOW); - k_sleep(ENABLE_DELAY); + k_msleep(ENABLE_DELAY); GPIO_PIN_WR(gpio_dev, GPIO_PIN_PC25_E, HIGH); - k_sleep(ENABLE_DELAY); + k_msleep(ENABLE_DELAY); GPIO_PIN_WR(gpio_dev, GPIO_PIN_PC25_E, LOW); - k_sleep(ENABLE_DELAY); + k_msleep(ENABLE_DELAY); } @@ -563,7 +563,7 @@ void main(void) pi_lcd_set_cursor(gpio_dev, 19, 3); pi_lcd_left_to_right(gpio_dev); pi_lcd_string(gpio_dev, "********************"); - k_sleep(MSEC_PER_SEC * 3U); + k_msleep(MSEC_PER_SEC * 3U); /* Clear display */ pi_lcd_clear(gpio_dev); @@ -579,7 +579,7 @@ void main(void) pi_lcd_string(gpio_dev, "My super RTOS"); pi_lcd_set_cursor(gpio_dev, 0, 3); pi_lcd_string(gpio_dev, "-------------------"); - k_sleep(MSEC_PER_SEC * 3U); + k_msleep(MSEC_PER_SEC * 3U); /* Clear display */ pi_lcd_clear(gpio_dev); @@ -594,7 +594,7 @@ void main(void) pi_lcd_string(gpio_dev, "I am home!"); pi_lcd_set_cursor(gpio_dev, 0, 2); pi_lcd_string(gpio_dev, ""); - k_sleep(MSEC_PER_SEC * 3U); + k_msleep(MSEC_PER_SEC * 3U); /* Clear display */ pi_lcd_clear(gpio_dev); diff --git a/samples/drivers/led_lp5562/src/main.c b/samples/drivers/led_lp5562/src/main.c index 331a9edac89..ba899b78233 100644 --- a/samples/drivers/led_lp5562/src/main.c +++ b/samples/drivers/led_lp5562/src/main.c @@ -18,7 +18,7 @@ LOG_MODULE_REGISTER(main); #define NUM_LEDS 4 #define BLINK_DELAY_ON 500 #define BLINK_DELAY_OFF 500 -#define DELAY_TIME K_MSEC(2000) +#define DELAY_TIME 2000 #define COLORS_TO_SHOW 8 #define VALUES_PER_COLOR 3 @@ -188,7 +188,7 @@ void main(void) return; } - k_sleep(DELAY_TIME); + k_msleep(DELAY_TIME); } ret = turn_off_all_leds(dev); @@ -204,7 +204,7 @@ void main(void) } /* Wait a few blinking before turning off the LEDs */ - k_sleep(DELAY_TIME * 2); + k_msleep(DELAY_TIME * 2); /* Change the color of the LEDs while keeping blinking. */ for (i = 0; i < COLORS_TO_SHOW; i++) { @@ -216,7 +216,7 @@ void main(void) return; } - k_sleep(DELAY_TIME * 2); + k_msleep(DELAY_TIME * 2); } ret = turn_off_all_leds(dev); @@ -224,6 +224,6 @@ void main(void) return; } - k_sleep(DELAY_TIME); + k_msleep(DELAY_TIME); } } diff --git a/samples/drivers/led_pca9633/src/main.c b/samples/drivers/led_pca9633/src/main.c index 350a9fa7fc8..c204e8880db 100644 --- a/samples/drivers/led_pca9633/src/main.c +++ b/samples/drivers/led_pca9633/src/main.c @@ -20,7 +20,8 @@ LOG_MODULE_REGISTER(main); #define HALF_BRIGHTNESS (MAX_BRIGHTNESS / 2) #define BLINK_DELAY_ON 500 #define BLINK_DELAY_OFF 500 -#define DELAY_TIME K_MSEC(1000) +#define DELAY_TIME_MS 1000 +#define DELAY_TIME K_MSEC(DELAY_TIME_MS) void main(void) { @@ -90,7 +91,7 @@ void main(void) } /* Wait a few blinking before turning off the LEDs */ - k_sleep(DELAY_TIME * 10); + k_msleep(DELAY_TIME_MS * 10); /* Turn off LEDs one by one */ for (i = 0; i < NUM_LEDS; i++) { diff --git a/samples/nfc/nfc_hello/src/main.c b/samples/nfc/nfc_hello/src/main.c index e6666827a20..17f7bfccbd8 100644 --- a/samples/nfc/nfc_hello/src/main.c +++ b/samples/nfc/nfc_hello/src/main.c @@ -69,6 +69,6 @@ void main(void) uart_fifo_fill(uart1_dev, tx_buf, sizeof(u32_t) + sizeof(nci_reset)); while (1) { - k_sleep(SLEEP_TIME); + k_msleep(SLEEP_TIME); } } diff --git a/samples/philosophers/src/main.c b/samples/philosophers/src/main.c index 0db2f7e9507..b852bfbf7ef 100644 --- a/samples/philosophers/src/main.c +++ b/samples/philosophers/src/main.c @@ -166,7 +166,7 @@ void philosopher(void *id, void *unused1, void *unused2) delay = get_random_delay(my_id, 25); print_phil_state(my_id, " EATING [ %s%d ms ] ", delay); - k_sleep(delay); + k_msleep(delay); drop(fork2); print_phil_state(my_id, " DROPPED ONE FORK ", 0); @@ -174,7 +174,7 @@ void philosopher(void *id, void *unused1, void *unused2) delay = get_random_delay(my_id, 25); print_phil_state(my_id, " THINKING [ %s%d ms ] ", delay); - k_sleep(delay); + k_msleep(delay); } } diff --git a/samples/scheduler/metairq_dispatch/src/main.c b/samples/scheduler/metairq_dispatch/src/main.c index 32c47844e7d..9ca3e00aeca 100644 --- a/samples/scheduler/metairq_dispatch/src/main.c +++ b/samples/scheduler/metairq_dispatch/src/main.c @@ -26,7 +26,7 @@ K_THREAD_STACK_ARRAY_DEFINE(thread_stacks, NUM_THREADS, STACK_SIZE); /* The static metairq thread we'll use for dispatch */ static void metairq_fn(void *p1, void *p2, void *p3); K_THREAD_DEFINE(metairq_thread, STACK_SIZE, metairq_fn, - NULL, NULL, NULL, K_HIGHEST_THREAD_PRIO, 0, K_NO_WAIT); + NULL, NULL, NULL, K_HIGHEST_THREAD_PRIO, 0, 0); /* Accumulated list of latencies, for a naive variance computation at * the end. @@ -138,7 +138,7 @@ static void record_latencies(struct msg *m, u32_t latency) ret = k_sem_take(&report_cookie, K_FOREVER); __ASSERT_NO_MSG(ret == 0); - k_sleep(100); + k_msleep(100); calc_stats(stats.mirq_latencies, stats.num_mirq, &lo, &hi, &mean, &stdev); diff --git a/samples/sensor/bmg160/src/main.c b/samples/sensor/bmg160/src/main.c index d1a460327cf..de458723c45 100644 --- a/samples/sensor/bmg160/src/main.c +++ b/samples/sensor/bmg160/src/main.c @@ -59,7 +59,7 @@ static void test_polling_mode(struct device *bmg160) print_temp_data(bmg160); /* wait a while */ - k_sleep(SLEEPTIME); + k_msleep(SLEEPTIME); remaining_test_time -= SLEEPTIME; } while (remaining_test_time > 0); @@ -120,7 +120,7 @@ static void test_trigger_mode(struct device *bmg160) printf("Gyro: rotate the device and wait for events.\n"); do { - k_sleep(SLEEPTIME); + k_msleep(SLEEPTIME); remaining_test_time -= SLEEPTIME; } while (remaining_test_time > 0); @@ -153,7 +153,7 @@ static void test_trigger_mode(struct device *bmg160) remaining_test_time = MAX_TEST_TIME; do { - k_sleep(SLEEPTIME); + k_msleep(SLEEPTIME); remaining_test_time -= SLEEPTIME; } while (remaining_test_time > 0); diff --git a/samples/sensor/ccs811/src/main.c b/samples/sensor/ccs811/src/main.c index d52d577a2a7..9389186bb4e 100644 --- a/samples/sensor/ccs811/src/main.c +++ b/samples/sensor/ccs811/src/main.c @@ -106,7 +106,7 @@ static void do_main(struct device *dev) printk("Timed fetch failed: %d\n", rc); break; } - k_sleep(1000); + k_msleep(1000); } } diff --git a/samples/sensor/grove_light/src/main.c b/samples/sensor/grove_light/src/main.c index 7ed773c2c41..8968862cdd5 100644 --- a/samples/sensor/grove_light/src/main.c +++ b/samples/sensor/grove_light/src/main.c @@ -9,7 +9,7 @@ #include #include -#define SLEEP_TIME 1000 +#define SLEEP_TIME K_MSEC(1000) void main(void) { diff --git a/samples/sensor/grove_temperature/src/main.c b/samples/sensor/grove_temperature/src/main.c index 0401918cee5..8e855264c35 100644 --- a/samples/sensor/grove_temperature/src/main.c +++ b/samples/sensor/grove_temperature/src/main.c @@ -15,7 +15,7 @@ #include #endif -#define SLEEP_TIME 1000 +#define SLEEP_TIME K_MSEC(1000) void main(void) { diff --git a/samples/subsys/ipc/openamp/src/main.c b/samples/subsys/ipc/openamp/src/main.c index 08c24f92c90..4d28adaa55a 100644 --- a/samples/subsys/ipc/openamp/src/main.c +++ b/samples/subsys/ipc/openamp/src/main.c @@ -292,7 +292,7 @@ void main(void) defined(CONFIG_SOC_V2M_MUSCA_A) || \ defined(CONFIG_SOC_V2M_MUSCA_B1) wakeup_cpu1(); - k_sleep(500); + k_msleep(500); #endif /* #if defined(CONFIG_SOC_MPS2_AN521) */ } diff --git a/samples/subsys/logging/logger/src/main.c b/samples/subsys/logging/logger/src/main.c index af4c768d964..ec288859d09 100644 --- a/samples/subsys/logging/logger/src/main.c +++ b/samples/subsys/logging/logger/src/main.c @@ -313,4 +313,4 @@ static void log_demo_supervisor(void *p1, void *p2, void *p3) K_THREAD_DEFINE(log_demo_thread_id, STACKSIZE, log_demo_supervisor, NULL, NULL, NULL, - K_LOWEST_APPLICATION_THREAD_PRIO, 0, K_MSEC(1)); + K_LOWEST_APPLICATION_THREAD_PRIO, 0, 1); diff --git a/samples/subsys/nvs/src/main.c b/samples/subsys/nvs/src/main.c index bfa098b8ee0..14b47ab5a7a 100644 --- a/samples/subsys/nvs/src/main.c +++ b/samples/subsys/nvs/src/main.c @@ -183,7 +183,7 @@ void main(void) cnt = 5; while (1) { - k_sleep(SLEEP_TIME); + k_msleep(SLEEP_TIME); if (reboot_counter < MAX_REBOOT) { if (cnt == 5) { /* print some history information about diff --git a/samples/subsys/shell/shell_module/src/main.c b/samples/subsys/shell/shell_module/src/main.c index 5bbba2a8709..441b1335011 100644 --- a/samples/subsys/shell/shell_module/src/main.c +++ b/samples/subsys/shell/shell_module/src/main.c @@ -31,7 +31,7 @@ static int cmd_log_test_start(const struct shell *shell, size_t argc, { ARG_UNUSED(argv); - k_timer_start(&log_timer, period, period); + k_timer_start(&log_timer, K_MSEC(period), K_MSEC(period)); shell_print(shell, "Log test started\n"); return 0; diff --git a/samples/subsys/usb/hid-cdc/src/main.c b/samples/subsys/usb/hid-cdc/src/main.c index 96d28ba2995..60e775ad36e 100644 --- a/samples/subsys/usb/hid-cdc/src/main.c +++ b/samples/subsys/usb/hid-cdc/src/main.c @@ -660,7 +660,7 @@ void main(void) LOG_INF("DTR on CDC ACM 1 set"); /* Wait 1 sec for the host to do all settings */ - k_busy_wait(K_SECONDS(1) * USEC_PER_MSEC); + k_busy_wait(USEC_PER_SEC); uart_irq_callback_set(cdc0_dev, cdc_mouse_int_handler); uart_irq_callback_set(cdc1_dev, cdc_kbd_int_handler); diff --git a/samples/synchronization/src/main.c b/samples/synchronization/src/main.c index 3c86b618239..dbe997ab57f 100644 --- a/samples/synchronization/src/main.c +++ b/samples/synchronization/src/main.c @@ -52,7 +52,7 @@ void helloLoop(const char *my_name, } /* wait a while, then let other thread have a turn */ - k_sleep(SLEEPTIME); + k_msleep(SLEEPTIME); k_sem_give(other_sem); } } @@ -98,4 +98,4 @@ void threadA(void *dummy1, void *dummy2, void *dummy3) } K_THREAD_DEFINE(thread_a, STACKSIZE, threadA, NULL, NULL, NULL, - PRIORITY, 0, K_NO_WAIT); + PRIORITY, 0, 0); diff --git a/soc/arm/st_stm32/common/stm32cube_hal.c b/soc/arm/st_stm32/common/stm32cube_hal.c index 4a7c643755d..9a71b7e7541 100644 --- a/soc/arm/st_stm32/common/stm32cube_hal.c +++ b/soc/arm/st_stm32/common/stm32cube_hal.c @@ -33,5 +33,5 @@ uint32_t HAL_GetTick(void) */ void HAL_Delay(__IO uint32_t Delay) { - k_sleep(Delay); + k_msleep(Delay); } diff --git a/subsys/console/tty.c b/subsys/console/tty.c index b0654bdbf79..2f1d57e905f 100644 --- a/subsys/console/tty.c +++ b/subsys/console/tty.c @@ -186,7 +186,8 @@ static ssize_t tty_read_unbuf(struct tty_serial *tty, void *buf, size_t size) size--; } - if (size == 0 || (timeout != K_FOREVER && timeout-- == 0U)) { + if (size == 0 || + (!K_TIMEOUT_EQ(timeout, K_FOREVER) && timeout-- == 0U)) { break; } diff --git a/subsys/disk/disk_access_sdhc.h b/subsys/disk/disk_access_sdhc.h index 7b6de430396..7387bedc6ef 100644 --- a/subsys/disk/disk_access_sdhc.h +++ b/subsys/disk/disk_access_sdhc.h @@ -99,11 +99,11 @@ enum sdhc_app_ext_cmd { #define SDHC_RESPONSE_WRITE_ERR 0x0E #define SDHC_MIN_TRIES 20 -#define SDHC_RETRY_DELAY K_MSEC(20) +#define SDHC_RETRY_DELAY 20 /* Time to wait for the card to initialise */ -#define SDHC_INIT_TIMEOUT K_MSEC(5000) +#define SDHC_INIT_TIMEOUT 5000 /* Time to wait for the card to respond or come ready */ -#define SDHC_READY_TIMEOUT K_MSEC(500) +#define SDHC_READY_TIMEOUT 500 enum sdhc_rsp_type { SDHC_RSP_TYPE_NONE = 0U, @@ -568,7 +568,7 @@ static inline bool sdhc_retry_ok(struct sdhc_retry *retry) if (retry->tries < SDHC_MIN_TRIES) { retry->tries++; if (retry->sleep != 0U) { - k_sleep(retry->sleep); + k_msleep(retry->sleep); } return true; @@ -576,7 +576,7 @@ static inline bool sdhc_retry_ok(struct sdhc_retry *retry) if (remain >= 0) { if (retry->sleep > 0) { - k_sleep(retry->sleep); + k_msleep(retry->sleep); } else { k_yield(); } diff --git a/subsys/logging/log_backend_rtt.c b/subsys/logging/log_backend_rtt.c index 67c7570400a..c9f484b6b18 100644 --- a/subsys/logging/log_backend_rtt.c +++ b/subsys/logging/log_backend_rtt.c @@ -177,7 +177,7 @@ static void on_failed_write(int retry_cnt) k_busy_wait(USEC_PER_MSEC * CONFIG_LOG_BACKEND_RTT_RETRY_DELAY_MS); } else { - k_sleep(CONFIG_LOG_BACKEND_RTT_RETRY_DELAY_MS); + k_msleep(CONFIG_LOG_BACKEND_RTT_RETRY_DELAY_MS); } } diff --git a/subsys/logging/log_core.c b/subsys/logging/log_core.c index ac3a4ac6145..8e81037d06c 100644 --- a/subsys/logging/log_core.c +++ b/subsys/logging/log_core.c @@ -203,7 +203,7 @@ static inline void msg_finalize(struct log_msg *msg, irq_unlock(key); } else if (proc_tid != NULL && buffered_cnt == 1) { k_timer_start(&log_process_thread_timer, - CONFIG_LOG_PROCESS_THREAD_SLEEP_MS, K_NO_WAIT); + K_MSEC(CONFIG_LOG_PROCESS_THREAD_SLEEP_MS), K_NO_WAIT); } else if (CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD) { if ((buffered_cnt == CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD) && (proc_tid != NULL)) { diff --git a/subsys/logging/log_msg.c b/subsys/logging/log_msg.c index 1680e5e2bd5..e016d1e7eb7 100644 --- a/subsys/logging/log_msg.c +++ b/subsys/logging/log_msg.c @@ -75,8 +75,9 @@ union log_msg_chunk *log_msg_chunk_alloc(void) { union log_msg_chunk *msg = NULL; int err = k_mem_slab_alloc(&log_msg_pool, (void **)&msg, - block_on_alloc() ? - CONFIG_LOG_BLOCK_IN_THREAD_TIMEOUT_MS : K_NO_WAIT); + block_on_alloc() + ? K_MSEC(CONFIG_LOG_BLOCK_IN_THREAD_TIMEOUT_MS) + : K_NO_WAIT); if (err != 0) { msg = log_msg_no_space_handle(); diff --git a/subsys/shell/shell_log_backend.c b/subsys/shell/shell_log_backend.c index 1805c844827..b89269498d2 100644 --- a/subsys/shell/shell_log_backend.c +++ b/subsys/shell/shell_log_backend.c @@ -91,7 +91,7 @@ static void msg_to_fifo(const struct shell *shell, }; err = k_msgq_put(shell->log_backend->msgq, &t_msg, - shell->log_backend->timeout); + K_MSEC(shell->log_backend->timeout)); switch (err) { case 0: diff --git a/subsys/shell/shell_rtt.c b/subsys/shell/shell_rtt.c index 8333dcf93ac..1caea172886 100644 --- a/subsys/shell/shell_rtt.c +++ b/subsys/shell/shell_rtt.c @@ -44,8 +44,8 @@ static int init(const struct shell_transport *transport, k_timer_init(&sh_rtt->timer, timer_handler, NULL); k_timer_user_data_set(&sh_rtt->timer, (void *)sh_rtt); - k_timer_start(&sh_rtt->timer, CONFIG_SHELL_RTT_RX_POLL_PERIOD, - CONFIG_SHELL_RTT_RX_POLL_PERIOD); + k_timer_start(&sh_rtt->timer, K_MSEC(CONFIG_SHELL_RTT_RX_POLL_PERIOD), + K_MSEC(CONFIG_SHELL_RTT_RX_POLL_PERIOD)); return 0; } diff --git a/subsys/shell/shell_uart.c b/subsys/shell/shell_uart.c index 6203ed8d3c6..6e5422ed5f6 100644 --- a/subsys/shell/shell_uart.c +++ b/subsys/shell/shell_uart.c @@ -13,9 +13,9 @@ LOG_MODULE_REGISTER(shell_uart); #ifdef CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD -#define RX_POLL_PERIOD CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD +#define RX_POLL_PERIOD K_MSEC(CONFIG_SHELL_BACKEND_SERIAL_RX_POLL_PERIOD) #else -#define RX_POLL_PERIOD 0 +#define RX_POLL_PERIOD K_NO_WAIT #endif SHELL_UART_DEFINE(shell_transport_uart, diff --git a/subsys/testsuite/ztest/src/ztest.c b/subsys/testsuite/ztest/src/ztest.c index e1e0d60e393..43abbdf784b 100644 --- a/subsys/testsuite/ztest/src/ztest.c +++ b/subsys/testsuite/ztest/src/ztest.c @@ -427,7 +427,7 @@ void main(void) if (test_status == 0) { PRINT("Reset board #%u to test again\n", state.boots); - k_sleep(K_MSEC(10)); + k_msleep(10); sys_reboot(SYS_REBOOT_COLD); } else { PRINT("Failed after %u attempts\n", state.boots); diff --git a/subsys/tracing/tracing_core.c b/subsys/tracing/tracing_core.c index 63f473fc5f1..bc5ca021965 100644 --- a/subsys/tracing/tracing_core.c +++ b/subsys/tracing/tracing_core.c @@ -118,7 +118,8 @@ void tracing_trigger_output(bool before_put_is_empty) { if (before_put_is_empty) { k_timer_start(&tracing_thread_timer, - CONFIG_TRACING_THREAD_WAIT_THRESHOLD, K_NO_WAIT); + K_MSEC(CONFIG_TRACING_THREAD_WAIT_THRESHOLD), + K_NO_WAIT); } } diff --git a/subsys/usb/class/usb_dfu.c b/subsys/usb/class/usb_dfu.c index a31bdf58ed8..7fb9d1a7093 100644 --- a/subsys/usb/class/usb_dfu.c +++ b/subsys/usb/class/usb_dfu.c @@ -821,7 +821,7 @@ void wait_for_usb_dfu(void) break; } - k_sleep(INTERMITTENT_CHECK_DELAY); + k_msleep(INTERMITTENT_CHECK_DELAY); } } diff --git a/tests/benchmarks/app_kernel/src/master.c b/tests/benchmarks/app_kernel/src/master.c index fa81f1613e8..09225a6b99f 100644 --- a/tests/benchmarks/app_kernel/src/master.c +++ b/tests/benchmarks/app_kernel/src/master.c @@ -37,7 +37,7 @@ u32_t tm_off; /********************************************************************/ /* static allocation */ -K_THREAD_DEFINE(RECVTASK, 1024, recvtask, NULL, NULL, NULL, 5, 0, K_NO_WAIT); +K_THREAD_DEFINE(RECVTASK, 1024, recvtask, NULL, NULL, NULL, 5, 0, 0); K_MSGQ_DEFINE(DEMOQX1, 1, 500, 4); K_MSGQ_DEFINE(DEMOQX4, 4, 500, 4); diff --git a/tests/benchmarks/app_kernel/src/sema_r.c b/tests/benchmarks/app_kernel/src/sema_r.c index df4a01ed757..3abe9830248 100644 --- a/tests/benchmarks/app_kernel/src/sema_r.c +++ b/tests/benchmarks/app_kernel/src/sema_r.c @@ -27,7 +27,7 @@ void waittask(void) k_sem_take(&SEM1, K_FOREVER); } for (i = 0; i < NR_OF_SEMA_RUNS; i++) { - k_sem_take(&SEM1, SEMA_WAIT_TIME); + k_sem_take(&SEM1, K_MSEC(SEMA_WAIT_TIME)); } } diff --git a/tests/benchmarks/latency_measure/src/int_to_thread_evt.c b/tests/benchmarks/latency_measure/src/int_to_thread_evt.c index 96e041c2f36..d0aafdc0aa1 100644 --- a/tests/benchmarks/latency_measure/src/int_to_thread_evt.c +++ b/tests/benchmarks/latency_measure/src/int_to_thread_evt.c @@ -73,7 +73,7 @@ void int_thread(void) K_THREAD_DEFINE(int_thread_id, 512, (k_thread_entry_t) int_thread, NULL, NULL, NULL, - 11, 0, K_NO_WAIT); + 11, 0, 0); /** * diff --git a/tests/benchmarks/latency_measure/src/main.c b/tests/benchmarks/latency_measure/src/main.c index f9c26236fa2..b9459f864da 100644 --- a/tests/benchmarks/latency_measure/src/main.c +++ b/tests/benchmarks/latency_measure/src/main.c @@ -55,7 +55,7 @@ void test_thread(void *arg1, void *arg2, void *arg3) K_THREAD_DEFINE(tt_id, STACK_SIZE, test_thread, NULL, NULL, NULL, - 10, 0, K_NO_WAIT); + 10, 0, 0); void main(void) diff --git a/tests/boards/intel_s1000_crb/main/src/dma_test.c b/tests/boards/intel_s1000_crb/main/src/dma_test.c index 036124d7f33..3ee3fb73f97 100644 --- a/tests/boards/intel_s1000_crb/main/src/dma_test.c +++ b/tests/boards/intel_s1000_crb/main/src/dma_test.c @@ -42,10 +42,10 @@ #define PRIORITY 7 /* delay between greetings (in ms) */ -#define SLEEPTIME 500 +#define SLEEPTIME K_MSEC(500) /* max time to be waited for dma to complete (in ms) */ -#define WAITTIME 1000 +#define WAITTIME K_MSEC(1000) #define MAX_TRANSFERS 4 @@ -273,4 +273,4 @@ void dma_thread(void) } K_THREAD_DEFINE(dma_thread_id, STACKSIZE, dma_thread, NULL, NULL, NULL, - PRIORITY, 0, K_NO_WAIT); + PRIORITY, 0, 0); diff --git a/tests/boards/intel_s1000_crb/main/src/i2c_test.c b/tests/boards/intel_s1000_crb/main/src/i2c_test.c index d2962d987f1..b829cb7d73d 100644 --- a/tests/boards/intel_s1000_crb/main/src/i2c_test.c +++ b/tests/boards/intel_s1000_crb/main/src/i2c_test.c @@ -167,9 +167,9 @@ void i2c_thread(void *dummy1, void *dummy2, void *dummy3) k_sem_give(&thread_sem); /* wait a while */ - k_sleep(SLEEPTIME); + k_msleep(SLEEPTIME); } } K_THREAD_DEFINE(i2c_thread_id, STACKSIZE, i2c_thread, NULL, NULL, NULL, - PRIORITY, 0, K_NO_WAIT); + PRIORITY, 0, 0); diff --git a/tests/boards/intel_s1000_crb/main/src/i2s_test.c b/tests/boards/intel_s1000_crb/main/src/i2s_test.c index 077b1bb2465..9529c362c8f 100644 --- a/tests/boards/intel_s1000_crb/main/src/i2s_test.c +++ b/tests/boards/intel_s1000_crb/main/src/i2s_test.c @@ -36,7 +36,7 @@ #define PRIORITY 7 /* delay between greetings (in ms) */ -#define SLEEPTIME 500 +#define SLEEPTIME K_MSEC(500) extern struct k_sem thread_sem; @@ -182,4 +182,4 @@ void i2s_thread(void *dummy1, void *dummy2, void *dummy3) } K_THREAD_DEFINE(i2s_thread_id, STACKSIZE, i2s_thread, NULL, NULL, NULL, - PRIORITY, 0, K_NO_WAIT); + PRIORITY, 0, 0); diff --git a/tests/boards/native_posix/rtc/src/main.c b/tests/boards/native_posix/rtc/src/main.c index 4153a311705..5dbe6e37d35 100644 --- a/tests/boards/native_posix/rtc/src/main.c +++ b/tests/boards/native_posix/rtc/src/main.c @@ -69,7 +69,7 @@ static void test_realtime(void) hwtimer_set_rt_ratio(1.0); /*Let's wait >=1 tick to ensure everything is settled*/ - k_sleep(TICK_MS); + k_msleep(TICK_MS); start_time = get_host_us_time(); start_rtc_time[2] = native_rtc_gettime_us(RTC_CLOCK_PSEUDOHOSTREALTIME); @@ -81,7 +81,7 @@ static void test_realtime(void) acc_ratio *= time_ratios[i]; /* k_sleep waits 1 tick more than asked */ - k_sleep(WAIT_TIME - TICK_MS); + k_msleep(WAIT_TIME - TICK_MS); /* * Check that during the sleep, the correct amount of real time diff --git a/tests/drivers/counter/counter_cmos/src/main.c b/tests/drivers/counter/counter_cmos/src/main.c index 34c1e96f767..59b7d022972 100644 --- a/tests/drivers/counter/counter_cmos/src/main.c +++ b/tests/drivers/counter/counter_cmos/src/main.c @@ -27,7 +27,7 @@ void test_cmos_rate(void) err = counter_get_value(cmos, &start); zassert_true(err == 0, "failed to read CMOS counter device"); - k_sleep(DELAY_MS); + k_msleep(DELAY_MS); err = counter_get_value(cmos, &elapsed); zassert_true(err == 0, "failed to read CMOS counter device"); diff --git a/tests/kernel/common/src/errno.c b/tests/kernel/common/src/errno.c index 930a1e6bafd..b6115e0346d 100644 --- a/tests/kernel/common/src/errno.c +++ b/tests/kernel/common/src/errno.c @@ -46,7 +46,7 @@ static void errno_thread(void *_n, void *_my_errno, void *_unused) errno = my_errno; - k_sleep(30 - (n * 10)); + k_msleep(30 - (n * 10)); if (errno == my_errno) { result[n].pass = 1; } @@ -86,7 +86,7 @@ void test_thread_context(void) } for (int ii = 0; ii < N_THREADS; ii++) { - struct result *p = k_fifo_get(&fifo, 100); + struct result *p = k_fifo_get(&fifo, K_MSEC(100)); if (!p || !p->pass) { rv = TC_FAIL; diff --git a/tests/kernel/context/src/main.c b/tests/kernel/context/src/main.c index 81303b16d10..cd66ad84735 100644 --- a/tests/kernel/context/src/main.c +++ b/tests/kernel/context/src/main.c @@ -247,7 +247,7 @@ static void _test_kernel_cpu_idle(int atomic) k_timer_init(&idle_timer, idle_timer_expiry_function, NULL); for (i = 0; i < 5; i++) { /* Repeat the test five times */ - k_timer_start(&idle_timer, 1, 0); + k_timer_start(&idle_timer, K_MSEC(1), K_NO_WAIT); tms = k_uptime_get_32(); if (atomic) { unsigned int key = irq_lock(); @@ -724,7 +724,7 @@ static void thread_sleep(void *delta, void *arg2, void *arg3) TC_PRINT(" thread sleeping for %d milliseconds\n", timeout); timestamp = k_uptime_get(); - k_sleep(timeout); + k_msleep(timeout); timestamp = k_uptime_get() - timestamp; TC_PRINT(" thread back from sleep\n"); @@ -771,7 +771,7 @@ static void test_busy_wait(void) INT_TO_POINTER(timeout), NULL, NULL, K_PRIO_COOP(THREAD_PRIORITY), 0, K_NO_WAIT); - rv = k_sem_take(&reply_timeout, timeout * 2); + rv = k_sem_take(&reply_timeout, K_MSEC(timeout * 2)); zassert_false(rv, " *** thread timed out waiting for " "k_busy_wait()"); } @@ -798,7 +798,7 @@ static void test_k_sleep(void) INT_TO_POINTER(timeout), NULL, NULL, K_PRIO_COOP(THREAD_PRIORITY), 0, K_NO_WAIT); - rv = k_sem_take(&reply_timeout, timeout * 2); + rv = k_sem_take(&reply_timeout, K_MSEC(timeout * 2)); zassert_equal(rv, 0, " *** thread timed out waiting for thread on " "k_sleep()."); @@ -810,10 +810,11 @@ static void test_k_sleep(void) THREAD_STACKSIZE2, delayed_thread, INT_TO_POINTER(i), NULL, NULL, - K_PRIO_COOP(5), 0, timeouts[i].timeout); + K_PRIO_COOP(5), 0, + K_MSEC(timeouts[i].timeout)); } for (i = 0; i < NUM_TIMEOUT_THREADS; i++) { - data = k_fifo_get(&timeout_order_fifo, 750); + data = k_fifo_get(&timeout_order_fifo, K_MSEC(750)); zassert_not_null(data, " *** timeout while waiting for" " delayed thread"); @@ -826,7 +827,7 @@ static void test_k_sleep(void) } /* ensure no more thread fire */ - data = k_fifo_get(&timeout_order_fifo, 750); + data = k_fifo_get(&timeout_order_fifo, K_MSEC(750)); zassert_false(data, " *** got something unexpected in the fifo"); @@ -845,7 +846,8 @@ static void test_k_sleep(void) id = k_thread_create(&timeout_threads[i], timeout_stacks[i], THREAD_STACKSIZE2, delayed_thread, INT_TO_POINTER(i), NULL, NULL, - K_PRIO_COOP(5), 0, timeouts[i].timeout); + K_PRIO_COOP(5), 0, + K_MSEC(timeouts[i].timeout)); delayed_threads[i] = id; } @@ -871,7 +873,7 @@ static void test_k_sleep(void) } } - data = k_fifo_get(&timeout_order_fifo, 2750); + data = k_fifo_get(&timeout_order_fifo, K_MSEC(2750)); zassert_not_null(data, " *** timeout while waiting for" " delayed thread"); @@ -890,7 +892,7 @@ static void test_k_sleep(void) "got %d\n", num_cancellations, next_cancellation); /* ensure no more thread fire */ - data = k_fifo_get(&timeout_order_fifo, 750); + data = k_fifo_get(&timeout_order_fifo, K_MSEC(750)); zassert_false(data, " *** got something unexpected in the fifo"); } diff --git a/tests/kernel/critical/src/main.c b/tests/kernel/critical/src/main.c index 973ebd61f4b..1e5f81c4d99 100644 --- a/tests/kernel/critical/src/main.c +++ b/tests/kernel/critical/src/main.c @@ -172,7 +172,7 @@ void regression_thread(void *arg1, void *arg2, void *arg3) ncalls = critical_loop("reg1", ncalls); /* Wait for alternate_thread() to complete */ - zassert_true(k_sem_take(®RESS_SEM, TEST_TIMEOUT) == 0, + zassert_true(k_sem_take(®RESS_SEM, K_MSEC(TEST_TIMEOUT)) == 0, "Timed out waiting for REGRESS_SEM"); zassert_equal(critical_var, ncalls + alt_thread_iterations, @@ -186,7 +186,7 @@ void regression_thread(void *arg1, void *arg2, void *arg3) ncalls = critical_loop("reg2", ncalls); /* Wait for alternate_thread() to finish */ - zassert_true(k_sem_take(®RESS_SEM, TEST_TIMEOUT) == 0, + zassert_true(k_sem_take(®RESS_SEM, K_MSEC(TEST_TIMEOUT)) == 0, "Timed out waiting for REGRESS_SEM"); zassert_equal(critical_var, ncalls + alt_thread_iterations, @@ -230,7 +230,7 @@ void test_critical(void) init_objects(); start_threads(); - zassert_true(k_sem_take(&TEST_SEM, TEST_TIMEOUT * 2) == 0, + zassert_true(k_sem_take(&TEST_SEM, K_MSEC(TEST_TIMEOUT * 2)) == 0, "Timed out waiting for TEST_SEM"); } diff --git a/tests/kernel/early_sleep/src/main.c b/tests/kernel/early_sleep/src/main.c index 7466259ee98..82340e7a033 100644 --- a/tests/kernel/early_sleep/src/main.c +++ b/tests/kernel/early_sleep/src/main.c @@ -58,7 +58,7 @@ static int ticks_to_sleep(int ticks) u32_t stop_time; start_time = k_cycle_get_32(); - k_sleep(k_ticks_to_ms_floor64(ticks)); + k_sleep(K_MSEC(k_ticks_to_ms_floor64(ticks))); stop_time = k_cycle_get_32(); return (stop_time - start_time) / k_ticks_to_cyc_floor32(1); diff --git a/tests/kernel/fifo/fifo_api/src/test_fifo_cancel.c b/tests/kernel/fifo/fifo_api/src/test_fifo_cancel.c index 4fb3603d14c..5420d3b89d4 100644 --- a/tests/kernel/fifo/fifo_api/src/test_fifo_cancel.c +++ b/tests/kernel/fifo/fifo_api/src/test_fifo_cancel.c @@ -28,7 +28,7 @@ static void tfifo_thread_thread(struct k_fifo *pfifo) t_cancel_wait_entry, pfifo, NULL, NULL, K_PRIO_PREEMPT(0), 0, K_NO_WAIT); u32_t start_t = k_uptime_get_32(); - void *ret = k_fifo_get(pfifo, 500); + void *ret = k_fifo_get(pfifo, K_MSEC(500)); u32_t dur = k_uptime_get_32() - start_t; /* While we observed the side effect of the last statement diff --git a/tests/kernel/fifo/fifo_api/src/test_fifo_fail.c b/tests/kernel/fifo/fifo_api/src/test_fifo_fail.c index f69c728bbca..584ad623924 100644 --- a/tests/kernel/fifo/fifo_api/src/test_fifo_fail.c +++ b/tests/kernel/fifo/fifo_api/src/test_fifo_fail.c @@ -6,7 +6,7 @@ #include "test_fifo.h" -#define TIMEOUT 100 +#define TIMEOUT K_MSEC(100) /** * @addtogroup kernel_fifo_tests diff --git a/tests/kernel/fifo/fifo_timeout/src/main.c b/tests/kernel/fifo/fifo_timeout/src/main.c index 8b8e2b0accf..a77e66a3b0b 100644 --- a/tests/kernel/fifo/fifo_timeout/src/main.c +++ b/tests/kernel/fifo/fifo_timeout/src/main.c @@ -112,7 +112,7 @@ static void test_thread_put_timeout(void *p1, void *p2, void *p3) { u32_t timeout = *((u32_t *)p2); - k_sleep(timeout); + k_msleep(timeout); k_fifo_put((struct k_fifo *)p1, get_scratch_packet()); } @@ -123,10 +123,10 @@ static void test_thread_pend_and_timeout(void *p1, void *p2, void *p3) u32_t start_time; void *packet; - k_sleep(K_MSEC(1)); /* Align to ticks */ + k_msleep(1); /* Align to ticks */ start_time = k_cycle_get_32(); - packet = k_fifo_get(d->fifo, d->timeout); + packet = k_fifo_get(d->fifo, K_MSEC(d->timeout)); zassert_true(packet == NULL, NULL); zassert_true(is_timeout_in_range(start_time, d->timeout), NULL); @@ -200,7 +200,7 @@ static void test_thread_pend_and_get_data(void *p1, void *p2, void *p3) struct timeout_order_data *d = (struct timeout_order_data *)p1; void *packet; - packet = k_fifo_get(d->fifo, d->timeout); + packet = k_fifo_get(d->fifo, K_MSEC(d->timeout)); zassert_true(packet != NULL, NULL); put_scratch_packet(packet); @@ -300,12 +300,12 @@ static void test_timeout_empty_fifo(void) void *packet; u32_t start_time, timeout; - k_sleep(K_MSEC(1)); /* Align to ticks */ + k_msleep(1); /* Align to ticks */ /* Test empty fifo with timeout */ timeout = 10U; start_time = k_cycle_get_32(); - packet = k_fifo_get(&fifo_timeout[0], timeout); + packet = k_fifo_get(&fifo_timeout[0], K_MSEC(timeout)); zassert_true(packet == NULL, NULL); zassert_true(is_timeout_in_range(start_time, timeout), NULL); @@ -353,7 +353,7 @@ static void test_timeout_fifo_thread(void) struct reply_packet reply_packet; u32_t start_time, timeout; - k_sleep(K_MSEC(1)); /* Align to ticks */ + k_msleep(1); /* Align to ticks */ /* * Test fifo with some timeout and child thread that puts @@ -367,7 +367,7 @@ static void test_timeout_fifo_thread(void) &timeout, NULL, FIFO_THREAD_PRIO, K_INHERIT_PERMS, K_NO_WAIT); - packet = k_fifo_get(&fifo_timeout[0], timeout + 10); + packet = k_fifo_get(&fifo_timeout[0], K_MSEC(timeout + 10)); zassert_true(packet != NULL, NULL); zassert_true(is_timeout_in_range(start_time, timeout), NULL); put_scratch_packet(packet); diff --git a/tests/kernel/fp_sharing/generic/src/main.c b/tests/kernel/fp_sharing/generic/src/main.c index c535aeecd8f..0f2454c2ee1 100644 --- a/tests/kernel/fp_sharing/generic/src/main.c +++ b/tests/kernel/fp_sharing/generic/src/main.c @@ -362,16 +362,16 @@ void load_store_high(void) #endif K_THREAD_DEFINE(load_low, STACKSIZE, load_store_low, NULL, NULL, NULL, - LO_PRI, THREAD_FP_FLAGS, K_NO_WAIT); + LO_PRI, THREAD_FP_FLAGS, 0); K_THREAD_DEFINE(load_high, STACKSIZE, load_store_high, NULL, NULL, NULL, - HI_PRI, THREAD_FP_FLAGS, K_NO_WAIT); + HI_PRI, THREAD_FP_FLAGS, 0); K_THREAD_DEFINE(pi_low, STACKSIZE, calculate_pi_low, NULL, NULL, NULL, - LO_PRI, THREAD_FP_FLAGS, K_NO_WAIT); + LO_PRI, THREAD_FP_FLAGS, 0); K_THREAD_DEFINE(pi_high, STACKSIZE, calculate_pi_high, NULL, NULL, NULL, - HI_PRI, THREAD_FP_FLAGS, K_NO_WAIT); + HI_PRI, THREAD_FP_FLAGS, 0); void main(void) { diff --git a/tests/kernel/interrupt/src/interrupt_util.h b/tests/kernel/interrupt/src/interrupt_util.h index 20010b5352e..e55d64c0c2d 100644 --- a/tests/kernel/interrupt/src/interrupt_util.h +++ b/tests/kernel/interrupt/src/interrupt_util.h @@ -9,7 +9,7 @@ #include -#define MS_TO_US(ms) (K_MSEC(ms) * USEC_PER_MSEC) +#define MS_TO_US(ms) (ms * USEC_PER_MSEC) #if defined(CONFIG_CPU_CORTEX_M) #include diff --git a/tests/kernel/interrupt/src/prevent_irq.c b/tests/kernel/interrupt/src/prevent_irq.c index 85c03750c85..6271bb1ad57 100644 --- a/tests/kernel/interrupt/src/prevent_irq.c +++ b/tests/kernel/interrupt/src/prevent_irq.c @@ -45,7 +45,7 @@ void test_prevent_interruption(void) * timer ought to have fired during this time if interrupts weren't * locked -- but since they are, check_lock_new isn't updated. */ - k_timer_start(&irqlock_timer, DURATION, K_NO_WAIT); + k_timer_start(&irqlock_timer, K_MSEC(DURATION), K_NO_WAIT); k_busy_wait(MS_TO_US(1000)); zassert_not_equal(handler_result, HANDLER_TOKEN, "timer interrupt was serviced while interrupts are locked"); diff --git a/tests/kernel/lifo/lifo_api/src/test_lifo_fail.c b/tests/kernel/lifo/lifo_api/src/test_lifo_fail.c index 6245dc949a7..f87935ca85a 100644 --- a/tests/kernel/lifo/lifo_api/src/test_lifo_fail.c +++ b/tests/kernel/lifo/lifo_api/src/test_lifo_fail.c @@ -6,7 +6,7 @@ #include "test_lifo.h" -#define TIMEOUT 100 +#define TIMEOUT K_MSEC(100) /*test cases*/ /** diff --git a/tests/kernel/lifo/lifo_usage/src/main.c b/tests/kernel/lifo/lifo_usage/src/main.c index c88b124ac75..3787b3dfd6b 100644 --- a/tests/kernel/lifo/lifo_usage/src/main.c +++ b/tests/kernel/lifo/lifo_usage/src/main.c @@ -35,7 +35,7 @@ struct reply_packet { struct timeout_order_data { void *link_in_lifo; struct k_lifo *klifo; - u32_t timeout; + s32_t timeout; s32_t timeout_order; s32_t q_order; }; @@ -199,7 +199,7 @@ static void test_thread_put_timeout(void *p1, void *p2, void *p3) { u32_t timeout = *((u32_t *)p2); - k_sleep(timeout); + k_msleep(timeout); k_lifo_put((struct k_lifo *)p1, get_scratch_packet()); } @@ -269,7 +269,7 @@ static void test_timeout_empty_lifo(void) start_time = k_cycle_get_32(); - packet = k_lifo_get(&lifo_timeout[0], timeout); + packet = k_lifo_get(&lifo_timeout[0], K_MSEC(timeout)); zassert_equal(packet, NULL, NULL); @@ -324,7 +324,7 @@ static void test_timeout_lifo_thread(void) &timeout, NULL, LIFO_THREAD_PRIO, K_INHERIT_PERMS, K_NO_WAIT); - packet = k_lifo_get(&lifo_timeout[0], timeout + 10); + packet = k_lifo_get(&lifo_timeout[0], K_MSEC(timeout + 10)); zassert_true(packet != NULL, NULL); zassert_true(is_timeout_in_range(start_time, timeout), NULL); put_scratch_packet(packet); @@ -396,7 +396,7 @@ void test_thread_pend_and_timeout(void *p1, void *p2, void *p3) void *packet; start_time = k_cycle_get_32(); - packet = k_lifo_get(d->klifo, d->timeout); + packet = k_lifo_get(d->klifo, K_MSEC(d->timeout)); zassert_true(packet == NULL, NULL); zassert_true(is_timeout_in_range(start_time, d->timeout), NULL); diff --git a/tests/kernel/mbox/mbox_api/src/test_mbox_api.c b/tests/kernel/mbox/mbox_api/src/test_mbox_api.c index 2d58c9e04b1..8e2a831c9a0 100644 --- a/tests/kernel/mbox/mbox_api/src/test_mbox_api.c +++ b/tests/kernel/mbox/mbox_api/src/test_mbox_api.c @@ -6,7 +6,7 @@ #include -#define TIMEOUT 100 +#define TIMEOUT K_MSEC(100) #if !defined(CONFIG_BOARD_QEMU_X86) #define STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACKSIZE) #else diff --git a/tests/kernel/mbox/mbox_usage/src/main.c b/tests/kernel/mbox/mbox_usage/src/main.c index 47d484ddacd..34586cd61f2 100644 --- a/tests/kernel/mbox/mbox_usage/src/main.c +++ b/tests/kernel/mbox/mbox_usage/src/main.c @@ -40,9 +40,9 @@ static void msg_sender(struct k_mbox *pmbox, s32_t timeout) mmsg.info = PUT_GET_NULL; mmsg.size = 0; mmsg.tx_data = NULL; - if (timeout == K_FOREVER) { + if (K_TIMEOUT_EQ(timeout, K_FOREVER)) { k_mbox_put(pmbox, &mmsg, K_FOREVER); - } else if (timeout == K_NO_WAIT) { + } else if (K_TIMEOUT_EQ(timeout, K_NO_WAIT)) { k_mbox_put(pmbox, &mmsg, K_NO_WAIT); } else { k_mbox_put(pmbox, &mmsg, timeout); @@ -62,10 +62,10 @@ static void msg_receiver(struct k_mbox *pmbox, k_tid_t thd_id, s32_t timeout) case PUT_GET_NULL: mmsg.size = sizeof(rxdata); mmsg.rx_source_thread = thd_id; - if (timeout == K_FOREVER) { + if (K_TIMEOUT_EQ(timeout, K_FOREVER)) { zassert_true(k_mbox_get(pmbox, &mmsg, rxdata, K_FOREVER) == 0, NULL); - } else if (timeout == K_NO_WAIT) { + } else if (K_TIMEOUT_EQ(timeout, K_NO_WAIT)) { zassert_false(k_mbox_get(pmbox, &mmsg, rxdata, K_NO_WAIT) == 0, NULL); } else { @@ -102,7 +102,7 @@ void test_msg_receiver(void) test_send, &mbox, NULL, NULL, K_PRIO_PREEMPT(0), 0, K_NO_WAIT); - msg_receiver(&mbox, K_ANY, 2); + msg_receiver(&mbox, K_ANY, K_MSEC(2)); k_thread_abort(tid); } diff --git a/tests/kernel/mem_pool/mem_pool/src/main.c b/tests/kernel/mem_pool/mem_pool/src/main.c index 4aeadf03a8e..14dc086d423 100644 --- a/tests/kernel/mem_pool/mem_pool/src/main.c +++ b/tests/kernel/mem_pool/mem_pool/src/main.c @@ -107,7 +107,7 @@ static int pool_block_get_func(struct k_mem_block *block, struct k_mem_pool *poo static int pool_block_get_wt_func(struct k_mem_block *block, struct k_mem_pool *pool, int size, s32_t timeout) { - return k_mem_pool_alloc(pool, block, size, timeout); + return k_mem_pool_alloc(pool, block, size, K_MSEC(timeout)); } /** @@ -337,10 +337,10 @@ static void test_pool_malloc(void) } K_THREAD_DEFINE(t_alternate, STACKSIZE, alternate_task, NULL, NULL, NULL, - 6, 0, K_NO_WAIT); + 6, 0, 0); K_THREAD_DEFINE(t_helper, STACKSIZE, helper_task, NULL, NULL, NULL, - 7, 0, K_NO_WAIT); + 7, 0, 0); void test_main(void) { diff --git a/tests/kernel/mem_pool/mem_pool_api/src/test_mpool.h b/tests/kernel/mem_pool/mem_pool_api/src/test_mpool.h index 2c470706f58..83281de9890 100644 --- a/tests/kernel/mem_pool/mem_pool_api/src/test_mpool.h +++ b/tests/kernel/mem_pool/mem_pool_api/src/test_mpool.h @@ -7,7 +7,8 @@ #ifndef __TEST_MPOOL_H__ #define __TEST_MPOOL_H__ -#define TIMEOUT 100 +#define TIMEOUT_MS 100 +#define TIMEOUT K_MSEC(TIMEOUT_MS) #define BLK_SIZE_MIN 16 #define BLK_SIZE_MAX 256 #define BLK_NUM_MIN 32 diff --git a/tests/kernel/mem_pool/mem_pool_api/src/test_mpool_api.c b/tests/kernel/mem_pool/mem_pool_api/src/test_mpool_api.c index f8f12a13ddc..79eab209816 100644 --- a/tests/kernel/mem_pool/mem_pool_api/src/test_mpool_api.c +++ b/tests/kernel/mem_pool/mem_pool_api/src/test_mpool_api.c @@ -164,7 +164,7 @@ void test_mpool_alloc_timeout(void) * TESTPOINT: Maximum time to wait for operation to complete (in * milliseconds) */ - zassert_true(k_uptime_delta(&tms) >= TIMEOUT, NULL); + zassert_true(k_uptime_delta(&tms) >= TIMEOUT_MS, NULL); for (int i = 0; i < BLK_NUM_MIN; i++) { k_mem_pool_free(&block[i]); diff --git a/tests/kernel/mem_pool/mem_pool_concept/src/test_mpool.h b/tests/kernel/mem_pool/mem_pool_concept/src/test_mpool.h index cad8e687399..08ceb4e080e 100644 --- a/tests/kernel/mem_pool/mem_pool_concept/src/test_mpool.h +++ b/tests/kernel/mem_pool/mem_pool_concept/src/test_mpool.h @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define TIMEOUT 2000 +#define TIMEOUT K_MSEC(2000) #ifdef CONFIG_RISCV #define STACK_SIZE (1024 + CONFIG_TEST_EXTRA_STACKSIZE) #else diff --git a/tests/kernel/mem_pool/mem_pool_concept/src/test_mpool_merge_fail_diff_size.c b/tests/kernel/mem_pool/mem_pool_concept/src/test_mpool_merge_fail_diff_size.c index dfea2bbd702..8c27e70d1f7 100644 --- a/tests/kernel/mem_pool/mem_pool_concept/src/test_mpool_merge_fail_diff_size.c +++ b/tests/kernel/mem_pool/mem_pool_concept/src/test_mpool_merge_fail_diff_size.c @@ -5,7 +5,7 @@ */ #include -#define TIMEOUT 2000 +#define TIMEOUT K_MSEC(2000) #define BLK_SIZE_MIN 16 #define BLK_SIZE_MID 32 #define BLK_SIZE_MAX 256 diff --git a/tests/kernel/mem_pool/mem_pool_threadsafe/src/main.c b/tests/kernel/mem_pool/mem_pool_threadsafe/src/main.c index 6f701232196..7e15f097721 100644 --- a/tests/kernel/mem_pool/mem_pool_threadsafe/src/main.c +++ b/tests/kernel/mem_pool/mem_pool_threadsafe/src/main.c @@ -10,7 +10,7 @@ #define STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACKSIZE) #define POOL_NUM 2 #define LOOPS 10 -#define TIMEOUT 200 +#define TIMEOUT K_MSEC(200) #define BLK_SIZE_MIN _MPOOL_MINBLK #define BLK_SIZE_MAX (4 * BLK_SIZE_MIN) #define BLK_NUM_MIN 8 diff --git a/tests/kernel/mem_protect/futex/src/main.c b/tests/kernel/mem_protect/futex/src/main.c index ffead628d8c..9a4884d73ff 100644 --- a/tests/kernel/mem_protect/futex/src/main.c +++ b/tests/kernel/mem_protect/futex/src/main.c @@ -64,7 +64,7 @@ void futex_wait_task(void *p1, void *p2, void *p3) s32_t ret_value; int time_val = *(int *)p1; - zassert_true(time_val >= K_FOREVER, "invalid timeout parameter"); + zassert_true(time_val >= (int)K_FOREVER, "invalid timeout parameter"); ret_value = k_futex_wait(&simple_futex, atomic_get(&simple_futex.val), time_val); @@ -105,7 +105,7 @@ void futex_wait_wake_task(void *p1, void *p2, void *p3) s32_t ret_value; int time_val = *(int *)p1; - zassert_true(time_val >= K_FOREVER, "invalid timeout parameter"); + zassert_true(time_val >= (int)K_FOREVER, "invalid timeout parameter"); ret_value = k_futex_wait(&simple_futex, atomic_get(&simple_futex.val), time_val); @@ -148,7 +148,7 @@ void futex_multiple_wait_wake_task(void *p1, void *p2, void *p3) int time_val = *(int *)p1; int idx = *(int *)p2; - zassert_true(time_val == K_FOREVER, "invalid timeout parameter"); + zassert_true(time_val == (int)K_FOREVER, "invalid timeout parameter"); ret_value = k_futex_wait(&multiple_futex[idx], atomic_get(&(multiple_futex[idx].val)), time_val); diff --git a/tests/kernel/mem_protect/syscalls/src/main.c b/tests/kernel/mem_protect/syscalls/src/main.c index a73a6ac79cf..7fc262d5d24 100644 --- a/tests/kernel/mem_protect/syscalls/src/main.c +++ b/tests/kernel/mem_protect/syscalls/src/main.c @@ -322,7 +322,7 @@ void test_syscall_torture(void) * abort them. They will all be hammering the cpu(s) with system calls, * hopefully smoking out any issues and causing a crash. */ - k_sleep(15000); + k_msleep(15000); for (i = 0; i < NR_THREADS; i++) { k_thread_abort(&torture_threads[i]); diff --git a/tests/kernel/mem_slab/mslab/src/main.c b/tests/kernel/mem_slab/mslab/src/main.c index 04840fdb91f..65574413756 100644 --- a/tests/kernel/mem_slab/mslab/src/main.c +++ b/tests/kernel/mem_slab/mslab/src/main.c @@ -275,7 +275,7 @@ void test_mslab(void) } K_THREAD_DEFINE(HELPER, STACKSIZE, helper_thread, NULL, NULL, NULL, - 7, 0, K_NO_WAIT); + 7, 0, 0); /*test case main entry*/ void test_main(void) diff --git a/tests/kernel/mem_slab/mslab_api/src/test_mslab_api.c b/tests/kernel/mem_slab/mslab_api/src/test_mslab_api.c index e2bc267f269..02f8b664ebd 100644 --- a/tests/kernel/mem_slab/mslab_api/src/test_mslab_api.c +++ b/tests/kernel/mem_slab/mslab_api/src/test_mslab_api.c @@ -75,7 +75,8 @@ static void tmslab_alloc_timeout(void *data) NULL); /** TESTPOINT: -EAGAIN Waiting period timed out*/ tms = k_uptime_get(); - zassert_equal(k_mem_slab_alloc(pslab, &block_fail, TIMEOUT), -EAGAIN, + zassert_equal(k_mem_slab_alloc(pslab, &block_fail, K_MSEC(TIMEOUT)), + -EAGAIN, NULL); /** * TESTPOINT: timeout Maximum time to wait for operation to @@ -111,7 +112,8 @@ static void tmslab_used_get(void *data) /* used get on allocation failure*/ zassert_equal(k_mem_slab_num_used_get(pslab), BLK_NUM, NULL); - zassert_equal(k_mem_slab_alloc(pslab, &block_fail, TIMEOUT), -EAGAIN, + zassert_equal(k_mem_slab_alloc(pslab, &block_fail, K_MSEC(TIMEOUT)), + -EAGAIN, NULL); zassert_equal(k_mem_slab_num_free_get(pslab), 0, NULL); zassert_equal(k_mem_slab_num_used_get(pslab), BLK_NUM, NULL); diff --git a/tests/kernel/mem_slab/mslab_concept/src/test_mslab.h b/tests/kernel/mem_slab/mslab_concept/src/test_mslab.h index 9b5cc26146c..df87659aded 100644 --- a/tests/kernel/mem_slab/mslab_concept/src/test_mslab.h +++ b/tests/kernel/mem_slab/mslab_concept/src/test_mslab.h @@ -7,7 +7,7 @@ #ifndef __TEST_MSLAB_H__ #define __TEST_MSLAB_H__ -#define TIMEOUT 2000 +#define TIMEOUT K_MSEC(2000) #define BLK_NUM 3 #define BLK_ALIGN 8 #define BLK_SIZE 16 diff --git a/tests/kernel/mem_slab/mslab_concept/src/test_mslab_alloc_wait.c b/tests/kernel/mem_slab/mslab_concept/src/test_mslab_alloc_wait.c index 87c0c7162ae..4721efcbe7b 100644 --- a/tests/kernel/mem_slab/mslab_concept/src/test_mslab_alloc_wait.c +++ b/tests/kernel/mem_slab/mslab_concept/src/test_mslab_alloc_wait.c @@ -82,7 +82,7 @@ void test_mslab_alloc_wait_prio(void) tmslab_alloc_wait_timeout, NULL, NULL, NULL, K_PRIO_PREEMPT(0), 0, K_MSEC(20)); /*relinquish CPU for above threads to start */ - k_sleep(K_MSEC(30)); + k_msleep(30); /*free one block, expected to unblock thread "tid[1]"*/ k_mem_slab_free(&mslab1, &block[0]); /*wait for all threads exit*/ diff --git a/tests/kernel/mem_slab/mslab_threadsafe/src/test_mslab_threadsafe.c b/tests/kernel/mem_slab/mslab_threadsafe/src/test_mslab_threadsafe.c index e748c12b161..eb631be9835 100644 --- a/tests/kernel/mem_slab/mslab_threadsafe/src/test_mslab_threadsafe.c +++ b/tests/kernel/mem_slab/mslab_threadsafe/src/test_mslab_threadsafe.c @@ -10,7 +10,7 @@ #define STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACKSIZE) #define THREAD_NUM 4 #define SLAB_NUM 2 -#define TIMEOUT 200 +#define TIMEOUT K_MSEC(200) #define BLK_NUM 3 #define BLK_ALIGN 8 #define BLK_SIZE1 16 diff --git a/tests/kernel/msgq/msgq_api/src/test_msgq.h b/tests/kernel/msgq/msgq_api/src/test_msgq.h index 8d11dfbe2e0..c4d2357385f 100644 --- a/tests/kernel/msgq/msgq_api/src/test_msgq.h +++ b/tests/kernel/msgq/msgq_api/src/test_msgq.h @@ -12,7 +12,8 @@ #include #include -#define TIMEOUT 100 +#define TIMEOUT_MS 100 +#define TIMEOUT K_MSEC(TIMEOUT_MS) #define STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACKSIZE) #define MSG_SIZE 4 #define MSGQ_LEN 2 diff --git a/tests/kernel/msgq/msgq_api/src/test_msgq_purge.c b/tests/kernel/msgq/msgq_api/src/test_msgq_purge.c index 2cb0cd836c1..d8f3b0c9194 100644 --- a/tests/kernel/msgq/msgq_api/src/test_msgq_purge.c +++ b/tests/kernel/msgq/msgq_api/src/test_msgq_purge.c @@ -33,7 +33,7 @@ static void purge_when_put(struct k_msgq *q) tThread_entry, q, NULL, NULL, K_PRIO_PREEMPT(0), K_USER | K_INHERIT_PERMS, K_NO_WAIT); - k_sleep(TIMEOUT >> 1); + k_msleep(TIMEOUT_MS >> 1); /**TESTPOINT: msgq purge while another thread waiting to put msg*/ k_msgq_purge(q); diff --git a/tests/kernel/mutex/mutex_api/src/test_mutex_apis.c b/tests/kernel/mutex/mutex_api/src/test_mutex_apis.c index 9d5a565a909..db1c611a7e9 100644 --- a/tests/kernel/mutex/mutex_api/src/test_mutex_apis.c +++ b/tests/kernel/mutex/mutex_api/src/test_mutex_apis.c @@ -30,13 +30,15 @@ static void tThread_entry_lock_no_wait(void *p1, void *p2, void *p3) static void tThread_entry_lock_timeout_fail(void *p1, void *p2, void *p3) { - zassert_true(k_mutex_lock((struct k_mutex *)p1, TIMEOUT - 100) != 0, NULL); + zassert_true(k_mutex_lock((struct k_mutex *)p1, + K_MSEC(TIMEOUT - 100)) != 0, NULL); TC_PRINT("bypass locked resource from spawn thread\n"); } static void tThread_entry_lock_timeout_pass(void *p1, void *p2, void *p3) { - zassert_true(k_mutex_lock((struct k_mutex *)p1, TIMEOUT + 100) == 0, NULL); + zassert_true(k_mutex_lock((struct k_mutex *)p1, + K_MSEC(TIMEOUT + 100)) == 0, NULL); TC_PRINT("access resource from spawn thread\n"); k_mutex_unlock((struct k_mutex *)p1); } @@ -53,7 +55,7 @@ static void tmutex_test_lock(struct k_mutex *pmutex, TC_PRINT("access resource from main thread\n"); /* wait for spawn thread to take action */ - k_sleep(TIMEOUT); + k_msleep(TIMEOUT); } static void tmutex_test_lock_timeout(struct k_mutex *pmutex, @@ -69,9 +71,9 @@ static void tmutex_test_lock_timeout(struct k_mutex *pmutex, TC_PRINT("access resource from main thread\n"); /* wait for spawn thread to take action */ - k_sleep(TIMEOUT); + k_msleep(TIMEOUT); k_mutex_unlock(pmutex); - k_sleep(TIMEOUT); + k_msleep(TIMEOUT); } @@ -84,7 +86,7 @@ static void tmutex_test_lock_unlock(struct k_mutex *pmutex) zassert_true(k_mutex_lock(pmutex, K_NO_WAIT) == 0, "fail to lock K_NO_WAIT"); k_mutex_unlock(pmutex); - zassert_true(k_mutex_lock(pmutex, TIMEOUT) == 0, + zassert_true(k_mutex_lock(pmutex, K_MSEC(TIMEOUT)) == 0, "fail to lock TIMEOUT"); k_mutex_unlock(pmutex); } diff --git a/tests/kernel/mutex/sys_mutex/src/main.c b/tests/kernel/mutex/sys_mutex/src/main.c index c577230b497..5daae71508e 100644 --- a/tests/kernel/mutex/sys_mutex/src/main.c +++ b/tests/kernel/mutex/sys_mutex/src/main.c @@ -398,22 +398,22 @@ void test_user_access(void) } K_THREAD_DEFINE(THREAD_05, STACKSIZE, thread_05, NULL, NULL, NULL, - 5, K_USER, K_NO_WAIT); + 5, K_USER, 0); K_THREAD_DEFINE(THREAD_06, STACKSIZE, thread_06, NULL, NULL, NULL, - 6, K_USER, K_NO_WAIT); + 6, K_USER, 0); K_THREAD_DEFINE(THREAD_07, STACKSIZE, thread_07, NULL, NULL, NULL, - 7, K_USER, K_NO_WAIT); + 7, K_USER, 0); K_THREAD_DEFINE(THREAD_08, STACKSIZE, thread_08, NULL, NULL, NULL, - 8, K_USER, K_NO_WAIT); + 8, K_USER, 0); K_THREAD_DEFINE(THREAD_09, STACKSIZE, thread_09, NULL, NULL, NULL, - 9, K_USER, K_NO_WAIT); + 9, K_USER, 0); K_THREAD_DEFINE(THREAD_11, STACKSIZE, thread_11, NULL, NULL, NULL, - 11, K_USER, K_NO_WAIT); + 11, K_USER, 0); /*test case main entry*/ void test_main(void) diff --git a/tests/kernel/obj_tracing/src/main.c b/tests/kernel/obj_tracing/src/main.c index 6a4cea54850..498e45def4d 100644 --- a/tests/kernel/obj_tracing/src/main.c +++ b/tests/kernel/obj_tracing/src/main.c @@ -25,7 +25,7 @@ extern void test_obj_tracing(void); #define TAKE(x) k_sem_take(x, K_FOREVER) #define GIVE(x) k_sem_give(x) -#define RANDDELAY(x) k_sleep(10 * (x) + 1) +#define RANDDELAY(x) k_msleep(10 * (x) + 1) static int initial_count; diff --git a/tests/kernel/pending/src/main.c b/tests/kernel/pending/src/main.c index 252f0c18f10..b1b38cca170 100644 --- a/tests/kernel/pending/src/main.c +++ b/tests/kernel/pending/src/main.c @@ -83,12 +83,12 @@ static int __noinit counter; static inline void *my_fifo_get(struct k_fifo *fifo, s32_t timeout) { - return k_fifo_get(fifo, timeout); + return k_fifo_get(fifo, K_MSEC(timeout)); } static inline void *my_lifo_get(struct k_lifo *lifo, s32_t timeout) { - return k_lifo_get(lifo, timeout); + return k_lifo_get(lifo, K_MSEC(timeout)); } static int increment_counter(void) @@ -196,7 +196,7 @@ static void timer_tests(void) timer_start_tick = k_uptime_get_32(); - k_timer_start(&timer, NUM_SECONDS(1), K_NO_WAIT); + k_timer_start(&timer, K_SECONDS(1), K_NO_WAIT); if (k_timer_status_sync(&timer)) { timer_data = timer.user_data; @@ -314,7 +314,7 @@ void test_pending_fifo(void) (task_low_state != FIFO_TEST_START), NULL); /* Give waiting threads time to time-out */ - k_sleep(NUM_SECONDS(2)); + k_sleep(K_SECONDS(2)); /* * Verify that the cooperative and preemptible threads timed-out in @@ -386,7 +386,7 @@ void test_pending_lifo(void) (task_low_state != LIFO_TEST_START), NULL); /* Give waiting threads time to time-out */ - k_sleep(NUM_SECONDS(2)); + k_sleep(K_SECONDS(2)); TC_PRINT("Testing lifos time-out in correct order ...\n"); zassert_false((task_low_state != LIFO_TEST_START + 1) || @@ -449,7 +449,7 @@ void test_pending_timer(void) zassert_equal(timer_end_tick, 0, "Task did not pend on timer"); /* Let the timer expire */ - k_sleep(NUM_SECONDS(2)); + k_sleep(K_SECONDS(2)); zassert_false((timer_end_tick < timer_start_tick + NUM_SECONDS(1)), "Task waiting on timer error"); @@ -474,7 +474,7 @@ void test_main(void) } K_THREAD_DEFINE(TASK_LOW, PREEM_STACKSIZE, task_low, NULL, NULL, NULL, - 7, 0, K_NO_WAIT); + 7, 0, 0); K_THREAD_DEFINE(TASK_HIGH, PREEM_STACKSIZE, task_high, NULL, NULL, NULL, - 5, 0, K_NO_WAIT); + 5, 0, 0); diff --git a/tests/kernel/pipe/pipe_api/src/test_pipe_contexts.c b/tests/kernel/pipe/pipe_api/src/test_pipe_contexts.c index b08bd9eca99..2a8c4de96cb 100644 --- a/tests/kernel/pipe/pipe_api/src/test_pipe_contexts.c +++ b/tests/kernel/pipe/pipe_api/src/test_pipe_contexts.c @@ -42,7 +42,7 @@ K_SEM_DEFINE(end_sema, 0, 1); #endif K_MEM_POOL_DEFINE(test_pool, SZ, SZ, 4, 4); -static void tpipe_put(struct k_pipe *ppipe, int timeout) +static void tpipe_put(struct k_pipe *ppipe, s32_t timeout) { size_t to_wt, wt_byte = 0; @@ -57,7 +57,7 @@ static void tpipe_put(struct k_pipe *ppipe, int timeout) } static void tpipe_block_put(struct k_pipe *ppipe, struct k_sem *sema, - int timeout) + s32_t timeout) { struct k_mem_block block; @@ -73,7 +73,7 @@ static void tpipe_block_put(struct k_pipe *ppipe, struct k_sem *sema, } } -static void tpipe_get(struct k_pipe *ppipe, int timeout) +static void tpipe_get(struct k_pipe *ppipe, s32_t timeout) { unsigned char rx_data[PIPE_LEN]; size_t to_rd, rd_byte = 0; @@ -318,9 +318,10 @@ void test_half_pipe_saturating_block_put(void) /**TESTPOINT: thread-thread data passing via pipe*/ k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE, tThread_half_pipe_block_put, &khalfpipe, - NULL, NULL, K_PRIO_PREEMPT(0), 0, 0); + NULL, NULL, K_PRIO_PREEMPT(0), 0, + K_NO_WAIT); - k_sleep(10); + k_msleep(10); /* Ensure half the mempool is still queued in the pipe */ r[0] = k_mem_pool_alloc(&mpool, &blocks[0], BYTES_TO_WRITE, K_NO_WAIT); diff --git a/tests/kernel/pipe/pipe_api/src/test_pipe_fail.c b/tests/kernel/pipe/pipe_api/src/test_pipe_fail.c index d441e0602d5..6fd9fe16969 100644 --- a/tests/kernel/pipe/pipe_api/src/test_pipe_fail.c +++ b/tests/kernel/pipe/pipe_api/src/test_pipe_fail.c @@ -7,7 +7,7 @@ #include -#define TIMEOUT 100 +#define TIMEOUT K_MSEC(100) #define PIPE_LEN 8 static ZTEST_DMEM unsigned char __aligned(4) data[] = "abcd1234"; diff --git a/tests/kernel/poll/src/test_poll.c b/tests/kernel/poll/src/test_poll.c index d57cf3fda64..1db299800bc 100644 --- a/tests/kernel/poll/src/test_poll.c +++ b/tests/kernel/poll/src/test_poll.c @@ -114,7 +114,7 @@ void test_poll_no_wait(void) zassert_equal(k_sem_take(&no_wait_sem, K_NO_WAIT), 0, ""); zassert_equal(events[1].state, K_POLL_STATE_FIFO_DATA_AVAILABLE, ""); - msg_ptr = k_fifo_get(&no_wait_fifo, 0); + msg_ptr = k_fifo_get(&no_wait_fifo, K_NO_WAIT); zassert_not_null(msg_ptr, ""); zassert_equal(msg_ptr, &msg, ""); zassert_equal(msg_ptr->msg, FIFO_MSG_VALUE, ""); @@ -141,7 +141,7 @@ void test_poll_no_wait(void) zassert_equal(events[3].state, K_POLL_STATE_NOT_READY, ""); zassert_not_equal(k_sem_take(&no_wait_sem, K_NO_WAIT), 0, ""); - zassert_is_null(k_fifo_get(&no_wait_fifo, 0), ""); + zassert_is_null(k_fifo_get(&no_wait_fifo, K_NO_WAIT), ""); } /* verify k_poll() that has to wait */ @@ -228,7 +228,7 @@ void test_poll_wait(void) zassert_equal(wait_events[1].state, K_POLL_STATE_FIFO_DATA_AVAILABLE, ""); - msg_ptr = k_fifo_get(&wait_fifo, 0); + msg_ptr = k_fifo_get(&wait_fifo, K_NO_WAIT); zassert_not_null(msg_ptr, ""); zassert_equal(msg_ptr, &wait_msg, ""); zassert_equal(msg_ptr->msg, FIFO_MSG_VALUE, ""); diff --git a/tests/kernel/profiling/profiling_api/src/main.c b/tests/kernel/profiling/profiling_api/src/main.c index 64c713262ed..0d36560394f 100644 --- a/tests/kernel/profiling/profiling_api/src/main.c +++ b/tests/kernel/profiling/profiling_api/src/main.c @@ -99,7 +99,7 @@ void test_call_stacks_analyze_main(void) void test_call_stacks_analyze_idle(void) { TC_PRINT("from idle thread:\n"); - k_sleep(SLEEP_MS); + k_msleep(SLEEP_MS); } /** diff --git a/tests/kernel/queue/src/test_queue_fail.c b/tests/kernel/queue/src/test_queue_fail.c index 2ec3e8b57f0..b5070426d16 100644 --- a/tests/kernel/queue/src/test_queue_fail.c +++ b/tests/kernel/queue/src/test_queue_fail.c @@ -6,7 +6,7 @@ #include "test_queue.h" -#define TIMEOUT 100 +#define TIMEOUT K_MSEC(100) /*test cases*/ /** diff --git a/tests/kernel/sched/metairq/src/main.c b/tests/kernel/sched/metairq/src/main.c index e5263ee8f1a..0e53cbd53c3 100644 --- a/tests/kernel/sched/metairq/src/main.c +++ b/tests/kernel/sched/metairq/src/main.c @@ -54,7 +54,7 @@ void metairq_thread(void) printk("give sem2\n"); k_sem_give(&coop_sem2); - k_sleep(WAIT_MS); + k_msleep(WAIT_MS); printk("give sem1\n"); k_sem_give(&coop_sem1); @@ -121,13 +121,13 @@ void coop_thread2(void) K_THREAD_DEFINE(metairq_thread_id, 1024, metairq_thread, 0, 0, 0, - K_PRIO_COOP(0), 0, K_NO_WAIT); + K_PRIO_COOP(0), 0, 0); K_THREAD_DEFINE(coop_thread1_id, 1024, coop_thread1, 0, 0, 0, - K_PRIO_COOP(1), 0, K_NO_WAIT); + K_PRIO_COOP(1), 0, 0); K_THREAD_DEFINE(coop_thread2_id, 1024, coop_thread2, 0, 0, 0, - K_PRIO_COOP(2), 0, K_NO_WAIT); + K_PRIO_COOP(2), 0, 0); void test_preempt(void) { diff --git a/tests/kernel/sched/schedule_api/src/test_sched_timeslice_and_lock.c b/tests/kernel/sched/schedule_api/src/test_sched_timeslice_and_lock.c index d1a01a35611..6a3c7a82c33 100644 --- a/tests/kernel/sched/schedule_api/src/test_sched_timeslice_and_lock.c +++ b/tests/kernel/sched/schedule_api/src/test_sched_timeslice_and_lock.c @@ -6,7 +6,7 @@ #include "test_sched.h" #define THREADS_NUM 3 -#define DURATION 1 +#define DURATION K_MSEC(1) BUILD_ASSERT(THREADS_NUM <= MAX_NUM_THREAD); @@ -25,7 +25,7 @@ static void thread_entry(void *p1, void *p2, void *p3) int sleep_ms = POINTER_TO_INT(p2); if (sleep_ms > 0) { - k_sleep(sleep_ms); + k_msleep(sleep_ms); } int tnum = POINTER_TO_INT(p1); diff --git a/tests/kernel/semaphore/semaphore/src/main.c b/tests/kernel/semaphore/semaphore/src/main.c index 29ef44ac804..b28f23ebee5 100644 --- a/tests/kernel/semaphore/semaphore/src/main.c +++ b/tests/kernel/semaphore/semaphore/src/main.c @@ -18,6 +18,8 @@ #define STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACKSIZE) #define TOTAL_THREADS_WAITING (5) +#define SEC2MS(s) ((s) * 1000) + struct timeout_info { u32_t timeout; struct k_sem *sema; @@ -682,9 +684,9 @@ void test_sem_measure_timeouts(void) zassert_true(ret_value == -EAGAIN, "k_sem_take failed"); - zassert_true((end_ticks - start_ticks >= K_SECONDS(1)), + zassert_true((end_ticks - start_ticks >= SEC2MS(1)), "time missmatch expected %d, got %d", - K_SECONDS(1), end_ticks - start_ticks); + SEC2MS(1), end_ticks - start_ticks); /* With 0 as the timeout */ start_ticks = k_uptime_get(); @@ -744,9 +746,9 @@ void test_sem_measure_timeout_from_thread(void) zassert_true(ret_value == 0, "k_sem_take failed"); - zassert_true((end_ticks - start_ticks <= K_SECONDS(1)), + zassert_true((end_ticks - start_ticks <= SEC2MS(1)), "time missmatch. expected less than%d ,got %d", - K_SECONDS(1), end_ticks - start_ticks); + SEC2MS(1), end_ticks - start_ticks); } @@ -758,7 +760,7 @@ void sem_multiple_take_and_timeouts_helper(void *p1, void *p2, void *p3) start_ticks = k_uptime_get(); - k_sem_take(&simple_sem, timeout); + k_sem_take(&simple_sem, K_MSEC(timeout)); end_ticks = k_uptime_get(); @@ -791,14 +793,14 @@ void test_sem_multiple_take_and_timeouts(void) k_thread_create(&multiple_tid[i], multiple_stack[i], STACK_SIZE, sem_multiple_take_and_timeouts_helper, - INT_TO_POINTER(K_SECONDS(i + 1)), NULL, NULL, + INT_TO_POINTER(SEC2MS(i + 1)), NULL, NULL, K_PRIO_PREEMPT(1), 0, K_NO_WAIT); } for (int i = 0; i < TOTAL_THREADS_WAITING; i++) { k_pipe_get(&timeout_info_pipe, &timeout, sizeof(int), &bytes_read, sizeof(int), K_FOREVER); - zassert_true(timeout == K_SECONDS(i + 1), + zassert_true(timeout == SEC2MS(i + 1), "timeout didn't occur properly"); } @@ -823,7 +825,7 @@ void sem_multi_take_timeout_diff_sem_helper(void *p1, void *p2, void *p3) start_ticks = k_uptime_get(); - ret_value = k_sem_take(sema, timeout); + ret_value = k_sem_take(sema, K_MSEC(timeout)); end_ticks = k_uptime_get(); @@ -846,11 +848,11 @@ void test_sem_multi_take_timeout_diff_sem(void) { size_t bytes_read; struct timeout_info seq_info[] = { - { K_SECONDS(2), &simple_sem }, - { K_SECONDS(1), &multiple_thread_sem }, - { K_SECONDS(3), &simple_sem }, - { K_SECONDS(5), &multiple_thread_sem }, - { K_SECONDS(4), &simple_sem }, + { SEC2MS(2), &simple_sem }, + { SEC2MS(1), &multiple_thread_sem }, + { SEC2MS(3), &simple_sem }, + { SEC2MS(5), &multiple_thread_sem }, + { SEC2MS(4), &simple_sem }, }; struct timeout_info retrieved_info; @@ -880,7 +882,7 @@ void test_sem_multi_take_timeout_diff_sem(void) K_FOREVER); - zassert_true(retrieved_info.timeout == K_SECONDS(i + 1), + zassert_true(retrieved_info.timeout == SEC2MS(i + 1), "timeout didn't occur properly"); } diff --git a/tests/kernel/sleep/src/main.c b/tests/kernel/sleep/src/main.c index 7651a74f77b..224c3f13212 100644 --- a/tests/kernel/sleep/src/main.c +++ b/tests/kernel/sleep/src/main.c @@ -113,7 +113,7 @@ static void test_thread(int arg1, int arg2) align_to_tick_boundary(); start_tick = k_uptime_get_32(); - k_sleep(ONE_SECOND); + k_sleep(K_SECONDS(1)); end_tick = k_uptime_get_32(); if (!sleep_time_valid(start_tick, end_tick, ONE_SECOND_ALIGNED)) { @@ -128,7 +128,7 @@ static void test_thread(int arg1, int arg2) align_to_tick_boundary(); start_tick = k_uptime_get_32(); - k_sleep(ONE_SECOND); + k_sleep(K_SECONDS(1)); end_tick = k_uptime_get_32(); if (end_tick - start_tick > TICK_MARGIN) { @@ -142,7 +142,7 @@ static void test_thread(int arg1, int arg2) align_to_tick_boundary(); start_tick = k_uptime_get_32(); - k_sleep(ONE_SECOND); + k_sleep(K_SECONDS(1)); end_tick = k_uptime_get_32(); if (end_tick - start_tick > TICK_MARGIN) { @@ -156,7 +156,7 @@ static void test_thread(int arg1, int arg2) align_to_tick_boundary(); start_tick = k_uptime_get_32(); - k_sleep(ONE_SECOND); /* Task will execute */ + k_sleep(K_SECONDS(1)); /* Task will execute */ end_tick = k_uptime_get_32(); if (end_tick - start_tick > TICK_MARGIN) { @@ -235,7 +235,7 @@ void test_sleep(void) TC_PRINT("Testing kernel k_sleep()\n"); align_to_tick_boundary(); start_tick = k_uptime_get_32(); - k_sleep(ONE_SECOND); + k_sleep(K_SECONDS(1)); end_tick = k_uptime_get_32(); zassert_true(sleep_time_valid(start_tick, end_tick, ONE_SECOND_ALIGNED), "k_sleep() slept for %d ticks, not %d\n", diff --git a/tests/kernel/smp/src/main.c b/tests/kernel/smp/src/main.c index 7d5dd87e529..4ea89722d6a 100644 --- a/tests/kernel/smp/src/main.c +++ b/tests/kernel/smp/src/main.c @@ -208,7 +208,8 @@ static void spawn_threads(int prio, int thread_num, tinfo[i].tid = k_thread_create(&tthread[i], tstack[i], STACK_SIZE, thread_entry, INT_TO_POINTER(i), NULL, NULL, - tinfo[i].priority, 0, delay); + tinfo[i].priority, 0, + K_MSEC(delay)); if (delay) { /* Increase delay for each thread */ delay = delay + 10; @@ -348,7 +349,7 @@ void test_sleep_threads(void) spawn_threads(K_PRIO_COOP(10), THREADS_NUM, !EQUAL_PRIORITY, &thread_entry, !THREAD_DELAY); - k_sleep(TIMEOUT); + k_msleep(TIMEOUT); for (int i = 0; i < THREADS_NUM; i++) { zassert_true(tinfo[i].executed == 1, @@ -367,7 +368,7 @@ static void thread_wakeup_entry(void *p1, void *p2, void *p3) thread_started[thread_num] = 1; - k_sleep(DELAY_US * 1000); + k_msleep(DELAY_US * 1000); tinfo[thread_num].executed = 1; } diff --git a/tests/kernel/stack/stack/src/test_stack_fail.c b/tests/kernel/stack/stack/src/test_stack_fail.c index b387fc04030..1915c552cb8 100644 --- a/tests/kernel/stack/stack/src/test_stack_fail.c +++ b/tests/kernel/stack/stack/src/test_stack_fail.c @@ -7,7 +7,7 @@ #include #include -#define TIMEOUT 100 +#define TIMEOUT K_MSEC(100) #define STACK_LEN 2 static ZTEST_BMEM stack_data_t data[STACK_LEN]; diff --git a/tests/kernel/threads/thread_apis/src/main.c b/tests/kernel/threads/thread_apis/src/main.c index dc7b69a03f1..f6977d71755 100644 --- a/tests/kernel/threads/thread_apis/src/main.c +++ b/tests/kernel/threads/thread_apis/src/main.c @@ -66,7 +66,7 @@ void test_systhreads_main(void) */ void test_systhreads_idle(void) { - k_sleep(K_MSEC(100)); + k_msleep(100); /** TESTPOINT: check working thread priority should */ zassert_true(k_thread_priority_get(k_current_get()) < K_IDLE_PRIO, NULL); @@ -80,7 +80,7 @@ static void customdata_entry(void *p1, void *p2, void *p3) while (1) { k_thread_custom_data_set((void *)data); /* relinguish cpu for a while */ - k_sleep(K_MSEC(50)); + k_msleep(50); /** TESTPOINT: custom data comparison */ zassert_equal(data, (long)k_thread_custom_data_get(), NULL); data++; @@ -99,7 +99,7 @@ void test_customdata_get_set_coop(void) customdata_entry, NULL, NULL, NULL, K_PRIO_COOP(1), 0, K_NO_WAIT); - k_sleep(K_MSEC(500)); + k_msleep(500); /* cleanup environment */ k_thread_abort(tid); @@ -227,7 +227,7 @@ void test_customdata_get_set_preempt(void) customdata_entry, NULL, NULL, NULL, K_PRIO_PREEMPT(0), K_USER, K_NO_WAIT); - k_sleep(K_MSEC(500)); + k_msleep(500); /* cleanup environment */ k_thread_abort(tid); @@ -324,7 +324,7 @@ void do_join_from_isr(void *arg) int join_scenario(enum control_method m) { - s32_t timeout = K_FOREVER; + k_timeout_t timeout = K_FOREVER; int ret; printk("ztest_thread: method %d, create join_thread\n", m); @@ -336,7 +336,7 @@ int join_scenario(enum control_method m) case ALREADY_EXIT: case ISR_ALREADY_EXIT: /* Let join_thread run first */ - k_sleep(50); + k_msleep(50); break; case OTHER_ABORT: printk("ztest_thread: create control_thread\n"); @@ -346,7 +346,7 @@ int join_scenario(enum control_method m) K_USER | K_INHERIT_PERMS, K_NO_WAIT); break; case TIMEOUT: - timeout = 50; + timeout = K_MSEC(50); break; case NO_WAIT: timeout = K_NO_WAIT; @@ -402,7 +402,7 @@ void deadlock1_entry(void *p1, void *p2, void *p3) { int ret; - k_sleep(500); + k_msleep(500); ret = k_thread_join(&deadlock2_thread, K_FOREVER); zassert_equal(ret, -EDEADLK, "failed mutual join case"); diff --git a/tests/kernel/threads/thread_apis/src/test_kthread_for_each.c b/tests/kernel/threads/thread_apis/src/test_kthread_for_each.c index a804b8d499d..33931e57663 100644 --- a/tests/kernel/threads/thread_apis/src/test_kthread_for_each.c +++ b/tests/kernel/threads/thread_apis/src/test_kthread_for_each.c @@ -18,7 +18,7 @@ static bool thread_flag; static void thread_entry(void *p1, void *p2, void *p3) { - k_sleep(SLEEP_MS); + k_msleep(SLEEP_MS); } static void thread_callback(const struct k_thread *thread, void *user_data) @@ -63,7 +63,7 @@ void test_k_thread_foreach(void) k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE, (k_thread_entry_t)thread_entry, NULL, NULL, NULL, K_PRIO_PREEMPT(0), 0, K_NO_WAIT); - k_sleep(K_MSEC(1)); + k_msleep(1); /* Call k_thread_foreach() and check * thread_callback is getting called for diff --git a/tests/kernel/threads/thread_apis/src/test_threads_cancel_abort.c b/tests/kernel/threads/thread_apis/src/test_threads_cancel_abort.c index 18ecaa13ef0..106d0be6214 100644 --- a/tests/kernel/threads/thread_apis/src/test_threads_cancel_abort.c +++ b/tests/kernel/threads/thread_apis/src/test_threads_cancel_abort.c @@ -16,7 +16,7 @@ K_SEM_DEFINE(sync_sema, 0, 1); static void thread_entry(void *p1, void *p2, void *p3) { execute_flag = 1; - k_sleep(K_MSEC(100)); + k_msleep(100); execute_flag = 2; } @@ -44,7 +44,7 @@ void test_threads_abort_self(void) execute_flag = 0; k_thread_create(&tdata, tstack, STACK_SIZE, thread_entry_abort, NULL, NULL, NULL, 0, K_USER, K_NO_WAIT); - k_sleep(K_MSEC(100)); + k_msleep(100); /**TESTPOINT: spawned thread executed but abort itself*/ zassert_true(execute_flag == 1, NULL); } @@ -67,18 +67,18 @@ void test_threads_abort_others(void) 0, K_USER, K_NO_WAIT); k_thread_abort(tid); - k_sleep(K_MSEC(100)); + k_msleep(100); /**TESTPOINT: check not-started thread is aborted*/ zassert_true(execute_flag == 0, NULL); tid = k_thread_create(&tdata, tstack, STACK_SIZE, thread_entry, NULL, NULL, NULL, 0, K_USER, K_NO_WAIT); - k_sleep(K_MSEC(50)); + k_msleep(50); k_thread_abort(tid); /**TESTPOINT: check running thread is aborted*/ zassert_true(execute_flag == 1, NULL); - k_sleep(K_MSEC(1000)); + k_msleep(1000); zassert_true(execute_flag == 1, NULL); } @@ -96,9 +96,9 @@ void test_threads_abort_repeat(void) 0, K_USER, K_NO_WAIT); k_thread_abort(tid); - k_sleep(K_MSEC(100)); + k_msleep(100); k_thread_abort(tid); - k_sleep(K_MSEC(100)); + k_msleep(100); k_thread_abort(tid); /* If no fault occurred till now. The test case passed. */ ztest_test_pass(); @@ -119,7 +119,7 @@ static void uthread_entry(void) block = k_malloc(BLOCK_SIZE); zassert_true(block != NULL, NULL); printk("Child thread is running\n"); - k_sleep(K_MSEC(2)); + k_msleep(2); } /** @@ -137,7 +137,7 @@ void test_abort_handler(void) tdata.fn_abort = &abort_function; - k_sleep(K_MSEC(1)); + k_msleep(1); abort_called = false; @@ -177,7 +177,7 @@ void test_delayed_thread_abort(void) K_PRIO_PREEMPT(1), 0, K_MSEC(100)); /* Give up CPU */ - k_sleep(K_MSEC(50)); + k_msleep(50); /* Test point: check if thread delayed for 100ms has not started*/ zassert_true(execute_flag == 0, "Delayed thread created is not" diff --git a/tests/kernel/threads/thread_apis/src/test_threads_spawn.c b/tests/kernel/threads/thread_apis/src/test_threads_spawn.c index 8d715534dd3..8c51ff4855d 100644 --- a/tests/kernel/threads/thread_apis/src/test_threads_spawn.c +++ b/tests/kernel/threads/thread_apis/src/test_threads_spawn.c @@ -50,7 +50,7 @@ void test_threads_spawn_params(void) k_thread_create(&tdata, tstack, STACK_SIZE, thread_entry_params, tp1, INT_TO_POINTER(tp2), tp3, 0, K_USER, K_NO_WAIT); - k_sleep(K_MSEC(100)); + k_msleep(100); } /** @@ -68,7 +68,7 @@ void test_threads_spawn_priority(void) spawn_prio = k_thread_priority_get(k_current_get()) - 1; k_thread_create(&tdata, tstack, STACK_SIZE, thread_entry_priority, NULL, NULL, NULL, spawn_prio, K_USER, K_NO_WAIT); - k_sleep(K_MSEC(100)); + k_msleep(100); } /** @@ -87,11 +87,11 @@ void test_threads_spawn_delay(void) k_thread_create(&tdata, tstack, STACK_SIZE, thread_entry_delay, NULL, NULL, NULL, 0, K_USER, K_MSEC(120)); /* 100 < 120 ensure spawn thread not start */ - k_sleep(K_MSEC(100)); + k_msleep(100); /* checkpoint: check spawn thread not execute */ zassert_true(tp2 == 10, NULL); /* checkpoint: check spawn thread executed */ - k_sleep(K_MSEC(100)); + k_msleep(100); zassert_true(tp2 == 100, NULL); } diff --git a/tests/kernel/threads/thread_apis/src/test_threads_suspend_resume.c b/tests/kernel/threads/thread_apis/src/test_threads_suspend_resume.c index 5a52fb6c785..cd0564f51ac 100644 --- a/tests/kernel/threads/thread_apis/src/test_threads_suspend_resume.c +++ b/tests/kernel/threads/thread_apis/src/test_threads_suspend_resume.c @@ -29,11 +29,11 @@ static void threads_suspend_resume(int prio) create_prio, K_USER, K_NO_WAIT); /* checkpoint: suspend current thread */ k_thread_suspend(tid); - k_sleep(K_MSEC(100)); + k_msleep(100); /* checkpoint: created thread shouldn't be executed after suspend */ zassert_false(last_prio == create_prio, NULL); k_thread_resume(tid); - k_sleep(K_MSEC(100)); + k_msleep(100); /* checkpoint: created thread should be executed after resume */ zassert_true(last_prio == create_prio, NULL); } @@ -100,7 +100,7 @@ void test_threads_suspend(void) /* Give the thread a chance to start and verify that it * stopped executing after suspending itself. */ - k_sleep(K_MSEC(100)); + k_msleep(100); zassert_false(after_suspend, "thread woke up unexpectedly"); k_thread_abort(tid); @@ -115,7 +115,7 @@ void sleep_suspended(void *arg0, void *arg1, void *arg2) /* Sleep a half second, then set the flag after we wake up. * If we are suspended, the wakeup should not occur */ - k_sleep(K_MSEC(100)); + k_msleep(100); after_suspend = true; } @@ -134,14 +134,14 @@ void test_threads_suspend_timeout(void) sleep_suspended, NULL, NULL, NULL, 0, K_USER, K_NO_WAIT); - k_sleep(K_MSEC(50)); + k_msleep(50); k_thread_suspend(tid); /* Give the timer long enough to expire, and verify that it * has not (i.e. that the thread didn't wake up, because it * has been suspended) */ - k_sleep(K_MSEC(200)); + k_msleep(200); zassert_false(after_suspend, "thread woke up unexpectedly"); k_thread_abort(tid); diff --git a/tests/kernel/threads/thread_init/src/main.c b/tests/kernel/threads/thread_init/src/main.c index 75184d8c65f..c881b5b447c 100644 --- a/tests/kernel/threads/thread_init/src/main.c +++ b/tests/kernel/threads/thread_init/src/main.c @@ -20,7 +20,7 @@ #define INIT_PREEMPT_P2 ((void *)6) #define INIT_PREEMPT_P3 ((void *)7) #define INIT_PREEMPT_OPTION (K_USER | K_INHERIT_PERMS) -#define INIT_PREEMPT_DELAY K_NO_WAIT +#define INIT_PREEMPT_DELAY 0 static void thread_entry(void *p1, void *p2, void *p3); @@ -144,7 +144,8 @@ void test_kinit_preempt_thread(void) k_tid_t pthread = k_thread_create(&thread_preempt, stack_preempt, INIT_PREEMPT_STACK_SIZE, thread_entry, INIT_PREEMPT_P1, INIT_PREEMPT_P2, INIT_PREEMPT_P3, INIT_PREEMPT_PRIO, - INIT_PREEMPT_OPTION, INIT_PREEMPT_DELAY); + INIT_PREEMPT_OPTION, + K_MSEC(INIT_PREEMPT_DELAY)); /*record time stamp of thread creation*/ t_create = k_uptime_get(); @@ -175,9 +176,9 @@ void test_kinit_coop_thread(void) { /*create coop thread*/ k_tid_t pthread = k_thread_create(&thread_coop, stack_coop, - INIT_COOP_STACK_SIZE, thread_entry, INIT_COOP_P1, - INIT_COOP_P2, INIT_COOP_P3, INIT_COOP_PRIO, - INIT_COOP_OPTION, INIT_COOP_DELAY); + INIT_COOP_STACK_SIZE, thread_entry, INIT_COOP_P1, + INIT_COOP_P2, INIT_COOP_P3, INIT_COOP_PRIO, + INIT_COOP_OPTION, K_MSEC(INIT_COOP_DELAY)); /*record time stamp of thread creation*/ t_create = k_uptime_get(); diff --git a/tests/kernel/tickless/tickless/src/main.c b/tests/kernel/tickless/tickless/src/main.c index 473585e8246..4f024aa8e4f 100644 --- a/tests/kernel/tickless/tickless/src/main.c +++ b/tests/kernel/tickless/tickless/src/main.c @@ -120,13 +120,13 @@ void ticklessTestThread(void) * Do a single tick sleep to get us as close to a tick boundary * as we can. */ - k_sleep(TICKS_TO_MS); + k_msleep(TICKS_TO_MS); start_time = k_uptime_get_32(); start_tsc = _TIMESTAMP_READ(); /* FIXME: one tick less to account for * one extra tick for _TICK_ALIGN in k_sleep */ - k_sleep((SLEEP_TICKS - 1) * TICKS_TO_MS); + k_msleep((SLEEP_TICKS - 1) * TICKS_TO_MS); end_tsc = _TIMESTAMP_READ(); end_time = k_uptime_get_32(); cal_tsc += end_tsc - start_tsc; @@ -155,13 +155,13 @@ void ticklessTestThread(void) * Do a single tick sleep to get us as close to a tick boundary * as we can. */ - k_sleep(TICKS_TO_MS); + k_msleep(TICKS_TO_MS); start_time = k_uptime_get_32(); start_tsc = _TIMESTAMP_READ(); /* FIXME: one tick less to account for * one extra tick for _TICK_ALIGN in k_sleep */ - k_sleep((SLEEP_TICKS - 1) * TICKS_TO_MS); + k_msleep((SLEEP_TICKS - 1) * TICKS_TO_MS); end_tsc = _TIMESTAMP_READ(); end_time = k_uptime_get_32(); diff_tsc += end_tsc - start_tsc; diff --git a/tests/kernel/tickless/tickless/src/timestamps.c b/tests/kernel/tickless/tickless/src/timestamps.c index db1509a6530..25871645171 100644 --- a/tests/kernel/tickless/tickless/src/timestamps.c +++ b/tests/kernel/tickless/tickless/src/timestamps.c @@ -186,7 +186,7 @@ void _timestamp_open(void) _TIMESTAMP_IMASK = 0x0; /* mask all timer interrupts */ /* minimum 0.3 sec delay required for oscillator stabilization */ - k_sleep(0.3 * MSEC_PER_SEC); + k_msleep(0.3 * MSEC_PER_SEC); /* clear invalid time flag in status register */ _TIMESTAMP_VAL = 0x0; diff --git a/tests/kernel/tickless/tickless_concept/src/main.c b/tests/kernel/tickless/tickless_concept/src/main.c index c0137ea213a..91df2f49dd5 100644 --- a/tests/kernel/tickless/tickless_concept/src/main.c +++ b/tests/kernel/tickless/tickless_concept/src/main.c @@ -79,7 +79,7 @@ void test_tickless_sysclock(void) ALIGN_MS_BOUNDARY(); t0 = k_uptime_get_32(); - k_sleep(SLEEP_TICKLESS); + k_msleep(SLEEP_TICKLESS); t1 = k_uptime_get_32(); TC_PRINT("time %d, %d\n", t0, t1); /**TESTPOINT: verify system clock recovery after exiting tickless idle*/ @@ -87,7 +87,7 @@ void test_tickless_sysclock(void) ALIGN_MS_BOUNDARY(); t0 = k_uptime_get_32(); - k_sem_take(&sema, SLEEP_TICKFUL); + k_sem_take(&sema, K_MSEC(SLEEP_TICKFUL)); t1 = k_uptime_get_32(); TC_PRINT("time %d, %d\n", t0, t1); /**TESTPOINT: verify system clock recovery after exiting tickful idle*/ @@ -112,7 +112,8 @@ void test_tickless_slice(void) for (int i = 0; i < NUM_THREAD; i++) { tid[i] = k_thread_create(&tdata[i], tstack[i], STACK_SIZE, thread_tslice, NULL, NULL, NULL, - K_PRIO_PREEMPT(0), 0, SLICE_SIZE); + K_PRIO_PREEMPT(0), 0, + K_MSEC(SLICE_SIZE)); } k_uptime_delta(&elapsed_slice); /*relinquish CPU and wait for each thread to complete*/ diff --git a/tests/kernel/timer/timer_api/src/main.c b/tests/kernel/timer/timer_api/src/main.c index 8f7f2ce393c..8a2dea5a617 100644 --- a/tests/kernel/timer/timer_api/src/main.c +++ b/tests/kernel/timer/timer_api/src/main.c @@ -131,7 +131,7 @@ void test_timer_duration_period(void) { init_timer_data(); /** TESTPOINT: init timer via k_timer_init */ - k_timer_start(&duration_timer, DURATION, PERIOD); + k_timer_start(&duration_timer, K_MSEC(DURATION), K_MSEC(PERIOD)); tdata.timestamp = k_uptime_get(); busy_wait_ms(DURATION + PERIOD * EXPIRE_TIMES + PERIOD / 2); /** TESTPOINT: check expire and stop times */ @@ -161,7 +161,7 @@ void test_timer_period_0(void) { init_timer_data(); /** TESTPOINT: set period 0 */ - k_timer_start(&period0_timer, DURATION, K_NO_WAIT); + k_timer_start(&period0_timer, K_MSEC(DURATION), K_NO_WAIT); tdata.timestamp = k_uptime_get(); busy_wait_ms(DURATION + 1); @@ -192,7 +192,7 @@ void test_timer_expirefn_null(void) { init_timer_data(); /** TESTPOINT: expire function NULL */ - k_timer_start(&expire_timer, DURATION, PERIOD); + k_timer_start(&expire_timer, K_MSEC(DURATION), K_MSEC(PERIOD)); busy_wait_ms(DURATION + PERIOD * EXPIRE_TIMES + PERIOD / 2); k_timer_stop(&expire_timer); @@ -244,7 +244,7 @@ void test_timer_periodicity(void) init_timer_data(); /** TESTPOINT: set duration 0 */ - k_timer_start(&periodicity_timer, K_NO_WAIT, PERIOD); + k_timer_start(&periodicity_timer, K_NO_WAIT, K_MSEC(PERIOD)); /* clear the expiration that would have happened due to * whatever duration that was set. Since timer is likely @@ -298,7 +298,7 @@ void test_timer_periodicity(void) void test_timer_status_get(void) { init_timer_data(); - k_timer_start(&status_timer, DURATION, PERIOD); + k_timer_start(&status_timer, K_MSEC(DURATION), K_MSEC(PERIOD)); /** TESTPOINT: status get upon timer starts */ TIMER_ASSERT(k_timer_status_get(&status_timer) == 0, &status_timer); /** TESTPOINT: remaining get upon timer starts */ @@ -327,7 +327,8 @@ void test_timer_status_get(void) void test_timer_status_get_anytime(void) { init_timer_data(); - k_timer_start(&status_anytime_timer, DURATION, PERIOD); + k_timer_start(&status_anytime_timer, K_MSEC(DURATION), + K_MSEC(PERIOD)); busy_wait_ms(DURATION + PERIOD * (EXPIRE_TIMES - 1) + PERIOD / 2); /** TESTPOINT: status get at any time */ @@ -357,7 +358,7 @@ void test_timer_status_get_anytime(void) void test_timer_status_sync(void) { init_timer_data(); - k_timer_start(&status_sync_timer, DURATION, PERIOD); + k_timer_start(&status_sync_timer, K_MSEC(DURATION), K_MSEC(PERIOD)); for (int i = 0; i < EXPIRE_TIMES; i++) { /** TESTPOINT: check timer not expire */ @@ -392,7 +393,7 @@ void test_timer_k_define(void) { init_timer_data(); /** TESTPOINT: init timer via k_timer_init */ - k_timer_start(&ktimer, DURATION, PERIOD); + k_timer_start(&ktimer, K_MSEC(DURATION), K_MSEC(PERIOD)); tdata.timestamp = k_uptime_get(); busy_wait_ms(DURATION + PERIOD * EXPIRE_TIMES + PERIOD / 2); @@ -405,14 +406,14 @@ void test_timer_k_define(void) init_timer_data(); /** TESTPOINT: init timer via k_timer_init */ - k_timer_start(&ktimer, DURATION, PERIOD); + k_timer_start(&ktimer, K_MSEC(DURATION), K_MSEC(PERIOD)); /* Call the k_timer_start() again to make sure that * the initial timeout request gets cancelled and new * one will get added. */ busy_wait_ms(DURATION / 2); - k_timer_start(&ktimer, DURATION, PERIOD); + k_timer_start(&ktimer, K_MSEC(DURATION), K_MSEC(PERIOD)); tdata.timestamp = k_uptime_get(); busy_wait_ms(DURATION + PERIOD * EXPIRE_TIMES + PERIOD / 2); @@ -487,10 +488,11 @@ void test_timer_user_data(void) } for (ii = 0; ii < 5; ii++) { - k_timer_start(user_data_timer[ii], 50 + ii * 50, K_NO_WAIT); + k_timer_start(user_data_timer[ii], K_MSEC(50 + ii * 50), + K_NO_WAIT); } - k_sleep(50 * ii + 50); + k_msleep(50 * ii + 50); for (ii = 0; ii < 5; ii++) { k_timer_stop(user_data_timer[ii]); @@ -521,7 +523,7 @@ void test_timer_remaining_get(void) u32_t remaining; init_timer_data(); - k_timer_start(&remain_timer, DURATION, K_NO_WAIT); + k_timer_start(&remain_timer, K_MSEC(DURATION), K_NO_WAIT); busy_wait_ms(DURATION / 2); remaining = k_timer_remaining_get(&remain_timer); k_timer_stop(&remain_timer); diff --git a/tests/kernel/workq/work_queue/src/main.c b/tests/kernel/workq/work_queue/src/main.c index af2cf59cc7d..74705ccd7ce 100644 --- a/tests/kernel/workq/work_queue/src/main.c +++ b/tests/kernel/workq/work_queue/src/main.c @@ -60,7 +60,7 @@ static void work_handler(struct k_work *work) CONTAINER_OF(work, struct delayed_test_item, work); TC_PRINT(" - Running test item %d\n", ti->key); - k_sleep(WORK_ITEM_WAIT); + k_msleep(WORK_ITEM_WAIT); results[num_results++] = ti->key; } @@ -98,12 +98,12 @@ static void coop_work_main(int arg1, int arg2) ARG_UNUSED(arg2); /* Let the preempt thread submit the first work item. */ - k_sleep(SUBMIT_WAIT / 2); + k_msleep(SUBMIT_WAIT / 2); for (i = 1; i < NUM_TEST_ITEMS; i += 2) { TC_PRINT(" - Submitting work %d from coop thread\n", i + 1); k_work_submit(&delayed_tests[i].work.work); - k_sleep(SUBMIT_WAIT); + k_msleep(SUBMIT_WAIT); } } @@ -122,7 +122,7 @@ static void delayed_test_items_submit(void) for (i = 0; i < NUM_TEST_ITEMS; i += 2) { TC_PRINT(" - Submitting work %d from preempt thread\n", i + 1); k_work_submit(&delayed_tests[i].work.work); - k_sleep(SUBMIT_WAIT); + k_msleep(SUBMIT_WAIT); } } @@ -159,7 +159,7 @@ static void test_sequence(void) delayed_test_items_submit(); TC_PRINT(" - Waiting for work to finish\n"); - k_sleep(CHECK_WAIT); + k_msleep(CHECK_WAIT); check_results(NUM_TEST_ITEMS); reset_results(); @@ -172,7 +172,7 @@ static void resubmit_work_handler(struct k_work *work) struct delayed_test_item *ti = CONTAINER_OF(work, struct delayed_test_item, work); - k_sleep(WORK_ITEM_WAIT); + k_msleep(WORK_ITEM_WAIT); results[num_results++] = ti->key; @@ -200,7 +200,7 @@ static void test_resubmit(void) k_work_submit(&delayed_tests[0].work.work); TC_PRINT(" - Waiting for work to finish\n"); - k_sleep(CHECK_WAIT); + k_msleep(CHECK_WAIT); TC_PRINT(" - Checking results\n"); check_results(NUM_TEST_ITEMS); @@ -243,13 +243,13 @@ static void coop_delayed_work_main(int arg1, int arg2) ARG_UNUSED(arg2); /* Let the preempt thread submit the first work item. */ - k_sleep(SUBMIT_WAIT / 2); + k_msleep(SUBMIT_WAIT / 2); for (i = 1; i < NUM_TEST_ITEMS; i += 2) { TC_PRINT(" - Submitting delayed work %d from" " coop thread\n", i + 1); k_delayed_work_submit(&delayed_tests[i].work, - (i + 1) * WORK_ITEM_WAIT); + K_MSEC((i + 1) * WORK_ITEM_WAIT)); } } @@ -272,7 +272,7 @@ static void test_delayed_submit(void) TC_PRINT(" - Submitting delayed work %d from" " preempt thread\n", i + 1); zassert_true(k_delayed_work_submit(&delayed_tests[i].work, - (i + 1) * WORK_ITEM_WAIT) == 0, NULL); + K_MSEC((i + 1) * WORK_ITEM_WAIT)) == 0, NULL); } } @@ -282,7 +282,7 @@ static void coop_delayed_work_cancel_main(int arg1, int arg2) ARG_UNUSED(arg1); ARG_UNUSED(arg2); - k_delayed_work_submit(&delayed_tests[1].work, WORK_ITEM_WAIT); + k_delayed_work_submit(&delayed_tests[1].work, K_MSEC(WORK_ITEM_WAIT)); TC_PRINT(" - Cancel delayed work from coop thread\n"); k_delayed_work_cancel(&delayed_tests[1].work); @@ -308,7 +308,7 @@ static void test_delayed_cancel(void) { TC_PRINT("Starting delayed cancel test\n"); - k_delayed_work_submit(&delayed_tests[0].work, WORK_ITEM_WAIT); + k_delayed_work_submit(&delayed_tests[0].work, K_MSEC(WORK_ITEM_WAIT)); TC_PRINT(" - Cancel delayed work from preempt thread\n"); k_delayed_work_cancel(&delayed_tests[0].work); @@ -318,7 +318,7 @@ static void test_delayed_cancel(void) NULL, NULL, NULL, K_HIGHEST_THREAD_PRIO, 0, K_NO_WAIT); TC_PRINT(" - Waiting for work to finish\n"); - k_sleep(WORK_ITEM_WAIT_ALIGNED); + k_msleep(WORK_ITEM_WAIT_ALIGNED); TC_PRINT(" - Checking results\n"); check_results(0); @@ -334,7 +334,7 @@ static void delayed_resubmit_work_handler(struct k_work *work) if (ti->key < NUM_TEST_ITEMS) { ti->key++; TC_PRINT(" - Resubmitting delayed work\n"); - k_delayed_work_submit(&ti->work, WORK_ITEM_WAIT); + k_delayed_work_submit(&ti->work, K_MSEC(WORK_ITEM_WAIT)); } } @@ -354,10 +354,10 @@ static void test_delayed_resubmit(void) delayed_resubmit_work_handler); TC_PRINT(" - Submitting delayed work\n"); - k_delayed_work_submit(&delayed_tests[0].work, WORK_ITEM_WAIT); + k_delayed_work_submit(&delayed_tests[0].work, K_MSEC(WORK_ITEM_WAIT)); TC_PRINT(" - Waiting for work to finish\n"); - k_sleep(CHECK_WAIT); + k_msleep(CHECK_WAIT); TC_PRINT(" - Checking results\n"); check_results(NUM_TEST_ITEMS); @@ -404,7 +404,7 @@ static void test_delayed_resubmit_thread(void) NULL, NULL, NULL, K_PRIO_COOP(10), 0, K_NO_WAIT); TC_PRINT(" - Waiting for work to finish\n"); - k_sleep(WORK_ITEM_WAIT_ALIGNED); + k_msleep(WORK_ITEM_WAIT_ALIGNED); TC_PRINT(" - Checking results\n"); check_results(1); @@ -429,7 +429,7 @@ static void test_delayed(void) test_delayed_submit(); TC_PRINT(" - Waiting for delayed work to finish\n"); - k_sleep(CHECK_WAIT); + k_msleep(CHECK_WAIT); TC_PRINT(" - Checking results\n"); check_results(NUM_TEST_ITEMS); @@ -532,7 +532,7 @@ static void test_triggered(void) test_triggered_trigger(); /* Items should be executed when we will be sleeping. */ - k_sleep(WORK_ITEM_WAIT); + k_msleep(WORK_ITEM_WAIT); TC_PRINT(" - Checking results\n"); check_results(NUM_TEST_ITEMS); @@ -563,7 +563,7 @@ static void test_already_triggered(void) test_triggered_submit(K_FOREVER); /* Items should be executed when we will be sleeping. */ - k_sleep(WORK_ITEM_WAIT); + k_msleep(WORK_ITEM_WAIT); TC_PRINT(" - Checking results\n"); check_results(NUM_TEST_ITEMS); @@ -624,7 +624,7 @@ static void test_triggered_resubmit(void) i + 1); zassert_true(k_poll_signal_raise(&triggered_tests[0].signal, 1) == 0, NULL); - k_sleep(WORK_ITEM_WAIT); + k_msleep(WORK_ITEM_WAIT); } TC_PRINT(" - Checking results\n"); @@ -656,7 +656,7 @@ static void test_triggered_no_wait(void) test_triggered_submit(K_NO_WAIT); /* Items should be executed when we will be sleeping. */ - k_sleep(WORK_ITEM_WAIT); + k_msleep(WORK_ITEM_WAIT); TC_PRINT(" - Checking results\n"); check_results(NUM_TEST_ITEMS); @@ -684,7 +684,7 @@ static void test_triggered_no_wait_expired(void) test_triggered_submit(K_NO_WAIT); /* Items should be executed when we will be sleeping. */ - k_sleep(WORK_ITEM_WAIT); + k_msleep(WORK_ITEM_WAIT); TC_PRINT(" - Checking results\n"); check_results(NUM_TEST_ITEMS); @@ -712,10 +712,10 @@ static void test_triggered_wait(void) test_triggered_trigger(); TC_PRINT(" - Submitting triggered test items\n"); - test_triggered_submit(2 * SUBMIT_WAIT); + test_triggered_submit(K_MSEC(2 * SUBMIT_WAIT)); /* Items should be executed when we will be sleeping. */ - k_sleep(SUBMIT_WAIT); + k_msleep(SUBMIT_WAIT); TC_PRINT(" - Checking results\n"); check_results(NUM_TEST_ITEMS); @@ -740,15 +740,15 @@ static void test_triggered_wait_expired(void) test_triggered_init(); TC_PRINT(" - Submitting triggered test items\n"); - test_triggered_submit(2 * SUBMIT_WAIT); + test_triggered_submit(K_MSEC(2 * SUBMIT_WAIT)); /* Items should not be executed when we will be sleeping here. */ - k_sleep(SUBMIT_WAIT); + k_msleep(SUBMIT_WAIT); TC_PRINT(" - Checking results (before timeout)\n"); check_results(0); /* Items should be executed when we will be sleeping here. */ - k_sleep(SUBMIT_WAIT); + k_msleep(SUBMIT_WAIT); TC_PRINT(" - Checking results (after timeout)\n"); check_results(NUM_TEST_ITEMS); diff --git a/tests/kernel/workq/work_queue_api/src/main.c b/tests/kernel/workq/work_queue_api/src/main.c index 4f3b623b41d..cf608972820 100644 --- a/tests/kernel/workq/work_queue_api/src/main.c +++ b/tests/kernel/workq/work_queue_api/src/main.c @@ -15,7 +15,8 @@ #include #include -#define TIMEOUT 100 +#define TIMEOUT_MS 100 +#define TIMEOUT K_MSEC(TIMEOUT_MS) #define STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACKSIZE) #define NUM_OF_WORK 2 @@ -119,9 +120,6 @@ static void twork_resubmit(void *data) k_sem_give(&sync_sema); } -#define TIMEOUT_MS(_timeout) \ - k_ticks_to_ms_floor64(_timeout) - static void tdelayed_work_submit_1(struct k_work_q *work_q, struct k_delayed_work *w, k_work_handler_t handler) @@ -146,7 +144,7 @@ static void tdelayed_work_submit_1(struct k_work_q *work_q, } time_remaining = k_delayed_work_remaining_get(w); - timeout_ticks = z_ms_to_ticks(TIMEOUT); + timeout_ticks = z_ms_to_ticks(TIMEOUT_MS); /**TESTPOINT: check remaining timeout after submit */ zassert_true(time_remaining <= k_ticks_to_ms_floor64(timeout_ticks + @@ -344,7 +342,7 @@ static void ttriggered_work_cancel(void *data) if (!k_is_in_isr()) { /*wait for completed work_sleepy and triggered_work[1]*/ - k_sleep(2 * TIMEOUT); + k_msleep(2 * TIMEOUT_MS); /**TESTPOINT: check pending when work completed*/ ret = k_work_pending((struct k_work *)&triggered_work_sleepy); diff --git a/tests/misc/test_build/src/main.c b/tests/misc/test_build/src/main.c index 1d28987b92e..7a0e11e8e7f 100644 --- a/tests/misc/test_build/src/main.c +++ b/tests/misc/test_build/src/main.c @@ -43,7 +43,7 @@ void helloLoop(const char *my_name, printk("%s: Hello World from %s!\n", my_name, CONFIG_ARCH); /* wait a while, then let other thread have a turn */ - k_sleep(SLEEPTIME); + k_msleep(SLEEPTIME); k_sem_give(other_sem); } } @@ -87,4 +87,4 @@ void threadA(void *dummy1, void *dummy2, void *dummy3) } K_THREAD_DEFINE(threadA_id, STACKSIZE, threadA, NULL, NULL, NULL, - PRIORITY, 0, K_NO_WAIT); + PRIORITY, 0, 0); diff --git a/tests/subsys/logging/log_immediate/src/log_immediate_test.c b/tests/subsys/logging/log_immediate/src/log_immediate_test.c index 66ec5aedb03..3243b934869 100644 --- a/tests/subsys/logging/log_immediate/src/log_immediate_test.c +++ b/tests/subsys/logging/log_immediate/src/log_immediate_test.c @@ -44,7 +44,7 @@ static void thread_func(void *p1, void *p2, void *p3) while (1) { LOG_INF("test string printed %d %d %p", 1, 2, k_current_get()); LOG_HEXDUMP_INF(buf, buf_len, "data:"); - k_sleep(20+id); + k_msleep(20+id); } } @@ -62,7 +62,7 @@ static void test_log_immediate_preemption(void) k_thread_priority_get(k_current_get()) + i, 0, K_MSEC(10)); } - k_sleep(3000); + k_msleep(3000); for (int i = 0; i < NUM_THREADS; i++) { k_thread_abort(tids[i]); diff --git a/tests/subsys/tracing/src/main.c b/tests/subsys/tracing/src/main.c index b77680db278..66dc34a142a 100644 --- a/tests/subsys/tracing/src/main.c +++ b/tests/subsys/tracing/src/main.c @@ -51,7 +51,7 @@ void helloLoop(const char *my_name, } /* wait a while, then let other thread have a turn */ - k_sleep(SLEEPTIME); + k_msleep(SLEEPTIME); k_sem_give(other_sem); } } @@ -97,4 +97,4 @@ void threadA(void *dummy1, void *dummy2, void *dummy3) } K_THREAD_DEFINE(thread_a, STACKSIZE, threadA, NULL, NULL, NULL, - PRIORITY, 0, K_NO_WAIT); + PRIORITY, 0, 0);