/* This file has been prepared for Doxygen automatic documentation generation.*/ /*! \file ********************************************************************* * * \brief This files implements the API for the communications library for the * FTDI chip on the STK541 board and the AVR USART used for the RZ502 * version. * * This file contains the function prototypes for the Transceiver Access * Toolbox, hence it is an API. The Transceiver Access Toolbox is an * abstraction layer that hides the details of the radio transceiver from * the end-user. The goal for the Transceiver Access Toolbox is to wrap the * services that the radio transceiver can perform into easy to use functions. * * \par Application note: * AVR2001: Transceiver Access Toolbox for the AT86RF230 * * \par Documentation * For comprehensive code documentation, supported compilers, compiler * settings and supported devices see readme.html * * \author * Atmel Corporation: http://www.atmel.com \n * Support email: avr@atmel.com * * $Name$ * $Revision: 613 $ * $RCSfile$ * $Date: 2006-04-07 14:40:07 +0200 (fr, 07 apr 2006) $ \n * * Copyright (c) 2006, Atmel Corporation All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3. The name of ATMEL may not be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ #ifndef COM_H #define COM_H /*============================ INCLDUE =======================================*/ #include #include #include "compiler.h" /*============================ MACROS ========================================*/ #define ENABLE_RECEIVER ( UCSR0B |= ( 1 << RXEN0 ) ) /*!< Enables receiver. */ #define DISABLE_RECEIVER ( UCSR0B &= ~( 1 << RXEN0 ) ) /*!< Disables receiver. */ #define ENABLE_TRANSMITTER ( UCSR0B |= ( 1 << TXEN0 ) ) /*!< Enables transmitter. */ #define DISABLE_TRANSMITTER ( UCSR0B &= ~( 1 << TXEN0 ) ) /*!< Disables transmitter. */ #define ENABLE_RECEIVE_COMPLETE_INTERRUPT ( UCSR0B |= ( 1 << RXCIE0 ) ) /*!< Enables an interrupt each time the receiver completes a symbol. */ #define DISABLE_RECEIVE_COMPLETE_INTERRUPT ( UCSR0B &= ~( 1 << RXCIE0 ) ) /*!< Disables an interrupt each time the receiver completes a symbol. */ #define LOW ( 0x00 ) #define XRAM_ENABLE( ) XMCRA |= ( 1 << SRE ); XMCRB |= ( 1 << XMBK ) #define XRAM_DISABLE( ) XMCRA &= ~( 1 << SRE ) #define FTDI_PORT ( PORTE ) #define FTDI_DDR ( DDRE ) #define FTDI_PIN ( PINE ) #define FTDI_TX_PIN ( PINE6 ) //Transmit buffer empty. PE6 #define FTDI_TX_MASK ( 1 << FTDI_TX_PIN ) #define FTDI_RX_PIN ( PINE7 ) //Receive buffer full. PE7 #define FTDI_FIFO_ADDRESS ( 0xF000 ) #define FTDI_Fifo ( ( volatile uint8_t * )FTDI_FIFO_ADDRESS ) #define FTDI_ENABLE_TX( ) ( FTDI_DDR &= ~( 1 << FTDI_TX_PIN ) ) #define FTDI_CONFIGURE_PIN_CHANGE_INTERRUPT( ) ( EICRB &= ~( ( 1 << ISC71 ) | ( 1 << ISC70 ) ) ) #define FTDI_ENABLE_RECEIVER( ) ( EIMSK |= ( 1 << FTDI_RX_PIN ) ) #define FTDI_DISABLE_RECEIVER( ) (EIMSK &= ~( 1 << FTDI_RX_PIN ) ) /*============================ TYPEDEFS ======================================*/ /*! \brief Enumeration that defines the available baud rates for\n * the serial interface. The values cana be found in the * datasheet on page 233. * * \note The members should not be altered. This is possibly harmful for\n * setting of the baud rate registers in serialInterfaceInitialization. */ typedef enum{ BR_9600 = (F_CPU + 16UL * 9600UL / 2UL)/ (16UL * 9600UL) - 1, /*!< Sets the baud rate to 9600. */ BR_19200 = (F_CPU + 16UL * 19200UL / 2UL) / (16UL * 19200UL) - 1, /*!< Sets the baud rate to 19200. */ BR_38400 = (F_CPU + 16UL * 38400UL / 2UL)/ (16UL * 38400UL) - 1 /*!< Sets the baud rate to 38400. */ }baud_rate_t; /*============================ VARIABLES =====================================*/ /*============================ PROTOTYPES ====================================*/ void com_init( baud_rate_t rate ); void com_send_string( uint8_t *data, uint8_t data_length ); void com_send_hex( uint8_t nmbr ); uint8_t * com_get_received_data( void ); uint8_t com_get_number_of_received_bytes( void ); void com_reset_receiver( void ); #endif