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.

[参考译文] MSP430F5529:CdcWriteCtrl CdcReadCtrl 是重复定义的

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1070023/msp430f5529-cdcwritectrl-cdcreadctrl-is-defined-repeatedly

部件号:MSP430F5529

大家好,团队

客户提出的问题可能需要您的帮助:

下载正式的 MSP430 USB 开发包 MSP430USB DevelopersPackage_5_20_07_01.zip,解压到 MSP430 USB 软件/MSP4P_USB_API/Examples/CCDC_virtualCOMport/C0_SimpleSend/GCC 目录。 然后准备好使用 MSP430-EL-gcc 编译此项目,并简单地修改 Makefile 中的第4行:

RedHat_GCC =更改为:RedHat _GCC =/home/jinl/gcc_set/MSP430-gcc,用于指定 MSP430 gcc 路径。

更改 Makefile 的第17行:

添加-L $(support_file_directory),否则该错误将按如下方式报告:

再次执行 make 时,将报告重新定义,错误如下所示:

 make
/home/jjinl/gcc_set/msp430-gcc/bin/msp430-elf-gcc -I /home/jjinl/gcc_set/msp430-gcc/include -I ./../../../.. -I ./../../../../driverlib/MSP430F5xx_6xx -I ./../../../../examples/CDC_virtualCOMport/C0_SimpleSend -I ./../../../../examples/CDC_virtualCOMport/C0_SimpleSend/USB_config -I ./../../../../USB_API -D__MSP430F5529__ -DDEPRECATED -mmcu=msp430f5529 -O3 -Os -g -fdata-sections -w -L /home/jjinl/gcc_set/msp430-gcc/include -T ./../../../../USB_API/msp430USB.ld -T /home/jjinl/gcc_set/msp430-gcc/include/msp430f5529.ld -Wl,--gc-sections ../system_pre_init.c ../hal.c ../main.c ../USB_config/UsbIsr.c ../USB_config/descriptors.c ../USB_app/usbConstructs.c ../USB_app/usbEventHandling.c ../../../../USB_API/USB_PHDC_API/UsbPHDC.c ../../../../USB_API/USB_HID_API/UsbHid.c ../../../../USB_API/USB_HID_API/UsbHidReq.c ../../../../USB_API/USB_CDC_API/UsbCdc.c ../../../../USB_API/USB_Common/usb.c ../../../../USB_API/USB_Common/usbdma.c ../../../../USB_API/USB_MSC_API/UsbMscScsi.c ../../../../USB_API/USB_MSC_API/UsbMscStateMachine.c ../../../../USB_API/USB_MSC_API/UsbMscReq.c ../../../../driverlib/MSP430F5xx_6xx/dac12_a.c ../../../../driverlib/MSP430F5xx_6xx/usci_b_spi.c ../../../../driverlib/MSP430F5xx_6xx/usci_b_i2c.c ../../../../driverlib/MSP430F5xx_6xx/ctsd16.c ../../../../driverlib/MSP430F5xx_6xx/rtc_a.c ../../../../driverlib/MSP430F5xx_6xx/tec.c ../../../../driverlib/MSP430F5xx_6xx/ucs.c ../../../../driverlib/MSP430F5xx_6xx/ldopwr.c ../../../../driverlib/MSP430F5xx_6xx/battbak.c ../../../../driverlib/MSP430F5xx_6xx/sd24_b.c ../../../../driverlib/MSP430F5xx_6xx/gpio.c ../../../../driverlib/MSP430F5xx_6xx/dma.c ../../../../driverlib/MSP430F5xx_6xx/wdt_a.c ../../../../driverlib/MSP430F5xx_6xx/adc10_a.c ../../../../driverlib/MSP430F5xx_6xx/pmm.c ../../../../driverlib/MSP430F5xx_6xx/usci_a_uart.c ../../../../driverlib/MSP430F5xx_6xx/comp_b.c ../../../../driverlib/MSP430F5xx_6xx/sysctl.c ../../../../driverlib/MSP430F5xx_6xx/mpy32.c ../../../../driverlib/MSP430F5xx_6xx/flashctl.c ../../../../driverlib/MSP430F5xx_6xx/oa.c ../../../../driverlib/MSP430F5xx_6xx/lcd_b.c ../../../../driverlib/MSP430F5xx_6xx/tlv.c ../../../../driverlib/MSP430F5xx_6xx/eusci_a_uart.c ../../../../driverlib/MSP430F5xx_6xx/aes.c ../../../../driverlib/MSP430F5xx_6xx/timer_a.c ../../../../driverlib/MSP430F5xx_6xx/rtc_c.c ../../../../driverlib/MSP430F5xx_6xx/timer_b.c ../../../../driverlib/MSP430F5xx_6xx/ram.c ../../../../driverlib/MSP430F5xx_6xx/eusci_b_i2c.c ../../../../driverlib/MSP430F5xx_6xx/ref.c ../../../../driverlib/MSP430F5xx_6xx/timer_d.c ../../../../driverlib/MSP430F5xx_6xx/pmap.c ../../../../driverlib/MSP430F5xx_6xx/eusci_b_spi.c ../../../../driverlib/MSP430F5xx_6xx/adc12_a.c ../../../../driverlib/MSP430F5xx_6xx/rtc_b.c ../../../../driverlib/MSP430F5xx_6xx/eusci_a_spi.c ../../../../driverlib/MSP430F5xx_6xx/usci_a_spi.c ../../../../driverlib/MSP430F5xx_6xx/sfr.c ../../../../driverlib/MSP430F5xx_6xx/crc.c -o C0_SimpleSend.out
/home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccmmI6UN.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: multiple definition of `CdcReadCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: first defined here
/home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccmmI6UN.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: multiple definition of `CdcWriteCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: first defined here
/home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/cc7ugCZa.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: multiple definition of `CdcReadCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: first defined here
/home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/cc7ugCZa.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: multiple definition of `CdcWriteCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: first defined here
/home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccrOYl9x.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: multiple definition of `CdcReadCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: first defined here
/home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccrOYl9x.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: multiple definition of `CdcWriteCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: first defined here
/home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccR2FhpV.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: multiple definition of `CdcReadCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: first defined here
/home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccR2FhpV.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: multiple definition of `CdcWriteCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: first defined here
/home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/cchKoC7q.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/../../../../USB_API/USB_CDC_API/../USB_CDC_API/UsbCdc.h:94: multiple definition of `CdcWriteCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: first defined here
/home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/cchKoC7q.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/../../../../USB_API/USB_CDC_API/../USB_CDC_API/UsbCdc.h:107: multiple definition of `CdcReadCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: first defined here
/home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccBjRddP.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/../../../../USB_API/USB_Common/../USB_CDC_API/UsbCdc.h:107: multiple definition of `CdcReadCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:107: first defined here
/home/jjinl/gcc_set/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: /tmp/ccBjRddP.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/../../../../USB_API/USB_Common/../USB_CDC_API/UsbCdc.h:94: multiple definition of `CdcWriteCtrl'; /tmp/ccBnxKTq.o:/home/jjinl/wksp/msp430/5501/MSP430USBDevelopersPackage_5_20_06_03/MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC/./../../../../USB_API/USB_CDC_API/UsbCdc.h:94: first defined here
collect2: error: ld returned 1 exit status
Makefile:79: recipe for target 'C0_SimpleSend' failed
make: *** [C0_SimpleSend] Error 1

检查后发现原因是:在 MSP4P_USB_Software/MSP4P_USB_API/USB_API/USB_CDC_API/UsbCCDC.h 文件中,在头文件中定义了两个结构变量,在头文件包含在多个位置后,将导致重复定义。

/* 
 * ======== UsbCdc.h ========
 */

#ifndef _UsbCdc_H_
#define _UsbCdc_H_

#ifdef __cplusplus
extern "C"
{
#endif


/*----------------------------------------------------------------------------
 * The following function names and macro names are deprecated.  These were 
 * updated to new names to follow OneMCU naming convention.
 +---------------------------------------------------------------------------*/
#ifndef DEPRECATED
#define  kUSBCDC_sendStarted            USBCDC_SEND_STARTED
#define  kUSBCDC_sendComplete           USBCDC_SEND_COMPLETE
#define  kUSBCDC_intfBusyError          USBCDC_INTERFACE_BUSY_ERROR
#define  kUSBCDC_receiveStarted         USBCDC_RECEIVE_STARTED
#define  kUSBCDC_receiveCompleted       USBCDC_RECEIVE_COMPLETED
#define  kUSBCDC_receiveInProgress      USBCDC_RECEIVE_IN_PROGRESS
#define  kUSBCDC_generalError           USBCDC_GENERAL_ERROR
#define  kUSBCDC_busNotAvailable        USBCDC_BUS_NOT_AVAILABLE
#define  kUSBCDC_waitingForSend         USBCDC_WAITING_FOR_SEND
#define  kUSBCDC_waitingForReceive      USBCDC_WAITING_FOR_RECEIVE
#define  kUSBCDC_dataWaiting            USBCDC_DATA_WAITING
#define  kUSB_allCdcEvents              USBCDC_ALL_CDC_EVENTS
#define  kUSBCDC_noDataWaiting          USBCDC_NO_DATA_WAITING

#define USBCDC_intfStatus               USBCDC_getInterfaceStatus
#define USBCDC_bytesInUSBBuffer         USBCDC_getBytesInUSBBuffer
#endif


#define USBCDC_SEND_STARTED         0x01
#define USBCDC_SEND_COMPLETE        0x02
#define USBCDC_INTERFACE_BUSY_ERROR       0x03
#define USBCDC_RECEIVE_STARTED      0x04
#define USBCDC_RECEIVE_COMPLETED    0x05
#define USBCDC_RECEIVE_IN_PROGRESS   0x06
#define USBCDC_GENERAL_ERROR        0x07
#define USBCDC_BUS_NOT_AVAILABLE     0x08
//returned by USBCDC_rejectData() if no data pending
#define USBCDC_NO_DATA_WAITING        0X01
#define USBCDC_WAITING_FOR_SEND      0x01
#define USBCDC_WAITING_FOR_RECEIVE   0x02
#define USBCDC_DATA_WAITING         0x04
#define USBCDC_BUS_NOT_AVAILABLE     0x08
#define USBCDC_ALL_CDC_EVENTS           0xFF


#ifdef _CDC_
struct _CdcWrite {
    uint16_t nCdcBytesToSend;                       //holds counter of bytes to be sent
    uint16_t nCdcBytesToSendLeft;                   //holds counter how many bytes is still to be sent
    const uint8_t* pUsbBufferToSend;               //holds the buffer with data to be sent
    uint8_t bCurrentBufferXY;                      //is 0 if current buffer to write data is X, or 1 if current buffer is Y
    uint8_t bZeroPacketSent;                       //= FALSE;
    uint8_t last_ByteSend;
} CdcWriteCtrl[CDC_NUM_INTERFACES];

struct _CdcRead {
    uint8_t *pUserBuffer;                          //holds the current position of user's receiving buffer. If NULL- no receiving
                                                //operation started
    uint8_t *pCurrentEpPos;                        //current positon to read of received data from curent EP
    uint16_t nBytesToReceive;                       //holds how many bytes was requested by receiveData() to receive
    uint16_t nBytesToReceiveLeft;                   //holds how many bytes is still requested by receiveData() to receive
    uint8_t * pCT1;                                //holds current EPBCTxx register
    uint8_t * pCT2;                                //holds next EPBCTxx register
    uint8_t * pEP2;                                //holds addr of the next EP buffer
    uint8_t nBytesInEp;                            //how many received bytes still available in current EP
    uint8_t bCurrentBufferXY;                      //indicates which buffer is used by host to transmit data via OUT endpoint3
} CdcReadCtrl[CDC_NUM_INTERFACES];

#endif

客户想知道如何直接 修改标准标题文件来解决此问题,或者 USB 磁带库是否有意这样做?

请帮您检查此案例? 谢谢。

此致,

樱桃