/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Initializes the GPT driver 1. */ gptStart(&GPTD1, &gpt1cfg); #if !POLLED_TEST gptStartContinuous(&GPTD1, 2); #endif while (1) { #if POLLED_TEST gpt_lld_polled_delay(&GPTD1, 1) ; palTogglePad(GPIOB, GPIOB_LED); #else chThdSleepMilliseconds(500); #endif } }
/** * @brief Starts the timer in one shot mode and waits for completion. * @details This function specifically polls the timer waiting for completion * in order to not have extra delays caused by interrupt servicing, * this function is only recommended for short delays. * @note The configured callback is not invoked when using this function. * * @param[in] gptp pointer to the @p GPTDriver object * @param[in] interval time interval in ticks * * @api */ void gptPolledDelay(GPTDriver *gptp, gptcnt_t interval) { chDbgAssert(gptp->state == GPT_READY, "gptPolledDelay(), #1", "invalid state"); gptp->state = GPT_ONESHOT; gpt_lld_polled_delay(gptp, interval); }