示例#1
0
/*---------------------------------------------------------------------------*/
static int
configure_b1(int type, int value)
{
  switch(type) {
  case SENSORS_HW_INIT:
#if !MODELS_CONF_CC2531_USB_STICK
    P0INP |= 2; /* Tri-state */
#endif
    BUTTON_IRQ_ON_PRESS(1);
    BUTTON_FUNC_GPIO(1);
    BUTTON_DIR_INPUT(1);
    return 1;
  case SENSORS_ACTIVE:
    if(value) {
      if(!BUTTON_IRQ_ENABLED(1)) {
        timer_set(&debouncetimer, 0);
        BUTTON_IRQ_FLAG_OFF(1);
        BUTTON_IRQ_ENABLE(1);
      }
    } else {
      BUTTON_IRQ_DISABLE(1);
    }
    return 1;
  }
  return 0;
}
示例#2
0
/*---------------------------------------------------------------------------*/
static int
configure_b3(int type, int value)
{
  switch(type) {
  case SENSORS_HW_INIT:

    P0INP |= 1; /* Tri-state */

    BUTTON_IRQ_ON_PRESS(1);
    BUTTON_FUNC_GPIO(1);
    BUTTON_DIR_INPUT(1);
    return 1;
  case SENSORS_ACTIVE:
    if(value) {
      if(!BUTTON_IRQ_ENABLED(3)) {
        timer_set(&debouncetimer, 0);
        BUTTON_IRQ_FLAG_OFF(3);
        BUTTON_IRQ_ENABLE(3);
      }
    } else {
      BUTTON_IRQ_DISABLE(3);
    }
    return 1;
  }
  return 0;
}
示例#3
0
/*---------------------------------------------------------------------------*/
static int
status_b2(int type)
{
  switch(type) {
  case SENSORS_ACTIVE:
  case SENSORS_READY:
    return BUTTON_IRQ_ENABLED(2);
  }
  return 0;
}
/*---------------------------------------------------------------------------*/
static int
configure(int type, int value)
{
  switch(type) {
  case SENSORS_HW_INIT:
    BUTTON_IRQ_EDGE_SELECTD();
    BUTTON_SELECT_IO();
    BUTTON_MAKE_INPUT();
    return 1;
  case SENSORS_ACTIVE:
    if(value) {
      if(!BUTTON_IRQ_ENABLED()) {
        timer_set(&debouncetimer, 0);
        BUTTON_ENABLE_IRQ();
      }
    } else {
      BUTTON_DISABLE_IRQ();
    }
    return 1;
  }
  return 0;
}
示例#5
0
/*---------------------------------------------------------------------------*/
static
int configure_b2(int type, int value)
{
  switch(type) {
  case SENSORS_HW_INIT:
    BUTTON_IRQ_ON_PRESS(2);
    BUTTON_FUNC_GPIO(2);
    BUTTON_DIR_INPUT(2);
    return 1;
  case SENSORS_ACTIVE:
    if(value) {
      if(!BUTTON_IRQ_ENABLED(2)) {
        timer_set(&debouncetimer, 0);
        BUTTON_IRQ_FLAG_OFF(2);
        BUTTON_IRQ_ENABLE(2);
      }
    } else {
      BUTTON_IRQ_DISABLE(2);
    }
    return 1;
  }
  return 0;
}
示例#6
0
/*---------------------------------------------------------------------------*/
static int
active(void)
{
  return BUTTON_IRQ_ENABLED();
}