--- terminal.s	2014-06-26 23:14:38.000000000 +1000
+++ terminal-usart2-only.s	2017-04-27 20:22:53.245790175 +1000
@@ -47,21 +47,42 @@
         .equ USART1_BASE     ,   0x40013800
         
         .equ USART1_CR1      ,   USART1_BASE + 0x00
-        .equ USART1_CR2      ,   USART1_BASE + 0x04
-        .equ USART1_CR3      ,   USART1_BASE + 0x08
+        .equ USART1_CR2      ,   USART1_BASE + 0x04 @ unused
+        .equ USART1_CR3      ,   USART1_BASE + 0x08 @ unused
         .equ USART1_BRR      ,   USART1_BASE + 0x0C
-        .equ USART1_GTPR     ,   USART1_BASE + 0x10
-        .equ USART1_RTOR     ,   USART1_BASE + 0x14
-        .equ USART1_RQR      ,   USART1_BASE + 0x18
-        .equ USART1_ISR      ,   USART1_BASE + 0x1C
-        .equ USART1_ICR      ,   USART1_BASE + 0x20
+        .equ USART1_GTPR     ,   USART1_BASE + 0x10 @ unused
+        .equ USART1_RTOR     ,   USART1_BASE + 0x14 @ unused
+        .equ USART1_RQR      ,   USART1_BASE + 0x18 @ unused
+        .equ USART1_ISR      ,   USART1_BASE + 0x1C 
+        .equ USART1_ICR      ,   USART1_BASE + 0x20 @ unused
         .equ USART1_RDR      ,   USART1_BASE + 0x24
         .equ USART1_TDR      ,   USART1_BASE + 0x28
 
         @ Flags for USART1_ISR register:
-          .equ RXNE            ,   BIT5
-          .equ TC              ,   BIT6
-          .equ TXE             ,   BIT7
+          .equ USART1_RXNE            ,   BIT5
+          .equ USART1_TC              ,   BIT6
+          .equ USART1_TXE             ,   BIT7
+
+
+
+	.equ USART2_BASE     ,   0x40004400
+        
+        .equ USART2_CR1      ,   USART2_BASE + 0x00
+        .equ USART2_CR2      ,   USART2_BASE + 0x04	
+        .equ USART2_CR3      ,   USART2_BASE + 0x08
+        .equ USART2_BRR      ,   USART2_BASE + 0x0C
+        .equ USART2_GTPR     ,   USART2_BASE + 0x10
+        .equ USART2_RTOR     ,   USART2_BASE + 0x14
+        .equ USART2_RQR      ,   USART2_BASE + 0x18
+        .equ USART2_ISR      ,   USART2_BASE + 0x1C
+        .equ USART2_ICR      ,   USART2_BASE + 0x20
+        .equ USART2_RDR      ,   USART2_BASE + 0x24
+        .equ USART2_TDR      ,   USART2_BASE + 0x28
+
+        @ Flags for USART2_ISR register:
+          .equ USART2_RXNE            ,   BIT5
+          .equ USART2_TC              ,   BIT6
+          .equ USART2_TXE             ,   BIT7
 
 @ -----------------------------------------------------------------------------
 uart_init:
@@ -73,30 +94,58 @@
   str r0, [r1]
 
   @ Turn on the clock for USART1.
-  ldr r1, = RCC_APB2ENR
-  ldr r0, = BIT14 @ USART1EN
+  @ ldr r1, = RCC_APB2ENR
+  @ ldr r0, = BIT14 @ RCC_USART1EN
+  @ str r0, [r1]
+
+  @ Turn on the clock for USART2
+  ldr r1, = RCC_APB1ENR
+  ldr r0, = BIT17 @ RCC_USART2EN
   str r0, [r1]
 
-  @ Set PORTA pins 9 and 10 in alternate function mode
+
+  @ Set PORTA pins 9 (TX) and 10 (RX) in AF1 for USART1
+  @ ldr r1, = GPIOA_MODER
+  @ ldr r0, = 0x280000 @ 2800 0000 is Reset value for Port A, and switch PA9 and PA10 to alternate function
+  @ str r0, [r1]
+
+  @ Set PORTA pins 2 (TX) and 3 (RX) in AF1 for USART2
   ldr r1, = GPIOA_MODER
