void device_mass_storage_task(void)
#endif
{
#ifdef FREERTOS_USED
  portTickType xLastWakeTime;

  xLastWakeTime = xTaskGetTickCount();
  while (true)
  {
    vTaskDelayUntil(&xLastWakeTime, configTSK_USB_DMS_PERIOD);

    // First, check the device enumeration state
    if (!Is_device_enumerated()) continue;
#else
    // First, check the device enumeration state
    if (!Is_device_enumerated()) return;
#endif  // FREERTOS_USED

    // Display Start-of-Frame counter on LEDs
    /*LED_Display_Field(LED_MONO0_GREEN |
                      LED_MONO1_GREEN |
                      LED_MONO2_GREEN |
                      LED_MONO3_GREEN,
                      sof_cnt >> 5);*/

    // If we receive something in the OUT endpoint, parse it
    if (Is_usb_out_received(EP_MS_OUT))
    {
      usb_mass_storage_cbw();
      usb_mass_storage_csw();
    }
#ifdef FREERTOS_USED
  }
#endif
}
Example #2
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();
}
/** 
  * @brief This function transmits a ram buffer content to the USB.
  * This function is mode efficient in term of USB bandwith transfer.
  * 
  * @param U8 *buffer : the pointer to the RAM buffer to be sent 
  * @param data_to_send : the number of data to be sent
  */
void uart_usb_send_buffer(U8 *buffer, U8 nb_data)
{
  U8 zlp;

  if(!Is_device_enumerated())
    return;
   
  // Compute if zlp required
  if(nb_data%TX_EP_SIZE) 
    zlp=FALSE;
  else 
    zlp=TRUE;
   
  Usb_select_endpoint(TX_EP);
  while (nb_data)
  {
    while(Is_usb_write_enabled()==FALSE); // Wait Endpoint ready
    while(Is_usb_write_enabled() && nb_data)
    {
      Usb_write_byte(*buffer);
      buffer++;
      nb_data--;
    }
    Usb_ack_in_ready();
  }
  if(zlp)
  {
    while(Is_usb_write_enabled()==FALSE); // Wait Endpoint ready
    Usb_ack_in_ready();
  }
}
void device_mass_storage_task(void)
#endif
{
#ifdef FREERTOS_USED
  portTickType xLastWakeTime;

  xLastWakeTime = xTaskGetTickCount();
  while (true)
  {
    vTaskDelayUntil(&xLastWakeTime, configTSK_USB_DMS_PERIOD);

    // First, check the device enumeration state
    if (!Is_device_enumerated()) continue;
#else
    // First, check the device enumeration state
    if (!Is_device_enumerated()) return;
#endif  // FREERTOS_USED

#if BOARD == EVK1100
#if 0 // Error for NS8100
    // Display Start-of-Frame counter on LEDs
    LED_Display_Field(LED_MONO0_GREEN |
                      LED_MONO1_GREEN |
                      LED_MONO2_GREEN |
                      LED_MONO3_GREEN,
                      sof_cnt >> 5);
#endif
#elif BOARD == EVK1101 || BOARD == EVK1104 || BOARD == EVK1105 || BOARD == UC3C_EK
    // Display Start-of-Frame counter on LEDs
    LED_Display_Field(LED0 |
                      LED1,
                      sof_cnt >> 5);
#else
  #error The display of the SOFs must be defined here.
#endif

    // If we receive something in the OUT endpoint, parse it
    if (Is_usb_out_received(EP_MS_OUT))
    {
      usb_mass_storage_cbw();
      usb_mass_storage_csw();
    }
#ifdef FREERTOS_USED
  }
#endif
}
//! @brief Entry point of the HID generic communication task
//! This function manages IN/OUT report management.
//!
void device_generic_hid_task(void)
{
   if(!Is_device_enumerated())          // Check USB HID is enumerated
      return;

   hid_report_out();
   hid_report_in();
}
Example #6
0
//! Task which links mouse events with the USB HID mouse device
//!
void mouse_task(void)
{
   if(Is_usb_vbus_low())
   {
      Setup_power_down_mode();
      Sleep_instruction();
   }

   if(!Is_device_enumerated())
      return;  // Device not ready

#if (USB_LOW_SPEED_DEVICE==DISABLE)
   // The SOF is used to schedule the task at the same frequency that Endpoint Interrupt frequency
   // This check allow to win a CPU time
   if(g_u8_cpt_sof<NB_IDLE_POLLING_SOF)
      return;  // Wait a delay
   g_u8_cpt_sof=0;
#endif

   if(!g_b_send_report)
   {
      // No report sending on going, then check mouse event to eventualy fill a new report
      if(is_mouse_event())
      {
         // Enable sending of report
         g_b_send_report      = TRUE;
      }
   }

   if((!g_b_send_report)&&(!g_b_send_ack_report))
      return;  // No report and ack to send

   //** A report or ack must be send
   Usb_select_endpoint(EP_MOUSE_IN);
   if(!Is_usb_write_enabled())
      return;  // Endpoint no free

   Led0_on();
   if( g_b_send_report )
   {
      g_b_send_report      = FALSE;
      // Send an ack after a "clic" report only
      g_b_send_ack_report = (0!=g_hid_mouse_report[0]);
   }
   else
   {
      Hid_mouse_report_reset();     // Reset report to have a ack report
      g_b_send_ack_report  = FALSE;
   }
   // Send report
   Usb_write_byte(g_hid_mouse_report[0]);
   Usb_write_byte(g_hid_mouse_report[1]);
   Usb_write_byte(g_hid_mouse_report[2]);
   Usb_write_byte(g_hid_mouse_report[3]);
   Usb_ack_in_ready();
   Led0_off();
}
/** 
  * @brief This function checks if the USB emission buffer is ready to accept at
  * at least 1 byte
  * 
  * @return Boolean. TRUE if the firmware can write a new byte to transmit.
  */
bit uart_usb_tx_ready(void)
{
  if(!Is_device_enumerated())
     return FALSE;

  if (!Is_usb_write_enabled())
  {
    return FALSE;
  }
  return TRUE;
}
/**
 * \brief Communication Data Class (CDC) Process
 *
 *   This is the link between USB and the "good stuff". In this routine data
 *   is received and processed by CDC-ACM Class
 */
