Browse Source

Fix Serial ISR priority for LPC1768

Co-Authored-By: p3p <p3p@p3psoft.co.uk>
Scott Lahteine 7 years ago
parent
commit
d86f25ab63
1 changed files with 17 additions and 4 deletions
  1. 17
    4
      Marlin/src/HAL/HAL_LPC1768/HardwareSerial.cpp

+ 17
- 4
Marlin/src/HAL/HAL_LPC1768/HardwareSerial.cpp View File

@@ -109,10 +109,23 @@ void HardwareSerial::begin(uint32_t baudrate) {
109 109
   UART_IntConfig(UARTx, UART_INTCFG_RBR, ENABLE);
110 110
   UART_IntConfig(UARTx, UART_INTCFG_RLS, ENABLE);
111 111
 
112
-  if (UARTx == LPC_UART0) NVIC_EnableIRQ(UART0_IRQn);
113
-  else if ((LPC_UART1_TypeDef *) UARTx == LPC_UART1) NVIC_EnableIRQ(UART1_IRQn);
114
-  else if (UARTx == LPC_UART2) NVIC_EnableIRQ(UART2_IRQn);
115
-  else if (UARTx == LPC_UART3) NVIC_EnableIRQ(UART3_IRQn);
112
+  // Set proper priority and enable interrupts
113
+  if (UARTx == LPC_UART0) {
114
+    NVIC_SetPriority(UART0_IRQn, NVIC_EncodePriority(0, 3, 0));
115
+    NVIC_EnableIRQ(UART0_IRQn);
116
+  }
117
+  else if ((LPC_UART1_TypeDef *) UARTx == LPC_UART1) {
118
+    NVIC_SetPriority(UART1_IRQn, NVIC_EncodePriority(0, 3, 0));
119
+   NVIC_EnableIRQ(UART1_IRQn);
120
+  }
121
+  else if (UARTx == LPC_UART2) {
122
+    NVIC_SetPriority(UART2_IRQn, NVIC_EncodePriority(0, 3, 0));
123
+    NVIC_EnableIRQ(UART2_IRQn);
124
+  }
125
+  else if (UARTx == LPC_UART3) {
126
+    NVIC_SetPriority(UART3_IRQn, NVIC_EncodePriority(0, 3, 0));
127
+    NVIC_EnableIRQ(UART3_IRQn);
128
+  }
116 129
 
117 130
   RxQueueWritePos = RxQueueReadPos = 0;
118 131
   #if TX_BUFFER_SIZE > 0

Loading…
Cancel
Save