mbed library sources
Dependents: Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more
Superseded
This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.
Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.
If you are looking for a stable and tested release, please import one of the official mbed library releases:
Import librarymbed
The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Diff: targets/hal/TARGET_NXP/TARGET_LPC82X/serial_api.c
- Revision:
- 503:486aded571c7
- Parent:
- 387:643a59b3dbac
- Child:
- 600:7d17ca308cd1
--- a/targets/hal/TARGET_NXP/TARGET_LPC82X/serial_api.c Tue Apr 07 07:15:17 2015 +0100 +++ b/targets/hal/TARGET_NXP/TARGET_LPC82X/serial_api.c Tue Apr 07 07:30:12 2015 +0100 @@ -90,10 +90,39 @@ int stdio_uart_inited = 0; serial_t stdio_uart; +static int check_duplication(serial_t *obj, PinName tx, PinName rx) +{ + if (uart_used == 0) + return 0; + + const SWM_Map *swm; + uint32_t assigned_tx, assigned_rx; + int ch; + for (ch=0; ch<UART_NUM; ch++) { + // read assigned TX in the UART channel of switch matrix + swm = &SWM_UART_TX[ch]; + assigned_tx = LPC_SWM->PINASSIGN[swm->n] & (0xFF << swm->offset); + assigned_tx = assigned_tx >> swm->offset; + // read assigned RX in the UART channel of switch matrix + swm = &SWM_UART_RX[ch]; + assigned_rx = LPC_SWM->PINASSIGN[swm->n] & (0xFF << swm->offset); + assigned_rx = assigned_rx >> swm->offset; + if ((assigned_tx == (uint32_t)(tx >> PIN_SHIFT)) && (assigned_rx == (uint32_t)(rx >> PIN_SHIFT))) { + obj->index = ch; + obj->uart = (LPC_USART0_Type *)(LPC_USART0_BASE + (0x4000 * ch)); + return 1; + } + } + return 0; +} + void serial_init(serial_t *obj, PinName tx, PinName rx) { int is_stdio_uart = 0; + if (check_duplication(obj, tx, rx) == 1) + return; + int uart_n = get_available_uart(); if (uart_n == -1) { error("No available UART"); @@ -192,7 +221,7 @@ stop_bits -= 1; data_bits -= 7; - int paritysel; + int paritysel = 0; switch (parity) { case ParityNone: paritysel = 0; break; case ParityEven: paritysel = 2; break;