示例#1
0
文件: pin.c 项目: stxent/halm
/*----------------------------------------------------------------------------*/
void pinSetPull(struct Pin pin, enum PinPull pull)
{
  volatile uint32_t * const reg = calcPinMode(pin.data);
  uint32_t value = *reg & ~PIN_OFFSET(PIN_MASK, pin.data.offset);

  switch (pull)
  {
    case PIN_NOPULL:
      value |= PIN_OFFSET(PIN_MODE_INACTIVE, pin.data.offset);
      break;

    case PIN_PULLUP:
      value |= PIN_OFFSET(PIN_MODE_PULLUP, pin.data.offset);
      break;

    case PIN_PULLDOWN:
      value |= PIN_OFFSET(PIN_MODE_PULLDOWN, pin.data.offset);
      break;
  }

  *reg = value;
}
示例#2
0
文件: pin.c 项目: stxent/halm
/*----------------------------------------------------------------------------*/
void pinSetFunction(struct Pin pin, uint8_t function)
{
  /* Function should not be used outside platform drivers */
  switch (function)
  {
    case PIN_DEFAULT:
      function = 0; /* Zero function is the default for all pins */
      break;

    case PIN_ANALOG:
      return;
  }

  volatile uint32_t * const reg = calcPinSelect(pin.data);
  uint32_t value = *reg & ~PIN_OFFSET(PIN_MASK, pin.data.offset);

  value |= PIN_OFFSET(function, pin.data.offset);

  *reg = value;
}
示例#3
0
文件: gpio_read.c 项目: rsenn/dirlist
int
gpio_read(int const pin_nr) {
  assert(gpio != NULL);

  return GPLEV[PIN_OFFSET(pin_nr)] & PIN_VAL(pin_nr);
}