// CrossWorks Tasking Library.
//
// CTL support for the Embedded Artists' LPC3250 OEM  board
//
// Copyright (c) 2009 Rowley Associates Limited.
//
// This file may be distributed under the terms of the License Agreement
// provided with this software.
//
// THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

#include <ctl_api.h>
#include <targets/LPC3200.h>

void
ctl_board_init(void)
{
}

static CTL_ISR_FN_t userButtonISR;
void
buttonISR(void)
{
  userButtonISR();  
}

void 
ctl_board_on_button_pressed(CTL_ISR_FN_t buttonFn)
{
  userButtonISR = buttonFn;
  ctl_set_isr(GPI_02_INT, 1, CTL_ISR_TRIGGER_NEGATIVE_EDGE, buttonISR, 0);
  ctl_unmask_isr(GPI_02_INT);
}

void
ctl_board_set_leds(unsigned v)
{
  if (v)
    P3_OUTP_SET = (1<<1);
  else
    P3_OUTP_CLR = (1<<1);
}

void
delay(volatile unsigned int d)
{
  d *= 10;
  for (;d ;--d);
}