-  ldr r0, = 0x28280000 @ 2800 0000 is Reset value for Port A, and switch PA9 and PA10 to alternate function
+  ldr r0, = 0xA0
   str r0, [r1]
 
-  @ Set alternate function 1 to enable USART1 pins on Port A
-  ldr r1, = GPIOA_AFRH
-  ldr r0, = 0x110      @ Alternate function 1 for TX and RX pins of USART1 on PORTA 
+
+  @ Set alternate function 1 to enable USART1 pins 9 AND 10 on Port A
+  @ ldr r1, = GPIOA_AFRH
+  @ ldr r0, = 0x110      @ Alternate function 1 for TX and RX pins of USART1 on PORTA 
+  @ str r0, [r1]
+
+  @ Set alternate function 1 to enable USART2 pins 2 and 3 on Port A:               0001|0001|0000|0000
+  ldr r1, = GPIOA_AFRL
+  ldr r0, = 0x1100	@ Alternate function 1 for TX and RX pins of USART2 on PORTA
   str r0, [r1]
 
-  @ Configure BRR by deviding the bus clock with the baud rate
-  ldr r1, = USART1_BRR
-  movs r0, #0x46  @ 115200 bps, ein ganz kleines bisschen langsamer...
+  @ Configure USART1_BRR by deviding the bus clock with the baud rate
+  @ ldr r1, = USART1_BRR
+  @ movs r0, #0x46  @ 115200 bps, a little bit slower
+  @ str r0, [r1]
+
+  @ Configure USART2_BRR by deviding the bus clock with the baud rate
+  ldr r1, = USART2_BRR
+  movs r0, #0x46  @ 115200 bps, a little bit slower
   str r0, [r1]
 
-  @ Enable the USART, TX, and RX circuit
-  ldr r1, =USART1_CR1
-  ldr r0, =BIT3+BIT2+BIT0 @ USART_CR1_UE | USART_CR1_TE | USART_CR1_RE
+  @ Enable the USART1, TX, and RX circuit
+  @ ldr r1, =USART1_CR1
+  @ ldr r0, =BIT3+BIT2+BIT0 @ USART1_UE | USART1_TE | USART_RE
+  @ str r0, [r1]
+
+  @ Enable the USART2, TX, and RX circuit 
+  ldr r1, =USART2_CR1
+  ldr r0, =BIT3+BIT2+BIT0 @ USART2_UE | USART2_TE | USART2_RE
   str r0, [r1]
 
+
   bx lr
 
 .include "../common/terminalhooks.s"
@@ -112,7 +161,7 @@
    drop
    beq 1b
 
-   ldr r2, =USART1_TDR
+   ldr r2, =USART2_TDR
    strb tos, [r2]         @ Output the character
    drop
 
@@ -130,7 +179,7 @@
    beq 1b
 
    pushdatos
-   ldr r2, =USART1_RDR
+   ldr r2, =USART2_RDR
    ldrb tos, [r2]         @ Fetch the character
 
    pop {pc}
@@ -143,9 +192,9 @@
    bl pause
 
    pushdaconst 0  @ False Flag
-   ldr r0, =USART1_ISR
+   ldr r0, =USART2_ISR
    ldr r1, [r0]     @ Fetch status
-   movs r0, #TXE
+   movs r0, #USART2_TXE
    ands r1, r0
    beq 1f
      mvns tos, tos @ True Flag
@@ -159,12 +208,13 @@
    bl pause
 
    pushdaconst 0  @ False Flag
-   ldr r0, =USART1_ISR
+   ldr r0, =USART2_ISR
    ldr r1, [r0]     @ Fetch status
-   movs r0, #RXNE
+   movs r0, #USART2_RXNE
    ands r1, r0
    beq 1f
      mvns tos, tos @ True Flag
 1: pop {pc}
 
-  .ltorg @ Hier werden viele spezielle Hardwarestellenkonstanten gebraucht, schreibe sie gleich !
+  .ltorg @ Here, many special hardware site constants are needed, write them immediately
+
