比如 定义static bool ImageCalibrated = false;
、、、
if(ImageCalibrated == false){
ImageCalibrated = true;
do something;
}
、、、
很简单的依据,但是根部不会执行花括号内的程序,如果把定义变量的static去掉,就能正常执行了。
这是CCS自身的问题还是编译器版本的问题?我用的版本如下:
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.
比如 定义static bool ImageCalibrated = false;
、、、
if(ImageCalibrated == false){
ImageCalibrated = true;
do something;
}
、、、
很简单的依据,但是根部不会执行花括号内的程序,如果把定义变量的static去掉,就能正常执行了。
这是CCS自身的问题还是编译器版本的问题?我用的版本如下:
变量和调用是否在同一文件中,和编译器和CCS都没关系,你可以看到在例程pininterrupt中调用没有问题
/* * ======== pinInterrupt.c ======== */ #include <unistd.h> /* Driver Header files */ #include <ti/drivers/PIN.h> /* Example/Board Header files */ #include "Board.h" /* Pin driver handles */ static PIN_Handle buttonPinHandle; static PIN_Handle ledPinHandle; /* Global memory storage for a PIN_Config table */ static PIN_State buttonPinState; static PIN_State ledPinState; /* * Initial LED pin configuration table * - LEDs Board_PIN_LED0 is on. * - LEDs Board_PIN_LED1 is off. */ PIN_Config ledPinTable[] = { Board_PIN_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, Board_PIN_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, PIN_TERMINATE }; /* * Application button pin configuration table: * - Buttons interrupts are configured to trigger on falling edge. */ PIN_Config buttonPinTable[] = { Board_PIN_BUTTON0 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE, Board_PIN_BUTTON1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE, PIN_TERMINATE }; /* * ======== buttonCallbackFxn ======== * Pin interrupt Callback function board buttons configured in the pinTable. * If Board_PIN_LED3 and Board_PIN_LED4 are defined, then we'll add them to the PIN * callback function. */ void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) { uint32_t currVal = 0; /* Debounce logic, only toggle if the button is still pushed (low) */ CPUdelay(8000*50); if (!PIN_getInputValue(pinId)) { /* Toggle LED based on the button pressed */ switch (pinId) { case Board_PIN_BUTTON0: currVal = PIN_getOutputValue(Board_PIN_LED0); PIN_setOutputValue(ledPinHandle, Board_PIN_LED0, !currVal); break; case Board_PIN_BUTTON1: currVal = PIN_getOutputValue(Board_PIN_LED1); PIN_setOutputValue(ledPinHandle, Board_PIN_LED1, !currVal); break; default: /* Do nothing */ break; } } } /* * ======== mainThread ======== */ void *mainThread(void *arg0) { /* Open LED pins */ ledPinHandle = PIN_open(&ledPinState, ledPinTable); if(!ledPinHandle) { /* Error initializing board LED pins */ while(1); } buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable); if(!buttonPinHandle) { /* Error initializing button pins */ while(1); } /* Setup callback for button pins */ if (PIN_registerIntCb(buttonPinHandle, &buttonCallbackFxn) != 0) { /* Error registering button callback function */ while(1); } /* Loop forever */ while(1) { sleep(1000); } }