Niki
Here is how to configure and read your input in the uTasker project:
#define BUTTON_SOS (PORTC_BIT16)
_CONFIG_PORT_INPUT_FAST_HIGH(C, BUTTON_SOS, PORT_PS_UP_ENABLE);
if (_READ_PORT_MASK(C, BUTTON_SOS) != 0) {
fndDebugMsg("SOS is not pressed\n\r");
}
else {
fndDebugMsg("SOS is pressed\n\r");
}
If you prefer to configure an interrupt to fire when the button is pressed, the following code does it:
INTERRUPT_SETUP interrupt_setup; // interrupt configuration parameters
interrupt_setup.int_type = PORT_INTERRUPT; // identifier to configure port interrupt
interrupt_setup.int_handler = fnButtonPressed; // handling function
interrupt_setup.int_priority = 5; // interrupt priority level
interrupt_setup.int_port = PORTC; // the port that the interrupt input is on
interrupt_setup.int_port_bits = BUTTON_SOS;
interrupt_setup.int_port_sense = (IRQ_FALLING_EDGE | PULLUP_ON); // interrupt is to be falling edge sensitive
fnConfigureInterrupt((void *)&interrupt_setup); // configure interrupt
whereby the interrupt callback to handle the press is something like:
// Button interrupt handler
//
static void fnButtonPressed(void)
{
fnInterruptMessage(BUTTON_TASK, E_BUTTON_PRESSED);
}
Why not add your board to the uTasker project so that you can simulate and test all operation and greaty accelerate your work with it?
Take a look at the following University board that was added to it in just a couple of hours (including SD card and USB operation):
µTasker Kinetis Capuccino-KL27 support
http://www.coffeebrain.org/blog/
Regards
Mark
Kinetis: µTasker Kinetis support
K60: µTasker Kinetis TWR-K60N512 support / µTasker Kinetis TWR-K60D100M support / µTasker Kinetis TWR-K60F120M support
For the complete "out-of-the-box" Kinetis experience and faster time to market