3 This file is part of the AVR-uart_ni.
4 Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "avr-asm-macros.S"
22 #include "uart_defs.h"
23 /******************************************************************************/
28 # warning "UART0: using default paraty: 'none'"
29 # define UART0_PARATY UART_PARATY_NONE
32 #ifndef UART0_STOPBITS
33 # warning "UART0: using default ammount of stop bits: '1'"
34 # define UART0_STOPBITS UART_STOPBITS_1
37 #ifndef UART0_DATABITS
38 # warning "UART0: using default ammount of data bits: '8'"
39 # define UART0_DATABITS UART_DATABITS_8
46 # error "can not decide which registernames to use, UDR and UDR0 are defined"
65 #define BAUD (UART0_BAUD_RATE)
66 #include "setbaud_asm.inc"
68 /******************************************************************************/
76 #if _SFR_IO_REG_P(UCSR0A)
78 sbi _SFR_IO_ADDR(UCSR0A), 1
80 cbi _SFR_IO_ADDR(UCSR0A), 1
83 lds r24, _SFR_MEM_ADDR(UCSR0A)
89 sts _SFR_MEM_ADDR(UCSR0A), r24
91 ldi r24, (UART0_PARATY<<4)|(UART0_STOPBITS<<3)|((UART0_DATABITS&3)<<1)
93 ldi r24, _BV(TXEN0)|_BV(RXEN0)|((UART0_DATABITS>>2)<<2)
97 /******************************************************************************/
101 #if _SFR_IO_REG_P(UCSR0A)
102 sbis _SFR_IO_ADDR(UCSR0A), UDRE0
105 lds r25, _SFR_MEM_ADDR(UCSR0A)
109 #if UART0_DATABITS == UART_DATABITS_9
110 # if _SFR_IO_REG_P(UCSR0B)
115 lds r23, _SFR_MEM_ADDR(UCSR0B)
118 sts _SFR_MEM_ADDR(UCSR0B), r23
124 /******************************************************************************/
128 #if _SFR_IO_REG_P(UCSR0A)
129 sbis _SFR_IO_ADDR(UCSR0A), RXC0
132 lds r25, _SFR_MEM_ADDR(UCSR0A)
137 #if UART0_DATABITS == UART_DATABITS_9
147 /******************************************************************************/
149 .global uart0_dataavail
156 #endif /* UART0_NI */
158 /******************************************************************************/
159 /******************************************************************************/
160 /******************************************************************************/
165 # error "registernames for second UART not defined"
169 # warning "UART1: using default paraty: 'none'"
170 # define UART1_PARATY UART_PARATY_NONE
173 #ifndef UART1_STOPBITS
174 # warning "UART1: using default ammount of stop bits: '1'"
175 # define UART1_STOPBITS UART_STOPBITS_1
178 #ifndef UART1_DATABITS
179 # warning "UART1: using default ammount of data bits: '8'"
180 # define UART1_DATABITS UART_DATABITS_8
187 #define BAUD (UART1_BAUD_RATE)
189 #include "setbaud_asm.inc"
191 /******************************************************************************/
199 #if _SFR_IO_REG_P(UCSR1A)
201 sbi _SFR_IO_ADDR(UCSR1A), 1
203 cbi _SFR_IO_ADDR(UCSR1A), 1
206 lds r24, _SFR_MEM_ADDR(UCSR1A)
212 sts _SFR_MEM_ADDR(UCSR1A), r24
214 ldi r24, (UART1_PARATY<<4)|(UART1_STOPBITS<<3)|((UART1_DATABITS&3)<<1)
216 ldi r24, _BV(TXEN1)|_BV(RXEN1)|((UART1_DATABITS>>2)<<2)
220 /******************************************************************************/
224 #if _SFR_IO_REG_P(UCSR1A)
225 sbis _SFR_IO_ADDR(UCSR1A), UDRE1
228 lds r23, _SFR_MEM_ADDR(UCSR1A)
232 #if UART1_DATABITS == UART_DATABITS_9
233 # if _SFR_IO_REG_P(UCSR1B)
238 lds r23, _SFR_MEM_ADDR(UCSR1B)
241 sts _SFR_MEM_ADDR(UCSR1B), r23
247 /******************************************************************************/
251 #if _SFR_IO_REG_P(UCSR1A)
252 sbis _SFR_IO_ADDR(UCSR1A), RXC1
255 lds r25, _SFR_MEM_ADDR(UCSR1A)
259 #if UART1_DATABITS == UART_DATABITS_9
269 /******************************************************************************/
271 .global uart1_dataavail
278 #endif /* UART1_NI */