host_ms_task.c

Go to the documentation of this file.
00001 /*This file is prepared for Doxygen automatic documentation generation.*/
00013 
00014 /* Copyright (c) 2009 Atmel Corporation. All rights reserved.
00015  *
00016  * Redistribution and use in source and binary forms, with or without
00017  * modification, are permitted provided that the following conditions are met:
00018  *
00019  * 1. Redistributions of source code must retain the above copyright notice,
00020  * this list of conditions and the following disclaimer.
00021  *
00022  * 2. Redistributions in binary form must reproduce the above copyright notice,
00023  * this list of conditions and the following disclaimer in the documentation
00024  * and/or other materials provided with the distribution.
00025  *
00026  * 3. The name of Atmel may not be used to endorse or promote products derived
00027  * from this software without specific prior written permission.
00028  *
00029  * 4. This software may only be redistributed and used in connection with an Atmel
00030  * AVR product.
00031  *
00032  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
00033  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00034  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND
00035  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00036  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00037  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00038  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00039  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00040  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00041  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00042  */
00043 
00044 //_____  I N C L U D E S ___________________________________________________
00045 
00046 #include "config.h"
00047 #include "conf_usb.h"
00048 
00049 // File system includes required for SYNC mode
00050 #if (HOST_SYNC_MODE==ENABLE)
00051    #include "modules/file_system/fat.h"
00052    #include "modules/file_system/fs_com.h"
00053    #include "modules/file_system/navigation.h"
00054    #include "modules/file_system/file.h"
00055 #endif
00056 
00057 #include "host_ms_task.h"
00058 #include "lib_mem/host_mem/host_mem.h"
00059 #include "modules/usb/host_chap9/usb_host_task.h"
00060 #include "modules/file_system/nav_utils.h"
00061 
00062 
00063 //_____ M A C R O S ________________________________________________________
00064 
00065 #ifndef HOST_SYNC_MODE
00066 #warning HOST_SYNC_MODE not defined as ENABLE or DISABLE, using DISABLE...
00067 #define HOST_SYNC_MODE  DISABLE
00068 #endif
00069 
00070 
00071 
00072 //_____ D E C L A R A T I O N S ____________________________________________
00073 
00075 volatile U8 host_cpt_sof;
00076 
00077 #if (HOST_SYNC_MODE==ENABLE)
00079    U8 code dir_usb_out_name[]=DIR_USB_OUT_NAME;
00081    U8 code dir_usb_in_name[]=DIR_USB_IN_NAME;
00083    U8 code dir_local_out_name[]=DIR_LOCAL_OUT_NAME;
00085    U8 code dir_local_in_name[]=DIR_LOCAL_IN_NAME;
00087    U8 sync_on_going=0;
00089    U8 ms_str_ram[MAX_FILE_LENGHT];
00090 #endif
00091 
00092 
00095 void host_ms_task_init(void)
00096 {
00097    Leds_init();
00098 #if (HOST_SYNC_MODE==ENABLE)
00099    Joy_init();
00100 #endif
00101    host_mem_init();
00102 }
00103 
00104 
00107 void host_ms_task(void)
00108 {
00109    if( Is_host_ready() )   
00110    {
00111       // Here, Enumeration successfull, device is operationnal
00112       if(Is_new_device_connection_event())
00113       {
00114          // Update MS driver in case of
00115          if( host_mem_install() )
00116          {
00117             Led1_on();
00118          }
00119       }
00120 
00121 #if (HOST_SYNC_MODE==ENABLE)  // Sync operating mode(if available)
00122       if( 0 != host_mem_get_lun() )
00123       {
00124          if(Is_joy_right())   // Sync device to host stream
00125          {
00126             Led0_on();
00127             sync_on_going=1;
00128             copy_dir( (U8 code *)dir_usb_out_name, (U8 code *)dir_local_in_name, 1 );
00129             sync_on_going=0;
00130             Led3_off();
00131             Led0_off();
00132          }
00133          if(Is_joy_left())    // Sync host to device stream
00134          {
00135             Led0_on();
00136             sync_on_going=1;
00137             copy_dir( (U8 code *)dir_local_out_name, (U8 code *)dir_usb_in_name, 1 );
00138             sync_on_going=0;
00139             Led0_off();
00140             Led3_off();
00141          }
00142       }
00143 #endif
00144    }
00145 
00146    // Device disconnection...
00147    if( Is_device_disconnection_event() )
00148    {
00149       // Update MS driver in case of
00150       host_mem_uninstall();
00151       Led1_off();
00152    }
00153 }
00154 
00155 
00159 void host_sof_action(void)
00160 {
00161    host_cpt_sof++;
00162    #if (HOST_SYNC_MODE==ENABLE)
00163    if(host_cpt_sof==0 &&sync_on_going) Led3_toggle();
00164    #endif
00165 }
00166 

Generated on Wed Sep 23 09:17:02 2009 for ATMEL by  doxygen 1.5.3