aboutsummaryrefslogtreecommitdiffstats
path: root/src/atsam/serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/atsam/serial.c')
-rw-r--r--src/atsam/serial.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/atsam/serial.c b/src/atsam/serial.c
index 62c8ac44..cf69acb0 100644
--- a/src/atsam/serial.c
+++ b/src/atsam/serial.c
@@ -5,6 +5,7 @@
// This file may be distributed under the terms of the GNU GPLv3 license.
#include "autoconf.h" // CONFIG_SERIAL_BAUD
+#include "board/armcm_boot.h" // armcm_enable_irq
#include "board/serial_irq.h" // serial_rx_data
#include "command.h" // DECL_CONSTANT_STR
#include "internal.h" // gpio_peripheral
@@ -12,30 +13,27 @@
// Serial port pins
#if CONFIG_MACH_SAM3X
-#define Serial_IRQ_Handler UART_Handler
+#define UARTx_IRQn UART_IRQn
static Uart * const Port = UART;
-static const uint32_t Pmc_id = ID_UART, Irq_id = UART_IRQn;
-static const uint32_t rx_pin = GPIO('A', 8);
-static const uint32_t tx_pin = GPIO('A', 9);
+static const uint32_t Pmc_id = ID_UART;
+static const uint32_t rx_pin = GPIO('A', 8), tx_pin = GPIO('A', 9);
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA8,PA9");
#elif CONFIG_MACH_SAM4S
-#define Serial_IRQ_Handler UART1_Handler
+#define UARTx_IRQn UART1_IRQn
static Uart * const Port = UART1;
-static const uint32_t Pmc_id = ID_UART1, Irq_id = UART1_IRQn;
-static const uint32_t rx_pin = GPIO('B', 2);
-static const uint32_t tx_pin = GPIO('B', 3);
+static const uint32_t Pmc_id = ID_UART1;
+static const uint32_t rx_pin = GPIO('B', 2), tx_pin = GPIO('B', 3);
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PB2,PB3");
#elif CONFIG_MACH_SAM4E
-#define Serial_IRQ_Handler UART0_Handler
+#define UARTx_IRQn UART0_IRQn
static Uart * const Port = UART0;
-static const uint32_t Pmc_id = ID_UART0, Irq_id = UART0_IRQn;
-static const uint32_t rx_pin = GPIO('A', 9);
-static const uint32_t tx_pin = GPIO('A', 10);
+static const uint32_t Pmc_id = ID_UART0;
+static const uint32_t rx_pin = GPIO('A', 9), tx_pin = GPIO('A', 10);
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA9,PA10");
#endif
-void __visible
-Serial_IRQ_Handler(void)
+void
+UARTx_Handler(void)
{
uint32_t status = Port->UART_SR;
if (status & UART_SR_RXRDY)
@@ -74,8 +72,7 @@ serial_init(void)
| UART_MR_CHMODE_NORMAL);
Port->UART_BRGR = SystemCoreClock / (16 * CONFIG_SERIAL_BAUD);
Port->UART_IER = UART_IER_RXRDY;
- NVIC_EnableIRQ(Irq_id);
- NVIC_SetPriority(Irq_id, 0);
+ armcm_enable_irq(UARTx_Handler, UARTx_IRQn, 0);
Port->UART_CR = UART_CR_RXEN | UART_CR_TXEN;
}
DECL_INIT(serial_init);