예제 #1
0
/**
 * \brief Wait for button press and release
 *
 * Waits for the button connected to \ref BUTTON_PIN to be pressed and released.
 * Debouncing is done with an approximate 20 ms delay after both the press and
 * the release.
 */
static void wait_for_button(void)
{
	do {} while (ioport_pin_is_high(BUTTON_PIN));
	mdelay(20);
	do {} while (ioport_pin_is_low(BUTTON_PIN));
	mdelay(20);
}
예제 #2
0
static void wait_for_btn_press(void)
{
	do { } while (ioport_pin_is_high(NEXT_BUTTON));
	delay_ms(5);
	do { } while (ioport_pin_is_low(NEXT_BUTTON));
	delay_ms(5);
}
예제 #3
0
파일: main.c 프로젝트: Tjalling7/asf
/**
 * \brief Returns the SW1 state
 *
 * \return Exit is requested if true
 */
static bool main_introduction_is_exist(void)
{
    if (ioport_pin_is_low(GPIO_PUSH_BUTTON_1)) {
        return true;
    }

    return false;
}
예제 #4
0
void VBusMon_check(void)
{
	static volatile uint8_t r = 0;
	if(1==r) return;
	r = 1;
	if(ioport_pin_is_low(USB_PROBE_PIN)) {
		vbus_action(false);
		udc_stop();
		OSC.DFLLCTRL = 2;
		DFLLRC32M.CTRL = 1;
		statusled_blink(2);
		debug_string(VERBOSE,PSTR("[EVENT] USB off\r\n"),true);
	} else {
		OSC.DFLLCTRL = 4;
		DFLLRC32M.CTRL = 1;

		udc_start();
		vbus_action(true);
		statusled_blink(2);
		debug_string(VERBOSE,PSTR("[EVENT] USB on\r\n"),true);
	}
	r=0;
}
예제 #5
0
void app_usb_task(void)
{
	static bool sw0_released = true;
	static bool usb_running = false;
	static bool cdc_running = false;
	static bool toggle = true;

	if (sw0_released && ioport_pin_is_low(GPIO_PUSH_BUTTON_0)) {
		/* A new press has been done */
		sw0_released = false;
		/* Switch USB state */
		if (usb_running) {
			udc_stop();
			gfx_mono_draw_filled_rect(DISPLAY_USB_STA_POS_X,
					DISPLAY_USB_STA_POS_Y,
					DISPLAY_USB_STA_SIZE_X,
					DISPLAY_USB_STA_SIZE_Y,
					GFX_PIXEL_CLR);
			app_microsd_start();
		} else {
			/* Stop FatFS on uSD card if enabled */
			app_microsd_stop();
			stdio_usb_init(); /* Start USB */
			gfx_mono_generic_put_bitmap(&bitmap_usb,
					DISPLAY_USB_STA_POS_X,
					DISPLAY_USB_STA_POS_Y);
		}

		usb_running = !usb_running;
		cdc_running = true;
	} else {
		/* Wait switch release */
		sw0_released = ioport_pin_is_high(GPIO_PUSH_BUTTON_0);
	}

	if (!usb_running) {
		return;
	}

	/* USB MSC task */
	while (udi_msc_process_trans()) {
	}

	if (app_usb_cdc_open && !cdc_running) {
		printf("\x0CSensor data logs:\r\n");
		cdc_running = true;
	}

	if (!app_usb_cdc_open && cdc_running) {
		cdc_running = false;
	}

	/* Toggle USB icon */
	if ((app_usb_cdc_open && app_usb_rec_toggle) ||
			(toggle && app_usb_rec_toggle)) {
		app_usb_rec_toggle = false;
		toggle = !toggle;
		gfx_mono_draw_rect(DISPLAY_USB_STACDC_POS_X,
				DISPLAY_USB_STACDC_POS_Y,
				DISPLAY_USB_STACDC_SIZE_X,
				DISPLAY_USB_STACDC_SIZE_Y,
				toggle ? GFX_PIXEL_SET : GFX_PIXEL_CLR);
	}
}