/*----------------------------------------------------------------------------*/ 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; }
/*----------------------------------------------------------------------------*/ 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; }
/*----------------------------------------------------------------------------*/ 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; }