Browse Source

Checks for nested interrupt. Fixed USART TX problem.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@672 bbd45198-f89e-11dd-88c7-29a3b14d5316
kyle.hu.gz 15 years ago
parent
commit
2c0f89d99a
2 changed files with 9 additions and 4 deletions
  1. 8 3
      libcpu/avr32/uc3/exception.S
  2. 1 1
      libcpu/avr32/uc3/serial.c

+ 8 - 3
libcpu/avr32/uc3/exception.S

@@ -202,16 +202,21 @@ _int\priority:
   call    rt_interrupt_enter
   icall   r12
   call    rt_interrupt_leave
-_spint\priority:
-  lda.w   r12, rt_thread_switch_interrupt_flag
+  ssrf    AVR32_SR_GM_OFFSET			/* Disable global interrupt */
+  lda.w   r12, rt_interrupt_nest		/* Is nested interrupt? */
+  ld.w    r11, r12[0]
+  cp.w    r11, 0
+  brne    _spint\priority
+  lda.w   r12, rt_thread_switch_interrupt_flag	/* Is thread switch required? */
   ld.w    r11, r12[0]
   cp.w    r11, 1
   breq    rt_hw_context_switch_interrupt_do
+_spint\priority:
+  csrf    AVR32_SR_GM_OFFSET			/* Enable global interrupt */
   rete                    // If this was a spurious interrupt (R12 == NULL), return from event handler.
   .endr
 
 rt_hw_context_switch_interrupt_do:
-  ssrf    AVR32_SR_GM_OFFSET			/* Disable global interrupt */
   mov     r11, 0
   st.w    r12[0], r11					/* Clear rt_thread_switch_interrupt_flag */
   stm     --sp, r0-r7					/* Push R0-R7 */

+ 1 - 1
libcpu/avr32/uc3/serial.c

@@ -160,7 +160,7 @@ static rt_size_t rt_serial_write (rt_device_t dev, rt_off_t pos, const void* buf
 			/* write data directly */
 			while (size)
 			{
-				while (usart_write_char(uart->uart_device, (int) *ptr) != USART_SUCCESS);
+				while (usart_bw_write_char(uart->uart_device, (int) *ptr) != USART_SUCCESS);
 
 				++ptr; --size;
 			}