int console_start(void) { usb_device_start(&module.console.usb); #if CONFIG_START_CONSOLE_USB_CDC_WAIT_FOR_CONNETION == 1 /* Wait for the host to connect. */ while (usb_device_class_cdc_is_connected(&module.console.cdc) == 0) { thrd_sleep_us(100000); } thrd_sleep_us(100000); #endif return (0); }
int test_sleep(struct harness_t *harness_p) { BTASSERT(thrd_sleep(0.001) == 0); BTASSERT(thrd_sleep_ms(1) == 0); BTASSERT(thrd_sleep_us(1000) == 0); return (0); }
static int test_get_set(struct harness_t *harness) { struct time_t time1; struct time_t time2; /* Start by getting the current time. */ BTASSERT(time_get(&time1) == 0); std_printf(FSTR("time1: seconds = %lu, nanoseconds = %lu\r\n"), time1.seconds, time1.nanoseconds); /* Wait a while and verify that the time has changed. */ thrd_sleep_us(100000); BTASSERT(time_get(&time2) == 0); std_printf(FSTR("time2: seconds = %lu, nanoseconds = %lu\r\n"), time2.seconds, time2.nanoseconds); BTASSERT((time2.seconds > time1.seconds) || (time2.nanoseconds > time1.nanoseconds)); /* Set the time to a high value. */ time1.seconds = 100; time1.nanoseconds = 350000000; BTASSERT(time_set(&time1) == 0); /* Get the new time. */ BTASSERT(time_get(&time1) == 0); std_printf(FSTR("time1: seconds = %lu, nanoseconds = %lu\r\n"), time1.seconds, time1.nanoseconds); /* Wait a while and verify that the time has changed. */ thrd_sleep_us(100000); BTASSERT(time_get(&time2) == 0); std_printf(FSTR("time2: seconds = %lu, nanoseconds = %lu\r\n"), time2.seconds, time2.nanoseconds); BTASSERT((time2.seconds > time1.seconds) || (time2.nanoseconds > time1.nanoseconds)); return (0); }
int main() { struct pin_driver_t led; /* Start the system. */ sys_start(); /* Initialize the LED pin as output and set its value to 1. */ pin_init(&led, &pin_led_dev, PIN_OUTPUT); pin_write(&led, 1); while (1) { /* Wait half a second. */ thrd_sleep_us(500000); /* Toggle the LED on/off. */ pin_toggle(&led); } return (0); }