Nordic(?)/STM should also be done, but I don't know if they do their own
stuff.
Issue is that since the mbed-assert implementation, calling pin_mode
causes an assert when a pin is NC. Since defining a serial object with
only TX or RX is a valid use case, this should be handled.
pinmap_pinout does accept NC pins, so there no guards are needed (person
who adds asserts there may also fix it in all other code).
Made error(...) a weak function so that it can be overridden in
production projects. Also fixed several serial_api.c files that required
stdlib.h, but were getting it from error.h.
While fixing this issue in the various LPC* ports, I noticed a comment
pointing to this mbed forum post which summarizes this bug quite well:
https://mbed.org/forum/bugs-suggestions/topic/4473/
This bug was introduced in the following commit:
2662e105c4
The following code was added to serial_putc() as part of this commit:
uint32_t lsr = obj->uart->LSR;
lsr = lsr;
uint32_t thr = obj->uart->THR;
thr = thr;
As the forum post indicates, this causes the serial_putc() routine to
actually eat an inbound received byte if it exists since reading THR is
really reading the RBR, the Receiver Buffer Register. This code looks
like code that was probably added so that the developer could take a
snapshot of these registers and look at them in the debugger. It
probably got committed in error.