Thnx for your help, it was helpfull for me.
JMGross wrote: > > > Unfortunately your posting does nto really tell what your problem is. You > do not tell what you think what your quoted code should do and what it > actually does. > As you posted it, it is, well, just some code. It is formally okay and > might or might not compile, depending on other code prior in your project. > > To all I can figure out by your posting, your problem seems to be not with > enum but with a misunderstandig of the way the C compiler works. > To be specific: the C preprocessor. > > None of the four values in the enum is used after your strobe command. So > I don't see where the problem is. > I'm assuming, that CC2420_CONF_AUTOACK is also in the enum you quoted (the > ',' behind CC2420_SRXON indicates that there are more values than only 4 > in this enum). > So the enum and its members are defined for the processor in the context > of the C(++) language. > But I may be wrong, as the 'CONF' in the name seems to indicate that it is > rather a global compile-time-configuration define than a runtime value. > > Also, the term 'variable enum' you use is incorrect. An enum is no > variable. Enums are constants. To be precise, they are numeric constants > of a certain type. > The line > strobe(CC2420_SXOSCON); > is 100% identical to > strobe(1); > except that the compiler can complain, if the function requires a > parameter of type cc2420_register and the value is of a different int > type. > At runtime, all occurrences of an enum have been replaced by static > numerical values. > > In opposition to the enum declaration, the usage of CC2420_CONF_AUTOACK > behind an #if directive is in the context of the c++ preprocessor. > The preprocessor just preprocesses your files without knowledge of the > final language. (so it treats the enum as any other plain text) > It takes defines (done with #define), includes header files (with > #include) and does text replacement (based on the defines) as well as some > conditional text selection (also based on the defines). > > your line > #if CC2420_CONF_AUTOACK > tells the precompiler to include the following text in its output if > CC2420_CONF_AUTOACK is true. > But the preprocessor has never seen CC2420_CONF_AUTOACK > There is no > #define CC2420_CONF_AUTOACK > anywhere. > So the preprocessor might either complain or assume 'false' (usually the > second option) > > In any case, the code you posted will statically include either of the two > lines. There is no runtime decision made to execute one or the other. > > Maybe this is intentional. If so, you'll need to put > #define CC2420_CONF_AUTOACK 1 > anywhere before in your code to always execute > reg |= AUTOACK | ADR_DECODE; > or > #define CC2420_CONF_AUTOACK 0 > to always execute > reg &= ~(AUTOACK | ADR_DECODE); > > I hope, my guesses somehow hit the nail on the head. If not, please be a > bit more detailed about what is going wrong (what it does and what you > think it should instead). > Simple 'this code doesn't work' problems can only be solved if the problem > is a formal programming error. > > JMGross > > ----- Ursprüngliche Nachricht ----- > Von: macosioleon > An: [email protected] > Gesendet am: 05 Dez 2009 20:35:29 > Betreff: [Mspgcc-users] problems with enum variables > > > i am working with a cc2420_const.h file but when i want to compile doesnt > work correctly > > In cc2420_const.h the variable enum is declare at this way. > > enum cc2420_register { > CC2420_SNOP = 0x00, > CC2420_SXOSCON = 0x01, > CC2420_STXCAL = 0x02, > CC2420_SRXON = 0x03, > } > > and at cc2420.c useit as > > strobe(CC2420_SXOSCON); BUT AFTER THIS LINE DONT WORK THE VARIABLES > ENUM > +++++++++++++++++++++++++++++++++++++ > /* Turn on/off automatic packet acknowledgment and address decoding. */ > reg = getreg(CC2420_MDMCTRL0); > #if CC2420_CONF_AUTOACK > reg |= AUTOACK | ADR_DECODE; > #else > reg &= ~(AUTOACK | ADR_DECODE); > #endif /* CC2420_CONF_AUTOACK */ > setreg(CC2420_MDMCTRL0, reg); > > i am using msp430xF261& > > what is wrong ? > > thnx for your help > -- > View this message in context: > http://old.nabble.com/problems-with-enum-variables-tp26658500p26658500.html > Sent from the MSP430 gcc - Users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Join us December 9, 2009 for the Red Hat Virtual Experience, > a free event focused on virtualization and cloud computing. > Attend in-depth sessions from your desk. Your couch. Anywhere. > http://p.sf.net/sfu/redhat-sfdev2dev > _______________________________________________ > Mspgcc-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/mspgcc-users > > > ------------------------------------------------------------------------------ > Join us December 9, 2009 for the Red Hat Virtual Experience, > a free event focused on virtualization and cloud computing. > Attend in-depth sessions from your desk. Your couch. Anywhere. > http://p.sf.net/sfu/redhat-sfdev2dev > _______________________________________________ > Mspgcc-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/mspgcc-users > > -- View this message in context: http://old.nabble.com/problems-with-enum-variables-tp26658500p26717934.html Sent from the MSP430 gcc - Users mailing list archive at Nabble.com.
