EP1 2 3 分别用了三个interface0 1 2 枚举成功了,电脑识别到设备
EP1 EP2通讯OK EP3不行? 现像就是EP3送到电脑的数据非我发送的数据,(电脑能收到数据)
感觉就像数据溢出一样, 缓冲区 可以到1K 没超啊
uint16_t pmaadress; /*!< PMA Address
This parameter can be any value between Min_addr = 0 and Max_addr = 1K */
uint16_t pmaaddr0; /*!< PMA Address0
This parameter can be any value between Min_addr = 0 and Max_addr = 1K */
uint16_t pmaaddr1; /*!< PMA Address1
This parameter can be any value between Min_addr = 0 and Max_addr = 1K */
USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev)
{
/* Init USB Ip. */
/* Link the driver to the stack. */
hpcd_USB_FS.pData = pdev;
pdev->pData = &hpcd_USB_FS;
hpcd_USB_FS.Instance = USB;
hpcd_USB_FS.Init.dev_endpoints = 8;
hpcd_USB_FS.Init.speed = PCD_SPEED_FULL;
hpcd_USB_FS.Init.ep0_mps = DEP0CTL_MPS_8;
hpcd_USB_FS.Init.low_power_enable = DISABLE;
hpcd_USB_FS.Init.lpm_enable = DISABLE;
hpcd_USB_FS.Init.battery_charging_enable = DISABLE;
if (HAL_PCD_Init(&hpcd_USB_FS) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x00 , PCD_SNG_BUF, 0x18); //???这里不太明白为什么要从0x18 开始 手册上看了无结果
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x80 , PCD_SNG_BUF, 0x58);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x01, PCD_SNG_BUF, 0x98);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x81, PCD_SNG_BUF, 0xD8);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x02, PCD_SNG_BUF, 0x118);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x82, PCD_SNG_BUF, 0x158);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x03, PCD_SNG_BUF, 0x198); //EP3
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x83, PCD_SNG_BUF, 0x1D8);
return USBD_OK;
}
uint8_t USBD_EP3_HID_SendReport (USBD_HandleTypeDef *pdev,
uint8_t *report,
uint16_t len)
{
USBD_CUSTOM_HID_HandleTypeDef *hhid = (USBD_CUSTOM_HID_HandleTypeDef*)pdev->pClassData;
if (pdev->dev_state == USBD_STATE_CONFIGURED )
{
static u32 iOut;
iOut = 0xffff;
while(hhid->state3 != CUSTOM_HID_IDLE && iOut); //等待发送完成
{
iOut--;
}
if(hhid->state3 == CUSTOM_HID_IDLE)
{
hhid->state3 = CUSTOM_HID_BUSY;
USBD_LL_Transmit (pdev,
0X83,
report,
len);
}
}
return USBD_OK;
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
感谢解惑!野火的板他的历程mass store,没HID.还用一个IO控制D+的!另外已买一个最小系统板,但是再做测试
一周热门 更多>