Initial commit: TXW82x FPV v2.7.0.7-42229 SDK + project sources
This commit is contained in:
138
sdk/include/dev/usb/usb11_v0/hgusb11_v0_dev_api.h
Normal file
138
sdk/include/dev/usb/usb11_v0/hgusb11_v0_dev_api.h
Normal file
@@ -0,0 +1,138 @@
|
||||
#ifndef _HG_USB11_V0_DEV_H
|
||||
#define _HG_USB11_V0_DEV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "hal/usb_device.h"
|
||||
|
||||
enum hgusb11_device_flags {
|
||||
HGUSB11_DEVICE_FLAGS_OPENED = BIT(0),
|
||||
HGUSB11_DEVICE_FLAGS_READY = BIT(1),
|
||||
HGUSB11_DEVICE_FLAGS_SUSPEND = BIT(2),
|
||||
HGUSB11_DEVICE_FLAGS_DMA_MODE = BIT(3),
|
||||
HGUSB11_DEVICE_FLAGS_SOFT_SUBPACKAGE = BIT(4),
|
||||
};
|
||||
|
||||
/* USB通信控制块:USB Device Requests */
|
||||
struct _usb_device_requests {
|
||||
uint8 bmrequesttype;
|
||||
uint8 brequest;
|
||||
uint16 wvalue;
|
||||
uint16 windex;
|
||||
uint16 wlength;
|
||||
};
|
||||
|
||||
|
||||
/* USB EP0控制块:状态机 */
|
||||
enum _usb_ep0_state {
|
||||
USB_EP0_STATE_SETUP,
|
||||
USB_EP0_STATE_OUT,
|
||||
USB_EP0_STATE_IN,
|
||||
USB_EP0_STATE_LAST_IN,
|
||||
USB_EP0_STATE_LAST_OUT,
|
||||
USB_EP0_STATE_STATUS_IN,
|
||||
USB_EP0_STATE_STATUS_OUT,
|
||||
USB_EP0_STATE_STALL,
|
||||
};
|
||||
|
||||
|
||||
/* USB EP0控制块 */
|
||||
struct _usb_ep0_ctrl {
|
||||
|
||||
enum _usb_ep0_state ep0_state;
|
||||
|
||||
//本次要发送包的地址、总长度
|
||||
uint8 *p_ep0_ptk2send;
|
||||
uint32 ep0_ptk2send_size;
|
||||
|
||||
//偏移量和计数
|
||||
uint32 ep0_ptk_counter;
|
||||
uint32 ep0_buf_offset;
|
||||
|
||||
//单次发送包的最大长度
|
||||
uint32 ep0_oneptk_max_size;
|
||||
|
||||
uint8 ep0_buf[1024] __attribute__((aligned(4))); //针对iso传输接收非word对齐的数据dma写入的情况 fix:修改64为1024
|
||||
|
||||
};
|
||||
|
||||
struct usb11_ep_trx_ctrl {
|
||||
uint32 addr;
|
||||
uint32 total_bytes;
|
||||
uint32 max_packet_size;
|
||||
uint32 cur_addr;
|
||||
uint32 cur_counter;
|
||||
uint32 last_counter;
|
||||
};
|
||||
|
||||
union __comm_state{
|
||||
uint32 comm;
|
||||
struct {
|
||||
uint32 dev_open : 1,
|
||||
dev_host_mode : 1,
|
||||
dev_device_mode : 1,
|
||||
reserve : 29;
|
||||
} comm_bits;
|
||||
};
|
||||
typedef union __comm_state hgusb11_dev_v0_comm;
|
||||
|
||||
struct hgusb11_dev {
|
||||
struct usb_device dev;
|
||||
void *usb_hw;
|
||||
usbdev_irq_hdl irq_hdl;
|
||||
uint32 irq_data;
|
||||
uint8 ep_irq_num;
|
||||
uint8 dma_irq_num;
|
||||
|
||||
/* common areas */
|
||||
union __comm_state comm_dat;
|
||||
/* Pointer of common areas */
|
||||
void *p_comm;
|
||||
|
||||
/*
|
||||
* USB EP0的控制块
|
||||
*/
|
||||
struct _usb_ep0_ctrl ep0_ctrl;
|
||||
|
||||
struct os_event trx_lock;
|
||||
struct os_event trx_done;
|
||||
|
||||
struct usb11_ep_trx_ctrl ep_trans_ctrl[4];
|
||||
struct usb11_ep_trx_ctrl ep_recevice_ctrl[4];
|
||||
|
||||
//状态位
|
||||
uint32 flags;
|
||||
};
|
||||
|
||||
|
||||
int32 hgusb11_v0_dev_ep_set_stall(struct usb_device *p_usb_d, uint8 address);
|
||||
int32 hgusb11_v0_dev_ep_clear_stall(struct usb_device *p_usb_d, uint8 address);
|
||||
int32 hgusb11_v0_dev_set_address(struct usb_device *p_usb_d, uint8 address);
|
||||
int32 hgusb11_v0_dev_set_config(struct usb_device *p_usb_d, uint8 address);
|
||||
int32 hgusb11_v0_dev_ep_enable(struct usb_device *p_usb_d, uint8 ep, uint16 max_pkt_size, uint8 attributes);
|
||||
int32 hgusb11_v0_dev_ep_disable(struct usb_device *p_usb_d, uint8 ep);
|
||||
int32 hgusb11_v0_dev_ep_read(struct usb_device *p_usb_d, uint8 address, void *buffer);
|
||||
int32 hgusb11_v0_dev_ep_read_prepare(struct usb_device *p_usb_d, uint8 address, void *buffer, uint32 size);
|
||||
int32 hgusb11_v0_dev_read(struct usb_device *p_usb_d, uint8 ep, uint8 *buff, uint32 len, uint8 sync);
|
||||
int32 hgusb11_v0_dev_ep_write(struct usb_device *p_usb_d, uint8 address, void *buffer, uint32 size);
|
||||
int32 hgusb11_v0_dev_write(struct usb_device *p_usb_d, uint8 ep, uint8 *buff, uint32 len, uint8 sync);
|
||||
int32 hgusb11_v0_dev_ep0_send_status(struct usb_device *p_usb_d);
|
||||
int32 hgusb11_v0_dev_attach(uint32 dev_id, struct hgusb11_dev *p_dev);
|
||||
int32 hgusb11_v0_dev_close(struct usb_device *p_usb_d);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _HG_USB11_V0_DEV_H */
|
||||
|
||||
96
sdk/include/dev/usb/usb11_v0/hgusb11_v0_host_api.h
Normal file
96
sdk/include/dev/usb/usb11_v0/hgusb11_v0_host_api.h
Normal file
@@ -0,0 +1,96 @@
|
||||
#ifndef _HG_USB11_V0_HOST_H
|
||||
#define _HG_USB11_V0_HOST_H
|
||||
|
||||
#include "typesdef.h"
|
||||
#include "list.h"
|
||||
#include "errno.h"
|
||||
#include "dev.h"
|
||||
#include "osal/irq.h"
|
||||
#include "osal/string.h"
|
||||
#include "osal/semaphore.h"
|
||||
#include "osal/mutex.h"
|
||||
#include "osal/event.h"
|
||||
#include "hal/usb_device.h"
|
||||
#include "dev/usb/usb11_v0/hgusb11_v0_dev_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define USB11_CORE_HOST_EP_RX 0
|
||||
#define USB11_CORE_HOST_EP_TX 1
|
||||
|
||||
#define USB11_CORE_HOST_EP0_TIMEOUT 18000
|
||||
|
||||
#define USB11_EP_ATTR_CONTROL 0x00
|
||||
#define USB11_EP_ATTR_ISOC 0x01
|
||||
#define USB11_EP_ATTR_BULK 0x02
|
||||
#define USB11_EP_ATTR_INT 0x03
|
||||
#define USB11_EP_ATTR_TYPE_MASK 0x03
|
||||
|
||||
#define USB11_DIR_OUT 0
|
||||
#define USB11_DIR_IN 0x80
|
||||
|
||||
enum hgusb11_host_flags {
|
||||
HGUSB11_HOST_FLAGS_OPENED = BIT(0),
|
||||
HGUSB11_HOST_FLAGS_READY = BIT(1),
|
||||
HGUSB11_HOST_FLAGS_SUSPEND = BIT(2),
|
||||
HGUSB11_HOST_FLAGS_DMA_MODE = BIT(3),
|
||||
HGUSB11_HOST_FLAGS_SOFT_SUBPACKAGE = BIT(4),
|
||||
};
|
||||
|
||||
enum hgusb11_host_speed_det {
|
||||
HGUSB11_HOST_NONE = 0,
|
||||
HGUSB11_HOST_FS,
|
||||
HGUSB11_HOST_LS,
|
||||
};
|
||||
|
||||
struct hgusb11_host {
|
||||
struct usb_device dev;
|
||||
void *usb_hw;
|
||||
usbdev_irq_hdl irq_hdl;
|
||||
uint32 irq_data;
|
||||
uint8 ep_irq_num;
|
||||
uint8 dma_irq_num;
|
||||
/*
|
||||
* USB EP0的控制块
|
||||
*/
|
||||
struct _usb_ep0_ctrl ep0_ctrl;
|
||||
/* Pointer of common areas */
|
||||
void * p_comm;
|
||||
|
||||
struct os_event trx_lock;
|
||||
struct os_event trx_done;
|
||||
|
||||
struct usb11_ep_trx_ctrl ep_trans_ctrl[4];
|
||||
struct usb11_ep_trx_ctrl ep_recevice_ctrl[4];
|
||||
|
||||
//状态位
|
||||
uint32 flags;
|
||||
};
|
||||
|
||||
int32 hgusb11_v0_host_dev_speed_detect();
|
||||
int32 hgusb11_v0_host_set_address(uint8 addr);
|
||||
int32 hgusb11_v0_host_reset();
|
||||
int32 hgusb11_v0_host_is_ep_crc_err(uint8 ep_num);
|
||||
int32 hgusb11_v0_host_is_rx_stall(uint8 ep_num, uint8 ep_type);
|
||||
int32 hgusb11_v0_host_is_xact_err(uint8 ep_num, uint8 ep_type);
|
||||
int32 hgusb11_v0_host_is_nak_timeout(uint8 ep_num, uint8 ep_type);
|
||||
void hgusb11_v0_host_clear_data_toggle(uint8 ep_num, uint8 ep_type);
|
||||
void hgusb11_v0_host_reset_ep_rxcsr(uint8 ep_num);
|
||||
void hgusb11_v0_host_reset_ep_txcsr(uint8 ep_num);
|
||||
int32 hgusb11_v0_host_ep_get_rx_dma_len(uint8 ep_num);
|
||||
int32 hgusb11_v0_host_ep0_tx_kick(struct usb_device *p_usb_d, uint8 setup_pkt, uint8 *buf, uint32 len);
|
||||
int32 hgusb11_v0_host_ep0_rx_kick(struct usb_device *p_usb_d, uint8* buf, uint32 len);
|
||||
int32 hgusb11_v0_host_ep_init(struct usb_device *p_usb_d, uint8 tx_or_rx, uint8 ep_num, uint8 ep_addr, uint8 ep_type, uint32 max_pktsize);
|
||||
int32 hgusb11_v0_host_set_ep_interval(uint8 tx_or_rx, uint8 ep_num, uint32 interval);
|
||||
int32 hgusb11_v0_host_ep_rx_kick(struct usb_device *p_usb_d, uint8 ep_num, uint8 *buf, uint32 len);
|
||||
int32 hgusb11_v0_host_ep_tx_kick(struct usb_device *p_usb_d, uint8 ep_num, uint8 *buf, uint32 len, uint8 setup_pkt);
|
||||
int32 hgusb11_v0_host_ep_abort(struct usb_device *p_usb_d, uint8 tx_or_rx, uint8 ep_num);
|
||||
int32 hgusb11_v0_host_attch(uint32 dev_id, struct hgusb11_host *p_dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user