PROCESS_THREAD(cdc_process, ev, data_proc)
{

	PROCESS_BEGIN();
	uart_usb_init();

	while(1) {
      

	    // turn off LED's if necessary
		if (led3_timer) led3_timer--;
		else			Led3_off();

 		if(Is_device_enumerated() && (usb_mode == rndis_debug) && rndis_state && (!usb_busy)) {

			if (justenumerated) {

				//If we have serial port, set it as output
			    if (usb_mode == rndis_debug) {
					uart_usb_set_stdout();
					menu_print();
				}
				justenumerated = 0;
			}

			//Flush buffer if timeout
	        if(timer >= 4 && tx_counter!=0 ){
	            timer = 0;
	            uart_usb_flush();
	        } else {
				timer++;
			}

			while (uart_usb_test_hit()){
  		  	   menu_process(uart_usb_getchar());   // See what they want
            }


		}//if (Is_device_enumerated())


		if (usb_mode == rndis_debug) {
			etimer_set(&et, CLOCK_SECOND/80);
		} else {
			etimer_set(&et, CLOCK_SECOND);
		}

		PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));	
		
	} // while(1)

	PROCESS_END();
}
// this function should be continuously called
void my_uart_usb_send_to_endpoint(void){
  static uint8_t zlp=FALSE; /* zero load packet */
  static uint8_t local_buffer[TX_EP_SIZE];
  uint16_t num_read;
  bit ret;
  if(!Is_device_enumerated())
    return;


  // make atomic, this will be fixed by interrupts
  Usb_select_endpoint(TX_EP);
  if(Is_usb_write_enabled()==FALSE) // Only if endpoint ready
    return;

  if(line_status.DTR == 0){
    Usb_ack_in_ready();
    return;
  }


  // we send in chunks of TX_EP_SIZE 
  num_read = TX_EP_SIZE;
  ret = circ_buffer_get_nbytes(&my_uart_usb_tx_buffer, local_buffer, &num_read);
  if(num_read == 0 && zlp == TRUE){
    Usb_ack_in_ready();
    zlp = FALSE;
    Usb_disable_in_ready_interrupt(); // Nothing left to send, disable this until next time
    return;
  }
  // if we got exactly TX_EP_SIZE bytes, we should send zlp the next time if we send 0
  if(ret == PASS){
    zlp = TRUE;
    //Usb_enable_in_ready_interrupt(); // We don't need to do this since this is inside an interrupt.
  }
  else{ // this is the second pass and we didn't get a full TX_EP_SIZE bytes so the buffer is not full
    zlp = FALSE;
  }

  // write to the endpoint
  uint16_t nb_data = 0;
  Usb_select_endpoint(TX_EP);
  while(nb_data < num_read)
  {
    Usb_write_byte(local_buffer[nb_data]);
    nb_data++;
  }
  Usb_ack_in_ready();

  cdc_update_serial_state(); // I really do not know what this does, it could have been an old artifact from usart usb

//  if(usb_request_break_generation == TRUE)
//   usb_request_break_generation = FALSE;
}
uint8_t my_uart_usb_num_to_read(void){
  uint8_t num=0;

  if(!Is_device_enumerated())
     return 0;

  Usb_select_endpoint(RX_EP);
  if (Is_usb_receive_out()){
    num = Usb_byte_counter();
    if (num == 0)
      Usb_ack_receive_out();
  }
  return num;
}
Example #11
0
void device_mouse_hid_task(void)
#endif
{
#ifdef FREERTOS_USED
  portTickType xLastWakeTime;

  xLastWakeTime = xTaskGetTickCount();
  while (true)
  {
    vTaskDelayUntil(&xLastWakeTime, configTSK_USB_DHID_MOUSE_PERIOD);

    // First, check the device enumeration state
    if (!Is_device_enumerated()) continue;
#else
    // First, check the device enumeration state
    if (!Is_device_enumerated()) return;
#endif  // FREERTOS_USED

    if( is_usb_mouse_event() )
    {
       if( Is_usb_in_ready(EP_HID_MOUSE_IN) )
       {
          Usb_reset_endpoint_fifo_access(EP_HID_MOUSE_IN);

          //! Write report
          Usb_write_endpoint_data(EP_HID_MOUSE_IN, 8, u8_report_buttons);
          Usb_write_endpoint_data(EP_HID_MOUSE_IN, 8, u8_report_disp_x);
          Usb_write_endpoint_data(EP_HID_MOUSE_IN, 8, u8_report_disp_y);
          Usb_write_endpoint_data(EP_HID_MOUSE_IN, 8, u8_report_disp_wheel);

          Usb_ack_in_ready_send(EP_HID_MOUSE_IN);
       }
    }
#ifdef FREERTOS_USED
  }
#endif
}
  //!
  //! @brief Entry point of the device HID task management
  //!
void device_hid_task(void)
{
  // First, check the device enumeration state
  if (!Is_device_enumerated()) {
    return;
  }

  if (Is_usb_in_ready(EP_KBD_IN)) {
    if (is_usb_hid_event()) {
      Usb_reset_endpoint_fifo_access(EP_KBD_IN);

      //! Write report
      Usb_write_endpoint_data(EP_KBD_IN, 8, key);
      Usb_ack_in_ready_send(EP_KBD_IN);
    }
  }
}
/** 
  * @brief This function checks if a character has been received on the USB bus.
  * 
  * @return bit (true if a byte is ready to be read)
  */
