- Main Page
- Modules
- Data Structures
- Files
- Related Pages

# usb_host_task.h

Go to the documentation of this file.

    00001 /*This file has been prepared for Doxygen automatic documentation generation.*/
    00013
    00014 /* Copyright (c) 2007, 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  * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
    00030  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    00031  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND
    00032  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
    00033  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    00034  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    00035  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    00036  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    00037  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    00038  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00039  */
    00040
    00041 #ifndef _USB_HOST_TASK_H_
    00042 #define _USB_HOST_TASK_H_
    00043
    00044 //_____ I N C L U D E S ____________________________________________________
    00045
    00046 #if (USB_HUB_SUPPORT==ENABLE)
    00047 #include "modules/usb/host_chap9/usb_host_hub.h"
    00048 #endif
    00049
    00050 //_____ T Y P E S  _________________________________________________________
    00051
    00052 typedef struct
    00053 {
    00054    bit enable;
    00055    U16 nb_byte_to_process;
    00056    U16 nb_byte_processed;
    00057    U16 nb_byte_on_going;
    00058    U8 *ptr_buf;
    00059    void(*handle)(U8 status, U16 nb_byte);
    00060    U8 status;
    00061    U8 timeout;
    00062    U16 nak_timeout;
    00063 } S_pipe_int;
    00064
    00065
    00066
    00067 //_____ M A C R O S ________________________________________________________
    00068
    00069 #define PIPE_GOOD             0
    00070 #define PIPE_DATA_TOGGLE   0x01
    00071 #define PIPE_DATA_PID      0x02
    00072 #define PIPE_PID           0x04
    00073 #define PIPE_TIMEOUT       0x08
    00074 #define PIPE_CRC16         0x10
    00075 #define PIPE_STALL         0x20
    00076 #define PIPE_NAK_TIMEOUT   0x40
    00077 #define PIPE_DELAY_TIMEOUT 0x80
    00078
    00081
    00085    #define Is_host_ready()        ((device_state==DEVICE_READY)   ? TRUE : FALSE)
    00086
    00088    #define Is_host_not_ready()    ((device_state==DEVICE_READY)   ? FALSE :TRUE)
    00089
    00091    #define Is_host_suspended()    (((device_state==DEVICE_WAIT_RESUME) ||(device_state==DEVICE_SUSPENDED))  ? TRUE : FALSE)
    00092
    00094    #define Is_host_not_suspended()    (((device_state==DEVICE_WAIT_RESUME) ||(device_state==DEVICE_SUSPENDED))  ? FALSE : TRUE)
    00095
    00097    #define Is_host_unattached()   ((device_state==DEVICE_UNATTACHED)   ? TRUE : FALSE)
    00098
    00100    #define Is_host_attached()     ((device_state>=DEVICE_UNATTACHED)   ? TRUE : FALSE)
    00101
    00103    #define Host_request_suspend()     (device_state=DEVICE_SUSPENDED)
    00104
    00106    #define Host_request_resume()      (request_resume=TRUE)
    00107
    00109    #define Host_ack_request_resume()  (request_resume=FALSE)
    00110
    00112    #define Host_force_enumeration()    (force_enumeration=TRUE, device_state=DEVICE_ATTACHED, init_usb_tree())
    00113
    00115    #define Is_host_request_resume()   ((request_resume==TRUE)   ? TRUE : FALSE)
    00116
    00118    #define Is_new_device_connection_event()   (new_device_connected ? TRUE : FALSE)
    00119
    00121 #if (USB_HUB_SUPPORT==ENABLE)
    00122    #define Is_device_disconnection_event()   ((device_state==DEVICE_DISCONNECTED_ACK || device_state==DEVICE_DISCONNECTED || f_hub_port_disconnect) ? TRUE : FALSE)
    00123 #else
    00124    #define Is_device_disconnection_event()   ((device_state==DEVICE_DISCONNECTED_ACK || device_state==DEVICE_DISCONNECTED) ? TRUE : FALSE)
    00125 #endif
    00126
    00128    #define Host_stop_pipe_interrupt(i) (\
    00129          Host_disable_transmit_interrupt(), \
    00130          Host_disable_receive_interrupt(), \
    00131          Host_disable_stall_interrupt(), \
    00132          Host_disable_error_interrupt(), \
    00133          Host_disable_nak_interrupt(), \
    00134          Host_reset_pipe(i))
    00135
    00140    #define DEVICE_UNATTACHED        0
    00141    #define DEVICE_ATTACHED          1
    00142    #define DEVICE_POWERED           2
    00143    #define DEVICE_DEFAULT           3
    00144    #define DEVICE_ADDRESSED         4
    00145    #define DEVICE_CONFIGURED        5
    00146    #define DEVICE_READY             6
    00147
    00148    #define DEVICE_ERROR             7
    00149
    00150    #define DEVICE_SUSPENDED         8
    00151    #define DEVICE_WAIT_RESUME       9
    00152
    00153    #define DEVICE_DISCONNECTED      10
    00154    #define DEVICE_DISCONNECTED_ACK  11
    00155
    00156    #define Host_set_device_supported()   (device_status |=  0x01)
    00157    #define Host_clear_device_supported() (device_status &= ~0x01)
    00158    #define Is_host_device_supported()    (device_status &   0x01)
    00159
    00160    #define Host_set_device_ready()       (device_status |=  0x02)
    00161    #define Host_clear_device_ready()     (device_status &= ~0x02)
    00162    #define Is_host_device_ready()        (device_status &   0x02)
    00163
    00164    #define Host_set_configured()      (device_status |=  0x04)
    00165    #define Host_clear_configured()    (device_status &= ~0x04)
    00166    #define Is_host_configured()       (device_status &   0x04)
    00167
    00168    #define Host_clear_device_status()    (device_status =   0x00)
    00170
    00171
    00172
    00173 //_____ D E C L A R A T I O N S ____________________________________________
    00174
    00186 void usb_host_task_init     (void);
    00187
    00205 void usb_host_task          (void);
    00206
    00219 U8 host_send_data(U8 pipe, U16 nb_data, U8 *buf);
    00220
    00236 U8 host_get_data(U8 pipe, U16 *nb_data, U8 *buf);
    00237
    00238 U8 host_get_data_interrupt(U8 pipe, U16 nb_data, U8 *buf, void  (*handle)(U8 status, U16 nb_byte));
    00239
    00240 U8 host_send_data_interrupt(U8 pipe, U16 nb_data, U8 *buf, void  (*handle)(U8 status, U16 nb_byte));
    00241
    00242 void reset_it_pipe_str(void);
    00243
    00244 U8 is_any_interrupt_pipe_active(void);
    00245
    00246 extern U8 device_state;
    00247 extern U8 request_resume;
    00248 extern U8 new_device_connected;
    00249 extern U8 force_enumeration;
    00250
    00251
    00253
    00254
    00255 #endif /* _USB_HOST_TASK_H_ */
    00256