diff --git a/libs/core/serial.cpp b/libs/core/serial.cpp index 614423fe..daeb813b 100644 --- a/libs/core/serial.cpp +++ b/libs/core/serial.cpp @@ -83,16 +83,19 @@ namespace serial { /** * Dynamically configuring the serial instance to use pins other than USBTX and USBRX. - * @param tx the new transmission pins - * @param rx the new reception pin - * @param baud the new baud rate. eg: 115200 + * @param tx the new transmission pins, eg: SerialPin.P0 + * @param rx the new reception pin, eg: SerialPin.P1 + * @param rate the new baud rate. eg: 115200 */ //% weight=10 //% help=serial/redirect-to //% blockId=serial_redirect block="serial|redirect to|TX %tx|RX %rx|at baud rate %rate" //% blockExternalInputs=1 void redirect(SerialPin tx, SerialPin rx, BaudRate rate) { - uBit.serial.redirect((PinName)tx, (PinName)rx); + MicroBitPin* txp = getPin(tx); if (!tx) return; + MicroBitPin* rxp = getPin(rx); if (!rx) return; + + uBit.serial.redirect(txp->name, rxp->name); uBit.serial.baud((int)rate); } }