bit uart_usb_test_hit(void)
{
  if(!Is_device_enumerated())
     return FALSE;

  if (!rx_counter)
  {
    Usb_select_endpoint(RX_EP);
    if (Is_usb_receive_out())
    {
      rx_counter = Usb_byte_counter();
      if (!rx_counter)
      {
        Usb_ack_receive_out();
      }
    }
  }
  return (rx_counter!=0);
}
Example #14
0
//!
//! @brief Entry point of the device mass-storage task management
//!
//! This function links the device mass-storage SCSI commands to the USB bus.
//!
//! @param pvParameters Input. Unused.
//!
void device_mass_storage_task(void *pvParameters)
{
  portTickType xLastWakeTime;

  xLastWakeTime = xTaskGetTickCount();
  while (true)
  {
    vTaskDelayUntil(&xLastWakeTime, configTSK_USB_DMS_PERIOD);

    // First, check the device enumeration state
    if (!Is_device_enumerated()) continue;

    // Display Start-of-Frame counter on LEDs
    // LED_Display_Field(0x7E, sof_cnt >> 5);

    // If we receive something in the OUT endpoint, parse it
    if (Is_usb_out_received(EP_MS_OUT))
    {
      usb_mass_storage_cbw();
      usb_mass_storage_csw();
    }
  }
}
Example #15
0
/**
 \brief Sends a single ethernet frame over USB using appropriate low-level protocol (EEM or RNDIS)
 \param senddata Data to send
 \param sendlen Length of data to send
 \param led Should the LED be light up for this frame?
 */
uint8_t usb_eth_send(uint8_t * senddata, uint16_t sendlen, uint8_t led)
{
	uint8_t ret = 0;
	
	if(!usb_eth_is_active) {
		USB_ETH_HOOK_TX_ERROR("Inactive");
		goto bail;
	}

	//Check device is set up
	if (Is_device_enumerated() == 0) {
		USB_ETH_HOOK_TX_ERROR("Device not enumerated");
		goto bail;
	}

	switch(usb_configuration_nb) {
		case USB_CONFIG_RNDIS_DEBUG:
		case USB_CONFIG_RNDIS:
			ret = rndis_send(senddata, sendlen, led);
			break;
		case USB_CONFIG_EEM:
			ret = eem_send(senddata, sendlen, led);
			break;
		case USB_CONFIG_ECM:
		case USB_CONFIG_ECM_DEBUG:
			ret = ecm_send(senddata, sendlen, led);
			break;
	}

bail:

	if(!ret) // Hit the watchdog if we have a successful send.
		watchdog_periodic();

	return ret;
}
Example #16
0
void device_full_custom_task(void)
#endif
{
  U32  time=0;
  bool startup=true;

#ifdef FREERTOS_USED
  portTickType xLastWakeTime;

  xLastWakeTime = xTaskGetTickCount();
  while (true)
  {
    vTaskDelayUntil(&xLastWakeTime, configTSK_USB_DFC_PERIOD);

    if( startup )
    {
       time+=configTSK_USB_DFC_PERIOD;
       #define STARTUP_LED_DELAY  100
       if     ( time== 1*STARTUP_LED_DELAY ) LED_On( LED_MONO0_GREEN );
       else if( time== 2*STARTUP_LED_DELAY ) LED_On( LED_MONO1_GREEN );
       else if( time== 3*STARTUP_LED_DELAY ) LED_On( LED_MONO2_GREEN );
       else if( time== 4*STARTUP_LED_DELAY ) LED_On( LED_MONO3_GREEN );
       else if( time== 5*STARTUP_LED_DELAY ) LED_Off( LED_MONO0_GREEN );
       else if( time== 6*STARTUP_LED_DELAY ) LED_Off( LED_MONO1_GREEN );
       else if( time== 7*STARTUP_LED_DELAY ) LED_Off( LED_MONO2_GREEN );
       else if( time== 8*STARTUP_LED_DELAY ) LED_Off( LED_MONO3_GREEN );
       else if( time== 9*STARTUP_LED_DELAY ) startup=false;
    }

    // First, check the device enumeration state
    if (!Is_device_enumerated()) continue;
#else
    // First, check the device enumeration state
    if (!Is_device_enumerated()) return;
#endif  // FREERTOS_USED

    if(Is_usb_out_received(EP_FC_OUT))
    {
       U32 nchar;
       Usb_reset_endpoint_fifo_access(EP_FC_OUT);
       memset(rxbuf, 0, RXBUF_SIZE);
       usb_read_ep_rxpacket(EP_FC_OUT, &rxbuf, RXBUF_SIZE, NULL);
       Usb_ack_out_received_free(EP_FC_OUT);
       //printf("Received %s\n\r", rxbuf);
       if( !strcmp((const char*)rxbuf, "get_sensor_value sensor=temp") )
       {  // Temperature sensor
          nchar=build_answer(txbuf, "temp");
          b_temperature_get_value( txbuf+nchar );
          b_report_pending=true;
       }

       else if( !strcmp((const char*)rxbuf, "get_sensor_value sensor=js") )
       {  // Joystick
          nchar=build_answer(txbuf, "js");
          b_joystick_get_value( txbuf+nchar );
          b_report_pending=true;
       }

       else if( !strcmp((const char*)rxbuf, "get_sensor_value sensor=pb1") )
       {  // Push button 1
          nchar=build_answer(txbuf, "pb1");
          b_pushb1_get_value( txbuf+nchar );
          b_report_pending=true;
       }

       else if( !strcmp((const char*)rxbuf, "get_sensor_value sensor=pb2") )
       {  // Push button 2
          nchar=build_answer(txbuf, "pb2");
          b_pushb2_get_value( txbuf+nchar );
          b_report_pending=true;
       }

#if BOARD == EVK1100
       else if( !strcmp((const char*)rxbuf, "get_sensor_value sensor=pb3") )
       {  // Push button 3
          nchar=build_answer(txbuf, "pb3");
          sprintf( txbuf+nchar, "RELEASE\r\n");
          b_report_pending=true;
       }
#endif

       else if( !strcmp((const char*)rxbuf, "get_sensor_value sensor=light") )
       {  // light
          U32 value;
          nchar=build_answer(txbuf, "light");
          b_light_get_value( txbuf+nchar, &value );
          e_ledm_refresh_intensity( value );
          b_report_pending=true;
       }


       else if( !strcmp((const char*)rxbuf, "get_actuator_value actuator=ledm1") )
       {  // led1
          nchar=build_answer(txbuf, "ledm1");
          b_ledm1_get_value( txbuf+nchar );
          b_report_pending=true;
       }
       else if( !strcmp((const char*)rxbuf, "get_actuator_value actuator=ledm2") )
       {  // led2
          nchar=build_answer(txbuf, "ledm2");
          b_ledm2_get_value( txbuf+nchar );
          b_report_pending=true;
       }
       else if( !strcmp((const char*)rxbuf, "get_actuator_value actuator=ledm3") )
       {  // led3
          nchar=build_answer(txbuf, "ledm3");
          b_ledm3_get_value( txbuf+nchar );
          b_report_pending=true;
       }
       else if( !strcmp((const char*)rxbuf, "get_actuator_value actuator=ledm4") )
       {  // led4
          nchar=build_answer(txbuf, "ledm4");
          b_ledm4_get_value( txbuf+nchar );
          b_report_pending=true;
       }


       else if( !strncmp((const char*)rxbuf, STR_SET_LEDM1, strlen(STR_SET_LEDM1)) )
       {  // led1
          nchar=build_answer(txbuf, "ledm1");
          e_ledm1_set_value(rxbuf+strlen(STR_SET_LEDM1), txbuf+nchar);
          b_report_pending=true;
       }
       else if( !strncmp((const char*)rxbuf, STR_SET_LEDM2, strlen(STR_SET_LEDM2)) )
       {  // led2
          nchar=build_answer(txbuf, "ledm2");
          e_ledm2_set_value(rxbuf+strlen(STR_SET_LEDM2), txbuf+nchar);
          b_report_pending=true;
       }
       else if( !strncmp((const char*)rxbuf, STR_SET_LEDM3, strlen(STR_SET_LEDM3)) )
       {  // led3
          nchar=build_answer(txbuf, "ledm3");
          e_ledm3_set_value(rxbuf+strlen(STR_SET_LEDM2), txbuf+nchar);
          b_report_pending=true;
       }
       else if( !strncmp((const char*)rxbuf, STR_SET_LEDM4, strlen(STR_SET_LEDM4)) )
       {  // led4
          nchar=build_answer(txbuf, "ledm4");
          e_ledm4_set_value(rxbuf+strlen(STR_SET_LEDM2), txbuf+nchar);
          b_report_pending=true;
       }


       else if( !strcmp((const char*)rxbuf, "get_sensor_value sensor=accx") )
       {  // accelerometer
          nchar=build_answer(txbuf, "accx");
          accelerometer_measure(0, txbuf+nchar);
          b_report_pending=true;
       }
       else if( !strcmp((const char*)rxbuf, "get_sensor_value sensor=accy") )
       {  // accelerometer
          nchar=build_answer(txbuf, "accy");
          accelerometer_measure(1, txbuf+nchar);
          b_report_pending=true;
       }
    }

    if( b_report_pending && Is_usb_in_ready(EP_FC_IN) )
    {
       U8  data_to_transfer;
       char* ptr_cram=txbuf;

       //printf( "Sending %s", txbuf);
       #if 0
       Usb_reset_endpoint_fifo_access(EP_FC_IN);
       usb_write_ep_txpacket(EP_FC_IN, &txbuf, TXBUF_SIZE, NULL);
       Usb_ack_in_ready_send(EP_FC_IN);
       #endif

       data_to_transfer = strlen(txbuf);
       while (data_to_transfer)
       {
         while (!Is_usb_in_ready(EP_FC_IN));

         Usb_reset_endpoint_fifo_access(EP_FC_IN);
         data_to_transfer = usb_write_ep_txpacket(EP_FC_IN, ptr_cram, data_to_transfer, (const void**)&ptr_cram);
         Usb_ack_in_ready_send(EP_FC_IN);
       }
       b_report_pending=false;
    }
#ifdef FREERTOS_USED
  }
#endif
}
Example #17
0
/**
 * \brief Communication Data Class (CDC) Process
 *
 *   This is the link between USB and the "good stuff". In this routine data
 *   is received and processed by CDC-ACM Class
 */
