📄 usb_drv.h
字号:
#define Usb_enter_test_j_mode() // compatibility
#define Usb_force_normal_speed() // compatibility
#define Usb_force_full_speed() // compatibility
#define Usb_force_high_speed() // compatibility
#define Usb_force_full_speed_utmi() // compatibility
#define Usb_exit_test_packet_mode() // compatibility
#define Usb_exit_test_k_mode() // compatibility
#define Usb_exit_test_j_mode() // compatibility
#define Usb_set_loopback_mode() // compatibility
//! General endpoint management
//! These macros manage the common features of the endpoints
//!
#define Usb_select_endpoint(ep) (UEPNUM = (U8)ep)
#define Usb_select_endpoint_dfc(ep) (UEPNUM = (U8)ep) // compatibility
#define Usb_reset_endpoint(ep) (UEPRST = 1 << (U8)ep, UEPRST = 0)
#define Usb_enable_endpoint() (UEPCONX |= MSK_EPEN)
#define Usb_enable_stall_handshake() (UEPSTAX |= MSK_STALLRQ)
#define Usb_reset_data_toggle() // compatibility
#define Usb_select_epnum_for_dfc() // compatibility
#define Usb_enable_dfc() // compatibility
#define Usb_disable_endpoint() (UEPCONX &= ~MSK_EPEN)
#define Usb_disable_stall_handshake() (UEPSTAX &= ~MSK_STALLRQ)
#define Usb_select_epnum_for_cpu() // compatibility
#define Usb_disable_dfc() // compatibility
#define Is_usb_endpoint_enabled() (UEPCONX & MSK_EPEN)
#define Is_usb_endpoint_stall_requested() (UEPSTAX & MSK_STALLRQ)
#define Usb_configure_endpoint_type(type) (UEPCONX = (UEPCONX & ~MSK_EPTYPE) | ((U8)type))
#define Usb_enable_iso_autoswitch() // compatibility
#define Usb_enable_autoswitch() // compatibility
#define Usb_enable_nyet() // compatibility
#define Usb_disable_iso_autoswitch() // compatibility
#define Usb_disable_autoswitch() // compatibility
#define Usb_disable_nyet() // compatibility
#define Usb_configure_endpoint_direction(dir) (UEPCONX = (UEPCONX & ~MSK_EPDIR) | ((U8)dir << 2))
#define Usb_configure_endpoint_size(size) // compatibility
#define Usb_configure_endpoint_bank(bank) // compatibility
#define Usb_allocate_memory() // compatibility
#define Usb_unallocate_memory() // compatibility
#define Usb_ack_overflow_interrupt() // compatibility
#define Usb_ack_underflow_interrupt() // compatibility
#define Usb_ack_zlp() // compatibility
#define Usb_data_toggle() // compatibility
#define Usb_nb_busy_bank() (0xFF)
#define Is_usb_one_bank_busy() (FALSE)
#define Is_endpoint_configured() (UEPCONX & MSK_EPEN == MSK_EPEN)
#define Is_usb_overflow() (FALSE)
#define Is_usb_underflow() (FALSE)
#define Is_usb_zlp() (FALSE)
#define Usb_control_direction() (UEPCONX & MSK_EPDIR)
#define Usb_current_bank() (0xFF)
#define Usb_ack_fifocon() // compatibility
#define Usb_ack_nak_in() // compatibility
#define Usb_ack_nak_out() // compatibility
#define Usb_ack_receive_setup() (UEPSTAX &= ~MSK_RXSETUP)
#define Usb_ack_receive_out() (UEPSTAX &= ~MSK_RXOUT)
#define Usb_ack_stalled() (UEPSTAX &= ~MSK_STALLED)
#define Usb_ack_in_ready() (UEPSTAX &= ~MSK_TXCMPL)
#define Usb_kill_last_in_bank() // compatibility
#define Is_usb_read_enabled() (TRUE)// compatibility
#define Is_usb_write_enabled() (TRUE)// compatibility
#define Is_usb_read_control_enabled() (UEPSTAX & MSK_TXCMPL) // compatibility
#define Is_usb_receive_setup() (UEPSTAX & MSK_RXSETUP)
#define Is_usb_receive_out() (UEPSTAX & MSK_RXOUTB0B1)
#ifdef NO_SUPPORT_USB_PING_PONG
#define Usb_ack_receive_out_ms() Usb_ack_receive_out()
#define Is_usb_receive_out_ms() Is_usb_receive_out()
#else
#define Usb_ack_receive_out_ms() {if(rx_bank){UEPSTAX&=~MSK_RXOUTB1;}else{UEPSTAX&=(~MSK_RXOUTB0);}rx_bank=~rx_bank;}
#define Is_usb_receive_out_ms() Is_usb_receive_out()
#endif
#ifdef NO_SUPPORT_USB_PING_PONG
#define Usb_ack_receive_out_hid() Usb_ack_receive_out()
#define Is_usb_receive_out_hid() Is_usb_receive_out()
#else
#define Usb_ack_receive_out_hid() {if(rx_bank){UEPSTAX&=~MSK_RXOUTB1;}else{UEPSTAX&=(~MSK_RXOUTB0);}rx_bank=~rx_bank;}
#define Is_usb_receive_out_hid() Is_usb_receive_out()
#endif
#define Is_usb_in_ready() (UEPSTAX & MSK_TXCMPL)
#define Usb_send_in() UEPSTAX |= MSK_TXRDY; while(!Is_usb_in_ready());Usb_ack_in_ready()
#define Usb_send_control_in() (UEPSTAX |= MSK_TXRDY)
#define Usb_free_out_bank() (UEPSTAX |= MSK_RXOUT)
#define Usb_ack_control_out() (UEPSTAX |= MSK_RXOUT)
#define Usb_set_DIR() (UEPSTAX |= MSK_DIR)
#define Usb_enable_flow_error_interrupt() // compatibility
#define Usb_enable_nak_in_interrupt() // compatibility
#define Usb_enable_nak_out_interrupt() // compatibility
#define Usb_enable_receive_setup_interrupt() // compatibility
#define Usb_enable_receive_out_interrupt() // compatibility
#define Usb_enable_stalled_interrupt() // compatibility
#define Usb_enable_in_ready_interrupt() // compatibility
#define Usb_disable_flow_error_interrupt() // compatibility
#define Usb_disable_nak_in_interrupt() // compatibility
#define Usb_disable_nak_out_interrupt() // compatibility
#define Usb_disable_receive_setup_interrupt() // compatibility
#define Usb_disable_receive_out_interrupt() // compatibility
#define Usb_disable_stalled_interrupt() // compatibility
#define Usb_disable_in_ready_interrupt() // compatibility
#define Usb_read_byte() (UEPDATX)
#define Usb_write_byte(byte) (UEPDATX = (U8)byte)
#define Usb_byte_counter() ((((U16)UBYCTHX) << 8) | (UBYCTLX))
#define Usb_byte_counter_8() ((U8)UBYCTLX)
#define Usb_interrupt_flags() (UEPINT != 0x00)
#define Is_usb_endpoint_event() (Usb_interrupt_flags())
// ADVANCED MACROS
#define Usb_select_ep_for_cpu(ep) // compatibility
#define Usb_select_ep_for_dfc(ep) // compatibility
#define Usb_set_cfg0(cfg0) (cfg0 = cfg0)//(UECFG0X = cfg0)
#define Usb_set_cfg1(cfg1) (cfg1 = cfg1)//(UECFG1X = (UECFG1X & MSK_ALLOC) | cfg1)
//! wSWAP
//! This macro swaps the U8 order in words.
//!
//! @param x (U16) the 16 bit word to swap
//!
//! @return (U16) the 16 bit word x with the 2 bytes swaped
#define wSWAP(x) \
( (((x)>>8)&0x00FF) \
| (((x)<<8)&0xFF00) \
)
//! dwSWAP
//! This macro swaps the U8 order in double words.
//!
//! @param x (U32) the 32 bit double word to swap
//!
//! @return (U32) the 32 bit double word x with the 4 bytes swaped
#if 0
#define dwSWAP(x) \
( (((x)>>24)&0x000000FF) \
| (((x)>> 8)&0x0000FF00) \
| (((x)<<24)&0xFF000000) \
| (((x)<< 8)&0x00FF0000) \
)
#endif
#define PLL_3MHz 0xF0
#define PLL_4MHz 0xC0
#define PLL_6MHz 0x70
#define PLL_8MHz 0x50
#define PLL_12MHz 0x30
#define PLL_16MHz 0x20
#define PLL_18MHz 0x72
#define PLL_20MHz 0xB4
#define PLL_24MHz 0x10
#define PLL_32MHz 0x21
#define PLL_40MHz 0xB9
#define Pll_stop() (PLLCON &= ~MSK_PLLEN)
#define Pll_set_div(n) (PLLDIV = n)
#define Pll_enable() (PLLCON |= MSK_PLLEN)
//_____ D E C L A R A T I O N ______________________________________________
U8 usb_config_ep (U8, U8);
U8 usb_select_enpoint_interrupt (void);
U16 usb_get_nb_byte_epw (void);
U8 usb_send_packet (U8 , U8*, U8);
U8 usb_read_packet (U8 , U8*, U8);
void usb_halt_endpoint (U8);
void usb_reset_endpoint (U8);
U8 usb_init_device (void);
void usb_generate_clock (void);
#endif // _USB_DRV_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -