Xmega Application Note | |||||
Copyright (c) 2010, Atmel Corporation All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file usb_drv.h.
Go to the source code of this file.
Defines | |
#define | EP_1 1 |
#define | EP_2 2 |
#define | EP_3 3 |
#define | EP_4 4 |
#define | EP_5 5 |
#define | EP_6 6 |
#define | EP_7 7 |
#define | EP_CONTROL 0 |
#define | Get_pipe_token(x) ((x & (0x80)) ? TOKEN_IN : TOKEN_OUT) |
#define | Is_bconnection_error_interrupt_enabled() ((OTGIEN & (1<<BCERRE)) ? true : false) |
#define | Is_endpoint_configured() ((UESTA0X & (1<<CFGOK)) ? true : false) |
#define | Is_hnp_error_interrupt_enabled() ((OTGIEN & (1<<HNPERRE)) ? true : false) |
#define | Is_otg_cache_bconnection_error(x) (((x) & MSK_BCERRI)) |
#define | Is_remote_wake_up_interrupt_enabled() ((UDIEN & (1<<UPRSME)) ? true : false) |
#define | Is_reset_interrupt_enabled() ((UDIEN & (1<<EORSTE)) ? true : false) |
#define | Is_resume_interrupt_enabled() ((UDIEN & (1<<EORSME)) ? true : false) |
#define | Is_role_exchange_interrupt_enabled() ((OTGIEN & (1<<ROLEEXE)) ? true : false) |
#define | Is_sof_interrupt_enabled() ((UDIEN & (1<<SOFE)) ? true : false) |
#define | Is_srp_interrupt_enabled() ((OTGIEN & (1<<SRPE)) ? true : false) |
#define | Is_suspend_interrupt_enabled() ((UDIEN & (1<<SUSPE)) ? true : false) |
#define | Is_suspend_time_out_interrupt_enabled() ((OTGIEN & (1<<STOE)) ? true : false) |
#define | Is_swake_up_interrupt_enabled() ((UDIEN & (1<<WAKEUPE)) ? true : false) |
#define | Is_usb_bconnection_error_interrupt() ((OTGINT & (1<<BCERRI)) ? true : false) |
#define | Is_usb_cache_id_transition(x) (((x) & (1<<IDTI)) ) |
#define | Is_usb_cache_vbus_transition(x) (((x) & (1<<VBUSTI))) |
#define | Is_usb_clock_freezed() ((USBCON & (1<<FRZCLK)) ? true : false) |
#define | Is_usb_detached() ((UDCON & (1<<DETACH)) ? true : false) |
#define | Is_usb_device_srp() ((OTGCON & (1<<SRPREQ)) ? true : false) |
#define | Is_usb_enabled() ((USBCON & (1<<USBE)) ? true : false) |
#define | Is_usb_endpoint_enabled() ((UECONX & (1<<EPEN)) ? true : false) |
#define | Is_usb_endpoint_event() (Usb_interrupt_flags()) |
#define | Is_usb_endpoint_stall_requested() ((UECONX & (1<<STALLRQ)) ? true : false) |
#define | Is_usb_frame_number_crc_error() ((UDMFN & (1<<FNCERR)) ? true : false) |
#define | Is_usb_hnp() ((OTGCON & (1<<HNPREQ)) ? true : false) |
#define | Is_usb_hnp_error_interrupt() ((OTGINT & (1<<HNPERRI)) ? true : false) |
#define | Is_usb_host_enabled() ((USBCON & (1<<HOST)) ? true : false) |
#define | Is_usb_id_device() ((USBSTA & (1<<ID)) ? true : false) |
#define | Is_usb_id_interrupt_enabled() ((USBCON & (1<<IDTE)) ? true : false) |
#define | Is_usb_id_transition() ((USBINT & (1<<IDTI)) ? true : false) |
#define | Is_usb_in_ready() (UEINTX&(1<<TXINI)) |
#define | Is_usb_one_bank_busy() ((UESTA0X & MSK_NBUSYBK) == 0 ? false : true) |
#define | Is_usb_overflow() ((UESTA0X & (1<<OVERFI)) ? true : false) |
#define | Is_usb_pending_remote_wake_up() ((UDCON & (1<<RMWKUP)) ? true : false) |
#define | Is_usb_read_control_enabled() (UEINTX&(1<<TXINI)) |
#define | Is_usb_read_enabled() (UEINTX&(1<<RWAL)) |
#define | Is_usb_receive_out() (UEINTX&(1<<RXOUTI)) |
#define | Is_usb_receive_setup() (UEINTX&(1<<RXSTPI)) |
#define | Is_usb_regulator_enabled() ((UHWCON & (1<<UVREGE)) ? true : false) |
#define | Is_usb_remote_wake_up_start() ((UDINT & (1<<UPRSMI)) ? true : false) |
#define | Is_usb_reset() ((UDINT & (1<<EORSTI)) ? true : false) |
#define | Is_usb_resume() ((UDINT & (1<<EORSMI)) ? true : false) |
#define | Is_usb_role_exchange_interrupt() ((OTGINT & (1<<ROLEEXI)) ? true : false) |
#define | Is_usb_sof() ((UDINT & (1<<SOFI)) ? true : false) |
#define | Is_usb_srp_interrupt() ((OTGINT & (1<<SRPI)) ? true : false) |
#define | Is_usb_suspend() ((UDINT & (1<<SUSPI)) ? true : false) |
#define | Is_usb_suspend_time_out_interrupt() ((OTGINT & (1<<STOI)) ? true : false) |
#define | Is_usb_underflow() ((UESTA0X & (1<<UNDERFI)) ? true : false) |
#define | Is_usb_vbus_enabled() ((OTGCON & (1<<VBUSREQ)) ? true : false) |
#define | Is_usb_vbus_error_interrupt() ((OTGINT & (1<<VBERRI)) ? true : false) |
#define | Is_usb_vbus_high() ((USBSTA & (1<<VBUS)) ? true : false) |
#define | Is_usb_vbus_interrupt_enabled() ((USBCON & (1<<VBUSTE)) ? true : false) |
#define | Is_usb_vbus_low() ((USBSTA & (1<<VBUS)) ? false : true) |
#define | Is_usb_vbus_transition() ((USBINT & (1<<VBUSTI)) ? true : false) |
#define | Is_usb_wake_up() ((UDINT & (1<<WAKEUPI)) ? true : false) |
#define | Is_usb_write_enabled() (UEINTX&(1<<RWAL)) |
#define | Is_usb_zlp() ((UESTA0X & (1<<ZLPSEEN)) ? true : false) |
#define | Is_vbus_error_interrupt_enabled() ((OTGIEN & (1<<VBERRE)) ? true : false) |
#define | MAX_EP_NB 7 |
#define | MSK_BYCTH 0x07 |
#define | MSK_BYCTL 0xFF |
#define | MSK_CURRBK 0x03 |
#define | MSK_DAT 0xFF |
#define | MSK_DTSEQ 0x0C |
#define | MSK_EP_DIR 0x7F |
#define | MSK_EPBK 0x0C |
#define | MSK_EPINT 0x7F |
#define | MSK_EPSIZE 0x70 |
#define | MSK_EPTYPE 0xC0 |
#define | MSK_ERROR 0x1F |
#define | MSK_HADDR 0xFF |
#define | MSK_NBUSYBK 0x03 |
#define | MSK_NBUSYBK 0x03 |
#define | MSK_PBK 0x0C |
#define | MSK_PBK 0x0C |
#define | MSK_PEPNUM 0x0F |
#define | MSK_PEPNUM 0x0F |
#define | MSK_PNUM 0x07 |
#define | MSK_PRST 0x7F |
#define | MSK_PSIZE 0x70 |
#define | MSK_PSIZE 0x70 |
#define | MSK_PTOKEN 0x30 |
#define | MSK_PTOKEN 0x30 |
#define | MSK_PTYPE 0xC0 |
#define | MSK_PTYPE 0xC0 |
#define | MSK_TOKEN_IN 0x10 |
#define | MSK_TOKEN_OUT 0x20 |
#define | MSK_TOKEN_SETUP 0x30 |
#define | MSK_UADD 0x7F |
#define | PIPE_0 0 |
#define | PIPE_1 1 |
#define | PIPE_2 2 |
#define | PIPE_3 3 |
#define | PIPE_4 4 |
#define | PIPE_5 5 |
#define | PIPE_6 6 |
#define | PIPE_7 7 |
#define | PIPE_CONTROL 0 |
#define | Usb_ack_all_device_interrupt() (UDINT = ~(1<<UDIEN)) |
#define | Usb_ack_all_general_interrupt() (USBINT = ~(USBCON & MSK_IDTE_VBUSTE)) |
#define | Usb_ack_all_otg_interrupt() (OTGINT = ~OTGIEN) |
#define | Usb_ack_bconnection_error_interrupt() (OTGINT &= ~(1<<BCERRI)) |
#define | Usb_ack_cache_bconnection_error(x) ((x) &= ~MSK_BCERRI) |
#define | Usb_ack_cache_id_transition(x) ((x) &= ~(1<<IDTI)) |
#define | Usb_ack_cache_vbus_transition(x) ((x) &= ~(1<<VBUSTI)) |
#define | Usb_ack_control_out() (UEINTX &= ~(1<<RXOUTI)) |
#define | Usb_ack_fifocon() (UEINTX &= ~(1<<FIFOCON)) |
#define | Usb_ack_hnp_error_interrupt() (OTGINT &= ~(1<<HNPERRI)) |
#define | Usb_ack_id_transition() (USBINT = ~(1<<IDTI)) |
#define | Usb_ack_in_ready() (UEINTX &= ~(1<<TXINI), Usb_ack_fifocon()) |
#define | Usb_ack_nak_in() (UEINTX &= ~(1<<NAKINI)) |
#define | Usb_ack_nak_out() (UEINTX &= ~(1<<NAKOUTI)) |
#define | Usb_ack_overflow_interrupt() (UESTA0X &= ~(1<<OVERFI)) |
#define | Usb_ack_receive_out() (UEINTX &= ~(1<<RXOUTI), Usb_ack_fifocon()) |
#define | Usb_ack_receive_setup() (UEINTX &= ~(1<<RXSTPI)) |
#define | Usb_ack_remote_wake_up_start() (UDINT = ~(1<<UPRSMI)) |
#define | Usb_ack_reset() (UDINT = ~(1<<EORSTI)) |
#define | Usb_ack_resume() (UDINT = ~(1<<EORSMI)) |
#define | Usb_ack_role_exchange_interrupt() (OTGINT &= ~(1<<ROLEEXI)) |
#define | Usb_ack_sof() (UDINT = ~(1<<SOFI)) |
#define | Usb_ack_srp_interrupt() (OTGINT &= ~(1<<SRPI)) |
#define | Usb_ack_stalled() (MSK_STALLEDI= 0) |
#define | Usb_ack_suspend() (UDINT = ~(1<<SUSPI)) |
#define | Usb_ack_suspend_time_out_interrupt() (OTGINT &= ~(1<<STOI)) |
#define | Usb_ack_underflow_interrupt() (UESTA0X &= ~(1<<UNDERFI)) |
#define | Usb_ack_vbus_error_interrupt() (OTGINT &= ~(1<<VBERRI)) |
#define | Usb_ack_vbus_transition() (USBINT = ~(1<<VBUSTI)) |
#define | Usb_ack_wake_up() (UDINT = ~(1<<WAKEUPI)) |
#define | Usb_ack_zlp() (UESTA0X &= ~(1<<ZLPSEEN)) |
#define | Usb_allocate_memory() (UECFG1X |= (1<<ALLOC)) |
#define | Usb_attach() (UDCON &= ~(1<<DETACH)) |
#define | Usb_build_ep_config0(type, dir, nyet) ((type<<6) | (nyet<<1) | (dir)) |
#define | Usb_build_ep_config1(size, bank) ((size<<4) | (bank<<2)) |
#define | Usb_byte_counter() ((((uint16_t)UEBCHX) << 8) | (UEBCLX)) |
#define | Usb_byte_counter_8() ((uint8_t)UEBCLX) |
#define | Usb_configure_address(addr) (UDADDR = (UDADDR & (1<<ADDEN)) | ((uint8_t)addr & MSK_UADD)) |
#define | usb_configure_endpoint(num, type, dir, size, bank, nyet) |
#define | Usb_configure_endpoint_bank(bank) (UECFG1X = (UECFG1X & ~MSK_EPBK) | ((uint8_t)bank << 2)) |
#define | Usb_configure_endpoint_direction(dir) (UECFG0X = (UECFG0X & ~(1<<EPDIR)) | ((uint8_t)dir)) |
#define | Usb_configure_endpoint_size(size) (UECFG1X = (UECFG1X & ~MSK_EPSIZE) | ((uint8_t)size << 4)) |
#define | Usb_configure_endpoint_type(type) (UECFG0X = (UECFG0X & ~(MSK_EPTYPE)) | ((uint8_t)type << 6)) |
#define | Usb_control_direction() ((UESTA1X & (1<<CTRLDIR)) >> 2) |
#define | Usb_current_bank() ( UESTA1X & MSK_CURRBK) |
#define | Usb_data_toggle() ((UESTA0X&MSK_DTSEQ) >> 2) |
#define | Usb_detach() (UDCON |= (1<<DETACH)) |
#define | Usb_device_initiate_hnp() (OTGCON |= (1<<HNPREQ)) |
#define | Usb_device_initiate_srp() (OTGCON |= (1<<SRPREQ)) |
#define | Usb_disable() (USBCON &= ~((1<<USBE) | (1<<OTGPADE))) |
#define | Usb_disable_address() (UDADDR &= ~(1<<ADDEN)) |
#define | Usb_disable_bconnection_error_interrupt() (OTGIEN &= ~(1<<BCERRE)) |
#define | Usb_disable_endpoint() (UECONX &= ~(1<<EPEN)) |
#define | Usb_disable_flow_error_interrupt() (UEIENX &= ~(1<<FLERRE)) |
#define | Usb_disable_hnp_error_interrupt() (OTGIEN &= ~(1<<HNPERRE)) |
#define | Usb_disable_id_interrupt() (USBCON &= ~(1<<IDTE)) |
#define | Usb_disable_in_ready_interrupt() (UEIENX &= ~(1<<TXIN)) |
#define | Usb_disable_nak_in_interrupt() (UEIENX &= ~(1<<NAKINE)) |
#define | Usb_disable_nak_out_interrupt() (UEIENX &= ~(1<<NAKOUTE)) |
#define | Usb_disable_receive_out_interrupt() (UEIENX &= ~(1<<RXOUTE)) |
#define | Usb_disable_receive_setup_interrupt() (UEIENX &= ~(1<<RXSTPE)) |
#define | Usb_disable_regulator() (UHWCON &= ~(1<<UVREGE)) |
#define | Usb_disable_remote_wake_up_interrupt() (UDIEN &= ~(1<<UPRSME)) |
#define | Usb_disable_reset_interrupt() (UDIEN &= ~(1<<EORSTE)) |
#define | Usb_disable_resume_interrupt() (UDIEN &= ~(1<<EORSME)) |
#define | Usb_disable_role_exchange_interrupt() (OTGIEN &= ~(1<<ROLEEXE)) |
#define | Usb_disable_sof_interrupt() (UDIEN &= ~(1<<SOFE)) |
#define | Usb_disable_srp_interrupt() (OTGIEN &= ~(1<<SRPE)) |
#define | Usb_disable_stall_handshake() (UECONX |= (1<<STALLRQC)) |
#define | Usb_disable_stalled_interrupt() (UEIENX &= ~(1<<STALLEDE)) |
#define | Usb_disable_suspend_interrupt() (UDIEN &= ~(1<<SUSPE)) |
#define | Usb_disable_suspend_time_out_interrupt() (OTGIEN &= ~(1<<STOE)) |
#define | Usb_disable_uid_pin() (UHWCON &= ~(1<<UIDE)) |
#define | Usb_disable_uvcon_pin() (UHWCON &= ~(1<<UVCONE)) |
#define | Usb_disable_vbus() (OTGCON |= (1<<VBUSRQC)) |
#define | Usb_disable_vbus_error_interrupt() (OTGIEN &= ~(1<<VBERRE)) |
#define | Usb_disable_vbus_hw_control() (OTGCON |= (1<<VBUSHWC)) |
#define | Usb_disable_vbus_interrupt() (USBCON &= ~(1<<VBUSTE)) |
#define | Usb_disable_vbus_pad() (USBCON &= ~(1<<OTGPADE)) |
#define | Usb_disable_wake_up_interrupt() (UDIEN &= ~(1<<WAKEUPE)) |
#define | Usb_enable() (USBCON |= ((1<<USBE) | (1<<OTGPADE))) |
#define | Usb_enable_address() (UDADDR |= (1<<ADDEN)) |
#define | Usb_enable_bconnection_error_interrupt() (OTGIEN |= (1<<BCERRE)) |
#define | Usb_enable_endpoint() (UECONX |= (1<<EPEN)) |
#define | Usb_enable_flow_error_interrupt() (UEIENX |= (1<<FLERRE)) |
#define | Usb_enable_hnp_error_interrupt() (OTGIEN |= (1<<HNPERRE)) |
#define | Usb_enable_id_interrupt() (USBCON |= (1<<IDTE)) |
#define | Usb_enable_in_ready_interrupt() (UEIENX |= (1<<TXIN)) |
#define | Usb_enable_manual_vbus() (PORTE|=0x80,DDRE|=0x80,Usb_disable_uvcon_pin()) |
#define | Usb_enable_nak_in_interrupt() (UEIENX |= (1<<NAKINE)) |
#define | Usb_enable_nak_out_interrupt() (UEIENX |= (1<<NAKOUTE)) |
#define | Usb_enable_receive_out_interrupt() (UEIENX |= (1<<RXOUTE)) |
#define | Usb_enable_receive_setup_interrupt() (UEIENX |= (1<<RXSTPE)) |
#define | Usb_enable_regulator() (UHWCON |= (1<<UVREGE)) |
#define | Usb_enable_remote_wake_up_interrupt() (UDIEN |= (1<<UPRSME)) |
#define | Usb_enable_reset_interrupt() (UDIEN |= (1<<EORSTE)) |
#define | Usb_enable_resume_interrupt() (UDIEN |= (1<<EORSME)) |
#define | Usb_enable_role_exchange_interrupt() (OTGIEN |= (1<<ROLEEXE)) |
#define | Usb_enable_sof_interrupt() (UDIEN |= (1<<SOFE)) |
#define | Usb_enable_srp_interrupt() (OTGIEN |= (1<<SRPE)) |
#define | Usb_enable_stall_handshake() (UECONX |= (1<<STALLRQ)) |
#define | Usb_enable_stalled_interrupt() (UEIENX |= (1<<STALLEDE)) |
#define | Usb_enable_suspend_interrupt() (UDIEN |= (1<<SUSPE)) |
#define | Usb_enable_suspend_time_out_interrupt() (OTGIEN |= (1<<STOE)) |
#define | Usb_enable_uid_pin() (UHWCON |= (1<<UIDE)) |
#define | Usb_enable_uvcon_pin() (UHWCON |= (1<<UVCONE)) |
#define | Usb_enable_vbus() (OTGCON |= (1<<VBUSREQ)) |
#define | Usb_enable_vbus_error_interrupt() (OTGIEN |= (1<<VBERRE)) |
#define | Usb_enable_vbus_hw_control() (OTGCON &= ~(1<<VBUSHWC)) |
#define | Usb_enable_vbus_interrupt() (USBCON |= (1<<VBUSTE)) |
#define | Usb_enable_vbus_pad() (USBCON |= (1<<OTGPADE)) |
#define | Usb_enable_wake_up_interrupt() (UDIEN |= (1<<WAKEUPE)) |
#define | Usb_enter_dpram_mode() (UDPADDH = (1<<DPACC)) |
#define | Usb_exit_dpram_mode() (UDPADDH = (uint8_t)~(1<<DPACC)) |
#define | Usb_force_device_mode() (Usb_disable_uid_pin(), UHWCON |= (1<<UIMOD)) |
#define | Usb_force_host_mode() (Usb_disable_uid_pin(), UHWCON &= ~(1<<UIMOD)) |
#define | Usb_frame_number() ((uint16_t)((((uint16_t)UDFNUMH) << 8) | ((uint16_t)UDFNUML))) |
#define | Usb_free_out_bank() (UEINTX &= ~(1<<FIFOCON)) |
#define | Usb_freeze_clock() (USBCON |= (1<<FRZCLK)) |
#define | Usb_full_speed_mode() (UHWCON |= (1<<UDSS)) |
#define | Usb_get_device_interrupt() (UDINT & (1<<UDIEN)) |
#define | Usb_get_general_interrupt() (USBINT & (USBCON & MSK_IDTE_VBUSTE)) |
#define | Usb_get_otg_interrupt() (OTGINT & OTGIEN) |
#define | Usb_host_accept_hnp() (OTGCON |= (1<<HNPREQ)) |
#define | Usb_host_reject_hnp() (OTGCON &= ~(1<<HNPREQ)) |
#define | Usb_initiate_remote_wake_up() (UDCON |= (1<<RMWKUP)) |
#define | Usb_interrupt_flags() (UEINT != 0x00) |
#define | Usb_kill_last_in_bank() (UENTTX |= (1<<RXOUTI)) |
#define | Usb_low_speed_mode() (UHWCON &= ~(1<<UDSS)) |
#define | Usb_nb_busy_bank() (UESTA0X & MSK_NBUSYBK) |
#define | Usb_read_byte() (UEDATX) |
#define | Usb_read_dpram_byte() (UEDATX) |
#define | Usb_reset_data_toggle() (UECONX |= (1<<RSTDT)) |
#define | Usb_reset_endpoint(ep) (UERST = 1 << (uint8_t)ep, UERST = 0) |
#define | Usb_select_data_srp_method() (OTGCON &= ~(1<<SRPSEL)) |
#define | Usb_select_device() (USBCON &= ~(1<<HOST)) |
#define | Usb_select_endpoint(ep) (UENUM = (uint8_t)ep ) |
#define | Usb_select_ep_for_cpu(ep) (Usb_select_epnum_for_cpu(), Usb_select_endpoint(ep)) |
#define | Usb_select_epnum_for_cpu() (UECONX &= ~(1<<EPNUMS)) |
#define | Usb_select_host() (USBCON |= (1<<HOST)) |
#define | Usb_select_vbus_srp_method() (OTGCON |= (1<<SRPSEL)) |
#define | Usb_send_control_in() (UEINTX &= ~(1<<TXINI)) |
#define | Usb_send_in() (UEINTX &= ~(1<<FIFOCON)) |
#define | Usb_set_dpram_address(addr) (UDPADDH = (1<<DPACC) + ((Uint16)addr >> 8), UDPADDL = (uint8_t)addr) |
#define | Usb_unallocate_memory() (UECFG1X &= ~(1<<ALLOC)) |
#define | Usb_unfreeze_clock() (USBCON &= ~(1<<FRZCLK)) |
#define | Usb_write_byte(byte) (UEDATX = (uint8_t)byte) |
#define | Usb_write_dpram_byte(val) (UEDATX=val) |
#define | Usb_write_word_enum_struc(x) (x) |
Typedefs | |
typedef enum ep_bank | e_ep_bank |
typedef enum ep_dir | e_ep_dir |
typedef enum ep_nyet | e_ep_nyet |
typedef enum ep_size | e_ep_size |
typedef enum ep_token | e_ep_token |
typedef enum ep_type | e_ep_type |
Enumerations | |
enum | ep_bank { ONE_BANK = 0x00, TWO_BANKS = 0x01 } |
enum | ep_dir { DIRECTION_OUT = 0x00, DIRECTION_IN = 0x01 } |
enum | ep_nyet { NYET_DISABLED = 0x00, NYET_ENABLED = 0x01 } |
enum | ep_size { SIZE_8 = 0x00, SIZE_16 = 0x01, SIZE_32 = 0x02, SIZE_64 = 0x03, SIZE_128 = 0x04, SIZE_256 = 0x05, SIZE_512 = 0x06, SIZE_1024 = 0x07 } |
enum | ep_token { TOKEN_SETUP = 0x00, TOKEN_IN = 0x01, TOKEN_OUT = 0x02 } |
enum | ep_type { TYPE_CONTROL = 0x00, TYPE_ISOCHRONOUS = 0x01, TYPE_BULK = 0x02, TYPE_INTERRUPT = 0x03 } |
Functions | |
uint8_t | usb_config_ep (uint8_t, uint8_t) |
This function configures an endpoint with the selected type. | |
uint16_t | usb_get_nb_byte_epw (void) |
void | usb_halt_endpoint (uint8_t) |
This function sends a STALL handshake for the next Host request. A STALL handshake will be send for each next request untill a SETUP or a Clear Halt Feature occurs for this endpoint. | |
uint8_t | usb_init_device (void) |
This function initializes the USB device controller and configures the Default Control Endpoint. | |
uint8_t | usb_read_packet (uint8_t, uint8_t *, uint8_t) |
This function moves the data stored in the selected endpoint fifo to the address specified by *rbuf. | |
void | usb_reset_endpoint (uint8_t) |
uint8_t | usb_select_enpoint_interrupt (void) |
This function select the endpoint where an event occurs and returns the number of this endpoint. If no event occurs on the endpoints, this function returns 0. | |
uint8_t | usb_send_packet (uint8_t, uint8_t *, uint8_t) |
This function moves the data pointed by tbuf to the selected endpoint fifo and sends it through the USB. |
#define EP_CONTROL 0 |
Definition at line 55 of file usb_drv.h.
Referenced by usb_clear_feature(), usb_device_task(), usb_init_device(), and usb_set_feature().
#define Get_pipe_token | ( | x | ) | ((x & (0x80)) ? TOKEN_IN : TOKEN_OUT) |
#define Is_bconnection_error_interrupt_enabled | ( | ) | ((OTGIEN & (1<<BCERRE)) ? true : false) |
#define Is_endpoint_configured | ( | ) | ((UESTA0X & (1<<CFGOK)) ? true : false) |
tests if current endpoint is configured
Definition at line 565 of file usb_drv.h.
Referenced by usb_config_ep().
#define Is_hnp_error_interrupt_enabled | ( | ) | ((OTGIEN & (1<<HNPERRE)) ? true : false) |
#define Is_otg_cache_bconnection_error | ( | x | ) | (((x) & MSK_BCERRI)) |
#define Is_remote_wake_up_interrupt_enabled | ( | ) | ((UDIEN & (1<<UPRSME)) ? true : false) |
#define Is_reset_interrupt_enabled | ( | ) | ((UDIEN & (1<<EORSTE)) ? true : false) |
#define Is_resume_interrupt_enabled | ( | ) | ((UDIEN & (1<<EORSME)) ? true : false) |
#define Is_role_exchange_interrupt_enabled | ( | ) | ((OTGIEN & (1<<ROLEEXE)) ? true : false) |
#define Is_sof_interrupt_enabled | ( | ) | ((UDIEN & (1<<SOFE)) ? true : false) |
#define Is_srp_interrupt_enabled | ( | ) | ((OTGIEN & (1<<SRPE)) ? true : false) |
#define Is_suspend_interrupt_enabled | ( | ) | ((UDIEN & (1<<SUSPE)) ? true : false) |
#define Is_suspend_time_out_interrupt_enabled | ( | ) | ((OTGIEN & (1<<STOE)) ? true : false) |
#define Is_swake_up_interrupt_enabled | ( | ) | ((UDIEN & (1<<WAKEUPE)) ? true : false) |
#define Is_usb_bconnection_error_interrupt | ( | ) | ((OTGINT & (1<<BCERRI)) ? true : false) |
#define Is_usb_cache_id_transition | ( | x | ) | (((x) & (1<<IDTI)) ) |
#define Is_usb_cache_vbus_transition | ( | x | ) | (((x) & (1<<VBUSTI))) |
#define Is_usb_clock_freezed | ( | ) | ((USBCON & (1<<FRZCLK)) ? true : false) |
#define Is_usb_detached | ( | ) | ((UDCON & (1<<DETACH)) ? true : false) |
#define Is_usb_device_srp | ( | ) | ((OTGCON & (1<<SRPREQ)) ? true : false) |
#define Is_usb_enabled | ( | ) | ((USBCON & (1<<USBE)) ? true : false) |
#define Is_usb_endpoint_enabled | ( | ) | ((UECONX & (1<<EPEN)) ? true : false) |
tests if the current endpoint is enabled
Definition at line 521 of file usb_drv.h.
Referenced by usb_clear_feature(), usb_init_device(), and usb_set_feature().
#define Is_usb_endpoint_event | ( | ) | (Usb_interrupt_flags()) |
#define Is_usb_endpoint_stall_requested | ( | ) | ((UECONX & (1<<STALLRQ)) ? true : false) |
#define Is_usb_frame_number_crc_error | ( | ) | ((UDMFN & (1<<FNCERR)) ? true : false) |
#define Is_usb_hnp | ( | ) | ((OTGCON & (1<<HNPREQ)) ? true : false) |
#define Is_usb_hnp_error_interrupt | ( | ) | ((OTGINT & (1<<HNPERRI)) ? true : false) |
#define Is_usb_host_enabled | ( | ) | ((USBCON & (1<<HOST)) ? true : false) |
#define Is_usb_id_device | ( | ) | ((USBSTA & (1<<ID)) ? true : false) |
#define Is_usb_id_interrupt_enabled | ( | ) | ((USBCON & (1<<IDTE)) ? true : false) |
#define Is_usb_id_transition | ( | ) | ((USBINT & (1<<IDTI)) ? true : false) |
#define Is_usb_in_ready | ( | ) | (UEINTX&(1<<TXINI)) |
tests if IN ready
Definition at line 621 of file usb_drv.h.
Referenced by usb_set_address(), and usb_set_interface().
#define Is_usb_one_bank_busy | ( | ) | ((UESTA0X & MSK_NBUSYBK) == 0 ? false : true) |
#define Is_usb_overflow | ( | ) | ((UESTA0X & (1<<OVERFI)) ? true : false) |
#define Is_usb_pending_remote_wake_up | ( | ) | ((UDCON & (1<<RMWKUP)) ? true : false) |
#define Is_usb_read_control_enabled | ( | ) | (UEINTX&(1<<TXINI)) |
tests if read allowed on control endpoint
Definition at line 612 of file usb_drv.h.
Referenced by cdc_get_line_coding(), cdc_set_control_line_state(), cdc_set_line_coding(), and usb_get_descriptor().
#define Is_usb_read_enabled | ( | ) | (UEINTX&(1<<RWAL)) |
tests if endpoint read allowed
Definition at line 606 of file usb_drv.h.
Referenced by usb_read_packet().
#define Is_usb_receive_out | ( | ) | (UEINTX&(1<<RXOUTI)) |
tests if OUT received
Definition at line 618 of file usb_drv.h.
Referenced by cdc_get_line_coding(), cdc_set_line_coding(), uart_usb_test_hit(), usb_get_configuration(), usb_get_descriptor(), and usb_get_status().
#define Is_usb_receive_setup | ( | ) | (UEINTX&(1<<RXSTPI)) |
#define Is_usb_regulator_enabled | ( | ) | ((UHWCON & (1<<UVREGE)) ? true : false) |
#define Is_usb_remote_wake_up_start | ( | ) | ((UDINT & (1<<UPRSMI)) ? true : false) |
#define Is_usb_reset | ( | ) | ((UDINT & (1<<EORSTI)) ? true : false) |
#define Is_usb_resume | ( | ) | ((UDINT & (1<<EORSMI)) ? true : false) |
#define Is_usb_role_exchange_interrupt | ( | ) | ((OTGINT & (1<<ROLEEXI)) ? true : false) |
#define Is_usb_sof | ( | ) | ((UDINT & (1<<SOFI)) ? true : false) |
#define Is_usb_srp_interrupt | ( | ) | ((OTGINT & (1<<SRPI)) ? true : false) |
#define Is_usb_suspend | ( | ) | ((UDINT & (1<<SUSPI)) ? true : false) |
#define Is_usb_suspend_time_out_interrupt | ( | ) | ((OTGINT & (1<<STOI)) ? true : false) |
#define Is_usb_underflow | ( | ) | ((UESTA0X & (1<<UNDERFI)) ? true : false) |
#define Is_usb_vbus_enabled | ( | ) | ((OTGCON & (1<<VBUSREQ)) ? true : false) |
#define Is_usb_vbus_error_interrupt | ( | ) | ((OTGINT & (1<<VBERRI)) ? true : false) |
#define Is_usb_vbus_high | ( | ) | ((USBSTA & (1<<VBUS)) ? true : false) |
#define Is_usb_vbus_interrupt_enabled | ( | ) | ((USBCON & (1<<VBUSTE)) ? true : false) |
#define Is_usb_vbus_low | ( | ) | ((USBSTA & (1<<VBUS)) ? false : true) |
#define Is_usb_vbus_transition | ( | ) | ((USBINT & (1<<VBUSTI)) ? true : false) |
#define Is_usb_wake_up | ( | ) | ((UDINT & (1<<WAKEUPI)) ? true : false) |
#define Is_usb_write_enabled | ( | ) | (UEINTX&(1<<RWAL)) |
tests if endpoint write allowed
Definition at line 609 of file usb_drv.h.
Referenced by uart_usb_putchar(), uart_usb_tx_ready(), and usb_send_packet().
#define Is_usb_zlp | ( | ) | ((UESTA0X & (1<<ZLPSEEN)) ? true : false) |
#define Is_vbus_error_interrupt_enabled | ( | ) | ((OTGIEN & (1<<VBERRE)) ? true : false) |
#define MSK_EP_DIR 0x7F |
Definition at line 75 of file usb_drv.h.
Referenced by usb_clear_feature(), usb_get_status(), and usb_set_feature().
#define Usb_ack_all_device_interrupt | ( | ) | (UDINT = ~(1<<UDIEN)) |
#define Usb_ack_all_general_interrupt | ( | ) | (USBINT = ~(USBCON & MSK_IDTE_VBUSTE)) |
#define Usb_ack_all_otg_interrupt | ( | ) | (OTGINT = ~OTGIEN) |
#define Usb_ack_bconnection_error_interrupt | ( | ) | (OTGINT &= ~(1<<BCERRI)) |
#define Usb_ack_cache_bconnection_error | ( | x | ) | ((x) &= ~MSK_BCERRI) |
#define Usb_ack_cache_id_transition | ( | x | ) | ((x) &= ~(1<<IDTI)) |
#define Usb_ack_cache_vbus_transition | ( | x | ) | ((x) &= ~(1<<VBUSTI)) |
#define Usb_ack_control_out | ( | ) | (UEINTX &= ~(1<<RXOUTI)) |
#define Usb_ack_fifocon | ( | ) | (UEINTX &= ~(1<<FIFOCON)) |
#define Usb_ack_hnp_error_interrupt | ( | ) | (OTGINT &= ~(1<<HNPERRI)) |
#define Usb_ack_in_ready | ( | ) | (UEINTX &= ~(1<<TXINI), Usb_ack_fifocon()) |
#define Usb_ack_nak_in | ( | ) | (UEINTX &= ~(1<<NAKINI)) |
#define Usb_ack_nak_out | ( | ) | (UEINTX &= ~(1<<NAKOUTI)) |
#define Usb_ack_overflow_interrupt | ( | ) | (UESTA0X &= ~(1<<OVERFI)) |
#define Usb_ack_receive_out | ( | ) | (UEINTX &= ~(1<<RXOUTI), Usb_ack_fifocon()) |
acks reveive OUT
Definition at line 594 of file usb_drv.h.
Referenced by cdc_get_line_coding(), cdc_set_line_coding(), uart_usb_getchar(), uart_usb_test_hit(), usb_get_configuration(), usb_get_descriptor(), and usb_get_status().
#define Usb_ack_receive_setup | ( | ) | (UEINTX &= ~(1<<RXSTPI)) |
acks receive SETUP
Definition at line 591 of file usb_drv.h.
Referenced by cdc_get_line_coding(), cdc_set_control_line_state(), cdc_set_line_coding(), usb_clear_feature(), usb_get_configuration(), usb_get_descriptor(), usb_get_interface(), usb_get_status(), usb_process_request(), usb_set_address(), usb_set_configuration(), usb_set_feature(), and usb_set_interface().
#define Usb_ack_remote_wake_up_start | ( | ) | (UDINT = ~(1<<UPRSMI)) |
#define Usb_ack_reset | ( | ) | (UDINT = ~(1<<EORSTI)) |
#define Usb_ack_resume | ( | ) | (UDINT = ~(1<<EORSMI)) |
#define Usb_ack_role_exchange_interrupt | ( | ) | (OTGINT &= ~(1<<ROLEEXI)) |
#define Usb_ack_sof | ( | ) | (UDINT = ~(1<<SOFI)) |
#define Usb_ack_srp_interrupt | ( | ) | (OTGINT &= ~(1<<SRPI)) |
#define Usb_ack_stalled | ( | ) | (MSK_STALLEDI= 0) |
#define Usb_ack_suspend | ( | ) | (UDINT = ~(1<<SUSPI)) |
#define Usb_ack_suspend_time_out_interrupt | ( | ) | (OTGINT &= ~(1<<STOI)) |
#define Usb_ack_underflow_interrupt | ( | ) | (UESTA0X &= ~(1<<UNDERFI)) |
#define Usb_ack_vbus_error_interrupt | ( | ) | (OTGINT &= ~(1<<VBERRI)) |
#define Usb_ack_vbus_transition | ( | ) | (USBINT = ~(1<<VBUSTI)) |
#define Usb_ack_wake_up | ( | ) | (UDINT = ~(1<<WAKEUPI)) |
#define Usb_ack_zlp | ( | ) | (UESTA0X &= ~(1<<ZLPSEEN)) |
#define Usb_allocate_memory | ( | ) | (UECFG1X |= (1<<ALLOC)) |
allocates the current configuration in DPRAM memory
Definition at line 541 of file usb_drv.h.
Referenced by usb_config_ep().
#define Usb_attach | ( | ) | (UDCON &= ~(1<<DETACH)) |
attaches to USB bus
Definition at line 389 of file usb_drv.h.
Referenced by ISR(), usb_device_task(), and usb_start_device().
#define Usb_build_ep_config0 | ( | type, | |||
dir, | |||||
nyet | ) | ((type<<6) | (nyet<<1) | (dir)) |
#define Usb_build_ep_config1 | ( | size, | |||
bank | ) | ((size<<4) | (bank<<2)) |
#define Usb_byte_counter | ( | ) | ((((uint16_t)UEBCHX) << 8) | (UEBCLX)) |
returns number of bytes in FIFO current endpoint (16 bits)
Definition at line 684 of file usb_drv.h.
Referenced by uart_usb_test_hit().
#define Usb_byte_counter_8 | ( | ) | ((uint8_t)UEBCLX) |
#define Usb_configure_address | ( | addr | ) | (UDADDR = (UDADDR & (1<<ADDEN)) | ((uint8_t)addr & MSK_UADD)) |
sets the USB device address
Definition at line 489 of file usb_drv.h.
Referenced by usb_set_address().
#define usb_configure_endpoint | ( | num, | |||
type, | |||||
dir, | |||||
size, | |||||
bank, | |||||
nyet | ) |
Value:
( Usb_select_endpoint(num), \ usb_config_ep(Usb_build_ep_config0(type, dir, nyet), \ Usb_build_ep_config1(size, bank) ))
Definition at line 158 of file usb_drv.h.
Referenced by usb_init_device(), and usb_user_endpoint_init().
#define Usb_configure_endpoint_bank | ( | bank | ) | (UECFG1X = (UECFG1X & ~MSK_EPBK) | ((uint8_t)bank << 2)) |
#define Usb_configure_endpoint_direction | ( | dir | ) | (UECFG0X = (UECFG0X & ~(1<<EPDIR)) | ((uint8_t)dir)) |
#define Usb_configure_endpoint_size | ( | size | ) | (UECFG1X = (UECFG1X & ~MSK_EPSIZE) | ((uint8_t)size << 4)) |
#define Usb_configure_endpoint_type | ( | type | ) | (UECFG0X = (UECFG0X & ~(MSK_EPTYPE)) | ((uint8_t)type << 6)) |
#define Usb_control_direction | ( | ) | ((UESTA1X & (1<<CTRLDIR)) >> 2) |
#define Usb_current_bank | ( | ) | ( UESTA1X & MSK_CURRBK) |
#define Usb_data_toggle | ( | ) | ((UESTA0X&MSK_DTSEQ) >> 2) |
#define Usb_detach | ( | ) | (UDCON |= (1<<DETACH)) |
#define Usb_device_initiate_hnp | ( | ) | (OTGCON |= (1<<HNPREQ)) |
#define Usb_device_initiate_srp | ( | ) | (OTGCON |= (1<<SRPREQ)) |
#define Usb_disable | ( | ) | (USBCON &= ~((1<<USBE) | (1<<OTGPADE))) |
Disable both USB interface and Vbus pad
Definition at line 202 of file usb_drv.h.
Referenced by usb_device_task_init().
#define Usb_disable_address | ( | ) | (UDADDR &= ~(1<<ADDEN)) |
#define Usb_disable_bconnection_error_interrupt | ( | ) | (OTGIEN &= ~(1<<BCERRE)) |
#define Usb_disable_endpoint | ( | ) | (UECONX &= ~(1<<EPEN)) |
#define Usb_disable_flow_error_interrupt | ( | ) | (UEIENX &= ~(1<<FLERRE)) |
#define Usb_disable_hnp_error_interrupt | ( | ) | (OTGIEN &= ~(1<<HNPERRE)) |
#define Usb_disable_id_interrupt | ( | ) | (USBCON &= ~(1<<IDTE)) |
#define Usb_disable_in_ready_interrupt | ( | ) | (UEIENX &= ~(1<<TXIN)) |
#define Usb_disable_nak_in_interrupt | ( | ) | (UEIENX &= ~(1<<NAKINE)) |
#define Usb_disable_nak_out_interrupt | ( | ) | (UEIENX &= ~(1<<NAKOUTE)) |
#define Usb_disable_receive_out_interrupt | ( | ) | (UEIENX &= ~(1<<RXOUTE)) |
#define Usb_disable_receive_setup_interrupt | ( | ) | (UEIENX &= ~(1<<RXSTPE)) |
#define Usb_disable_regulator | ( | ) | (UHWCON &= ~(1<<UVREGE)) |
#define Usb_disable_remote_wake_up_interrupt | ( | ) | (UDIEN &= ~(1<<UPRSME)) |
#define Usb_disable_reset_interrupt | ( | ) | (UDIEN &= ~(1<<EORSTE)) |
#define Usb_disable_resume_interrupt | ( | ) | (UDIEN &= ~(1<<EORSME)) |
#define Usb_disable_role_exchange_interrupt | ( | ) | (OTGIEN &= ~(1<<ROLEEXE)) |
#define Usb_disable_sof_interrupt | ( | ) | (UDIEN &= ~(1<<SOFE)) |
#define Usb_disable_srp_interrupt | ( | ) | (OTGIEN &= ~(1<<SRPE)) |
#define Usb_disable_stall_handshake | ( | ) | (UECONX |= (1<<STALLRQC)) |
disables the STALL handshake
Definition at line 516 of file usb_drv.h.
Referenced by usb_clear_feature().
#define Usb_disable_stalled_interrupt | ( | ) | (UEIENX &= ~(1<<STALLEDE)) |
#define Usb_disable_suspend_interrupt | ( | ) | (UDIEN &= ~(1<<SUSPE)) |
#define Usb_disable_suspend_time_out_interrupt | ( | ) | (OTGIEN &= ~(1<<STOE)) |
#define Usb_disable_uid_pin | ( | ) | (UHWCON &= ~(1<<UIDE)) |
#define Usb_disable_uvcon_pin | ( | ) | (UHWCON &= ~(1<<UVCONE)) |
#define Usb_disable_vbus | ( | ) | (OTGCON |= (1<<VBUSRQC)) |
#define Usb_disable_vbus_error_interrupt | ( | ) | (OTGIEN &= ~(1<<VBERRE)) |
#define Usb_disable_vbus_hw_control | ( | ) | (OTGCON |= (1<<VBUSHWC)) |
#define Usb_disable_vbus_interrupt | ( | ) | (USBCON &= ~(1<<VBUSTE)) |
#define Usb_disable_vbus_pad | ( | ) | (USBCON &= ~(1<<OTGPADE)) |
#define Usb_disable_wake_up_interrupt | ( | ) | (UDIEN &= ~(1<<WAKEUPE)) |
#define Usb_enable | ( | ) | (USBCON |= ((1<<USBE) | (1<<OTGPADE))) |
Enable both USB interface and Vbus pad
Definition at line 199 of file usb_drv.h.
Referenced by usb_device_task_init().
#define Usb_enable_address | ( | ) | (UDADDR |= (1<<ADDEN)) |
enables USB device address
Definition at line 483 of file usb_drv.h.
Referenced by usb_set_address().
#define Usb_enable_bconnection_error_interrupt | ( | ) | (OTGIEN |= (1<<BCERRE)) |
#define Usb_enable_endpoint | ( | ) | (UECONX |= (1<<EPEN)) |
enables the current endpoint
Definition at line 504 of file usb_drv.h.
Referenced by usb_config_ep().
#define Usb_enable_flow_error_interrupt | ( | ) | (UEIENX |= (1<<FLERRE)) |
#define Usb_enable_hnp_error_interrupt | ( | ) | (OTGIEN |= (1<<HNPERRE)) |
#define Usb_enable_in_ready_interrupt | ( | ) | (UEIENX |= (1<<TXIN)) |
#define Usb_enable_manual_vbus | ( | ) | (PORTE|=0x80,DDRE|=0x80,Usb_disable_uvcon_pin()) |
#define Usb_enable_nak_in_interrupt | ( | ) | (UEIENX |= (1<<NAKINE)) |
#define Usb_enable_nak_out_interrupt | ( | ) | (UEIENX |= (1<<NAKOUTE)) |
#define Usb_enable_receive_out_interrupt | ( | ) | (UEIENX |= (1<<RXOUTE)) |
#define Usb_enable_receive_setup_interrupt | ( | ) | (UEIENX |= (1<<RXSTPE)) |
#define Usb_enable_regulator | ( | ) | (UHWCON |= (1<<UVREGE)) |
#define Usb_enable_remote_wake_up_interrupt | ( | ) | (UDIEN |= (1<<UPRSME)) |
#define Usb_enable_reset_interrupt | ( | ) | (UDIEN |= (1<<EORSTE)) |
enables USB reset interrupt
Definition at line 443 of file usb_drv.h.
Referenced by ISR(), usb_device_task(), and usb_start_device().
#define Usb_enable_resume_interrupt | ( | ) | (UDIEN |= (1<<EORSME)) |
#define Usb_enable_role_exchange_interrupt | ( | ) | (OTGIEN |= (1<<ROLEEXE)) |
#define Usb_enable_sof_interrupt | ( | ) | (UDIEN |= (1<<SOFE)) |
enables Start Of Frame Interrupt
Definition at line 456 of file usb_drv.h.
Referenced by cdc_task_init().
#define Usb_enable_srp_interrupt | ( | ) | (OTGIEN |= (1<<SRPE)) |
#define Usb_enable_stall_handshake | ( | ) | (UECONX |= (1<<STALLRQ)) |
enables the STALL handshake for the next transaction
Definition at line 507 of file usb_drv.h.
Referenced by usb_clear_feature(), usb_get_descriptor(), usb_get_interface(), usb_get_status(), usb_halt_endpoint(), usb_process_request(), usb_set_configuration(), and usb_set_feature().
#define Usb_enable_stalled_interrupt | ( | ) | (UEIENX |= (1<<STALLEDE)) |
#define Usb_enable_suspend_interrupt | ( | ) | (UDIEN |= (1<<SUSPE)) |
enables suspend state interrupt
Definition at line 470 of file usb_drv.h.
Referenced by usb_start_device().
#define Usb_enable_suspend_time_out_interrupt | ( | ) | (OTGIEN |= (1<<STOE)) |
#define Usb_enable_uid_pin | ( | ) | (UHWCON |= (1<<UIDE)) |
#define Usb_enable_uvcon_pin | ( | ) | (UHWCON |= (1<<UVCONE)) |
#define Usb_enable_vbus | ( | ) | (OTGCON |= (1<<VBUSREQ)) |
#define Usb_enable_vbus_error_interrupt | ( | ) | (OTGIEN |= (1<<VBERRE)) |
#define Usb_enable_vbus_hw_control | ( | ) | (OTGCON &= ~(1<<VBUSHWC)) |
#define Usb_enable_vbus_interrupt | ( | ) | (USBCON |= (1<<VBUSTE)) |
#define Usb_enable_vbus_pad | ( | ) | (USBCON |= (1<<OTGPADE)) |
#define Usb_enable_wake_up_interrupt | ( | ) | (UDIEN |= (1<<WAKEUPE)) |
#define Usb_exit_dpram_mode | ( | ) | (UDPADDH = (uint8_t)~(1<<DPACC)) |
#define Usb_force_device_mode | ( | ) | (Usb_disable_uid_pin(), UHWCON |= (1<<UIMOD)) |
Disable external UID pin and force device mode
Definition at line 181 of file usb_drv.h.
Referenced by usb_task_init().
#define Usb_force_host_mode | ( | ) | (Usb_disable_uid_pin(), UHWCON &= ~(1<<UIMOD)) |
#define Usb_frame_number | ( | ) | ((uint16_t)((((uint16_t)UDFNUMH) << 8) | ((uint16_t)UDFNUML))) |
#define Usb_free_out_bank | ( | ) | (UEINTX &= ~(1<<FIFOCON)) |
#define Usb_freeze_clock | ( | ) | (USBCON |= (1<<FRZCLK)) |
#define Usb_full_speed_mode | ( | ) | (UHWCON |= (1<<UDSS)) |
#define Usb_get_device_interrupt | ( | ) | (UDINT & (1<<UDIEN)) |
#define Usb_get_general_interrupt | ( | ) | (USBINT & (USBCON & MSK_IDTE_VBUSTE)) |
#define Usb_get_otg_interrupt | ( | ) | (OTGINT & OTGIEN) |
#define Usb_host_accept_hnp | ( | ) | (OTGCON |= (1<<HNPREQ)) |
#define Usb_host_reject_hnp | ( | ) | (OTGCON &= ~(1<<HNPREQ)) |
#define Usb_initiate_remote_wake_up | ( | ) | (UDCON |= (1<<RMWKUP)) |
#define Usb_interrupt_flags | ( | ) | (UEINT != 0x00) |
tests the general endpoint interrupt flags
Definition at line 690 of file usb_drv.h.
Referenced by usb_select_enpoint_interrupt().
#define Usb_kill_last_in_bank | ( | ) | (UENTTX |= (1<<RXOUTI)) |
#define Usb_low_speed_mode | ( | ) | (UHWCON &= ~(1<<UDSS)) |
#define Usb_nb_busy_bank | ( | ) | (UESTA0X & MSK_NBUSYBK) |
#define Usb_read_byte | ( | ) | (UEDATX) |
returns FIFO byte for current endpoint
Definition at line 678 of file usb_drv.h.
Referenced by cdc_set_line_coding(), uart_usb_getchar(), usb_clear_feature(), usb_get_descriptor(), usb_get_status(), usb_process_request(), usb_read_packet(), usb_set_address(), usb_set_configuration(), usb_set_feature(), and usb_user_read_request().
#define Usb_reset_data_toggle | ( | ) | (UECONX |= (1<<RSTDT)) |
resets the data toggle sequence
Definition at line 510 of file usb_drv.h.
Referenced by usb_clear_feature().
#define Usb_reset_endpoint | ( | ep | ) | (UERST = 1 << (uint8_t)ep, UERST = 0) |
resets the selected endpoint
Definition at line 501 of file usb_drv.h.
Referenced by usb_clear_feature(), usb_device_task(), and usb_user_endpoint_init().
#define Usb_select_data_srp_method | ( | ) | (OTGCON &= ~(1<<SRPSEL)) |
#define Usb_select_device | ( | ) | (USBCON &= ~(1<<HOST)) |
Definition at line 211 of file usb_drv.h.
Referenced by usb_device_task_init(), and usb_init_device().
#define Usb_select_endpoint | ( | ep | ) | (UENUM = (uint8_t)ep ) |
selects the endpoint number to interface with the CPU
Definition at line 498 of file usb_drv.h.
Referenced by uart_usb_flush(), uart_usb_getchar(), uart_usb_putchar(), uart_usb_test_hit(), usb_clear_feature(), usb_device_task(), usb_halt_endpoint(), usb_init_device(), usb_read_packet(), usb_send_packet(), and usb_set_feature().
#define Usb_select_ep_for_cpu | ( | ep | ) | (Usb_select_epnum_for_cpu(), Usb_select_endpoint(ep)) |
#define Usb_select_epnum_for_cpu | ( | ) | (UECONX &= ~(1<<EPNUMS)) |
#define Usb_select_vbus_srp_method | ( | ) | (OTGCON |= (1<<SRPSEL)) |
#define Usb_send_control_in | ( | ) | (UEINTX &= ~(1<<TXINI)) |
sends IN on control endpoint
Definition at line 627 of file usb_drv.h.
Referenced by cdc_get_line_coding(), cdc_set_control_line_state(), cdc_set_line_coding(), usb_clear_feature(), usb_get_descriptor(), usb_get_status(), usb_set_address(), usb_set_configuration(), usb_set_feature(), and usb_set_interface().
#define Usb_send_in | ( | ) | (UEINTX &= ~(1<<FIFOCON)) |
#define Usb_set_dpram_address | ( | addr | ) | (UDPADDH = (1<<DPACC) + ((Uint16)addr >> 8), UDPADDL = (uint8_t)addr) |
#define Usb_unallocate_memory | ( | ) | (UECFG1X &= ~(1<<ALLOC)) |
#define Usb_unfreeze_clock | ( | ) | (USBCON &= ~(1<<FRZCLK)) |
#define Usb_write_byte | ( | byte | ) | (UEDATX = (uint8_t)byte) |
writes byte in FIFO for current endpoint
Definition at line 681 of file usb_drv.h.
Referenced by cdc_get_line_coding(), uart_usb_putchar(), usb_get_configuration(), usb_get_descriptor(), usb_get_status(), and usb_send_packet().
#define Usb_write_word_enum_struc | ( | x | ) | (x) |
typedef enum ep_token e_ep_token |
enum ep_bank |
enum ep_dir |
Definition at line 120 of file usb_drv.h.
00120 { 00121 DIRECTION_OUT = 0x00, 00122 DIRECTION_IN = 0x01 00123 }e_ep_dir;
enum ep_nyet |
Definition at line 141 of file usb_drv.h.
00141 { 00142 NYET_DISABLED = 0x00, 00143 NYET_ENABLED = 0x01 00144 }e_ep_nyet;
enum ep_size |
enum ep_token |
Definition at line 146 of file usb_drv.h.
00146 { 00147 TOKEN_SETUP = 0x00, 00148 TOKEN_IN = 0x01, 00149 TOKEN_OUT = 0x02 00150 }e_ep_token;
enum ep_type |
Definition at line 113 of file usb_drv.h.
00113 { 00114 TYPE_CONTROL = 0x00, 00115 TYPE_ISOCHRONOUS = 0x01, 00116 TYPE_BULK = 0x02, 00117 TYPE_INTERRUPT = 0x03 00118 }e_ep_type;
uint8_t usb_config_ep | ( | uint8_t | config0, | |
uint8_t | config1 | |||
) |
This function configures an endpoint with the selected type.
config0 | ||
config1 |
Is_endpoint_configured. |
Definition at line 59 of file usb_drv.c.
References Is_endpoint_configured, Usb_allocate_memory, and Usb_enable_endpoint.
00060 { 00061 Usb_enable_endpoint(); 00062 UECFG0X = config0; 00063 UECFG1X = (UECFG1X & (1<<ALLOC)) | config1; 00064 Usb_allocate_memory(); 00065 return (Is_endpoint_configured()); 00066 }
uint16_t usb_get_nb_byte_epw | ( | void | ) |
void usb_halt_endpoint | ( | uint8_t | ep_num | ) |
This function sends a STALL handshake for the next Host request. A STALL handshake will be send for each next request untill a SETUP or a Clear Halt Feature occurs for this endpoint.
ep_num | number of the addressed endpoint |
Definition at line 153 of file usb_drv.c.
References Usb_enable_stall_handshake, and Usb_select_endpoint.
00154 { 00155 Usb_select_endpoint(ep_num); 00156 Usb_enable_stall_handshake(); 00157 }
uint8_t usb_init_device | ( | void | ) |
This function initializes the USB device controller and configures the Default Control Endpoint.
status |
Definition at line 165 of file usb_drv.c.
References DIRECTION_OUT, EP_CONTROL, Is_usb_endpoint_enabled, Is_usb_id_device, NYET_DISABLED, ONE_BANK, SIZE_64, TYPE_CONTROL, usb_configure_endpoint, Usb_select_device, and Usb_select_endpoint.
Referenced by ISR(), and usb_start_device().
00166 { 00167 Usb_select_device(); 00168 if(Is_usb_id_device()) 00169 { 00170 Usb_select_endpoint(EP_CONTROL); 00171 if(!Is_usb_endpoint_enabled()) 00172 { 00173 return usb_configure_endpoint(EP_CONTROL, \ 00174 TYPE_CONTROL, \ 00175 DIRECTION_OUT, \ 00176 SIZE_64, \ 00177 ONE_BANK, \ 00178 NYET_DISABLED); 00179 } 00180 } 00181 return false; 00182 }
uint8_t usb_read_packet | ( | uint8_t | ep_num, | |
uint8_t * | rbuf, | |||
uint8_t | data_length | |||
) |
This function moves the data stored in the selected endpoint fifo to the address specified by *rbuf.
ep_num | number of the addressed endpoint | |
rbuf | aaddress of the first data to write with the USB data | |
data_length | number of bytes to read |
address | of the next uint8_t to send. |
Definition at line 131 of file usb_drv.c.
References Is_usb_read_enabled, Usb_read_byte, and Usb_select_endpoint.
00132 { 00133 uint8_t remaining_length; 00134 00135 remaining_length = data_length; 00136 Usb_select_endpoint(ep_num); 00137 00138 while(Is_usb_read_enabled() && (0 != remaining_length)){ 00139 *rbuf = Usb_read_byte(); 00140 remaining_length--; 00141 rbuf++; 00142 } 00143 return remaining_length; 00144 }
void usb_reset_endpoint | ( | uint8_t | ) |
uint8_t usb_select_enpoint_interrupt | ( | void | ) |
This function select the endpoint where an event occurs and returns the number of this endpoint. If no event occurs on the endpoints, this function returns 0.
endpoint | number. |
Definition at line 75 of file usb_drv.c.
References Usb_interrupt_flags.
00076 { 00077 uint8_t interrupt_flags; 00078 uint8_t ep_num; 00079 00080 ep_num = 0; 00081 interrupt_flags = Usb_interrupt_flags(); 00082 00083 while(ep_num < 9){ 00084 if (interrupt_flags & 1){ 00085 return (ep_num); 00086 }else{ 00087 ep_num++; 00088 interrupt_flags = interrupt_flags >> 1; 00089 } 00090 } 00091 return 0; 00092 }
uint8_t usb_send_packet | ( | uint8_t | ep_num, | |
uint8_t * | tbuf, | |||
uint8_t | data_length | |||
) |
This function moves the data pointed by tbuf to the selected endpoint fifo and sends it through the USB.
ep_num | number of the addressed endpoint | |
*tbuf | address of the first data to send | |
data_length | number of bytes to send |
address | of the next byte to send. |
Definition at line 106 of file usb_drv.c.
References Is_usb_write_enabled, Usb_select_endpoint, and Usb_write_byte.
00107 { 00108 uint8_t remaining_length; 00109 00110 remaining_length = data_length; 00111 Usb_select_endpoint(ep_num); 00112 while(Is_usb_write_enabled() && (0 != remaining_length)){ 00113 Usb_write_byte(*tbuf); 00114 remaining_length--; 00115 tbuf++; 00116 } 00117 return remaining_length; 00118 }
Generated on Mon Jan 18 09:26:13 2010 for AVR1907 Xplain USB Gateway by ![]() |