This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TMS320F2.8069万M:controlSUITE:USBLIB:CDC-ACM:如果循环缓冲器已满,USB输出端点将停止工作。 补丁!

Guru**** 2574265 points
Other Parts Discussed in Thread: CONTROLSUITE

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/642923/tms320f28069m-controlsuite-usblib-cdc-acm-usb-out-endpoint-stops-working-if-the-circular-buffer-is-full-patch

部件号:TMS320F2.8069万M
主题:controlSUITE中讨论的其他部件

您好,

这是错误报告和补丁提交。  我之所以将其放在这里,是因为我花了一段时间才完成跟踪,我相信其他人会喜欢它。  (希望它能够维护到TI的USB堆栈中)

controlSUITE的v 3.4 6版本中的USB堆栈使用usbdcdc.c中的SetDeferredOpFlag功能来跟踪是否需要返回并在以后执行USB操作。  例如,如果循环缓冲区已满,则从硬件FIFO中删除数据。  此函数使用宏来设置或清除状态变量中的某个位,以指示是否需要延迟操作。

SetDeferredOpFlag (volatile uint16_t *pui16 DeferredOp,uint16_t ui16位,
布尔设置)
{
//
//使用位带访问将标志位设置为1或0。
//
HWREGBITHW (pui16DeferredOp,ui16Bit,Bset? 1:0);}


请注意,三元运算符计算布尔值Bset,它是HWREGBITHW宏中的第三个参数。  此宏在HW_Types.h中定义

#define HWREGBITHW (地址,掩码,值) \
(*(volatile unsigned short *)(address))= \
(*(volatile unsigned short *)(address))&~(unsigned short) 1 << mask)\
|(unsigned short) value << mask)((((无符号短)值<<掩

我们看到(unsigned short) value << mask)行扩展为(unsigned short) Bset? 1:0<<掩码)。  三元运算符的C运算符优先级非常低。  优先级比按位移低得多。  这意味着按位操作是值1或值0 <<掩码。  我们永远不会获得(1 <<掩码)的正确位掩码。  我们需要回来并执行的操作将永远丢失...  在我们的案例中,该延迟操作是在循环缓冲区稍微清空后,为RX硬件FIFO提供服务。

下面是一个修补程序差异,它在两个地方修复了该问题:1.) 在宏中,将()置于所有参数的周围以保证优先级和2。) 在功能中,删除不需要的三元运算符。  

diff --git a/device_support/f2806x/v151/mware/inc/hw_types.h


hw_types.h b/device_support/f2806x/v151/mware/inc/hw_types.h index 18.2252万c..6f7e83d 10.0644万 --a/device_support/f2806x/f151/mware/inc/hw_types.h +++++ b/device_inttype/f8f5f8;
@@ f55,1x/f8f8f8 @@ f8f8

\
(*(volatile unsigned short *)(address))= -
(*(volatile unsigned short *)(address))&~(unsigned short) 1 << mask)\
- |((unsigned short) value << mask)
+ (*(volatile unsigned short *)(address))&~(unsigned short) 1 <<(mask)))\
+ |(unsigned short)(value)<<(mask))
//模拟位带读取
#define HWREGBITHR (地址,mask) \
((*(volatile unsigned short *)(address))&((unsigned short) 1 << mask)>> mask)
diff --git a/device_support/f2806x/v151/mware/usbib/device/usbib/usbidb/usbidrub/uspers/dcpu16dc/dcpu16dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcpu/dcp/dcpu/dcp/fx/fx/fx/f6



@@@@

布尔设置)
{-//-//使用

位带访问将标志位设置为1或0。
-//
- HWREGBITHW (pui16DeferredOp,ui16Bit,Bset? 1:0);
+ HWREGBITHW(pui16DefredOp,ui16Bit,Bset);
}

希望能有所帮助!

-Colin

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    Colin,

    感谢您报告此情况以及您的解决方法。 我已将其记录到我们的错误跟踪系统中,以便我们的USB专家查看并将其整合到下一次更新中。

    此致
    Lori