TI中文支持网
TI专业的中文技术问题搜集分享网站

MSP430F5529: CdcWriteCtrl CdcReadCtrl 重复定义

Part Number:MSP430F5529

我下载官网的MSP430的USB开发包 MSP430USBDevelopersPackage_5_20_07_01.zip,解压后到解压目录下

MSP430_USB_Software/MSP430_USB_API/examples/CDC_virtualCOMport/C0_SimpleSend/GCC

准备使用msp430-elf-gcc 编译这个工程

简单修改Makefile中的第4行

原本是

REDHAT_GCC =

改为:

REDHAT_GCC = /home/jjinl/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

我仔细看了,原因是在 MSP430_USB_Software/MSP430_USB_API/USB_API/USB_CDC_API/UsbCdc.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_sendStartedUSBCDC_SEND_STARTED
#define  kUSBCDC_sendCompleteUSBCDC_SEND_COMPLETE
#define  kUSBCDC_intfBusyErrorUSBCDC_INTERFACE_BUSY_ERROR
#define  kUSBCDC_receiveStartedUSBCDC_RECEIVE_STARTED
#define  kUSBCDC_receiveCompletedUSBCDC_RECEIVE_COMPLETED
#define  kUSBCDC_receiveInProgressUSBCDC_RECEIVE_IN_PROGRESS
#define  kUSBCDC_generalErrorUSBCDC_GENERAL_ERROR
#define  kUSBCDC_busNotAvailableUSBCDC_BUS_NOT_AVAILABLE
#define  kUSBCDC_waitingForSendUSBCDC_WAITING_FOR_SEND
#define  kUSBCDC_waitingForReceiveUSBCDC_WAITING_FOR_RECEIVE
#define  kUSBCDC_dataWaitingUSBCDC_DATA_WAITING
#define  kUSB_allCdcEventsUSBCDC_ALL_CDC_EVENTS
#define  kUSBCDC_noDataWaitingUSBCDC_NO_DATA_WAITING

#define USBCDC_intfStatusUSBCDC_getInterfaceStatus
#define USBCDC_bytesInUSBBufferUSBCDC_getBytesInUSBBuffer
#endif


#define USBCDC_SEND_STARTED0x01
#define USBCDC_SEND_COMPLETE0x02
#define USBCDC_INTERFACE_BUSY_ERROR0x03
#define USBCDC_RECEIVE_STARTED0x04
#define USBCDC_RECEIVE_COMPLETED0x05
#define USBCDC_RECEIVE_IN_PROGRESS0x06
#define USBCDC_GENERAL_ERROR0x07
#define USBCDC_BUS_NOT_AVAILABLE0x08
//returned by USBCDC_rejectData() if no data pending
#define USBCDC_NO_DATA_WAITING0X01
#define USBCDC_WAITING_FOR_SEND0x01
#define USBCDC_WAITING_FOR_RECEIVE0x02
#define USBCDC_DATA_WAITING0x04
#define USBCDC_BUS_NOT_AVAILABLE0x08
#define USBCDC_ALL_CDC_EVENTS0xFF


#ifdef _CDC_
struct _CdcWrite {uint16_t nCdcBytesToSend;//holds counter of bytes to be sentuint16_t nCdcBytesToSendLeft;//holds counter how many bytes is still to be sentconst uint8_t* pUsbBufferToSend;//holds the buffer with data to be sentuint8_t bCurrentBufferXY;//is 0 if current buffer to write data is X, or 1 if current buffer is Yuint8_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 starteduint8_t *pCurrentEpPos;//current positon to read of received data from curent EPuint16_t nBytesToReceive;//holds how many bytes was requested by receiveData() to receiveuint16_t nBytesToReceiveLeft;//holds how many bytes is still requested by receiveData() to receiveuint8_t * pCT1;//holds current EPBCTxx registeruint8_t * pCT2;//holds next EPBCTxx registeruint8_t * pEP2;//holds addr of the next EP bufferuint8_t nBytesInEp;//how many received bytes still available in current EPuint8_t bCurrentBufferXY;//indicates which buffer is used by host to transmit data via OUT endpoint3
} CdcReadCtrl[CDC_NUM_INTERFACES];

#endif

这个问题怎么解决,直接修改标准头文件, 还是USB库故意这样做??

Cherry Zhou:

您好我们已收到您的问题并升级到英文论坛,如有答复将尽快回复您。谢谢!

,

Cherry Zhou:

您好,您试下注释掉重复的内容,再重新试下看看。

,

jinlong jiang:

我提这个问题,主要是想问,这个库中把变量定义到头文件中,是否有特殊用意。

出现重复定义,第一时间我就去屏蔽头文件,会出更多的问题。

我的解决方法是把这两个变量移到UsbCdc.c文件中,只在UsbCdc.h中使用extern进行声明,整个工程编译就没有问题,下载测试功能也是正常的。

我的问题就是,这是个bug还是不让直接包含UsbCdc.h而故意为之?

,

Johnson He:

不是为了不让直接包含.h文件而设计的。

赞(0)
未经允许不得转载:TI中文支持网 » MSP430F5529: CdcWriteCtrl CdcReadCtrl 重复定义
分享到: 更多 (0)