Exemplo n.º 1
0
//! @brief This function manages the HOST mass storage application
//!
void host_ms_task(void)
{
   if( Is_host_ready() )   
   {
      // Here, Enumeration successfull, device is operationnal
      if(Is_new_device_connection_event())
      {
         // Update MS driver in case of
         if( host_mem_install() )
         {
#if (HOST_UPGRADE_MODE==ENABLE)
            b_new_msc_connected = TRUE;
#endif
            Led1_on();
         }
      }

#if (HOST_SYNC_MODE==ENABLE)  // Sync operating mode(if available)
      if( 0 != host_mem_get_lun() )
      {
         if(Is_joy_right())   // Sync device to host stream
         {
            Led0_on();
            sync_on_going=1;
            copy_dir( (U8 code *)dir_usb_out_name, (U8 code *)dir_local_in_name, 1 );
            sync_on_going=0;
            Led3_off();
            Led0_off();
         }
         if(Is_joy_left())    // Sync host to device stream
         {
            Led0_on();
            sync_on_going=1;
            copy_dir( (U8 code *)dir_local_out_name, (U8 code *)dir_usb_in_name, 1 );
            sync_on_going=0;
            Led0_off();
            Led3_off();
         }
      }
#endif

#if (HOST_UPGRADE_MODE==ENABLE)
      if( b_new_msc_connected )
      {
         // A new MSC is connected then start upgrade routine
         b_new_msc_connected = FALSE;
         firm_upgrade_run();
      }
#endif
   }

   // Device disconnection...
   if( Is_device_disconnection_event() )
   {
      // Update MS driver in case of
      host_mem_uninstall();
      Led1_off();
   }
}
Exemplo n.º 2
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();
	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();
}
Exemplo n.º 3
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();
}