00001 /* USB driver */ 00002 00003 00004 /* Copyright (C) 2009 ThomasKlosa 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) version 3. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program; if not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef USB_H 00021 #define USB_H 00022 00028 /* for USB FIFO pin definitions */ 00029 #include "xpal_board.h" 00030 00033 void USBInit( void ); 00036 void USB_assign_stdio (void); 00037 00044 inline uint8_t USB_rx_ready (void) 00045 { 00046 return ((HL_USB_RXF_PIN & _BV(HL_USB_RXF)) == 0); 00047 } 00048 00051 typedef enum { 00052 USB_STDIN, 00053 USB_STDOUT, 00054 } USB_stream_sel_t; 00055 00058 typedef enum { 00059 USB_flag_clear = 0, 00060 USB_flag_toggle = 1, 00061 USB_flag_set = 2, 00062 USB_flag_assign = 3, 00063 } USB_flag_action_t; 00064 00065 typedef uint8_t USB_flags_t; 00066 00073 int8_t USB_set_flags (USB_stream_sel_t usb_stream, 00074 USB_flag_action_t action, 00075 USB_flags_t flags); 00076 00079 int8_t USB_get_flags (USB_stream_sel_t usb_stream, 00080 USB_flags_t * flags); 00081 00084 #define USB_FLAG_NONBLOCK (0x01) 00085 00086 00089 typedef struct USB_statistics_s { 00090 uint16_t bytes_in; 00091 uint16_t bytes_out; 00092 } USB_statistics_t; 00093 00094 extern USB_statistics_t USB_statistics; 00095 00096 #endif