mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
Diff: targets/hal/TARGET_NXP/TARGET_LPC408X/serial_api.c
- Revision:
- 227:7bd0639b8911
- Parent:
- 140:ca60b7a31055
- Child:
- 250:a49055e7a707
--- a/targets/hal/TARGET_NXP/TARGET_LPC408X/serial_api.c Wed Jun 11 09:45:09 2014 +0100 +++ b/targets/hal/TARGET_NXP/TARGET_LPC408X/serial_api.c Wed Jun 11 16:00:09 2014 +0100 @@ -72,9 +72,7 @@ UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx); - if ((int)uart == NC) { - error("Serial pinout mapping failed"); - } + MBED_ASSERT((int)uart != NC); obj->uart = (LPC_UART_TypeDef *)uart; // enable power @@ -209,16 +207,12 @@ } void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { - // 0: 1 stop bits, 1: 2 stop bits - if (stop_bits != 1 && stop_bits != 2) { - error("Invalid stop bits specified"); - } + MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits + MBED_ASSERT((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits + MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) || + (parity == ParityForced1) || (parity == ParityForced0)); + stop_bits -= 1; - - // 0: 5 data bits ... 3: 8 data bits - if (data_bits < 5 || data_bits > 8) { - error("Invalid number of bits (%d) in serial format, should be 5..8", data_bits); - } data_bits -= 5; int parity_enable, parity_select; @@ -229,8 +223,7 @@ case ParityForced1: parity_enable = 1; parity_select = 2; break; case ParityForced0: parity_enable = 1; parity_select = 3; break; default: - error("Invalid serial parity setting"); - return; + break; } obj->uart->LCR = data_bits << 0