lpcware

#define change does not enable code

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Andre Schoeman on Tue Mar 29 00:25:05 MST 2011
[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]Hi[/SIZE][/FONT][/COLOR]


[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]I have an interesting problem with #defines.[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]In the usbcdc project, I have changed the file usbcfg.h [/SIZE][/FONT][/COLOR]


[LEFT][COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]#define USB_POWER_EVENT 1[/SIZE][/FONT][/COLOR]


[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]This should enable some code in usbuser.c.c and usbhw.c [/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]for example[/SIZE][/FONT][/COLOR]


[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]#if USB_POWER_EVENT[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]void USB_Power_Event (uint32_t power)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]{[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]USB_Connect(TRUE); // USB Connect[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]while (!USB_Configuration); // wait until USB is configured[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]}[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]#endif[/SIZE][/FONT][/COLOR]


[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]When USB_POWER_EVENT is 0 then these bits of code are greyed(purple) out.[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]When USB_POWER_EVENT is changed from 0 to 1 the background colour should turn white indicating that the code is once again part of the application and will be compiled.[/SIZE][/FONT][/COLOR]


[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]This colour change is however not happening and the code appears not to be compiled.[/SIZE][/FONT][/COLOR]


[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]I have checked the following,[/SIZE][/FONT][/COLOR]


[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]I have removed the original USBCDC example code just in case my project is referencing the wrong file. I even renamed the USBCDC folder to be sure. [/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]I've created examples of how this should work and it does.[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]I've searched for additional #defines of USB_POWER_EVENT but can't find any.[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]I also renamed the function USB_Power_Event as it has the same name as the #define though this should not make a difference.[/SIZE][/FONT][/COLOR]


[COLOR=#000000][FONT=Arial, sans-serif][SIZE=2]I can obviously just discard the #if #endif completely, but I'd still like to know what the underlying problem is.[/SIZE][/FONT][/COLOR]


[FONT=Arial][SIZE=2]Has anybody seen anything like this?[/SIZE][/FONT][/LEFT]
[FONT=Arial][SIZE=2][SIZE=2]Version: LPCXpresso v3.6.2 [Build 279] [29/01/2011]
[/SIZE][/SIZE][/FONT][LEFT][FONT=Arial][SIZE=2]Andre
[/SIZE][/FONT]

[/LEFT]

Outcomes