Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-src by
Diff: targets/hal/TARGET_NXP/TARGET_LPC82X/serial_api.c
- Revision:
- 387:643a59b3dbac
- Parent:
- 337:6ed01c00b962
--- a/targets/hal/TARGET_NXP/TARGET_LPC82X/serial_api.c Wed Nov 05 09:00:08 2014 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC82X/serial_api.c Wed Nov 05 14:30:08 2014 +0000
@@ -76,6 +76,9 @@
#define RXRDY (0x01<<0)
#define TXRDY (0x01<<2)
+#define RXRDYEN RXRDY
+#define TXRDYEN TXRDY
+
#define TXBRKEN (0x01<<1)
#define CTSEN (0x01<<9)
@@ -206,22 +209,15 @@
/******************************************************************************
* INTERRUPTS HANDLING
******************************************************************************/
-static inline void uart_irq(uint32_t iir, uint32_t index)
+static inline void uart_irq(SerialIrq irq_type, uint32_t index)
{
- SerialIrq irq_type;
- switch (iir) {
- case 1: irq_type = TxIrq; break;
- case 2: irq_type = RxIrq; break;
- default: return;
- }
-
if (serial_irq_ids[index] != 0)
irq_handler(serial_irq_ids[index], irq_type);
}
-void uart0_irq() {uart_irq((LPC_USART0->STAT & (1 << 2)) ? 2 : 1, 0);}
-void uart1_irq() {uart_irq((LPC_USART1->STAT & (1 << 2)) ? 2 : 1, 1);}
-void uart2_irq() {uart_irq((LPC_USART2->STAT & (1 << 2)) ? 2 : 1, 2);}
+void uart0_irq() {uart_irq((LPC_USART0->INTSTAT & RXRDY) ? RxIrq : TxIrq, 0);}
+void uart1_irq() {uart_irq((LPC_USART1->INTSTAT & RXRDY) ? RxIrq : TxIrq, 1);}
+void uart2_irq() {uart_irq((LPC_USART2->INTSTAT & RXRDY) ? RxIrq : TxIrq, 2);}
void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id)
{
@@ -240,16 +236,15 @@
}
if (enable) {
- obj->uart->INTENSET = (1 << ((irq == RxIrq) ? 0 : 2));
+ NVIC_DisableIRQ(irq_n);
+ obj->uart->INTENSET |= (1 << ((irq == RxIrq) ? 0 : 2));
NVIC_SetVector(irq_n, vector);
NVIC_EnableIRQ(irq_n);
} else { // disable
- int all_disabled = 0;
- SerialIrq other_irq = (irq == RxIrq) ? (TxIrq) : (RxIrq);
- obj->uart->INTENSET &= ~(1 << ((irq == RxIrq) ? 0 : 2));
- all_disabled = (obj->uart->INTENSET & (1 << ((other_irq == RxIrq) ? 0 : 2))) == 0;
- if (all_disabled)
+ obj->uart->INTENCLR |= (1 << ((irq == RxIrq) ? 0 : 2));
+ if ( (obj->uart->INTENSET & (RXRDYEN | TXRDYEN)) == 0) {
NVIC_DisableIRQ(irq_n);
+ }
}
}
