delete workq
This commit is contained in:
@@ -81,7 +81,6 @@ if GetDepend(['PKG_CHERRYUSB_HOST']):
|
||||
path += [cwd + '/class/hub']
|
||||
src += Glob('core/usbh_core.c')
|
||||
src += Glob('osal/usb_osal_rtthread.c')
|
||||
src += Glob('osal/usb_workq.c')
|
||||
|
||||
if GetDepend(['PKG_CHERRYUSB_HOST_CDC']):
|
||||
path += [cwd + '/class/cdc']
|
||||
@@ -101,7 +100,6 @@ if GetDepend(['PKG_CHERRYUSB_HOST']):
|
||||
|
||||
if GetDepend(['PKG_CHERRYUSB_HOST_DWC2']):
|
||||
src += Glob('port/dwc2/usb_hc_dwc2.c')
|
||||
CPPDEFINES += ['CONFIG_USBHOST_HIGH_WORKQ']
|
||||
|
||||
if GetDepend(['PKG_CHERRYUSB_HOST_MUSB']):
|
||||
src += Glob('port/musb/usb_hc_musb.c')
|
||||
|
||||
@@ -830,8 +830,6 @@ int usbh_initialize(void)
|
||||
usbh_class_info_table_end = (struct usbh_class_info *)&_usbh_class_info_end;
|
||||
#endif
|
||||
|
||||
usbh_workq_initialize();
|
||||
|
||||
usbh_core_cfg.pscevent = usb_osal_event_create();
|
||||
if (usbh_core_cfg.pscevent == NULL) {
|
||||
return -1;
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "usb_log.h"
|
||||
#include "usb_hc.h"
|
||||
#include "usb_osal.h"
|
||||
#include "usb_workq.h"
|
||||
#include "usbh_hub.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -129,7 +128,6 @@ typedef struct usbh_hub {
|
||||
struct usb_hub_descriptor hub_desc;
|
||||
struct usbh_hubport child[CONFIG_USBHOST_EHPORTS];
|
||||
struct usbh_hubport *parent; /* Parent hub port */
|
||||
struct usb_work work;
|
||||
} usbh_hub_t;
|
||||
|
||||
void usbh_event_notify_handler(uint8_t event, uint8_t rhport);
|
||||
|
||||
@@ -173,22 +173,6 @@
|
||||
<Bp>
|
||||
<Number>1</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>819</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>..\..\..\..\..\core\usbh_core.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>2</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>1027</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
@@ -203,7 +187,7 @@
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>3</Number>
|
||||
<Number>2</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>1030</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
@@ -219,7 +203,7 @@
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>4</Number>
|
||||
<Number>3</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>1309</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
@@ -235,7 +219,7 @@
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>5</Number>
|
||||
<Number>4</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>1314</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
@@ -839,18 +823,6 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>40</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\osal\usb_workq.c</PathWithFileName>
|
||||
<FilenameWithoutPath>usb_workq.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
@@ -861,7 +833,7 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>41</FileNumber>
|
||||
<FileNumber>40</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -873,7 +845,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>42</FileNumber>
|
||||
<FileNumber>41</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -885,7 +857,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>43</FileNumber>
|
||||
<FileNumber>42</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -897,7 +869,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>44</FileNumber>
|
||||
<FileNumber>43</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -909,7 +881,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>45</FileNumber>
|
||||
<FileNumber>44</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
||||
@@ -338,7 +338,7 @@
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define>USE_HAL_DRIVER,STM32F429xx,CONFIG_USBHOST_HIGH_WORKQ</Define>
|
||||
<Define>USE_HAL_DRIVER,STM32F429xx</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>../Core/Inc;../Drivers/STM32F4xx_HAL_Driver/Inc;../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;../Drivers/CMSIS/Device/ST/STM32F4xx/Include;../Drivers/CMSIS/Include;..\..\..\..\..\common;..\..\..\..\..\core;..\..\..\..\..\class\cdc;..\..\..\..\..\class\hub;..\..\..\..\..\class\hid;..\..\..\..\..\class\msc;..\..\..\..\..\osal;..\..\..\..\..\third_party\FreeRTOS-10.4\include;..\..\..\..\..\third_party\FreeRTOS-10.4\portable\GCC\ARM_CM4F;..\..\..\..\..\third_party\fatfs-0.14\source</IncludePath>
|
||||
</VariousControls>
|
||||
@@ -604,11 +604,6 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\port\dwc2\usb_hc_dwc2.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usb_workq.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\osal\usb_workq.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
||||
@@ -812,18 +812,6 @@
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\osal\usb_workq.c</PathWithFileName>
|
||||
<FilenameWithoutPath>usb_workq.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>40</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\..\..\class\cdc\usbh_cdc_acm.c</PathWithFileName>
|
||||
<FilenameWithoutPath>usbh_cdc_acm.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
@@ -831,7 +819,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>41</FileNumber>
|
||||
<FileNumber>40</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -843,7 +831,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>42</FileNumber>
|
||||
<FileNumber>41</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@@ -855,7 +843,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>43</FileNumber>
|
||||
<FileNumber>42</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
||||
@@ -338,7 +338,7 @@
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define>USE_HAL_DRIVER,STM32H743xx,STM32H7,CONFIG_USBHOST_HIGH_WORKQ,CONFIG_USB_DCACHE_ENABLE,CONFIG_USB_ALIGN_SIZE=32</Define>
|
||||
<Define>USE_HAL_DRIVER,STM32H743xx,STM32H7,CONFIG_USB_DCACHE_ENABLE,CONFIG_USB_ALIGN_SIZE=32</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>../Core/Inc;../Drivers/STM32H7xx_HAL_Driver/Inc;../Drivers/STM32H7xx_HAL_Driver/Inc/Legacy;../Drivers/CMSIS/Device/ST/STM32H7xx/Include;../Drivers/CMSIS/Include;..\..\..\..\..\core;..\..\..\..\..\common;..\..\..\..\..\osal;..\..\..\..\..\class\cdc;..\..\..\..\..\class\hid;..\..\..\..\..\class\msc;..\..\..\..\..\class\hub;..\..\..\..\..\third_party\FreeRTOS-10.4\include;..\..\..\..\..\third_party\FreeRTOS-10.4\portable\GCC\ARM_CM7\r0p1</IncludePath>
|
||||
</VariousControls>
|
||||
@@ -599,11 +599,6 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\osal\usb_osal_freertos.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usb_workq.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\..\..\osal\usb_workq.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usbh_cdc_acm.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
|
||||
120
osal/usb_workq.c
120
osal/usb_workq.c
@@ -1,120 +0,0 @@
|
||||
/**
|
||||
* @file usb_workq.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2022 sakumisu
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
#include "usb_list.h"
|
||||
#include "usb_osal.h"
|
||||
#include "usb_workq.h"
|
||||
#include "usb_config.h"
|
||||
|
||||
void usb_workqueue_submit(struct usb_workqueue *queue, struct usb_work *work, usb_worker_t worker, void *arg, uint32_t ticks)
|
||||
{
|
||||
size_t flags;
|
||||
flags = usb_osal_enter_critical_section();
|
||||
usb_dlist_remove(&work->list);
|
||||
work->worker = worker;
|
||||
work->arg = arg;
|
||||
|
||||
if (ticks == 0) {
|
||||
usb_dlist_insert_after(&queue->work_list, &work->list);
|
||||
usb_osal_sem_give(queue->sem);
|
||||
}
|
||||
|
||||
usb_osal_leave_critical_section(flags);
|
||||
}
|
||||
|
||||
struct usb_workqueue g_hpworkq = { NULL };
|
||||
struct usb_workqueue g_lpworkq = { NULL };
|
||||
|
||||
#ifdef CONFIG_USBHOST_HIGH_WORKQ
|
||||
static void usbh_hpwork_thread(void *argument)
|
||||
{
|
||||
struct usb_work *work;
|
||||
size_t flags;
|
||||
int ret;
|
||||
struct usb_workqueue *queue = (struct usb_workqueue *)argument;
|
||||
while (1) {
|
||||
ret = usb_osal_sem_take(queue->sem, 0xffffffff);
|
||||
if (ret < 0) {
|
||||
continue;
|
||||
}
|
||||
flags = usb_osal_enter_critical_section();
|
||||
if (usb_dlist_isempty(&queue->work_list)) {
|
||||
usb_osal_leave_critical_section(flags);
|
||||
continue;
|
||||
}
|
||||
work = usb_dlist_first_entry(&queue->work_list, struct usb_work, list);
|
||||
usb_dlist_remove(&work->list);
|
||||
usb_osal_leave_critical_section(flags);
|
||||
work->worker(work->arg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_USBHOST_LOW_WORKQ
|
||||
static void usbh_lpwork_thread(void *argument)
|
||||
{
|
||||
struct usb_work *work;
|
||||
size_t flags;
|
||||
int ret;
|
||||
struct usb_workqueue *queue = (struct usb_workqueue *)argument;
|
||||
while (1) {
|
||||
ret = usb_osal_sem_take(queue->sem, 0xffffffff);
|
||||
if (ret < 0) {
|
||||
continue;
|
||||
}
|
||||
flags = usb_osal_enter_critical_section();
|
||||
if (usb_dlist_isempty(&queue->work_list)) {
|
||||
usb_osal_leave_critical_section(flags);
|
||||
continue;
|
||||
}
|
||||
work = usb_dlist_first_entry(&queue->work_list, struct usb_work, list);
|
||||
usb_dlist_remove(&work->list);
|
||||
usb_osal_leave_critical_section(flags);
|
||||
work->worker(work->arg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int usbh_workq_initialize(void)
|
||||
{
|
||||
#ifdef CONFIG_USBHOST_HIGH_WORKQ
|
||||
g_hpworkq.sem = usb_osal_sem_create(0);
|
||||
if (g_hpworkq.sem == NULL) {
|
||||
return -1;
|
||||
}
|
||||
g_hpworkq.thread = usb_osal_thread_create("usbh_hpworkq", CONFIG_USBHOST_HPWORKQ_STACKSIZE, CONFIG_USBHOST_HPWORKQ_PRIO, usbh_hpwork_thread, &g_hpworkq);
|
||||
if (g_hpworkq.thread == NULL) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_USBHOST_LOW_WORKQ
|
||||
g_lpworkq.sem = usb_osal_sem_create(0);
|
||||
if (g_lpworkq.sem == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_lpworkq.thread = usb_osal_thread_create("usbh_lpworkq", CONFIG_USBHOST_LPWORKQ_STACKSIZE, CONFIG_USBHOST_LPWORKQ_PRIO, usbh_lpwork_thread, &g_lpworkq);
|
||||
if (g_lpworkq.thread == NULL) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/**
|
||||
* @file usb_workq.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2022 sakumisu
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
#ifndef _USB_WORKQUEUE_H
|
||||
#define _USB_WORKQUEUE_H
|
||||
|
||||
/* Defines the work callback */
|
||||
typedef void (*usb_worker_t)(void *arg);
|
||||
|
||||
struct usb_work
|
||||
{
|
||||
usb_dlist_t list;
|
||||
usb_worker_t worker;
|
||||
void *arg;
|
||||
};
|
||||
|
||||
struct usb_workqueue
|
||||
{
|
||||
usb_dlist_t work_list;
|
||||
usb_dlist_t delay_work_list;
|
||||
usb_osal_sem_t sem;
|
||||
usb_osal_thread_t thread;
|
||||
};
|
||||
|
||||
extern struct usb_workqueue g_hpworkq;
|
||||
extern struct usb_workqueue g_lpworkq;
|
||||
|
||||
void usb_workqueue_submit(struct usb_workqueue *queue, struct usb_work *work, usb_worker_t worker, void *arg, uint32_t ticks);
|
||||
int usbh_workq_initialize();
|
||||
#endif
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "usbh_core.h"
|
||||
#include "usb_dwc2_reg.h"
|
||||
|
||||
#ifndef CONFIG_USBHOST_HIGH_WORKQ
|
||||
#error "dwc2 host must use high workq"
|
||||
#endif
|
||||
|
||||
#if defined(STM32F7) || defined(STM32H7)
|
||||
#ifndef CONFIG_USB_DCACHE_ENABLE
|
||||
#warning "if you enable dcache,please enable this macro"
|
||||
@@ -65,7 +61,7 @@ struct dwc2_pipe {
|
||||
|
||||
struct dwc2_hcd {
|
||||
volatile bool connected;
|
||||
struct usb_work work;
|
||||
volatile bool port_enable;
|
||||
struct dwc2_pipe chan[CONFIG_USB_DWC2_PIPE_NUM];
|
||||
} g_dwc2_hcd;
|
||||
|
||||
@@ -624,8 +620,8 @@ int usb_hc_hw_init(void)
|
||||
USB_OTG_GLB->GCCFG &= ~USB_OTG_GCCFG_VBUSBSEN;
|
||||
USB_OTG_GLB->GCCFG &= ~USB_OTG_GCCFG_VBUSASEN;
|
||||
#endif
|
||||
/*!< FS/LS PHY clock select */
|
||||
USB_OTG_HOST->HCFG |= USB_OTG_HCFG_FSLSPCS_0;
|
||||
usbh_reset_port(1);
|
||||
|
||||
/* Set default Max speed support */
|
||||
USB_OTG_HOST->HCFG &= ~(USB_OTG_HCFG_FSLSS);
|
||||
@@ -694,6 +690,10 @@ int usbh_reset_port(const uint8_t port)
|
||||
usb_osal_msleep(100U); /* See Note #1 */
|
||||
USB_OTG_HPRT = ((~USB_OTG_HPRT_PRST) & hprt0);
|
||||
usb_osal_msleep(10U);
|
||||
|
||||
while (!g_dwc2_hcd.port_enable) {
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1098,56 +1098,6 @@ int usb_ep_cancel(usbh_epinfo_t ep)
|
||||
return 0;
|
||||
}
|
||||
|
||||
//static void usb_dwc2_rxqlvl_irq_handler(void)
|
||||
//{
|
||||
// uint32_t pktsts;
|
||||
// uint32_t pktcnt;
|
||||
// uint32_t GrxstspReg;
|
||||
// uint32_t xferSizePktCnt;
|
||||
// uint32_t tmpreg;
|
||||
// uint32_t ch_num;
|
||||
// uint32_t len32b;
|
||||
// uint32_t *pdest;
|
||||
// struct dwc2_pipe *chan;
|
||||
|
||||
// GrxstspReg = USB_OTG_GLB->GRXSTSP;
|
||||
// ch_num = GrxstspReg & USB_OTG_GRXSTSP_EPNUM;
|
||||
// pktsts = (GrxstspReg & USB_OTG_GRXSTSP_PKTSTS) >> 17;
|
||||
// pktcnt = (GrxstspReg & USB_OTG_GRXSTSP_BCNT) >> 4;
|
||||
|
||||
// chan = &g_dwc2_hcd.chan[ch_num];
|
||||
// switch (pktsts) {
|
||||
// case GRXSTS_PKTSTS_IN:
|
||||
// /* Read the data into the host buffer. */
|
||||
// if ((pktcnt > 0U) && (chan->buffer != NULL)) {
|
||||
// len32b = ((uint32_t)pktcnt + 3U) / 4U;
|
||||
|
||||
// pdest = (uint32_t *)chan->buffer;
|
||||
|
||||
// for (uint8_t i = 0U; i < len32b; i++) {
|
||||
// *pdest = USB_OTG_FIFO(0U);
|
||||
// pdest++;
|
||||
// }
|
||||
|
||||
// chan->buffer += pktcnt;
|
||||
// chan->xfrd += pktcnt;
|
||||
// chan->buflen -= pktcnt;
|
||||
|
||||
// if (chan->buflen == 0) {
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
|
||||
// case GRXSTS_PKTSTS_DATA_TOGGLE_ERR:
|
||||
// break;
|
||||
|
||||
// case GRXSTS_PKTSTS_IN_XFER_COMP:
|
||||
// case GRXSTS_PKTSTS_CH_HALTED:
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
static void dwc2_inchan_irq_handler(uint8_t ch_num)
|
||||
{
|
||||
uint32_t chan_intstatus;
|
||||
@@ -1333,16 +1283,9 @@ static void dwc2_outchan_irq_handler(uint8_t ch_num)
|
||||
}
|
||||
}
|
||||
|
||||
void dwc2_reset_handler(void *arg)
|
||||
{
|
||||
usb_osal_msleep(300); /* let the usb host power keep stable */
|
||||
usbh_reset_port(1);
|
||||
}
|
||||
|
||||
static void dwc2_port_irq_handler(void)
|
||||
{
|
||||
__IO uint32_t hprt0, hprt0_dup, regval;
|
||||
bool reset = false;
|
||||
|
||||
/* Handle Host Port Interrupts */
|
||||
hprt0 = USB_OTG_HPRT;
|
||||
@@ -1354,7 +1297,7 @@ static void dwc2_port_irq_handler(void)
|
||||
/* Check whether Port Connect detected */
|
||||
if ((hprt0 & USB_OTG_HPRT_PCDET) == USB_OTG_HPRT_PCDET) {
|
||||
if ((hprt0 & USB_OTG_HPRT_PCSTS) == USB_OTG_HPRT_PCSTS) {
|
||||
reset = true;
|
||||
usbh_event_notify_handler(USBH_EVENT_CONNECTED, 1);
|
||||
}
|
||||
hprt0_dup |= USB_OTG_HPRT_PCDET;
|
||||
}
|
||||
@@ -1373,7 +1316,6 @@ static void dwc2_port_irq_handler(void)
|
||||
regval &= ~USB_OTG_HCFG_FSLSPCS;
|
||||
regval |= USB_OTG_HCFG_FSLSPCS_1;
|
||||
USB_OTG_HOST->HCFG = regval;
|
||||
reset = true;
|
||||
}
|
||||
} else {
|
||||
USB_OTG_HOST->HFIR = 48000U;
|
||||
@@ -1382,22 +1324,14 @@ static void dwc2_port_irq_handler(void)
|
||||
regval &= ~USB_OTG_HCFG_FSLSPCS;
|
||||
regval |= USB_OTG_HCFG_FSLSPCS_0;
|
||||
USB_OTG_HOST->HCFG = regval;
|
||||
reset = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
usbh_event_notify_handler(USBH_EVENT_CONNECTED, 1);
|
||||
for (uint32_t i = 0; i < 1000; i++) {
|
||||
}
|
||||
g_dwc2_hcd.port_enable = true;
|
||||
} else {
|
||||
for (int chidx = 0; chidx < CONFIG_USB_DWC2_PIPE_NUM; chidx++) {
|
||||
struct dwc2_pipe *chan;
|
||||
chan = &g_dwc2_hcd.chan[chidx];
|
||||
if (chan->waiter) {
|
||||
chan->waiter = false;
|
||||
chan->result = -ENXIO;
|
||||
usb_osal_sem_give(chan->waitsem);
|
||||
}
|
||||
}
|
||||
usbh_event_notify_handler(USBH_EVENT_DISCONNECTED, 1);
|
||||
g_dwc2_hcd.port_enable = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1407,9 +1341,6 @@ static void dwc2_port_irq_handler(void)
|
||||
}
|
||||
/* Clear Port Interrupts */
|
||||
USB_OTG_HPRT = hprt0_dup;
|
||||
if (reset) {
|
||||
usb_workqueue_submit(&g_hpworkq, &g_dwc2_hcd.work, dwc2_reset_handler, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void USBH_IRQHandler(void)
|
||||
@@ -1426,13 +1357,18 @@ void USBH_IRQHandler(void)
|
||||
dwc2_port_irq_handler();
|
||||
}
|
||||
if (gint_status & USB_OTG_GINTSTS_DISCINT) {
|
||||
for (int chidx = 0; chidx < CONFIG_USB_DWC2_PIPE_NUM; chidx++) {
|
||||
struct dwc2_pipe *chan;
|
||||
chan = &g_dwc2_hcd.chan[chidx];
|
||||
if (chan->waiter) {
|
||||
chan->waiter = false;
|
||||
chan->result = -ENXIO;
|
||||
usb_osal_sem_give(chan->waitsem);
|
||||
}
|
||||
}
|
||||
usbh_event_notify_handler(USBH_EVENT_DISCONNECTED, 1);
|
||||
USB_OTG_GLB->GINTSTS = USB_OTG_GINTSTS_DISCINT;
|
||||
}
|
||||
// if (gint_status & USB_OTG_GINTSTS_RXFLVL) {
|
||||
// USB_MASK_INTERRUPT(USB_OTG_GLB, USB_OTG_GINTSTS_RXFLVL);
|
||||
// usb_dwc2_rxqlvl_irq_handler();
|
||||
// USB_UNMASK_INTERRUPT(USB_OTG_GLB, USB_OTG_GINTSTS_RXFLVL);
|
||||
// }
|
||||
if (gint_status & USB_OTG_GINTSTS_HCINT) {
|
||||
chan_int = (USB_OTG_HOST->HAINT & USB_OTG_HOST->HAINTMSK) & 0xFFFFU;
|
||||
for (uint8_t i = 0U; i < CONFIG_USB_DWC2_PIPE_NUM; i++) {
|
||||
|
||||
14
usb_config.h
14
usb_config.h
@@ -89,20 +89,6 @@
|
||||
#define CONFIG_USBHOST_MSC_TIMEOUT 5000
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBHOST_HPWORKQ_PRIO
|
||||
#define CONFIG_USBHOST_HPWORKQ_PRIO 5
|
||||
#endif
|
||||
#ifndef CONFIG_USBHOST_HPWORKQ_STACKSIZE
|
||||
#define CONFIG_USBHOST_HPWORKQ_STACKSIZE 2048
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBHOST_LPWORKQ_PRIO
|
||||
#define CONFIG_USBHOST_LPWORKQ_PRIO 1
|
||||
#endif
|
||||
#ifndef CONFIG_USBHOST_LPWORKQ_STACKSIZE
|
||||
#define CONFIG_USBHOST_LPWORKQ_STACKSIZE 2048
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBHOST_PSC_PRIO
|
||||
#define CONFIG_USBHOST_PSC_PRIO 4
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user