/*================================================================================================ usart.c SiWiCom copyright 2006 v1.0 (2006-05-22) Name: Christoffer Martinsson E-mail: cm@cmtec.se Name: Joakim Nilsson E-mail: mail@jopin.se Description: Routines for USART USART configuration is done by hardware.h witch must contain the following definitions: (X=letter i.e PORTX=PORTB, n=number i.e PXn=PB4) USART_DDR DDRX (Example: #define USART_DDR DDRD) USART_PORT PORTX (Example: #define USART_PORT PORTD) USART_RX PXn (Example: #define USART_RX PD0) USART_TX PXn (Example: #define USART_TX PD1) ================================================================================================*/ #include #include #include #include /*================================================================================================ Functions ================================================================================================*/ /*================================================================================================ usartSetBaud Description: Set baudrate. Input value should be acording to following formula: baud = ((F_CPU/(8*BAUDRATE))-1) Input: baud (uint8_t ((F_CPU/(8*BAUDRATE))-1)) Return: - ------------------------------------------------------------------------------------------------*/ void usartSetBaud(uint16_t baud) { UCSR0A |= (1<>8); UBRR0L = (uint8_t )(baud); } /*================================================================================================ usartReceive Description: Get byte from input buffer. Input: - Return: UDR (uint8_t) ------------------------------------------------------------------------------------------------*/ uint8_t usartReceive( void ) { /* Wait for data to be received */ while ( !(UCSR0A & (1<