コード例 #1
0
/*----------------------------------------------------------------------------*/
const struct PinGroupEntry *pinGroupFind(const struct PinGroupEntry *list,
    pinNumber key, uint8_t channel)
{
  struct PinData pin;

  pin.port = PIN_TO_PORT(key);
  pin.offset = PIN_TO_OFFSET(key);

  while (list->begin && list->end)
  {
    if (list->channel == channel)
    {
      const struct PinData begin = {
          .offset = PIN_TO_OFFSET(list->begin),
          .port = PIN_TO_PORT(list->begin)
      };
      const struct PinData end = {
          .offset = PIN_TO_OFFSET(list->end),
          .port = PIN_TO_PORT(list->end)
      };
      const bool found = pin.port >= begin.port && pin.port <= end.port
          && pin.offset >= begin.offset && pin.offset <= end.offset;

      if (found)
        return list;
    }

    ++list;
  }

  return 0;
}
コード例 #2
0
/*----------------------------------------------------------------------------*/
struct Pin pinInit(pinNumber id)
{
  struct Pin pin;

  pin.data.port = PIN_TO_PORT(id);
  pin.data.offset = PIN_TO_OFFSET(id);
  pin.reg = calcMaskedReg(pin.data);

  return pin;
}
コード例 #3
0
ファイル: pin.c プロジェクト: stxent/halm
/*----------------------------------------------------------------------------*/
struct Pin pinInit(PinNumber id)
{
  struct Pin pin;

  pin.data.port = PIN_TO_PORT(id);
  pin.data.offset = PIN_TO_OFFSET(id);
  pin.reg = id ? calcPort(pin.data) : 0;

  return pin;
}