timeout: Fix up API usage

Kernel timeouts have always been a 32 bit integer despite the
existence of generation macros, and existing code has been
inconsistent about using them.  Upcoming commits are going to make the
timeout arguments opaque, so fix things up to be rigorously correct.
Changes include:

+ Adding a K_TIMEOUT_EQ() macro for code that needs to compare timeout
  values for equality (e.g. with K_FOREVER or K_NO_WAIT).

+ Adding a k_msleep() synonym for k_sleep() which can continue to take
  integral arguments as k_sleep() moves away to timeout arguments.

+ Pervasively using the K_MSEC(), K_SECONDS(), et. al. macros to
  generate timeout arguments.

+ Removing the usage of K_NO_WAIT as the final argument to
  K_THREAD_DEFINE().  This is just a count of milliseconds and we need
  to use a zero.

This patch include no logic changes and should not affect generated
code at all.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2020-03-05 14:54:28 -08:00 committed by Anas Nashif
parent 99a8155914
commit 32bb2395c2
125 changed files with 363 additions and 341 deletions

View file

@ -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)

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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;
}

View file

@ -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

View file

@ -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;
}

View file

@ -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,

View file

@ -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

View file

@ -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);

View file

@ -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) {

View file

@ -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)

View file

@ -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)

View file

@ -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) {

View file

@ -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);

View file

@ -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) {

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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 */

View file

@ -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;

View file

@ -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;
}

View file

@ -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);
}
}

View file

@ -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
}
}

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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);

View file

@ -122,6 +122,6 @@ void main(void)
}
/* wait a while */
k_sleep(SLEEPTIME);
k_msleep(SLEEPTIME);
}
}

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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++) {

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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);

View file

@ -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);
}
}

View file

@ -9,7 +9,7 @@
#include <stdio.h>
#include <drivers/sensor.h>
#define SLEEP_TIME 1000
#define SLEEP_TIME K_MSEC(1000)
void main(void)
{

View file

@ -15,7 +15,7 @@
#include <string.h>
#endif
#define SLEEP_TIME 1000
#define SLEEP_TIME K_MSEC(1000)
void main(void)
{

View file

@ -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) */
}

View file

@ -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);

View file

@ -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

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -33,5 +33,5 @@ uint32_t HAL_GetTick(void)
*/
void HAL_Delay(__IO uint32_t Delay)
{
k_sleep(Delay);
k_msleep(Delay);
}

View file

@ -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;
}

View file

@ -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();
}

View file

@ -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);
}
}

View file

@ -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)) {

View file

@ -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();

View file

@ -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:

View file

@ -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;
}

View file

@ -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,

View file

@ -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);

View file

@ -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);
}
}

View file

@ -821,7 +821,7 @@ void wait_for_usb_dfu(void)
break;
}
k_sleep(INTERMITTENT_CHECK_DELAY);
k_msleep(INTERMITTENT_CHECK_DELAY);
}
}

View file

@ -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);

View file

@ -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));
}
}

View file

@ -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);
/**
*

View file

@ -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)

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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

View file

@ -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");

View file

@ -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;

View file

@ -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");
}

View file

@ -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(&REGRESS_SEM, TEST_TIMEOUT) == 0,
zassert_true(k_sem_take(&REGRESS_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(&REGRESS_SEM, TEST_TIMEOUT) == 0,
zassert_true(k_sem_take(&REGRESS_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");
}

View file

@ -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);

View file

@ -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

View file

@ -6,7 +6,7 @@
#include "test_fifo.h"
#define TIMEOUT 100
#define TIMEOUT K_MSEC(100)
/**
* @addtogroup kernel_fifo_tests

View file

@ -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);

View file

@ -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)
{

View file

@ -9,7 +9,7 @@
#include <ztest.h>
#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 <arch/arm/aarch32/cortex_m/cmsis.h>

View file

@ -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");

View file

@ -6,7 +6,7 @@
#include "test_lifo.h"
#define TIMEOUT 100
#define TIMEOUT K_MSEC(100)
/*test cases*/
/**

View file

@ -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);

View file

@ -6,7 +6,7 @@
#include <ztest.h>
#define TIMEOUT 100
#define TIMEOUT K_MSEC(100)
#if !defined(CONFIG_BOARD_QEMU_X86)
#define STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACKSIZE)
#else

View file

@ -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);
}

View file

@ -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)
{

View file

@ -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

View file

@ -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]);

View file

@ -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

View file

@ -5,7 +5,7 @@
*/
#include <ztest.h>
#define TIMEOUT 2000
#define TIMEOUT K_MSEC(2000)
#define BLK_SIZE_MIN 16
#define BLK_SIZE_MID 32
#define BLK_SIZE_MAX 256

View file

@ -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

View file

@ -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);

View file

@ -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]);

View file

@ -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)

View file

@ -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);

View file

@ -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

View file

@ -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*/

View file

@ -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

View file

@ -12,7 +12,8 @@
#include <ztest.h>
#include <limits.h>
#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

View file

@ -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);

View file

@ -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);
}

View file

@ -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)

View file

@ -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;

View file

@ -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);

View file

@ -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);

Some files were not shown because too many files have changed in this diff Show more