Allow Serial pin to be NC on Freescale/NXP devices

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).
pull/530/head
Sissors 2014-10-04 22:47:25 +02:00
parent b5b42b5f4b
commit 86e71216fa
11 changed files with 44 additions and 22 deletions

View File

@ -98,7 +98,9 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
pinmap_pinout(rx, PinMap_UART_RX);
// set rx/tx pins in PullUp mode
if (tx != NC)
pin_mode(tx, PullUp);
if (rx != NC)
pin_mode(rx, PullUp);
obj->uart->C2 |= (UART_C2_RE_MASK | UART_C2_TE_MASK);

View File

@ -96,7 +96,9 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
pinmap_pinout(rx, PinMap_UART_RX);
// set rx/tx pins in PullUp mode
if (tx != NC)
pin_mode(tx, PullUp);
if (rx != NC)
pin_mode(rx, PullUp);
obj->uart->C2 |= (UARTLP_C2_RE_MASK | UARTLP_C2_TE_MASK);

View File

@ -68,7 +68,9 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
pinmap_pinout(tx, PinMap_UART_TX);
pinmap_pinout(rx, PinMap_UART_RX);
if (tx != NC)
pin_mode(tx, PullUp);
if (rx != NC)
pin_mode(rx, PullUp);
if (obj->index == STDIO_UART) {

View File

@ -142,7 +142,9 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
pinmap_pinout(rx, PinMap_UART_RX);
// set rx/tx pins in PullUp mode
if (tx != NC)
pin_mode(tx, PullUp);
if (rx != NC)
pin_mode(rx, PullUp);
is_stdio_uart = (uart == STDIO_UART) ? (1) : (0);

View File

@ -73,7 +73,9 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
pinmap_pinout(rx, PinMap_UART_RX);
// set rx/tx pins in PullUp mode
if (tx != NC)
pin_mode(tx, PullUp);
if (rx != NC)
pin_mode(rx, PullUp);
switch (uart) {

View File

@ -82,7 +82,9 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
pinmap_pinout(rx, PinMap_UART_RX);
// set rx/tx pins in PullUp mode
if (tx != NC)
pin_mode(tx, PullUp);
if (rx != NC)
pin_mode(rx, PullUp);
switch (uart) {

View File

@ -85,7 +85,9 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
pinmap_pinout(rx, PinMap_UART_RX);
// set rx/tx pins in PullUp mode
if (tx != NC)
pin_mode(tx, PullUp);
if (rx != NC)
pin_mode(rx, PullUp);
switch (uart) {

View File

@ -120,7 +120,9 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
pinmap_pinout(rx, PinMap_UART_RX);
// set rx/tx pins in PullUp mode
if (tx != NC)
pin_mode(tx, PullUp);
if (rx != NC)
pin_mode(rx, PullUp);
switch (uart) {

View File

@ -96,7 +96,9 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
pinmap_pinout(rx, PinMap_UART_RX);
// set rx/tx pins in PullUp mode
if (tx != NC)
pin_mode(tx, PullUp);
if (rx != NC)
pin_mode(rx, PullUp);
switch (uart) {

View File

@ -104,7 +104,9 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
pinmap_pinout(rx, PinMap_UART_RX);
// set rx/tx pins in PullUp mode
if (tx != NC)
pin_mode(tx, PullUp);
if (rx != NC)
pin_mode(rx, PullUp);
switch (uart) {

View File

@ -139,8 +139,10 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
serial_format(obj, 8, ParityNone, 1);
// pinout the chosen uart
pinmap_pinout(tx, PinMap_UART_TX);
pinmap_pinout(rx, PinMap_UART_RX);
if (tx != NC)
pin_mode(tx, PullUp);
if (rx != NC)
pin_mode(rx, PullUp);
// set rx/tx pins in PullUp mode
pin_mode(tx, PullUp);