avr_lib_wiinunchuck_02.zip

  • PUDN用户
    了解作者
  • Unix_Linux
    开发工具
  • 87KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 2
    下载次数
  • 2014-10-28 23:05
    上传日期
AVR lib for nunchuck controller
avr_lib_wiinunchuck_02.zip
  • schematics
  • atmega8_wiinunchuck_sample.sch
    48.6KB
  • atmega8_wiinunchuck_sample.png
    10.5KB
  • src
  • uart
  • uart.h
    7.2KB
  • uart.c
    20.7KB
  • i2chw
  • i2cmaster.h
    5.5KB
  • twimaster.c
    6.1KB
  • wiinunchuck
  • wiinunchuck.h
    2.3KB
  • wiinunchuck.c
    6KB
  • main.c
    4.9KB
  • processing
  • avr_sample_wiinunchuck_01
  • data
  • ArialUnicodeMS-48.vlw
    211.5KB
  • avr_sample_wiinunchuck_01.pde
    6.2KB
  • LICENSE
    34.3KB
  • README
    1KB
内容介绍
/************************************************************************* Title: Interrupt UART library with receive/transmit circular buffers Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury File: $Id: uart.c,v 1.6.2.2 2009/11/29 08:56:12 Peter Exp $ Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher Hardware: any AVR with built-in UART, License: GNU General Public License DESCRIPTION: An interrupt is generated when the UART has finished transmitting or receiving a byte. The interrupt handling routines use circular buffers for buffering received and transmitted data. The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE variables define the buffer size in bytes. Note that these variables must be a power of 2. USAGE: Refere to the header file uart.h for a description of the routines. See also example test_uart.c. NOTES: Based on Atmel Application Note AVR306 LICENSE: Copyright (C) 2006 Peter Fleury This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. *************************************************************************/ #include <avr/io.h rel='nofollow' onclick='return false;'> #include <avr/interrupt.h rel='nofollow' onclick='return false;'> #include <avr/pgmspace.h rel='nofollow' onclick='return false;'> #include "uart.h" /* * constants and macros */ /* size of RX/TX buffers */ #define UART_RX_BUFFER_MASK ( UART_RX_BUFFER_SIZE - 1) #define UART_TX_BUFFER_MASK ( UART_TX_BUFFER_SIZE - 1) #if ( UART_RX_BUFFER_SIZE & UART_RX_BUFFER_MASK ) #error RX buffer size is not a power of 2 #endif #if ( UART_TX_BUFFER_SIZE & UART_TX_BUFFER_MASK ) #error TX buffer size is not a power of 2 #endif #if defined(__AVR_AT90S2313__) \ || defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \ || defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \ || defined(__AVR_ATmega103__) /* old AVR classic or ATmega103 with one UART */ #define AT90_UART #define UART0_RECEIVE_INTERRUPT SIG_UART_RECV #define UART0_TRANSMIT_INTERRUPT SIG_UART_DATA #define UART0_STATUS USR #define UART0_CONTROL UCR #define UART0_DATA UDR #define UART0_UDRIE UDRIE #elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__) /* old AVR classic with one UART */ #define AT90_UART #define UART0_RECEIVE_INTERRUPT SIG_UART_RECV #define UART0_TRANSMIT_INTERRUPT SIG_UART_DATA #define UART0_STATUS UCSRA #define UART0_CONTROL UCSRB #define UART0_DATA UDR #define UART0_UDRIE UDRIE #elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ || defined(__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) \ || defined(__AVR_ATmega323__) /* ATmega with one USART */ #define ATMEGA_USART #define UART0_RECEIVE_INTERRUPT SIG_UART_RECV #define UART0_TRANSMIT_INTERRUPT SIG_UART_DATA #define UART0_STATUS UCSRA #define UART0_CONTROL UCSRB #define UART0_DATA UDR #define UART0_UDRIE UDRIE #elif defined(__AVR_ATmega163__) /* ATmega163 with one UART */ #define ATMEGA_UART #define UART0_RECEIVE_INTERRUPT SIG_UART_RECV #define UART0_TRANSMIT_INTERRUPT SIG_UART_DATA #define UART0_STATUS UCSRA #define UART0_CONTROL UCSRB #define UART0_DATA UDR #define UART0_UDRIE UDRIE #elif defined(__AVR_ATmega162__) /* ATmega with two USART */ #define ATMEGA_USART0 #define ATMEGA_USART1 #define UART0_RECEIVE_INTERRUPT SIG_USART0_RECV #define UART1_RECEIVE_INTERRUPT SIG_USART1_RECV #define UART0_TRANSMIT_INTERRUPT SIG_USART0_DATA #define UART1_TRANSMIT_INTERRUPT SIG_USART1_DATA #define UART0_STATUS UCSR0A #define UART0_CONTROL UCSR0B #define UART0_DATA UDR0 #define UART0_UDRIE UDRIE0 #define UART1_STATUS UCSR1A #define UART1_CONTROL UCSR1B #define UART1_DATA UDR1 #define UART1_UDRIE UDRIE1 #elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) /* ATmega with two USART */ #define ATMEGA_USART0 #define ATMEGA_USART1 #define UART0_RECEIVE_INTERRUPT SIG_UART0_RECV #define UART1_RECEIVE_INTERRUPT SIG_UART1_RECV #define UART0_TRANSMIT_INTERRUPT SIG_UART0_DATA #define UART1_TRANSMIT_INTERRUPT SIG_UART1_DATA #define UART0_STATUS UCSR0A #define UART0_CONTROL UCSR0B #define UART0_DATA UDR0 #define UART0_UDRIE UDRIE0 #define UART1_STATUS UCSR1A #define UART1_CONTROL UCSR1B #define UART1_DATA UDR1 #define UART1_UDRIE UDRIE1 #elif defined(__AVR_ATmega161__) /* ATmega with UART */ #error "AVR ATmega161 currently not supported by this libaray !" #elif defined(__AVR_ATmega169__) /* ATmega with one USART */ #define ATMEGA_USART #define UART0_RECEIVE_INTERRUPT SIG_USART_RECV #define UART0_TRANSMIT_INTERRUPT SIG_USART_DATA #define UART0_STATUS UCSRA #define UART0_CONTROL UCSRB #define UART0_DATA UDR #define UART0_UDRIE UDRIE #elif defined(__AVR_ATmega48__) ||defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) /* ATmega with one USART */ #define ATMEGA_USART0 #define UART0_RECEIVE_INTERRUPT SIG_USART_RECV #define UART0_TRANSMIT_INTERRUPT SIG_USART_DATA #define UART0_STATUS UCSR0A #define UART0_CONTROL UCSR0B #define UART0_DATA UDR0 #define UART0_UDRIE UDRIE0 #elif defined(__AVR_ATtiny2313__) #define ATMEGA_USART #define UART0_RECEIVE_INTERRUPT SIG_USART0_RX #define UART0_TRANSMIT_INTERRUPT SIG_USART0_UDRE #define UART0_STATUS UCSRA #define UART0_CONTROL UCSRB #define UART0_DATA UDR #define UART0_UDRIE UDRIE #elif defined(__AVR_ATmega329__) ||defined(__AVR_ATmega3290__) ||\ defined(__AVR_ATmega649__) ||defined(__AVR_ATmega6490__) ||\ defined(__AVR_ATmega325__) ||defined(__AVR_ATmega3250__) ||\ defined(__AVR_ATmega645__) ||defined(__AVR_ATmega6450__) /* ATmega with one USART */ #define ATMEGA_USART0 #define UART0_RECEIVE_INTERRUPT SIG_UART_RECV #define UART0_TRANSMIT_INTERRUPT SIG_UART_DATA #define UART0_STATUS UCSR0A #define UART0_CONTROL UCSR0B #define UART0_DATA UDR0 #define UART0_UDRIE UDRIE0 #elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__) /* ATmega with two USART */ #define ATMEGA_USART0 #define ATMEGA_USART1 #define UART0_RECEIVE_INTERRUPT SIG_USART0_RECV #define UART1_RECEIVE_INTERRUPT SIG_USART1_RECV #define UART0_TRANSMIT_INTERRUPT SIG_USART0_DATA #define UART1_TRANSMIT_INTERRUPT SIG_USART1_DATA #define UART0_STATUS UCSR0A #define UART0_CONTROL UCSR0B #define UART0_DATA UDR0 #define UART0_UDRIE UDRIE0 #define UART1_STATUS UCSR1A #define UART1_CONTROL UCSR1B #define UART1_DATA UDR1 #define UART1_UDRIE UDRIE1 #elif defined(__AVR_ATmega644__) /* ATmega with one USART */ #define ATMEGA_USART0 #define UART0_RECEIVE_INTERRUPT SIG_USART_RECV #define UART0_TRANSMIT_INTERRUPT SIG_USART_DATA #define UART0_STATUS UCSR0A #define UART0_CONTROL UCSR0B #define UART0_DATA UDR0 #define UART0_UDRIE UDRIE0 #elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__) /* ATmega with two USART */ #define ATMEGA_USART0 #define ATMEGA_USART1 #define UART0_RECEIVE_INTERRUPT SIG_USART_RECV #define UART1_RECEIVE_INTERRUPT SIG_USART1_RECV #define UAR
评论
    相关推荐