2013-11-15 55 views
2

這發生在我身上幾次,我試圖找出它的根本原因。簡而言之,我會得到這些錯誤,說有些東西是未定義的,但我可以告訴它不應該。如下所示,我已經包含了pin_map.h,在~6580行定義了我得到的所有三個錯誤(SSI1CLK,SS1RX和SS1TX未定義)。標識符undefined

在我的項目屬性中,我包含了C:\ StellarisWare,並使用了其他幾個文件的定義。它只會偶爾發生一次,對於我的生活我無法弄清楚。有人可以告訴我我做錯了什麼嗎?

請注意,我正在使用TI與Code Composer Studio的LM3S2965評估板。

#include "inc/lm3s2965.h" 
#include "inc/hw_ints.h" 
#include "inc/hw_ssi.h" 
#include "inc/hw_memmap.h" 
#include "inc/hw_nvic.h" 
#include "inc/hw_types.h" 
#include "driverlib/gpio.h" 
#include "driverlib/ssi.h" 
#include "driverlib/pin_map.h" 
#include "driverlib/sysctl.h" 

void init_SPI(void){ 

    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1); 
    GPIOPinConfigure(GPIO_PE0_SSI1CLK); 
    GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE,GPIO_PIN_1); 
    GPIOPinConfigure(GPIO_PE2_SSI1RX); 
    GPIOPinConfigure(GPIO_PE3_SSI1TX); 

    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1,GPIO_PIN_1); 

    SSIDisable(SSI1_BASE); 
    GPIOPinTypeSSI(GPIO_PORTE_BASE, GPIO_PIN_3 | GPIO_PIN_2 | 
        GPIO_PIN_0); 

    SSIConfigSetExpClk(SSI1_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, 
         SSI_MODE_MASTER, 1000000, 8); 
    SSIEnable(SSI1_BASE); 

} 

文件pin_map.h是很長很長,但有問題的定義是:

#define GPIO_PE0_SSI1CLK  0x00040002 
#define GPIO_PE0_CCP3   0x00040003 
#define GPIO_PE0_EPI0S8   0x00040008 

#define GPIO_PE1_SSI1FSS  0x00040402 
#define GPIO_PE1_CCP2   0x00040404 
#define GPIO_PE1_CCP6   0x00040405 
#define GPIO_PE1_EPI0S9   0x00040408 

#define GPIO_PE2_CCP4   0x00040801 
#define GPIO_PE2_SSI1RX   0x00040802 
#define GPIO_PE2_CCP2   0x00040805 
#define GPIO_PE2_EPI0S24  0x00040808 

#define GPIO_PE3_CCP1   0x00040C01 
#define GPIO_PE3_SSI1TX   0x00040C02 
#define GPIO_PE3_CCP7   0x00040C05 
#define GPIO_PE3_EPI0S25  0x00040C08 

錯誤本身是:

Description Resource Path Location Type 
#20 identifier "GPIO_PE0_SSI1CLK" is undefined SPI.c /Sandbox 1v1v1/SPI line 23 C/C++ Problem 
+0

能否請您發佈的所有相關信息(pin_map.h,行〜6580,編譯器錯誤等)? –

+0

我向主要問題添加了信息。 – tmwoods

回答

2

確保pin_map.h是實際上在driverlib目錄中。另外,這些定義是否包含宏?例如:

#ifdef SOME_MACRO 
    #define GPIO_PE0_SSI1CLK 0x00040002 
#endif 

您可能需要#定義 「SOME_MACRO」

+0

這是宏。非常感謝你。 – tmwoods