PROCESS_THREAD(cdc_process, ev, data_proc)
{
	PROCESS_BEGIN();

#if USB_CONF_RS232
	static FILE *rs232_stdout,*usb_stdout;
	rs232_stdout=stdout;
#endif

	while(1) {
	    // turn off LED's if necessary
		if (led3_timer) led3_timer--;
		else			Led3_off();
		
 		if(Is_device_enumerated()) {
			// If the configuration is different than the last time we checked...
			if((uart_usb_get_control_line_state()&1)!=previous_uart_usb_control_line_state) {
				previous_uart_usb_control_line_state = uart_usb_get_control_line_state()&1;
				static FILE* previous_stdout;
				
				if(previous_uart_usb_control_line_state&1) {
					previous_stdout = stdout;
					uart_usb_init();
					uart_usb_set_stdout();
				//	menu_print(); do this later
				} else {
					stdout = previous_stdout;
				}
#if USB_CONF_RS232
				usb_stdout=stdout;
#endif
			}

			//Flush buffer if timeout
	        if(timer >= 4 && tx_counter!=0 ){
	            timer = 0;
	            uart_usb_flush();
	        } else {
				timer++;
			}

#if USB_CONF_RS232
			stdout=usb_stdout;
#endif
			while (uart_usb_test_hit()){
  		  	   menu_process(uart_usb_getchar());   // See what they want
            }
#if USB_CONF_RS232
            if (usbstick_mode.debugOn) {
			  stdout=rs232_stdout;
			} else {
			  stdout=NULL;
			}
#endif
		}//if (Is_device_enumerated())



		if (USB_CONFIG_HAS_DEBUG_PORT(usb_configuration_nb)) {
			etimer_set(&et, CLOCK_SECOND/80);
		} else {
			etimer_set(&et, CLOCK_SECOND);
		}

		PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));	
		
	} // while(1)

	PROCESS_END();
}
Example #18
0
void device_template_task(void)
#endif
{
  static U8 buf[EP_SIZE_TEMP2];

#ifdef FREERTOS_USED
  portTickType xLastWakeTime;

  xLastWakeTime = xTaskGetTickCount();
  while (true)
  {
    vTaskDelayUntil(&xLastWakeTime, configTSK_USB_DTP_PERIOD);

    // First, check the device enumeration state
    if (!Is_device_enumerated()) continue;
#else
    // First, check the device enumeration state
    if (!Is_device_enumerated()) return;
#endif  // FREERTOS_USED

    // HERE STARTS THE USB DEVICE APPLICATIVE CODE
    // The example below just performs a loopback transmission/reception.
    // All data received with the OUT endpoint is stored in a RAM buffer and
    // sent back to the IN endpoint.

#if BOARD == EVK1100
    // For example, display Start-of-Frame counter on LEDs
    LED_Display_Field(LED_MONO0_GREEN |
                      LED_MONO1_GREEN |
                      LED_MONO2_GREEN |
                      LED_MONO3_GREEN,
                      sof_cnt >> 5);
#elif BOARD == EVK1101 || BOARD == UC3C_EK || BOARD == EVK1104 || BOARD == EVK1105
    // For example, display Start-of-Frame counter on LEDs
    LED_Display_Field(LED0 |
                      LED1,
                      sof_cnt >> 5);
#else
  #error The display of the SOFs must be defined here.
#endif

    // If we receive something in the OUT endpoint, just store it in the RAM buffer
    if (Is_usb_out_received(EP_TEMP_OUT))
    {
      LED_On(LED_APPLI_1);
      Usb_reset_endpoint_fifo_access(EP_TEMP_OUT);
      data_length = Usb_byte_count(EP_TEMP_OUT);
      usb_read_ep_rxpacket(EP_TEMP_OUT, buf, data_length, NULL);
      Usb_ack_out_received_free(EP_TEMP_OUT);
      LED_Off(LED_APPLI_1);
    }

    // Load the IN endpoint with the contents of the RAM buffer
    if (data_length && Is_usb_in_ready(EP_TEMP_IN))
    {
      LED_On(LED_APPLI_0);
      Usb_reset_endpoint_fifo_access(EP_TEMP_IN);
      usb_write_ep_txpacket(EP_TEMP_IN, buf, data_length, NULL);
      data_length = 0;
      Usb_ack_in_ready_send(EP_TEMP_IN);
      LED_Off(LED_APPLI_0);
    }
#ifdef FREERTOS_USED
  }
#endif
}
void USB_CCID_task (void* pvParameters)
{
    unsigned char Startup_b = TRUE;
    portTickType xLastWakeTime;

    ISO7816_InitSC ();
    /*
       CI_LocalPrintf ("USB_CCID : USB CCID raise IN ready - %d\n",xTaskGetTickCount()); */
    // Start CCID interface
    while (0 != Usb_nb_busy_bank (EP_CCID_IN))  // MSC Compliance - Wait end of all transmitions on USB line
    {
        if (Is_usb_setup_received ())
            usb_process_request ();
    }
    Usb_raise_in_ready (EP_CCID_IN);

    // Start keyboard interface
    while (0 != Usb_nb_busy_bank (EP_KB_IN))    // MSC Compliance - Wait end of all transmitions on USB line
    {
        if (Is_usb_setup_received ())
            usb_process_request ();
    }
    Usb_raise_in_ready (EP_KB_IN);


    xLastWakeTime = xTaskGetTickCount ();

    while (TRUE)
    {
        vTaskDelayUntil (&xLastWakeTime, configTSK_USB_CCID_PERIOD);

        // First, check the device enumeration state
        if (!Is_device_enumerated ())
            continue;

        // If smartcard is ready send it over usb
        if (TRUE == Startup_b)
        {
            Startup_b = FALSE;
            // CI_LocalPrintf ("USB_CCID : USB CCID started - %d\n",xTaskGetTickCount());
            DelayMs (100);  // Wait 100 ms
            USB_CCID_send_INT_Message ();   // We are always online
        }

        // If we receive something in the OUT endpoint, parse it
        if (Is_usb_out_received (EP_CCID_OUT))
        {
#ifdef TIME_MEASURING_ENABLE
            TIME_MEASURING_Start (TIME_MEASURING_TIME_CCID_USB_GET);
#endif
            USB_CCID_GetDataFromUSB ();
#ifdef TIME_MEASURING_ENABLE
            TIME_MEASURING_Stop (TIME_MEASURING_TIME_CCID_USB_GET);
            TIME_MEASURING_Start (TIME_MEASURING_TIME_CCID_USB_SEND);
#endif
            USB_CCID_SendDataToUSB ();

            USB_to_CRD_DispatchUSBMessage_v (&USB_CCID_data_st);

// Clear buffer after transmission
            memset (USB_CCID_data_st.USB_data,0,CCID_MAX_XFER_LENGTH);

#ifdef TIME_MEASURING_ENABLE
            TIME_MEASURING_Stop (TIME_MEASURING_TIME_CCID_USB_SEND);
#endif
        }
    }
}
void device_mass_storage_task (void)
#endif
{
    unsigned int TickDelayToRestart = MAX_TICKS_UNTIL_RESTART_MSD_INTERFACE;
    int ErrorFound;
    unsigned long long ActualTime_u64;
    static unsigned int LoopCounter_u32 = 0;

#ifdef FREERTOS_USED
    portTickType xLastWakeTime;

    FAI_InitLun (0);

    xLastWakeTime = xTaskGetTickCount ();
    while (TRUE)
    {
        vTaskDelayUntil (&xLastWakeTime, configTSK_USB_DMS_PERIOD);

        // First, check the device enumeration state
        if (!Is_device_enumerated ())
            continue;
#else
    // First, check the device enumeration state
    if (!Is_device_enumerated ())
        return;
#endif // FREERTOS_USED

    // If we receive something in the OUT endpoint, parse it
    if (Is_usb_out_received (EP_MS_OUT))
    {
        usb_mass_storage_cbw ();
        usb_mass_storage_csw ();
    }

    // Check LUN activity

    if (30 <= LoopCounter_u32)
    {
        ActualTime_u64 = TIME_MEASURING_GetTime ();
        if ((FALSE == sd_mmc_mci_test_unit_only_local_access)   // On local access > disable check
            // || (ActualTime_u64 > MAX_TICKS_STARTUP_UNTIL_RESTART_MSD_INTERFACE) // Not check on startup
            )
        {
            ErrorFound = FALSE;
            if (ActualTime_u64 - LastLunAccessInTick_u64[0] > TickDelayToRestart)
            {
                CI_StringOut ("UNCRYPTED LUN 0 - TIMEOUT\r\n");
                ErrorFound = TRUE;
            }
            // Check LUN activity
            if (ActualTime_u64 - LastLunAccessInTick_u64[1] > TickDelayToRestart)
            {
                CI_StringOut ("ENCRYPTED LUN 1 - TIMEOUT\r\n");
                ErrorFound = TRUE;
            }
            /*
               if (TRUE == ErrorFound) { CI_StringOut ("*** RESTART MSD DEVICE TASK ***\r\n"); LastLunAccessInTick_u64[0] = ActualTime_u64;
               LastLunAccessInTick_u64[1] = ActualTime_u64; usb_device_task_delete(); usb_device_task_init(); } */
        }
        else
        {
            LastLunAccessInTick_u64[0] = ActualTime_u64;    // Avoid wrong timeout
            LastLunAccessInTick_u64[1] = ActualTime_u64;
        }
    }
    else
    {
        LoopCounter_u32 = 0;
    }


#ifdef FREERTOS_USED
}
#endif
}
Example #21
0
void device_audio_task(void)
#endif
{
#if( BOARD!=EVK1105) || (DEFAULT_DACS!=AUDIO_MIXER_DAC_AIC23B)
  uint32_t  i;
#endif
  uint32_t  fifo_cnt;
  int  stream_status;

#ifdef FREERTOS_USED
  portTickType xLastWakeTime;
  xLastWakeTime = xTaskGetTickCount();
  LED_On(LED0);

  while (true)
  {
    vTaskDelayUntil(&xLastWakeTime, configTSK_USB_DAUDIO_PERIOD);

    // First, check the device enumeration state
    if (!Is_device_enumerated()) { mmi_state=0; continue; }
#else
    // First, check the device enumeration state
    if (!Is_device_enumerated()) { mmi_state=0; return; }
#endif  // FREERTOS_USED

    mmi_display();

#if( BOARD!=EVK1105) || (DEFAULT_DACS!=AUDIO_MIXER_DAC_AIC23B)
    // Microphone emulation
    //
    if ( is_joystick_pressed() )
    {
       if (Is_usb_write_enabled(EP_AUDIO_IN))   // Endpoint buffer free ?
       {
          Usb_reset_endpoint_fifo_access(EP_AUDIO_IN);
          for( i=0 ; i<EP_SIZE_IN ; i++ )   // Fill endpoint with sample raw
          {
             if(mute==false)
             {
                uint8_t sample;
                sample = sample_sound[dat_sample_index++];
                LED_Set_Intensity(LED0, sample);
                Usb_write_endpoint_data(EP_AUDIO_IN, 8, sample);
                if (dat_sample_index >= SAMPLE_SOUND_LEN)
                {  dat_sample_index=0; }
             }
             else
             {
                LED_Set_Intensity(LED0, 0);
                Usb_write_endpoint_data(EP_AUDIO_IN, 8, 0x00);
             }
          }
          Usb_ack_in_ready_send(EP_AUDIO_IN);
       }
    }
#else
    // Handle input stream from microphone
    if( !b_microphone_started && (Is_usb_write_enabled(EP_AUDIO_IN)) && audio_mixer_dacs_input(NULL, 0) )
    {
      // Start ADC conversion. This will launch the IRL in background...
      mic_buf_id = 0;
      mic_frame_id=2;
      microphone[mic_buf_id].size=45;
      audio_mixer_dacs_input(microphone[0].buffer, 45 /*microphone[mic_buf_id].size*/);
      audio_mixer_dacs_input(microphone[1].buffer, 45 /*microphone[mic_buf_id].size*/);
      b_microphone_started=true;
    }
#endif



    // Handle incoming audio samples
    //
    if((Is_usb_out_received(EP_AUDIO_OUT) )
    /*&& (Is_usb_stall(EP_AUDIO_OUT)==false)*/)
    {
       stream_status = usb_stream_input(USB_STREAM_DEVICE, EP_AUDIO_OUT, &fifo_cnt);
       Usb_ack_out_received_free(EP_AUDIO_OUT);
       mmi_activity_display(false, fifo_cnt);
    }
#if USB_RESYNC_AUDIO_STREAM && (USB_RESYNC_AUDIO_STREAM==true)
    usb_stream_resync();
#endif

#ifdef FREERTOS_USED
  }
#endif
}
Example #22
0
/*!
 * \brief Supervisor task.
 *
 * \return never
 */
