Пример #1
0
/**
 * \brief RNDIS Process
 *
 *   This is the link between USB and the "good stuff". In this routine data
 *   is received and processed by RNDIS, CDC-ECM, or CDC-EEM
 */
PROCESS_THREAD(usb_eth_process, ev, data_proc)
{
	static struct etimer et;

	PROCESS_BEGIN();

	while(1) {
		rxtx_led_update();

#if USB_ETH_CONF_MASS_STORAGE_FALLBACK
		usb_eth_setup_timeout_fallback_check();
#endif
		
		switch(usb_configuration_nb) {
			case USB_CONFIG_RNDIS_DEBUG:
			case USB_CONFIG_RNDIS:
				if(Is_device_enumerated()) {
					if(rndis_process()) {
						etimer_set(&et, CLOCK_SECOND/80);
					} else {
						Led0_toggle();
						etimer_set(&et, CLOCK_SECOND/8);
					}
				}
				break;
			case USB_CONFIG_EEM:
				if(Is_device_enumerated())
					cdc_eem_process();
				etimer_set(&et, CLOCK_SECOND/80);
				break;
			case USB_CONFIG_ECM:
			case USB_CONFIG_ECM_DEBUG:
				if(Is_device_enumerated()) {
					if(cdc_ecm_process()) {
						etimer_set(&et, CLOCK_SECOND/80);
					} else {
						Led0_toggle();
						etimer_set(&et, CLOCK_SECOND/8);
					}
				}
				break;
			default:
				Led0_toggle();
				etimer_set(&et, CLOCK_SECOND/4);
				break;
		}


		PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)||(usb_eth_packet_is_available()&&usb_eth_ready_for_next_packet()));
	} // while(1)

	PROCESS_END();
}
Пример #2
0
void cb_push( READING* r )
{
    CB_t next_head = next_index(cb_head);

    if( next_head == cb_tail )
    {
        Led0_toggle();
        return;
    }

    cb_data[cb_head] = *r;
    cb_head = next_head;
}