Last change
on this file since 454 was
444,
checked in by satin@…, 7 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
2.3 KB
|
Rev | Line | |
---|
[444] | 1 | /* M68HC11/M68HC12 serial line operations |
---|
| 2 | * Copyright (C) 1999, 2001, 2003, 2004 Stephane Carrez (stcarrez@nerim.fr) |
---|
| 3 | * |
---|
| 4 | * The authors hereby grant permission to use, copy, modify, distribute, |
---|
| 5 | * and license this software and its documentation for any purpose, provided |
---|
| 6 | * that existing copyright notices are retained in all copies and that this |
---|
| 7 | * notice is included verbatim in any distributions. No written agreement, |
---|
| 8 | * license, or royalty fee is required for any of the authorized uses. |
---|
| 9 | * Modifications to this software may be copyrighted by their authors |
---|
| 10 | * and need not follow the licensing terms described here, provided that |
---|
| 11 | * the new terms are clearly indicated on the first page of each file where |
---|
| 12 | * they apply. |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | #ifdef __HAVE_SHORT_INT__ |
---|
| 16 | .mode mshort |
---|
| 17 | #else |
---|
| 18 | .mode mlong |
---|
| 19 | #endif |
---|
| 20 | |
---|
| 21 | #if defined(__USE_RTC__) |
---|
| 22 | .macro ret |
---|
| 23 | #if defined(mc68hc12) |
---|
| 24 | rtc |
---|
| 25 | #else |
---|
| 26 | jmp __return_32 |
---|
| 27 | #endif |
---|
| 28 | .endm |
---|
| 29 | #else |
---|
| 30 | .macro ret |
---|
| 31 | rts |
---|
| 32 | .endm |
---|
| 33 | #endif |
---|
| 34 | #ifdef mc68hc12 |
---|
| 35 | SC0CR1 = 0xC2 |
---|
| 36 | SC0CR2 = 0xC3 |
---|
| 37 | SC0SR1 = 0xC4 |
---|
| 38 | SC0DRL = 0xC7 |
---|
| 39 | SC0BD = 0xC0 |
---|
| 40 | |
---|
| 41 | .sect .data |
---|
| 42 | .globl _m68hc12_ports |
---|
| 43 | _m68hc12_ports: .word 0 |
---|
| 44 | |
---|
| 45 | .sect .text |
---|
| 46 | .globl outbyte |
---|
| 47 | ;;; |
---|
| 48 | ;;; int outbyte(char c); |
---|
| 49 | ;;; |
---|
| 50 | ;;; B : Character to send |
---|
| 51 | ;;; |
---|
| 52 | outbyte: |
---|
| 53 | bsr _sci_init |
---|
| 54 | L1: |
---|
| 55 | ldaa SC0SR1,x |
---|
| 56 | bge L1 |
---|
| 57 | stab SC0DRL,x |
---|
| 58 | ldab SC0CR2,x |
---|
| 59 | orab #0x8 |
---|
| 60 | stab SC0CR2,x |
---|
| 61 | ret |
---|
| 62 | |
---|
| 63 | .sect .text |
---|
| 64 | .globl inbyte |
---|
| 65 | ;;; |
---|
| 66 | ;;; char inbyte(void); |
---|
| 67 | ;;; |
---|
| 68 | inbyte: |
---|
| 69 | bsr _sci_init |
---|
| 70 | ldaa SC0SR1,x |
---|
| 71 | bita #0x20 |
---|
| 72 | beq inbyte |
---|
| 73 | ldab SC0CR2,x |
---|
| 74 | ret |
---|
| 75 | |
---|
| 76 | .globl _sci_init |
---|
| 77 | .sect .text |
---|
| 78 | _sci_init: |
---|
| 79 | ldx _m68hc12_ports |
---|
| 80 | beq do_init |
---|
| 81 | dex |
---|
| 82 | rts |
---|
| 83 | do_init: |
---|
| 84 | ldx #0x1 |
---|
| 85 | stx _m68hc12_ports |
---|
| 86 | dex |
---|
| 87 | ldd #26 |
---|
| 88 | std SC0BD,x |
---|
| 89 | ldaa #0 |
---|
| 90 | staa SC0CR1,x |
---|
| 91 | ldaa #0xC |
---|
| 92 | staa SC0CR2,x |
---|
| 93 | rts |
---|
| 94 | #else |
---|
| 95 | BAUD = 0x2b |
---|
| 96 | SCCR1= 0x2c |
---|
| 97 | SCCR2= 0x2d |
---|
| 98 | SCSR = 0x2e |
---|
| 99 | SCDR = 0x2f |
---|
| 100 | |
---|
| 101 | .sect .data |
---|
| 102 | .globl _m68hc11_ports |
---|
| 103 | _m68hc11_ports: .word 0 |
---|
| 104 | |
---|
| 105 | .sect .text |
---|
| 106 | .globl outbyte |
---|
| 107 | ;;; |
---|
| 108 | ;;; int outbyte(char c); |
---|
| 109 | ;;; |
---|
| 110 | ;;; B : Character to send |
---|
| 111 | ;;; |
---|
| 112 | outbyte: |
---|
| 113 | bsr _sci_init |
---|
| 114 | L1: |
---|
| 115 | ldaa SCSR,x |
---|
| 116 | bge L1 |
---|
| 117 | stab SCDR,x |
---|
| 118 | ldab SCCR2,x |
---|
| 119 | orab #0x8 |
---|
| 120 | stab SCCR2,x |
---|
| 121 | ret |
---|
| 122 | |
---|
| 123 | .sect .text |
---|
| 124 | .globl inbyte |
---|
| 125 | ;;; |
---|
| 126 | ;;; char inbyte(void); |
---|
| 127 | ;;; |
---|
| 128 | inbyte: |
---|
| 129 | bsr _sci_init |
---|
| 130 | ldaa SCSR,x |
---|
| 131 | bita #0x20 |
---|
| 132 | beq inbyte |
---|
| 133 | ldab SCDR,x |
---|
| 134 | ret |
---|
| 135 | |
---|
| 136 | .globl _sci_init |
---|
| 137 | .sect .text |
---|
| 138 | _sci_init: |
---|
| 139 | ldx _m68hc11_ports |
---|
| 140 | beq do_init |
---|
| 141 | rts |
---|
| 142 | do_init: |
---|
| 143 | ldx #0x1000 |
---|
| 144 | stx _m68hc11_ports |
---|
| 145 | ldaa #0x30 |
---|
| 146 | staa BAUD,x |
---|
| 147 | clra |
---|
| 148 | staa SCCR1,x |
---|
| 149 | ldaa #0xC |
---|
| 150 | staa SCCR2,x |
---|
| 151 | rts |
---|
| 152 | |
---|
| 153 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.