static portTASK_FUNCTION( vSupervisorTask, pvParameters )
{
   portTickType xDelayLength = SUPERVISOR_DEFAULT_PERIOD;
   portTickType xLastFocusTime;
#if configHEAP_INIT == 1
#if defined(__GNUC__)
   portLONG     lCheckHeapDelay = 1;
#endif
#endif
#if configCTRLPANEL_TRACE == 1
   portLONG     lPrintTrace = 3;
#endif
   portLONG     lUpdateTimeDelay = 1;
#ifdef MMILCD_ENABLE
   portLONG     lUpdateMMITimeDelay = 1;
   portCHAR DateTime[21];
   struct tm *pxDate;
   bool ms_connected_displayed = pdFALSE;
   bool enum_connected_displayed = pdFALSE;
#endif

   /* The parameters are not used. */
   ( void )pvParameters;

#if configCTRLPANEL_TRACE == 1
   /* Initialize the dump port COM2. */
   itracedump_Init();
#endif

#ifdef MMILCD_ENABLE
   // The MMI module.
   if( pdFALSE == bMMI_start() )
   {
      // vParTestSetLED( ERROR_LED_ID, pdTRUE );
      while( 1 );
   }
#endif

   // Create the SHELL mutex.
   vSemaphoreCreateBinary( xSHELLFSMutex );
   if( NULL == xSHELLFSMutex )
   { // The mutex creation failed.
      // TODO: Add msg on LCD.
      // vParTestSetLED( ERROR_LED_ID, pdTRUE );
      while( 1 );
   }
   // Start the COM1 Shell module.
   vStartCom1Shell( mainCOMSH_TASK_PRIORITY );

   // Create the CFG mutex.
   vSemaphoreCreateBinary( xCFGMutex );
   if( NULL == xCFGMutex )
   { // The mutex creation failed.
      // TODO: Add msg on LCD.
      // vParTestSetLED( ERROR_LED_ID, pdTRUE );
      while( 1 );
   }

   // Start the sensor module.
   if( false == bsensor_start() )
   {
      // TODO: Add msg on LCD.
      // vParTestSetLED( ERROR_LED_ID, pdTRUE );
      while( 1 );
   }

#if NW_INTEGRATED_IN_CONTROL_PANEL
   // Create the Web server mutex.
   vSemaphoreCreateBinary( xWEBMutex );
   if( NULL == xWEBMutex )
   { // The mutex creation failed.
      // TODO: Add msg on LCD.
      // vParTestSetLED( ERROR_LED_ID, pdTRUE );
      while( 1 );
   }
   // Start network tasks.
   vStartEthernetTaskLauncher( tskIDLE_PRIORITY + 1 );
#endif

   // Create the LOG mutex.
   vSemaphoreCreateBinary( xLOGMutex );
   if( NULL == xLOGMutex )
   { // The mutex creation failed.
      // TODO: Add msg on LCD.
      // vParTestSetLED( ERROR_LED_ID, pdTRUE );
      while( 1 );
   }
   // Start the data logger module.
   if( false == bdatalog_start( mainDATALOG_TASK_PRIORITY ) )
   {
      // TODO: Add msg on LCD.
      // vParTestSetLED( ERROR_LED_ID, pdTRUE );
      while( 1 );
   }

#ifdef USB_ENABLE
#if USB_DEVICE_FEATURE == true
   // Create the USB mutex.
   vSemaphoreCreateBinary( xUSBMutex );
   if( NULL == xUSBMutex )
   { // The mutex creation failed.
      // TODO: Add msg on LCD.
      // vParTestSetLED( ERROR_LED_ID, pdTRUE );
      while( 1 );
   }
   // Immediately take the USB mutex. i.e. when we're a Mass Storage device,
   // we'll refuse to give r/w access to the host until a user action. This user
   // action will make the Ctrl Panel device switch to maintenance mode, in which
   // the Mass Storage USB host has r/w access to the Ctrl Panel file system.
   while( pdFALSE == x_supervisor_SemaphoreTake( xUSBMutex, 0 ) );
#endif
   // Start the USB module tasks.
   if( false == b_usbsys_start() )
   {
      // TODO: Add msg on LCD.
      // vParTestSetLED( ERROR_LED_ID, pdTRUE );
      while( 1 );
   }
#endif

#ifdef MMILCD_ENABLE
   // Create the supervisor queue to deal with MMI actions
   xSUPERVISORQueue = xQueueCreate( SUPERVISOR_QUEUE_SIZE, sizeof(bool *) );
   if( 0 == xSUPERVISORQueue )
   {
      // TODO: Add msg on LCD.
      // vParTestSetLED( ERROR_LED_ID, pdTRUE );
      while( 1 );
   }

   /* Get a File System navigator for MMI actions. */
   fsaccess_take_mutex();
   sMmiNavId = fsaccess_alloc_nav_id();
   nav_select( sMmiNavId );   // Select the navigator.
   fsaccess_give_mutex();

   /* Spawn the User Action task. */
   if( pdPASS != xTaskCreate( vSupervisorUserActionTask,
                              ( const signed portCHAR * )"MMIACT",
                              SUPERVISOR_USER_ACTION_STACK_SIZE, NULL, SUPERVISOR_USER_ACTION_TASK_PRIORITY,
                              &xSupervisorUserActionHndl ) )
   {
      vTaskDelete( xSupervisorUserActionHndl );
      // TODO: Add msg on LCD.
      // vParTestSetLED( ERROR_LED_ID, pdTRUE );
      while( 1 );
   }
#endif // #ifdef MMILCD_ENABLE

   /* We need to initialise xLastFlashTime prior to the first call to vTaskDelayUntil(). */
   xLastFocusTime = xTaskGetTickCount();

#if defined(__GNUC__)
   NAKED_TRACE_COM2( "heap start @=%d, heap end @=%d", \
                     (portBASE_TYPE *)&__heap_start__, \
                     (portBASE_TYPE *)&__heap_end__ );
#endif

   /* Enable the watchdog timer. */
   // wdt_enable( SUPERVISOR_WDT_TIMEOUT );

   for(;;)
   {
      /* Delay for the flash period then check. */
      vTaskDelayUntil( &xLastFocusTime, xDelayLength );

      // wdt_clear(); // Kick the watchdog!

      /* MMI USB management. */
#ifdef MMILCD_ENABLE
#ifdef USB_ENABLE
/*** Start of Host behaviour ***/
      // first occurrence of MS connection, Host mode
      if (ms_connected == true && ms_connected_displayed == pdFALSE)
      {
        // display connected logo
        ms_connected_displayed = pdTRUE;
        vMMI_DisplayUSBState(ms_connected_displayed);
        // Display User Menu
        vMMI_SetUserMenuMode(eUserMenuUSBHost, pdTRUE);

      }
      // first occurrence of MS disconnection, end of Host mode
      if (ms_connected == false && ms_connected_displayed == pdTRUE)
      {
        // remove connected logo
        ms_connected_displayed = pdFALSE;
        vMMI_DisplayUSBState(ms_connected_displayed);
        // clear User Menu
        vMMI_SetUserMenuMode(eUserMenuIdle, pdTRUE);
      }
/*** End of Host behaviour ***/
/*** Start of Device behaviour ***/
#if USB_DEVICE_FEATURE == true
      // first occurrence of Device connection, Device mode
      if (Is_device_enumerated() && ( enum_connected_displayed == pdFALSE ) )
      {
        if( true == bIsInMaintenance )
        {
          // display connected logo
          enum_connected_displayed = pdTRUE;
          vMMI_DisplayUSBState(enum_connected_displayed);
          // Display User Menu
          vMMI_SetUserMenuMode(eUserMenuUSBDevice, pdTRUE);
        }
      }
      // first occurrence of Device disconnection, end of Device mode
      else if (!Is_device_enumerated() && enum_connected_displayed == pdTRUE)
      {
        // remove connected logo
        enum_connected_displayed = pdFALSE;
        vMMI_DisplayUSBState(enum_connected_displayed);
        // clear User Menu
        vMMI_SetUserMenuMode(eUserMenuIdle, pdTRUE);
      }
      else
      {
        // remove connected logo => this makes the USB logo blink when the Control
        // Panel is behaving as a USB key.
        enum_connected_displayed = pdFALSE;
        vMMI_DisplayUSBState(enum_connected_displayed);
      }
/*** End of Device behaviour ***/
#endif // #if USB_DEVICE_FEATURE == true
#endif // #ifdef USB_ENABLE
#endif // #ifdef MMILCD_ENABLE

      /* update time every SUPERVISOR_DELAY_TIMEUPDATE seconds. */
      if( 0 == --lUpdateTimeDelay )
      {
         /* Update the local time. */
         lUpdateTimeDelay = SUPERVISOR_DELAY_TIMEUPDATE;
         xcptime_LocalTime++;
         // v_cptime_UpdateLocalTime();
      }

#ifdef MMILCD_ENABLE
      /* Update time displayed on the LCD. */
      if( 0 == --lUpdateMMITimeDelay)
      {
         // Get the broken-down representation of the current date.
         pxDate = gmtime( &xcptime_LocalTime );

         // WARNING: pxDate->tm_year == number of years since 1900.
         // For years >= 2000, we'll display the last 2 digits only.
         if( pxDate->tm_year >= 100 )  pxDate->tm_year -= 100;
#if DISPLAY_MMI_SECOND == 1
         sprintf( DateTime, "%02d/%02d/20%02d  %02d:%02d:%02d", pxDate->tm_mon +1, pxDate->tm_mday,
                            pxDate->tm_year, pxDate->tm_hour, pxDate->tm_min, pxDate->tm_sec );
#else
         sprintf( DateTime, "%02d/%02d/20%02d     %02d:%02d", pxDate->tm_mon +1, pxDate->tm_mday,
                            pxDate->tm_year, pxDate->tm_hour, pxDate->tm_min );
#endif
         vMMI_DisplayDateAndTime(DateTime);
         lUpdateMMITimeDelay = SUPERVISOR_DELAY_MMI_TIMEUPDATE;
      }

      // Manage MMI
      vMMI_Manage();

      // Manage MMI user action
      prv_v_manage_user_action();
#endif // #ifdef MMILCD_ENABLE

#ifdef USB_ENABLE
      if( true == bOutOfMaintenance )
      {
         prv_v_leave_maintenance_mode();
      }
#endif

      /* Execute a scheduled command if expiration date is up. */
      v_cptime_ExecuteScheduledCmd();

#if configHEAP_INIT == 1
#if defined(__GNUC__)
      /* Record the malloc() heap highest consumption every SUPERVISOR_DELAY_HEAPCHECK seconds. */
      if( 0 == --lCheckHeapDelay )
      {
         lCheckHeapDelay = SUPERVISOR_DELAY_HEAPCHECK;
         prvCheckMallocHeap();
      }
#endif
#endif

#if configCTRLPANEL_TRACE == 1
      // Display traces on USART1 every SUPERVISOR_DELAY_PRINTTASKLIST seconds.
      if( 0 == --lPrintTrace )
      {
         lPrintTrace = SUPERVISOR_DELAY_PRINTTASKLIST; // Restart the delay.
         v_syscmds_display_traces();
      }
#endif

   } // for(;;)
} /*lint !e715 !e818 !e830 Function definition must be standard for task creation. */
Example #23
0
static void
usb_eth_setup_timeout_fallback_check() {
	extern uint8_t fingerPresent;
		/* Device is Enumerated but RNDIS not loading. We might
		   have a system that does not support IAD (winXP). If so
		   count the timeout then switch to just network interface. */
	static uint16_t iad_fail_timeout, rndis_fail_timeout;	
	if (usb_mode == rndis_debug) {
		//If we have timed out, detach
		if (iad_fail_timeout == IAD_TIMEOUT_DETACH) {
		
			//Failed - BUT we are using "reverse logic", hence we force device
			//into this mode. This is used to allow Windows Vista have time to
			//install the drivers
			if (fingerPresent && (rndis_state != rndis_data_initialized) && Is_device_enumerated() ) {
				iad_fail_timeout = 0;
			} else {
					stdout = NULL;
					Usb_detach();
					doInit = 1; //Also mark system as needing intilizing
			}
			
		//Then wait a few before re-attaching
		} else if (iad_fail_timeout == IAD_TIMEOUT_ATTACH) {
		
			if (fingerPresent) {
				usb_mode = mass_storage;
			} else {
				usb_mode = rndis_only;
			}
			Usb_attach();
		}

		//Increment timeout when device is not initializing, OR we have already detached,
		//OR the user had their finger on the device, indicating a reverse of logic
		if ( ( (rndis_state != rndis_data_initialized) && Is_device_enumerated() ) ||
		  (iad_fail_timeout > IAD_TIMEOUT_DETACH) || 
		   (fingerPresent) ) {
			iad_fail_timeout++;
		} else {	
		iad_fail_timeout = 0;
		}
	} //usb_mode == rndis_debug


	 /* Device is Enumerated but RNDIS STIL not loading. We just
		have RNDIS interface, so obviously no drivers on target.
		Just go ahead and mount ourselves as mass storage... */
	if (usb_mode == rndis_only) {
		//If we have timed out, detach
		if (rndis_fail_timeout == RNDIS_TIMEOUT_DETACH) {
			Usb_detach();
		//Then wait a few before re-attaching
		} else if (rndis_fail_timeout == RNDIS_TIMEOUT_ATTACH) {
			usb_mode = mass_storage;
			Usb_attach();
		}

		//Increment timeout when device is not initializing, OR we are already
		//counting to detach
		if ( ( (rndis_state != rndis_data_initialized)) ||
		  (rndis_fail_timeout > RNDIS_TIMEOUT_DETACH) ) {
			rndis_fail_timeout++;
		} else {	
		rndis_fail_timeout = 0;
		}
	}//usb_mode == rnids_only
}
Example #24
0
bool USB::isEnumerated()
{
  return Is_device_enumerated();
}