/** * @brief Polling monitor start. * * @param[in] p pointer to an object implementing @p BaseBlockDevice * * @notapi */ static void tmr_init(void *p) { chEvtObjectInit(&inserted_event); chEvtObjectInit(&removed_event); chSysLock(); cnt = POLLING_INTERVAL; chVTSetI(&tmr, MS2ST(POLLING_DELAY), tmrfunc, p); chSysUnlock(); }
/** * @brief Initialize the standard part of a @p MACDriver structure. * * @param[out] macp pointer to the @p MACDriver object * * @init */ void macObjectInit(MACDriver *macp) { macp->state = MAC_STOP; macp->config = NULL; chSemObjectInit(&macp->tdsem, 0); chSemObjectInit(&macp->rdsem, 0); #if MAC_USE_EVENTS chEvtObjectInit(&macp->rdevent); #endif }
void init_serial_link(void) { serial_link_connected = false; init_serial_link_hal(); add_remote_objects(remote_objects, sizeof(remote_objects)/sizeof(remote_object_t*)); init_byte_stuffer(); sdStart(&SD1, &config); sdStart(&SD2, &config); chEvtObjectInit(&new_data_event); (void)chThdCreateStatic(serialThreadStack, sizeof(serialThreadStack), SERIAL_LINK_THREAD_PRIORITY, serialThread, NULL); }
static void evt1_execute(void) { event_listener_t el1, el2; /* * Testing chEvtRegisterMask() and chEvtUnregister(). */ chEvtObjectInit(&es1); chEvtRegisterMask(&es1, &el1, 1); chEvtRegisterMask(&es1, &el2, 2); test_assert(1, chEvtIsListeningI(&es1), "no listener"); chEvtUnregister(&es1, &el1); test_assert(2, chEvtIsListeningI(&es1), "no listener"); chEvtUnregister(&es1, &el2); test_assert(3, !chEvtIsListeningI(&es1), "stuck listener"); /* * Testing chEvtDispatch(). */ chEvtDispatch(evhndl, 7); test_assert_sequence(4, "ABC"); }
static void evt2_execute(void) { eventmask_t m; event_listener_t el1, el2; systime_t target_time; /* * Test on chEvtWaitOne() without wait. */ chEvtAddEvents(5); m = chEvtWaitOne(ALL_EVENTS); test_assert(1, m == 1, "single event error"); m = chEvtWaitOne(ALL_EVENTS); test_assert(2, m == 4, "single event error"); m = chEvtGetAndClearEvents(ALL_EVENTS); test_assert(3, m == 0, "stuck event"); /* * Test on chEvtWaitOne() with wait. */ test_wait_tick(); target_time = chVTGetSystemTime() + MS2ST(50); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, thread1, chThdGetSelfX()); m = chEvtWaitOne(ALL_EVENTS); test_assert_time_window(4, target_time, target_time + ALLOWED_DELAY); test_assert(5, m == 1, "single event error"); m = chEvtGetAndClearEvents(ALL_EVENTS); test_assert(6, m == 0, "stuck event"); test_wait_threads(); /* * Test on chEvtWaitAny() without wait. */ chEvtAddEvents(5); m = chEvtWaitAny(ALL_EVENTS); test_assert(7, m == 5, "unexpected pending bit"); m = chEvtGetAndClearEvents(ALL_EVENTS); test_assert(8, m == 0, "stuck event"); /* * Test on chEvtWaitAny() with wait. */ test_wait_tick(); target_time = chVTGetSystemTime() + MS2ST(50); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, thread1, chThdGetSelfX()); m = chEvtWaitAny(ALL_EVENTS); test_assert_time_window(9, target_time, target_time + ALLOWED_DELAY); test_assert(10, m == 1, "single event error"); m = chEvtGetAndClearEvents(ALL_EVENTS); test_assert(11, m == 0, "stuck event"); test_wait_threads(); /* * Test on chEvtWaitAll(). */ chEvtObjectInit(&es1); chEvtObjectInit(&es2); chEvtRegisterMask(&es1, &el1, 1); chEvtRegisterMask(&es2, &el2, 4); test_wait_tick(); target_time = chVTGetSystemTime() + MS2ST(50); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1, thread2, "A"); m = chEvtWaitAll(5); test_assert_time_window(12, target_time, target_time + ALLOWED_DELAY); m = chEvtGetAndClearEvents(ALL_EVENTS); test_assert(13, m == 0, "stuck event"); test_wait_threads(); chEvtUnregister(&es1, &el1); chEvtUnregister(&es2, &el2); test_assert(14, !chEvtIsListeningI(&es1), "stuck listener"); test_assert(15, !chEvtIsListeningI(&es2), "stuck listener"); }
/** * @brief Shell manager initialization. * * @api */ void shellInit(void) { chEvtObjectInit(&shell_terminated); }
/** * @brief Initializes an @p event_timer_t structure. * * @param[out] etp the @p event_timer_t structure to be initialized * @param[in] time the interval in system ticks */ void evtObjectInit(event_timer_t *etp, systime_t time) { chEvtObjectInit(&etp->et_es); chVTObjectInit(&etp->et_vt); etp->et_interval = time; }
/*------------------------------------------------------------------------* * chibios_rt::EvtSource * *------------------------------------------------------------------------*/ EvtSource::EvtSource(void) { chEvtObjectInit(&ev_source); }