Ejemplo n.º 1
0
int main(void)
{
	clock_setup();
	gpio_setup();

	// provides time_curr_us to usbh_poll function
	tim6_setup();

#ifdef USART_DEBUG
	usart_init(USART6, 921600);
#endif
	LOG_PRINTF("\n\n\n\n\n###################\nInit\n");

	/**
	 * device driver initialization
	 *
	 * Pass configuration struct where the callbacks are defined
	 */
	hid_driver_init(&hid_config);
	hub_driver_init();
	gp_xbox_driver_init(&gp_xbox_config);
	midi_driver_init(&midi_config);

	gpio_set(GPIOD,  GPIO13);
	/**
	 * Pass array of supported low level drivers
	 * In case of stm32f407, there are up to two supported OTG hosts on one chip.
	 * Each one can be enabled or disabled in usbh_config.h - optimization for speed
	 *
	 * Pass array of supported device drivers
	 */
	usbh_init(lld_drivers, device_drivers);
	gpio_clear(GPIOD,  GPIO13);

	LOG_PRINTF("USB init complete\n");

	LOG_FLUSH();

	while (1) {
		// set busy led
		gpio_set(GPIOD,  GPIO14);

		uint32_t time_curr_us = tim6_get_time_us();

		usbh_poll(time_curr_us);

		// clear busy led
		gpio_clear(GPIOD,  GPIO14);

		LOG_FLUSH();

		// approx 1ms interval between usbh_poll()
		delay_ms_busy_loop(1);
	}

	return 0;
}
Ejemplo n.º 2
0
bool example_logger_qset::run(void *p)
{
    static int count = 0;

    /* Did the run() get called due to the mSec semaphore? */
    if (getQueueSetSelection() == mSec) {
        // This must work but just in case, return "false" to stop this task.
        if(!xSemaphoreTake(mSec, 0)) {
            return false;
        }

        LOG_INFO("Example log info");
    }

    /* Did the run() get called due to the mMin semaphore? */
    if(getQueueSetSelection() == mMin) {
        if(!xSemaphoreTake(mMin, 0)) {
            return false;
        }
        LOG_WARN("Example log warning");
    }

    /**
     * When count exceeds 60, we stop this task on purpose
     * We flush the remaining logger buffer, and return false to suspend the task.
     */
    if (count++ >= 60) {
        LOG_FLUSH();
        puts("Information was logged to a file.  Type 'cat log' to see it.");
        puts("Suspending this task on purpose");
        return false;
    }
    else {
        return true;
    }
}