From ca929c6fc63607f9611f86392cb8e056f9a9fd95 Mon Sep 17 00:00:00 2001
From: Gerardo Puga <glpuga@gmail.com>
Date: Thu, 10 Jun 2010 08:10:00 -0500
Subject: [PATCH] PR 1548: ERC32 console stops working when UART error flags
are set
Problem:
The console works fine when only transmitting data from the ERC32, but stops
working after a while when receiving data.
"Stops working" means, bytes are neither sent nor received from the UART, but
the rest of the system keeps functioning (task are executing, the operative
system is responsive, etc).
Context:
- When an RX error occurs, the ERC32 UARTS stop generating RX/TX interrupts
until the corresponding error flag in the UART_STATUS are cleared.
- The console.c code currently cleans the error flags from the console_isr_x
subroutines, but those are NOT called when an RX error occurs. Thus the error
flag is never cleaned and then the UARTs stop generating interrupts
indefinitely.
- The ERC32 UARTs generate a different interrupt when an RX error occurs.
Fixed by:
- Adding a third interrupt service routine console_isr_error to handle the
UART_ERROR trap. This isr cleans the error flags of the channels.
- Cleaning the error flags manually just after having initialized the interrupt
vectors. This is because if the error flag was already set by the time the
interrupt vectors are configured, the interrupts might never be called.
---
.../lib/libbsp/sparc/erc32/console/erc32_console.c | 26 ++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/c/src/lib/libbsp/sparc/erc32/console/erc32_console.c b/c/src/lib/libbsp/sparc/erc32/console/erc32_console.c
index 2acc72f156..8747e3e87b 100644
a
|
b
|
static ssize_t erc32_console_write_support_int(int minor, const char *buf, size_ |
174 | 174 | return 0; |
175 | 175 | } |
176 | 176 | |
| 177 | static void erc32_console_isr_error( |
| 178 | rtems_vector_number vector |
| 179 | ) |
| 180 | { |
| 181 | int UStat; |
| 182 | |
| 183 | UStat = ERC32_MEC.UART_Status; |
| 184 | |
| 185 | if (UStat & ERC32_MEC_UART_STATUS_ERRA) { |
| 186 | ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRA; |
| 187 | ERC32_MEC.Control = ERC32_MEC.Control; |
| 188 | } |
| 189 | |
| 190 | if (UStat & ERC32_MEC_UART_STATUS_ERRB) { |
| 191 | ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRB; |
| 192 | ERC32_MEC.Control = ERC32_MEC.Control; |
| 193 | } |
| 194 | |
| 195 | ERC32_Clear_interrupt( ERC32_INTERRUPT_UART_ERROR ); |
| 196 | } |
| 197 | |
177 | 198 | static void erc32_console_isr_a( |
178 | 199 | rtems_vector_number vector |
179 | 200 | ) |
… |
… |
static void erc32_console_initialize( |
304 | 325 | #if (CONSOLE_USE_INTERRUPTS) |
305 | 326 | set_vector(erc32_console_isr_a, CONSOLE_UART_A_TRAP, 1); |
306 | 327 | set_vector(erc32_console_isr_b, CONSOLE_UART_B_TRAP, 1); |
| 328 | set_vector(erc32_console_isr_error, CONSOLE_UART_ERROR_TRAP, 1); |
307 | 329 | #endif |
| 330 | |
| 331 | /* Clear any previous error flags */ |
| 332 | ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRA; |
| 333 | ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRB; |
308 | 334 | } |