- Timestamp:
- Sep 8, 2019, 9:09:42 AM (5 years ago)
- Branches:
- main
- Children:
- c956fd4
- Parents:
- 6f22754
- Location:
- libs/usart
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libs/usart/usart.c
r6f22754 re5dd493 8 8 #endif 9 9 10 #ifdef __AVR_ATmega128__11 10 // FIXME there are two USARTs in this case and we should be able to drive either 12 #define UBRRH UBRR0H 13 #define UBRRL UBRR0L 14 #define UCSRA UCSR0A 15 #define UCSRC UCSR0C 16 #define UCSRB UCSR0B 17 #define UDR UDR0 11 12 // Compatibility for devices with single USART only 13 #ifdef __AVR_ATmega8__ 14 #define UBRR0H UBRRH 15 #define UBRR0L UBRRL 16 #define UCSR0A UCSRA 17 #define UCSR0C UCSRC 18 #define UCSR0B UCSRB 19 #define UDR0 UDR 20 #define UDRE0 UDRE 21 #define RXC0 RXC 18 22 #endif 19 23 20 //This function is used to initialize the USART21 24 void USARTInit() 22 25 { … … 51 54 52 55 53 //This fuction writes the given "data" to54 //the USART which then transmit it via TX line55 56 void USARTWriteChar(char data) 56 57 { … … 67 68 68 69 69 //This function is used to read the available data70 //from USART. This function will wait untill data is71 //available.72 70 char USARTReadChar() 73 71 { -
libs/usart/usart.h
r6f22754 re5dd493 1 1 /* USART i/o library 2 * Copyright 2010-201 4, Adrien Destugues <pulkomandy@pulkomandy.tk>2 * Copyright 2010-2019, Adrien Destugues <pulkomandy@pulkomandy.tk> 3 3 * Distributed under the terms of the MIT Licence */ 4 4 5 #include <stdint.h> 5 /** Initialize the USART. 6 * 7 * Baudrate is set according to the BAUD define. 8 * Currently the USART is set to 8N1, except on ATmega128 where it's set to 7E1 9 * (don't ask why, I don't remember). This should be made configurable. 10 * 11 * On ATmega128, this always uses the first USART. 12 */ 13 void USARTInit(); 6 14 7 void USARTInit(); 15 /** Write a byte to the USART. 16 * 17 * This function blocks if the USART is not ready to accept any data. There is 18 * no IO buffering. 19 */ 8 20 void USARTWriteChar(char data); 21 22 /** Write an 8bit integer as hex to the USART. 23 */ 9 24 void USARTWriteHex(unsigned char i); 25 26 /** This function is used to read the available data from USART. 27 * 28 * It waits untill data is available. 29 */ 30 char USARTReadChar();
Note:
See TracChangeset
for help on using the changeset viewer.