summaryrefslogtreecommitdiff
path: root/samples/nfc
diff options
context:
space:
mode:
authorDaniel Leung <daniel.leung@intel.com>2016-03-03 10:14:50 -0800
committerAnas Nashif <nashif@linux.intel.com>2016-03-05 13:37:57 +0000
commite643cede3a4fb625bedc261240288a03e535dbf6 (patch)
treee31ed61a77635a0ecb4e9012e50f1a39b3b722e5 /samples/nfc
parentf8bf86c95fd17405a388ccca2bd7e5315f3df0fc (diff)
uart: add ISR callback mechanism for UART drivers
The peripherals utilizing UART were required to register their own ISR rountines. This means that all those peripherals drivers need to know which IRQ line is attached to a UART controller, and all the other config values required to register a ISR. This causes scalibility issue as every board and peripherals have to define those values. Another reason for this patch is to support virtual serial ports. Virtual serial ports do not have physical interrupt lines to attach, and thus would not work. This patch adds a simple callback mechanism, which calls a function when UART interrupts are triggered. The low level plumbing still needs to be done by the peripheral drivers, as these drivers may need to access low level capability of UART to function correctly. This simply moves the interrupt setup into the UART drivers themselves. By doing this, the peripheral drivers do not need to know all the config values to properly setup the interrupts and attaching the ISR. One drawback is that this adds to the interrupt latency. Note that this patch breaks backward compatibility in terms of setting up interrupt for UART controller. How to use UART is still the same. This also addresses the following issues: () UART driver for Atmel SAM3 currently does not support interrupts. So remove the code from vector table. This will be updated when there is interrupt support for the driver. () Corrected some config options for Stellaris UART driver. This was tested with samples/shell on Arduino 101, and on QEMU (Cortex-M3 and x86). Origin: original code Change-Id: Ib4593d8ccd711f4e97d388c7293205d213be1aec Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Diffstat (limited to 'samples/nfc')
-rw-r--r--samples/nfc/nfc_hello/src/main.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/samples/nfc/nfc_hello/src/main.c b/samples/nfc/nfc_hello/src/main.c
index 18a3e4263..42815e9d9 100644
--- a/samples/nfc/nfc_hello/src/main.c
+++ b/samples/nfc/nfc_hello/src/main.c
@@ -22,8 +22,6 @@
#include <board.h>
#include <uart.h>
-#define UART1_IRQ CONFIG_UART_NS16550_PORT_1_IRQ
-#define UART1_IRQ_PRI CONFIG_UART_NS16550_PORT_1_IRQ_PRI
#define BUF_MAXSIZE 256
struct device *uart1_dev;
@@ -53,7 +51,7 @@ static void msg_dump(const char *s, uint8_t *data, unsigned len)
printf("(%u bytes)\n", len);
}
-static void uart1_isr(void *x)
+static void uart1_isr(struct device *x)
{
int len = uart_fifo_read(uart1_dev, buf, BUF_MAXSIZE);
ARG_UNUSED(x);
@@ -64,9 +62,7 @@ static void uart1_init(void)
{
uart1_dev = device_get_binding("UART_1");
- IRQ_CONNECT(UART1_IRQ, UART1_IRQ_PRI, uart1_isr, 0, UART_IRQ_FLAGS);
-
- irq_enable(UART1_IRQ);
+ uart_irq_callback_set(uart1_dev, uart1_isr);
uart_irq_rx_enable(uart1_dev);