// Alarm output
#define ALARMENABLE port2.out.pin5 = 1
#define ALARMDISABLE port2.out.pin5 = 0
I prefer to make it simpler for the compiler and generally define things
like
#define P5_ALARM_ENABLE (1<<5) /* or 0x20 */
#define P5_ALARM (1<<6) /* or 0x40 */
and use it in the code like
P5_OUT |= P5_ALARM_ENABLE;
P5_OUT &= ~P5_ALARM_ENABLE;
then this also works,
P5_DIR |= P5_ALARM_ENABLE; /* make the ALARM_ENABLE pin an output */
and
if ((P5_IN & P5_ALARM) != 0)
{
printf("Alarm set\n");
}
or
if ((P5_OUT & P5_ALARM_ENABLE) != 0)
{
printf("Alarm enabled\n");
}
Ok, maybe its not as simple to write the main code as BitSet, BitReset
etc macros, bit its always obvious what is going on, and generally
compiles down to compact code, you do have to know how the bits work,
but as an embedded programmer maybe that is a good thing.
As usual many ways to skin a cat.
Regards,
--
Peter Jansen
___________________________________________________________________________
Australian Antarctic Division - Commonwealth of Australia
IMPORTANT: This transmission is intended for the addressee only. If you are not
the
intended recipient, you are notified that use or dissemination of this
communication is
strictly prohibited by Commonwealth law. If you have received this transmission
in error,
please notify the sender immediately by e-mail or by telephoning +61 3 6232
3209 and
DELETE the message.
Visit our web site at http://www.aad.gov.au/
___________________________________________________________________________