ATMEL: usb_host_task.h Source File

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

# usb_host_task.h

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 #ifndef _USB_HOST_TASK_H_
    00045 #define _USB_HOST_TASK_H_
    00046
    00047 //_____ I N C L U D E S ____________________________________________________
    00048
    00049 #if (USB_HUB_SUPPORT==ENABLE)
    00050 #include "modules/usb/host_chap9/usb_host_hub.h"
    00051 #endif
    00052
    00053 //_____ T Y P E S  _________________________________________________________
    00054
    00055 typedef struct
    00056 {
    00057    bit enable;
    00058    U16 nb_byte_to_process;
    00059    U16 nb_byte_processed;
    00060    U16 nb_byte_on_going;
    00061    U8 *ptr_buf;
    00062    void(*handle)(U8 status, U16 nb_byte);
    00063    U8 status;
    00064    U8 timeout;
    00065    U16 nak_timeout;
    00066 } S_pipe_int;
    00067
    00068
    00069
    00070 //_____ M A C R O S ________________________________________________________
    00071
    00072 #define PIPE_GOOD             0
    00073 #define PIPE_DATA_TOGGLE   0x01
    00074 #define PIPE_DATA_PID      0x02
    00075 #define PIPE_PID           0x04
    00076 #define PIPE_TIMEOUT       0x08
    00077 #define PIPE_CRC16         0x10
    00078 #define PIPE_STALL         0x20
    00079 #define PIPE_NAK_TIMEOUT   0x40
    00080 #define PIPE_DELAY_TIMEOUT 0x80
    00081
    00084
    00088    #define Is_host_ready()        ((device_state==DEVICE_READY)   ? TRUE : FALSE)
    00089
    00091    #define Is_host_not_ready()    ((device_state==DEVICE_READY)   ? FALSE :TRUE)
    00092
    00094    #define Is_host_suspended()    (((device_state==DEVICE_WAIT_RESUME) ||(device_state==DEVICE_SUSPENDED))  ? TRUE : FALSE)
    00095
    00097    #define Is_host_not_suspended()    (((device_state==DEVICE_WAIT_RESUME) ||(device_state==DEVICE_SUSPENDED))  ? FALSE : TRUE)
    00098
    00100    #define Is_host_unattached()   ((device_state==DEVICE_UNATTACHED)   ? TRUE : FALSE)
    00101
    00103    #define Is_host_attached()     ((device_state>=DEVICE_UNATTACHED)   ? TRUE : FALSE)
    00104
    00106    #define Host_request_suspend()     (device_state=DEVICE_SUSPENDED)
    00107
    00109    #define Host_request_resume()      (request_resume=TRUE)
    00110
    00112    #define Host_ack_request_resume()  (request_resume=FALSE)
    00113
    00115    #define Host_force_enumeration()    (force_enumeration=TRUE, device_state=DEVICE_ATTACHED, init_usb_tree())
    00116
    00118    #define Is_host_request_resume()   ((request_resume==TRUE)   ? TRUE : FALSE)
    00119
    00121    #define Is_new_device_connection_event()   (new_device_connected ? TRUE : FALSE)
    00122
    00124 #if (USB_HUB_SUPPORT==ENABLE)
    00125    #define Is_device_disconnection_event()   ((device_state==DEVICE_DISCONNECTED_ACK || device_state==DEVICE_DISCONNECTED || f_hub_port_disconnect) ? TRUE : FALSE)
    00126 #else
    00127    #define Is_device_disconnection_event()   ((device_state==DEVICE_DISCONNECTED_ACK || device_state==DEVICE_DISCONNECTED) ? TRUE : FALSE)
    00128 #endif
    00129
    00131    #define Host_stop_pipe_interrupt(i) (\
    00132          Host_disable_transmit_interrupt(), \
    00133          Host_disable_receive_interrupt(), \
    00134          Host_disable_stall_interrupt(), \
    00135          Host_disable_error_interrupt(), \
    00136          Host_disable_nak_interrupt(), \
    00137          Host_reset_pipe(i))
    00138
    00143    #define DEVICE_UNATTACHED        0
    00144    #define DEVICE_ATTACHED          1
    00145    #define DEVICE_POWERED           2
    00146    #define DEVICE_DEFAULT           3
    00147    #define DEVICE_ADDRESSED         4
    00148    #define DEVICE_CONFIGURED        5
    00149    #define DEVICE_READY             6
    00150
    00151    #define DEVICE_ERROR             7
    00152
    00153    #define DEVICE_SUSPENDED         8
    00154    #define DEVICE_WAIT_RESUME       9
    00155
    00156    #define DEVICE_DISCONNECTED      10
    00157    #define DEVICE_DISCONNECTED_ACK  11
    00158
    00159    #define Host_set_device_supported()   (device_status |=  0x01)
    00160    #define Host_clear_device_supported() (device_status &= ~0x01)
    00161    #define Is_host_device_supported()    (device_status &   0x01)
    00162
    00163    #define Host_set_device_ready()       (device_status |=  0x02)
    00164    #define Host_clear_device_ready()     (device_status &= ~0x02)
    00165    #define Is_host_device_ready()        (device_status &   0x02)
    00166
    00167    #define Host_set_configured()      (device_status |=  0x04)
    00168    #define Host_clear_configured()    (device_status &= ~0x04)
    00169    #define Is_host_configured()       (device_status &   0x04)
    00170
    00171    #define Host_clear_device_status()    (device_status =   0x00)
    00173
    00174
    00175
    00176 //_____ D E C L A R A T I O N S ____________________________________________
    00177
    00189 void usb_host_task_init     (void);
    00190
    00208 void usb_host_task          (void);
    00209
    00222 U8 host_send_data(U8 pipe, U16 nb_data, U8 *buf);
    00223
    00239 U8 host_get_data(U8 pipe, U16 *nb_data, U8 *buf);
    00240
    00241 U8 host_get_data_interrupt(U8 pipe, U16 nb_data, U8 *buf, void  (*handle)(U8 status, U16 nb_byte));
    00242
    00243 U8 host_send_data_interrupt(U8 pipe, U16 nb_data, U8 *buf, void  (*handle)(U8 status, U16 nb_byte));
    00244
    00245 void reset_it_pipe_str(void);
    00246
    00247 U8 is_any_interrupt_pipe_active(void);
    00248
    00249 extern U8 device_state;
    00250 extern U8 request_resume;
    00251 extern U8 new_device_connected;
    00252 extern U8 force_enumeration;
    00253
    00254
    00256
    00257
    00258 #endif /* _USB_HOST_TASK_H_ */
    00259