/*----------------------------------------------------------------------------*/ void uartConfigPins(struct UartBase *interface, const struct UartBaseConfig *config) { /* Direction configuration is not needed for alternate function pins */ if (config->rx) { /* Configure UART RX pin */ const struct PinEntry * const pinEntry = pinFind(uartPins, config->rx, interface->channel); assert(pinEntry); const struct Pin pin = pinInit(config->rx); pinInput(pin); pinSetFunction(pin, pinEntry->value); } if (config->tx) { /* Configure UART TX pin */ const struct PinEntry * const pinEntry = pinFind(uartPins, config->tx, interface->channel); assert(pinEntry); const struct Pin pin = pinInit(config->tx); pinInput(pin); pinSetFunction(pin, pinEntry->value); } }
/*----------------------------------------------------------------------------*/ static uint8_t configMatchPin(uint8_t channel, PinNumber key) { const struct PinEntry * const pinEntry = pinFind(gpPwmPins, key, channel); assert(pinEntry); const struct Pin pin = pinInit(key); pinOutput(pin, false); pinSetFunction(pin, UNPACK_FUNCTION(pinEntry->value)); return UNPACK_CHANNEL(pinEntry->value); }
/*----------------------------------------------------------------------------*/ static void configPins(struct I2sBase *interface, const struct I2sBaseConfig *config) { const pinNumber pinArray[] = { config->rx.sck, config->rx.ws, config->rx.sda, config->rx.mclk, config->tx.sck, config->tx.ws, config->tx.sda, config->tx.mclk }; for (unsigned int index = 0; index < ARRAY_SIZE(pinArray); ++index) { if (pinArray[index]) { const struct PinEntry * const pinEntry = pinFind(i2sPins, pinArray[index], interface->channel); assert(pinEntry); const struct Pin pin = pinInit(pinArray[index]); pinInput(pin); pinSetFunction(pin, pinEntry->value); } } }
/*----------------------------------------------------------------------------*/ static void configPins(struct SdmmcBase *interface, const struct SdmmcBaseConfig *config) { const pinNumber pinArray[] = { config->clk, config->cmd, config->dat0, config->dat1, config->dat2, config->dat3 }; bool wide = true; for (unsigned int index = 0; index < ARRAY_SIZE(pinArray); ++index) { if (!pinArray[index]) { /* First three pins are mandatory */ assert(index >= 3); wide = false; continue; } const struct PinEntry * const pinEntry = pinFind(sdmmcPins, pinArray[index], 0); assert(pinEntry); const struct Pin pin = pinInit(pinArray[index]); pinInput(pin); pinSetFunction(pin, pinEntry->value); } interface->wide = wide; }