#if ! (BSP430_PLATFORM_BUTTON0 - 0)
#error No button available on this platform
#endif
typedef struct sButtonState {
const unsigned char bit;
volatile unsigned int in_mask;
volatile unsigned int count;
} sButtonState;
static int
void * context,
int idx)
{
sButtonState * sp = (sButtonState *)cb;
++sp->count;
sp->in_mask = (hpl->
ies & sp->bit) ^ sp->bit;
hpl->ies ^= sp->bit;
}
static sButtonState button_state = {
.button_cb = { .callback_ni = button_isr_ni },
};
void main ()
{
cprintf(
"\nbutton " __DATE__
" " __TIME__
"\n");
cprintf(
"There's supposed to be a button at %s.%u\n",
b0pin);
if (! b0hal) {
cprintf(
"Whoops, guess it's not really there\n");
return;
}
#if (BSP430_PORT_SUPPORTS_REN - 0)
#endif
} else {
button_state.in_mask = 0;
}
cprintf(
"Button is configured. Try pressing it. No debouncing is done.\n");
#if ! (configBSP430_CORE_LPM_EXIT_CLEAR_GIE - 0)
cprintf(
"WARNING: Interrupts remain enabled after wakeup\n");
#endif
while (1) {
static const char * state_str[] = { "released", "pressed" };
cprintf(
"Count %u, in mask 0x%02x: %s\n", button_state.count, button_state.in_mask, state_str[!button_state.in_mask]);
#if ! (configBSP430_CORE_LPM_EXIT_CLEAR_GIE - 0)
#endif
}
}