Subversion Repositories svnkaklik

Compare Revisions

No changes between revisions

Ignore whitespace Rev 506 → Rev 507

/programy/C/avr/akcelerometr/.hfuse
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/C/avr/akcelerometr/.lfuse
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/C/avr/akcelerometr/.lock
0,0 → 1,0
?
/programy/C/avr/akcelerometr/Makefile
0,0 → 1,51
 
NAME := gpsrl
HEX := $(NAME).hex
OUT := $(NAME).out
MAP := $(NAME).map
SOURCES := $(wildcard *.c)
HEADERS := $(wildcard *.h)
OBJECTS := $(patsubst %.c,%.o,$(SOURCES))
 
MCU := atmega8
MCU_AVRDUDE := m8
 
CC := avr-gcc
OBJCOPY := avr-objcopy
SIZE := avr-size -A
DOXYGEN := doxygen
 
CFLAGS := -Wall -pedantic -mmcu=$(MCU) -std=c99 -g -Os
 
all: $(HEX)
 
clean:
rm -f $(HEX) $(OUT) $(MAP) $(OBJECTS)
rm -rf doc/html
 
flash: $(HEX)
avrdude -y -p $(MCU_AVRDUDE) -P /dev/ttyUSB0 -c stk500v2 -U flash:w:$(HEX)
 
$(HEX): $(OUT)
$(OBJCOPY) -R .eeprom -O ihex $< $@
 
$(OUT): $(OBJECTS)
$(CC) $(CFLAGS) -o $@ -Wl,-Map,$(MAP) $^
@echo
@$(SIZE) $@
@echo
 
%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -c -o $@ $<
 
%.pp: %.c
$(CC) $(CFLAGS) -E -o $@ $<
 
%.ppo: %.c
$(CC) $(CFLAGS) -E $<
 
doc: $(HEADERS) $(SOURCES) Doxyfile
$(DOXYGEN) Doxyfile
 
.PHONY: all clean flash doc
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/C/avr/akcelerometr/a2d.c
0,0 → 1,115
/*! \file a2d.c \brief Analog-to-Digital converter function library. */
//*****************************************************************************
//
// File Name : 'a2d.c'
// Title : Analog-to-digital converter functions
// Author : Pascal Stang - Copyright (C) 2002
// Created : 2002-04-08
// Revised : 2002-09-30
// Version : 1.1
// Target MCU : Atmel AVR series
// Editor Tabs : 4
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************
 
#include <avr/io.h>
#include <avr/interrupt.h>
 
#include "global.h"
#include "a2d.h"
 
// global variables
 
//! Software flag used to indicate when
/// the a2d conversion is complete.
volatile unsigned char a2dCompleteFlag;
 
// functions
 
// initialize a2d converter
void a2dInit(void)
{
sbi(ADCSR, ADEN); // enable ADC (turn on ADC power)
cbi(ADCSR, ADFR); // default to single sample convert mode
a2dSetPrescaler(ADC_PRESCALE); // set default prescaler
a2dSetReference(ADC_REFERENCE); // set default reference
cbi(ADMUX, ADLAR); // set to right-adjusted result
 
sbi(ADCSR, ADIE); // enable ADC interrupts
 
a2dCompleteFlag = FALSE; // clear conversion complete flag
sei(); // turn on interrupts (if not already on)
}
 
// turn off a2d converter
void a2dOff(void)
{
cbi(ADCSR, ADIE); // disable ADC interrupts
cbi(ADCSR, ADEN); // disable ADC (turn off ADC power)
}
 
// configure A2D converter clock division (prescaling)
void a2dSetPrescaler(unsigned char prescale)
{
outb(ADCSR, ((inb(ADCSR) & ~ADC_PRESCALE_MASK) | prescale));
}
 
// configure A2D converter voltage reference
void a2dSetReference(unsigned char ref)
{
outb(ADMUX, ((inb(ADMUX) & ~ADC_REFERENCE_MASK) | (ref<<6)));
}
 
// sets the a2d input channel
void a2dSetChannel(unsigned char ch)
{
outb(ADMUX, (inb(ADMUX) & ~ADC_MUX_MASK) | (ch & ADC_MUX_MASK)); // set channel
}
 
// start a conversion on the current a2d input channel
void a2dStartConvert(void)
{
sbi(ADCSR, ADIF); // clear hardware "conversion complete" flag
sbi(ADCSR, ADSC); // start conversion
}
 
// return TRUE if conversion is complete
u08 a2dIsComplete(void)
{
return bit_is_set(ADCSR, ADSC);
}
 
// Perform a 10-bit conversion
// starts conversion, waits until conversion is done, and returns result
unsigned short a2dConvert10bit(unsigned char ch)
{
a2dCompleteFlag = FALSE; // clear conversion complete flag
outb(ADMUX, (inb(ADMUX) & ~ADC_MUX_MASK) | (ch & ADC_MUX_MASK)); // set channel
sbi(ADCSR, ADIF); // clear hardware "conversion complete" flag
sbi(ADCSR, ADSC); // start conversion
//while(!a2dCompleteFlag); // wait until conversion complete
//while( bit_is_clear(ADCSR, ADIF) ); // wait until conversion complete
while( bit_is_set(ADCSR, ADSC) ); // wait until conversion complete
 
// CAUTION: MUST READ ADCL BEFORE ADCH!!!
return (inb(ADCL) | (inb(ADCH)<<8)); // read ADC (full 10 bits);
}
 
// Perform a 8-bit conversion.
// starts conversion, waits until conversion is done, and returns result
unsigned char a2dConvert8bit(unsigned char ch)
{
// do 10-bit conversion and return highest 8 bits
return a2dConvert10bit(ch)>>2; // return ADC MSB byte
}
 
//! Interrupt handler for ADC complete interrupt.
SIGNAL(SIG_ADC)
{
// set the a2d conversion flag to indicate "complete"
a2dCompleteFlag = TRUE;
}
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/C/avr/akcelerometr/a2d.h
0,0 → 1,151
/*! \file a2d.h \brief Analog-to-Digital converter function library. */
//*****************************************************************************
//
// File Name : 'a2d.h'
// Title : Analog-to-digital converter functions
// Author : Pascal Stang - Copyright (C) 2002
// Created : 4/08/2002
// Revised : 4/30/2002
// Version : 1.1
// Target MCU : Atmel AVR series
// Editor Tabs : 4
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
/// \ingroup driver_avr
/// \defgroup a2d A/D Converter Function Library (a2d.c)
/// \code #include "a2d.h" \endcode
/// \par Overview
/// This library provides an easy interface to the analog-to-digital
/// converter available on many AVR processors. Updated to support
/// the ATmega128.
//
//****************************************************************************
//@{
 
#ifndef A2D_H
#define A2D_H
 
// defines
 
// A2D clock prescaler select
// *selects how much the CPU clock frequency is divided
// to create the A2D clock frequency
// *lower division ratios make conversion go faster
// *higher division ratios make conversions more accurate
#define ADC_PRESCALE_DIV2 0x00 ///< 0x01,0x00 -> CPU clk/2
#define ADC_PRESCALE_DIV4 0x02 ///< 0x02 -> CPU clk/4
#define ADC_PRESCALE_DIV8 0x03 ///< 0x03 -> CPU clk/8
#define ADC_PRESCALE_DIV16 0x04 ///< 0x04 -> CPU clk/16
#define ADC_PRESCALE_DIV32 0x05 ///< 0x05 -> CPU clk/32
#define ADC_PRESCALE_DIV64 0x06 ///< 0x06 -> CPU clk/64
#define ADC_PRESCALE_DIV128 0x07 ///< 0x07 -> CPU clk/128
// default value
#define ADC_PRESCALE ADC_PRESCALE_DIV64
// do not change the mask value
#define ADC_PRESCALE_MASK 0x07
 
// A2D voltage reference select
// *this determines what is used as the
// full-scale voltage point for A2D conversions
#define ADC_REFERENCE_AREF 0x00 ///< 0x00 -> AREF pin, internal VREF turned off
#define ADC_REFERENCE_AVCC 0x01 ///< 0x01 -> AVCC pin, internal VREF turned off
#define ADC_REFERENCE_RSVD 0x02 ///< 0x02 -> Reserved
#define ADC_REFERENCE_256V 0x03 ///< 0x03 -> Internal 2.56V VREF
// default value
#define ADC_REFERENCE ADC_REFERENCE_AVCC
// do not change the mask value
#define ADC_REFERENCE_MASK 0xC0
 
// bit mask for A2D channel multiplexer
#define ADC_MUX_MASK 0x1F
 
// channel defines (for reference and use in code)
// these channels supported by all AVRs with A2D
#define ADC_CH_ADC0 0x00
#define ADC_CH_ADC1 0x01
#define ADC_CH_ADC2 0x02
#define ADC_CH_ADC3 0x03
#define ADC_CH_ADC4 0x04
#define ADC_CH_ADC5 0x05
#define ADC_CH_ADC6 0x06
#define ADC_CH_ADC7 0x07
#define ADC_CH_122V 0x1E ///< 1.22V voltage reference
#define ADC_CH_AGND 0x1F ///< AGND
// these channels supported only in ATmega128
// differential with gain
#define ADC_CH_0_0_DIFF10X 0x08
#define ADC_CH_1_0_DIFF10X 0x09
#define ADC_CH_0_0_DIFF200X 0x0A
#define ADC_CH_1_0_DIFF200X 0x0B
#define ADC_CH_2_2_DIFF10X 0x0C
#define ADC_CH_3_2_DIFF10X 0x0D
#define ADC_CH_2_2_DIFF200X 0x0E
#define ADC_CH_3_2_DIFF200X 0x0F
// differential
#define ADC_CH_0_1_DIFF1X 0x10
#define ADC_CH_1_1_DIFF1X 0x11
#define ADC_CH_2_1_DIFF1X 0x12
#define ADC_CH_3_1_DIFF1X 0x13
#define ADC_CH_4_1_DIFF1X 0x14
#define ADC_CH_5_1_DIFF1X 0x15
#define ADC_CH_6_1_DIFF1X 0x16
#define ADC_CH_7_1_DIFF1X 0x17
 
#define ADC_CH_0_2_DIFF1X 0x18
#define ADC_CH_1_2_DIFF1X 0x19
#define ADC_CH_2_2_DIFF1X 0x1A
#define ADC_CH_3_2_DIFF1X 0x1B
#define ADC_CH_4_2_DIFF1X 0x1C
#define ADC_CH_5_2_DIFF1X 0x1D
 
// compatibility for new Mega processors
// ADCSR hack apparently no longer necessary in new AVR-GCC
#ifdef ADCSRA
#ifndef ADCSR
#define ADCSR ADCSRA
#endif
#endif
#ifdef ADATE
#define ADFR ADATE
#endif
 
// function prototypes
 
//! Initializes the A/D converter.
/// Turns ADC on and prepares it for use.
void a2dInit(void);
 
//! Turn off A/D converter
void a2dOff(void);
 
//! Sets the division ratio of the A/D converter clock.
/// This function is automatically called from a2dInit()
/// with a default value.
void a2dSetPrescaler(unsigned char prescale);
 
//! Configures which voltage reference the A/D converter uses.
/// This function is automatically called from a2dInit()
/// with a default value.
void a2dSetReference(unsigned char ref);
 
//! sets the a2d input channel
void a2dSetChannel(unsigned char ch);
 
//! start a conversion on the current a2d input channel
void a2dStartConvert(void);
 
//! return TRUE if conversion is complete
u08 a2dIsComplete(void);
 
//! Starts a conversion on A/D channel# ch,
/// returns the 10-bit value of the conversion when it is finished.
unsigned short a2dConvert10bit(unsigned char ch);
 
//! Starts a conversion on A/D channel# ch,
/// returns the 8-bit value of the conversion when it is finished.
unsigned char a2dConvert8bit(unsigned char ch);
 
#endif
//@}
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/C/avr/akcelerometr/a2dtest.c
0,0 → 1,86
//*****************************************************************************
// File Name : a2dtest.c
//
// Title : example usage of some avr library functions
// Revision : 1.0
// Notes :
// Target MCU : Atmel AVR series
// Editor Tabs : 4
//
// Revision History:
// When Who Description of change
// ----------- ----------- -----------------------
// 20-Oct-2002 pstang Created the program
//*****************************************************************************
//----- Include Files ---------------------------------------------------------
#include <avr/io.h> // include I/O definitions (port names, pin names, etc)
#include <avr/interrupt.h> // include interrupt support
#include <math.h>
 
#include "global.h" // include our global settings
#include "uart.h" // include uart function library
#include "rprintf.h" // include printf function library
#include "timer.h" // include timer function library (timing, PWM, etc)
#include "a2d.h" // include A/D converter function library
 
//----- Begin Code ------------------------------------------------------------
#define BUFLEN 32
 
int main(void)
{
u08 i=0;
s16 x=0,y=0;
double fi;
s16 fia;
u16 fib;
 
// initialize our libraries
// initialize the UART (serial port)
uartInit();
uartSetBaudRate(9600);
// make all rprintf statements use uart for output
rprintfInit(uartSendByte);
// initialize the timer system
timerInit();
// turn on and initialize A/D converter
a2dInit();
// configure a2d port (PORTA) as input
// so we can receive analog signals
DDRC = 0x00;
// make sure pull-up resistors are turned off
PORTC = 0x00;
 
// set the a2d prescaler (clock division ratio)
// - a lower prescale setting will make the a2d converter go faster
// - a higher setting will make it go slower but the measurements
// will be more accurate
// - other allowed prescale values can be found in a2d.h
a2dSetPrescaler(ADC_PRESCALE_DIV128);
 
// set the a2d reference
// - the reference is the voltage against which a2d measurements are made
// - other allowed reference values can be found in a2d.h
a2dSetReference(ADC_REFERENCE_AREF);
 
// use a2dConvert8bit(channel#) to get an 8bit a2d reading
// use a2dConvert10bit(channel#) to get a 10bit a2d reading
 
while(1)
{
for(i=0; i<BUFLEN; i++)
{
x += a2dConvert10bit(0);
y += a2dConvert10bit(1);
}
x = x/BUFLEN - 512;
y = y/BUFLEN - 512;
 
fi = atan2(y,x) * 180.0 / PI;
fia = floor(fi);
fib = floor((fi - fia));
rprintf("X:%d Y:%d fi:%d.%d \r\n", x, y, fia, fib);
}
return 0;
}
/programy/C/avr/akcelerometr/avrlibdefs.h
0,0 → 1,83
/*! \file avrlibdefs.h \brief AVRlib global defines and macros. */
//*****************************************************************************
//
// File Name : 'avrlibdefs.h'
// Title : AVRlib global defines and macros include file
// Author : Pascal Stang
// Created : 7/12/2001
// Revised : 9/30/2002
// Version : 1.1
// Target MCU : Atmel AVR series
// Editor Tabs : 4
//
// Description : This include file is designed to contain items useful to all
// code files and projects, regardless of specific implementation.
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************
 
 
#ifndef AVRLIBDEFS_H
#define AVRLIBDEFS_H
 
// Code compatibility to new AVR-libc
// outb(), inb(), inw(), outw(), BV(), sbi(), cbi(), sei(), cli()
#ifndef outb
#define outb(addr, data) addr = (data)
#endif
#ifndef inb
#define inb(addr) (addr)
#endif
#ifndef outw
#define outw(addr, data) addr = (data)
#endif
#ifndef inw
#define inw(addr) (addr)
#endif
#ifndef BV
#define BV(bit) (1<<(bit))
#endif
#ifndef cbi
#define cbi(reg,bit) reg &= ~(BV(bit))
#endif
#ifndef sbi
#define sbi(reg,bit) reg |= (BV(bit))
#endif
#ifndef cli
#define cli() __asm__ __volatile__ ("cli" ::)
#endif
#ifndef sei
#define sei() __asm__ __volatile__ ("sei" ::)
#endif
 
// support for individual port pin naming in the mega128
// see port128.h for details
#ifdef __AVR_ATmega128__
// not currently necessary due to inclusion
// of these defines in newest AVR-GCC
// do a quick test to see if include is needed
#ifndef PD0
#include "port128.h"
#endif
#endif
 
// use this for packed structures
// (this is seldom necessary on an 8-bit architecture like AVR,
// but can assist in code portability to AVR)
#define GNUC_PACKED __attribute__((packed))
 
// port address helpers
#define DDR(x) ((x)-1) // address of data direction register of port x
#define PIN(x) ((x)-2) // address of input register of port x
 
// MIN/MAX/ABS macros
#define MIN(a,b) ((a<b)?(a):(b))
#define MAX(a,b) ((a>b)?(a):(b))
#define ABS(x) ((x>0)?(x):(-x))
 
// constants
#define PI 3.14159265359
 
#endif
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/C/avr/akcelerometr/avrlibtypes.h
0,0 → 1,84
/*! \file avrlibtypes.h \brief AVRlib global types and typedefines. */
//*****************************************************************************
//
// File Name : 'avrlibtypes.h'
// Title : AVRlib global types and typedefines include file
// Author : Pascal Stang
// Created : 7/12/2001
// Revised : 9/30/2002
// Version : 1.0
// Target MCU : Atmel AVR series
// Editor Tabs : 4
//
// Description : Type-defines required and used by AVRlib. Most types are also
// generally useful.
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************
 
 
#ifndef AVRLIBTYPES_H
#define AVRLIBTYPES_H
 
#ifndef WIN32
// true/false defines
#define FALSE 0
#define TRUE -1
#endif
 
// datatype definitions macros
typedef unsigned char u08;
typedef signed char s08;
typedef unsigned short u16;
typedef signed short s16;
typedef unsigned long u32;
typedef signed long s32;
typedef unsigned long long u64;
typedef signed long long s64;
 
/* use inttypes.h instead
// C99 standard integer type definitions
typedef unsigned char uint8_t;
typedef signed char int8_t;
typedef unsigned short uint16_t;
typedef signed short int16_t;
typedef unsigned long uint32_t;
typedef signed long int32_t;
typedef unsigned long uint64_t;
typedef signed long int64_t;
*/
// maximum value that can be held
// by unsigned data types (8,16,32bits)
#define MAX_U08 255
#define MAX_U16 65535
#define MAX_U32 4294967295
 
// maximum values that can be held
// by signed data types (8,16,32bits)
#define MIN_S08 -128
#define MAX_S08 127
#define MIN_S16 -32768
#define MAX_S16 32767
#define MIN_S32 -2147483648
#define MAX_S32 2147483647
 
#ifndef WIN32
// more type redefinitions
typedef unsigned char BOOL;
typedef unsigned char BYTE;
typedef unsigned int WORD;
typedef unsigned long DWORD;
 
typedef unsigned char UCHAR;
typedef unsigned int UINT;
typedef unsigned short USHORT;
typedef unsigned long ULONG;
 
typedef char CHAR;
typedef int INT;
typedef long LONG;
#endif
 
#endif
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/C/avr/akcelerometr/buffer.c
0,0 → 1,149
/*! \file buffer.c \brief Multipurpose byte buffer structure and methods. */
//*****************************************************************************
//
// File Name : 'buffer.c'
// Title : Multipurpose byte buffer structure and methods
// Author : Pascal Stang - Copyright (C) 2001-2002
// Created : 9/23/2001
// Revised : 9/23/2001
// Version : 1.0
// Target MCU : any
// Editor Tabs : 4
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************
 
#include "buffer.h"
#include "global.h"
#include "avr/io.h"
 
#ifndef CRITICAL_SECTION_START
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli()
#define CRITICAL_SECTION_END SREG = _sreg
#endif
 
// global variables
 
// initialization
 
void bufferInit(cBuffer* buffer, unsigned char *start, unsigned short size)
{
// begin critical section
CRITICAL_SECTION_START;
// set start pointer of the buffer
buffer->dataptr = start;
buffer->size = size;
// initialize index and length
buffer->dataindex = 0;
buffer->datalength = 0;
// end critical section
CRITICAL_SECTION_END;
}
 
// access routines
unsigned char bufferGetFromFront(cBuffer* buffer)
{
unsigned char data = 0;
// begin critical section
CRITICAL_SECTION_START;
// check to see if there's data in the buffer
if(buffer->datalength)
{
// get the first character from buffer
data = buffer->dataptr[buffer->dataindex];
// move index down and decrement length
buffer->dataindex++;
if(buffer->dataindex >= buffer->size)
{
buffer->dataindex -= buffer->size;
}
buffer->datalength--;
}
// end critical section
CRITICAL_SECTION_END;
// return
return data;
}
 
void bufferDumpFromFront(cBuffer* buffer, unsigned short numbytes)
{
// begin critical section
CRITICAL_SECTION_START;
// dump numbytes from the front of the buffer
// are we dumping less than the entire buffer?
if(numbytes < buffer->datalength)
{
// move index down by numbytes and decrement length by numbytes
buffer->dataindex += numbytes;
if(buffer->dataindex >= buffer->size)
{
buffer->dataindex -= buffer->size;
}
buffer->datalength -= numbytes;
}
else
{
// flush the whole buffer
buffer->datalength = 0;
}
// end critical section
CRITICAL_SECTION_END;
}
 
unsigned char bufferGetAtIndex(cBuffer* buffer, unsigned short index)
{
// begin critical section
CRITICAL_SECTION_START;
// return character at index in buffer
unsigned char data = buffer->dataptr[(buffer->dataindex+index)%(buffer->size)];
// end critical section
CRITICAL_SECTION_END;
return data;
}
 
unsigned char bufferAddToEnd(cBuffer* buffer, unsigned char data)
{
// begin critical section
CRITICAL_SECTION_START;
// make sure the buffer has room
if(buffer->datalength < buffer->size)
{
// save data byte at end of buffer
buffer->dataptr[(buffer->dataindex + buffer->datalength) % buffer->size] = data;
// increment the length
buffer->datalength++;
// end critical section
CRITICAL_SECTION_END;
// return success
return -1;
}
// end critical section
CRITICAL_SECTION_END;
// return failure
return 0;
}
 
unsigned short bufferIsNotFull(cBuffer* buffer)
{
// begin critical section
CRITICAL_SECTION_START;
// check to see if the buffer has room
// return true if there is room
unsigned short bytesleft = (buffer->size - buffer->datalength);
// end critical section
CRITICAL_SECTION_END;
return bytesleft;
}
 
void bufferFlush(cBuffer* buffer)
{
// begin critical section
CRITICAL_SECTION_START;
// flush contents of the buffer
buffer->datalength = 0;
// end critical section
CRITICAL_SECTION_END;
}
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/C/avr/akcelerometr/buffer.h
0,0 → 1,74
/*! \file buffer.h \brief Multipurpose byte buffer structure and methods. */
//*****************************************************************************
//
// File Name : 'buffer.h'
// Title : Multipurpose byte buffer structure and methods
// Author : Pascal Stang - Copyright (C) 2001-2002
// Created : 9/23/2001
// Revised : 11/16/2002
// Version : 1.1
// Target MCU : any
// Editor Tabs : 4
//
/// \ingroup general
/// \defgroup buffer Circular Byte-Buffer Structure and Function Library (buffer.c)
/// \code #include "buffer.h" \endcode
/// \par Overview
/// This byte-buffer structure provides an easy and efficient way to store
/// and process a stream of bytes.� You can create as many buffers as you
/// like (within memory limits), and then use this common set of functions to
/// access each buffer.� The buffers are designed for FIFO�operation (first
/// in, first out).� This means that the first byte you put in the buffer
/// will be the first one you get when you read out the buffer.� Supported
/// functions include buffer initialize, get byte from front of buffer, add
/// byte to end of buffer, check if buffer is full, and flush buffer.� The
/// buffer uses a circular design so no copying of data is ever necessary.
/// This buffer is not dynamically allocated, it has a user-defined fixed
/// maximum size.� This buffer is used in many places in the avrlib code.
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************
//@{
 
#ifndef BUFFER_H
#define BUFFER_H
 
// structure/typdefs
 
//! cBuffer structure
typedef struct struct_cBuffer
{
unsigned char *dataptr; ///< the physical memory address where the buffer is stored
unsigned short size; ///< the allocated size of the buffer
unsigned short datalength; ///< the length of the data currently in the buffer
unsigned short dataindex; ///< the index into the buffer where the data starts
} cBuffer;
 
// function prototypes
 
//! initialize a buffer to start at a given address and have given size
void bufferInit(cBuffer* buffer, unsigned char *start, unsigned short size);
 
//! get the first byte from the front of the buffer
unsigned char bufferGetFromFront(cBuffer* buffer);
 
//! dump (discard) the first numbytes from the front of the buffer
void bufferDumpFromFront(cBuffer* buffer, unsigned short numbytes);
 
//! get a byte at the specified index in the buffer (kind of like array access)
// ** note: this does not remove the byte that was read from the buffer
unsigned char bufferGetAtIndex(cBuffer* buffer, unsigned short index);
 
//! add a byte to the end of the buffer
unsigned char bufferAddToEnd(cBuffer* buffer, unsigned char data);
 
//! check if the buffer is full/not full (returns zero value if full)
unsigned short bufferIsNotFull(cBuffer* buffer);
 
//! flush (clear) the contents of the buffer
void bufferFlush(cBuffer* buffer);
 
#endif
//@}
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/C/avr/akcelerometr/global.h
0,0 → 1,42
 
//*****************************************************************************
//
// File Name : 'global.h'
// Title : AVR project global include
// Author : Pascal Stang
// Created : 7/12/2001
// Revised : 9/30/2002
// Version : 1.1
// Target MCU : Atmel AVR series
// Editor Tabs : 4
//
// Description : This include file is designed to contain items useful to all
// code files and projects.
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************
 
#ifndef GLOBAL_H
#define GLOBAL_H
 
// global AVRLIB defines
#include "avrlibdefs.h"
// global AVRLIB types definitions
#include "avrlibtypes.h"
 
// project/system dependent defines
 
#define UART_RX_BUFFER_SIZE 0x00FF
 
// CPU clock speed
//#define F_CPU 16000000 // 16MHz processor
//#define F_CPU 14745000 // 14.745MHz processor
#define F_CPU 8000000 // 8MHz processor
//#define F_CPU 7372800 // 7.37MHz processor
//#define F_CPU 4000000 // 4MHz processor
//#define F_CPU 3686400 // 3.69MHz processor
#define CYCLES_PER_US ((F_CPU+500000)/1000000) // cpu cycles per microsecond
 
#endif
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/C/avr/akcelerometr/gmetr.kontrollerlab
0,0 → 1,70
<!DOCTYPE KontrollerLab>
<PROJECT VERSION="0.8.0-beta1" >
<FILES>
<FILE VIEWS="0,0,1024,482,5," SHOWN="TRUE" NAME="a2dtest.c" />
<FILE SHOWN="FALSE" NAME="avrlibdefs.h" />
<FILE SHOWN="FALSE" NAME="avrlibtypes.h" />
<FILE SHOWN="FALSE" NAME="a2d.c" />
<FILE SHOWN="FALSE" NAME="a2d.h" />
<FILE SHOWN="FALSE" NAME="buffer.c" />
<FILE SHOWN="FALSE" NAME="buffer.h" />
<FILE SHOWN="FALSE" NAME="global.h" />
<FILE SHOWN="FALSE" NAME="rprintf.c" />
<FILE SHOWN="FALSE" NAME="rprintf.h" />
<FILE SHOWN="FALSE" NAME="timer.c" />
<FILE SHOWN="FALSE" NAME="timer.h" />
<FILE VIEWS="4,480,1,1,6," SHOWN="TRUE" NAME="uart.c" />
<FILE SHOWN="FALSE" NAME="uart.h" />
<FILE SHOWN="FALSE" NAME="vt100.c" />
<FILE SHOWN="FALSE" NAME="vt100.h" />
</FILES>
<SETTINGS>
<ASSEMBLER_COMMAND VALUE="avr-gcc" />
<BUILD_SYSTEM VALUE="BUILT_IN_BUILD" />
<CLOCK VALUE="8e+06" />
<COMPILER_CALL_PROLOGUES VALUE="FALSE" />
<COMPILER_COMMAND VALUE="avr-gcc" />
<COMPILER_F_CPU VALUE="FALSE" />
<COMPILER_GDEBUG VALUE="FALSE" />
<COMPILER_OPT_LEVEL VALUE="s" />
<COMPILER_STRICT_PROTOTYPES VALUE="TRUE" />
<COMPILER_WALL VALUE="TRUE" />
<CPU VALUE="ATMega8" />
<HEX_FILE VALUE="project.hex" />
<LINKER_COMMAND VALUE="avr-gcc" />
<LINKER_FLAGS VALUE="" />
<MAKE_CLEAN_TARGET VALUE="clean" />
<MAKE_COMMAND VALUE="make" />
<MAKE_DEFAULT_TARGET VALUE="all" />
<MAP_FILE VALUE="project.map" />
<OBJCOPY_COMMAND VALUE="avr-objcopy" />
</SETTINGS>
<DEBUGGER_SETTINGS/>
<PROGRAMMERCONFIG>
<AVRDUDE_CONNECTION_PORT VALUE="/dev/parport0" />
<AVRDUDE_COUNT_ERASE VALUE="FALSE" />
<AVRDUDE_DISABLE_AUTO_ERASE VALUE="FALSE" />
<AVRDUDE_OVERRIDE_INVALID_SIGNATURE VALUE="FALSE" />
<AVRDUDE_PROGRAMMER_TYPE VALUE="dapa" />
<AVRDUDE_TEST_MODE VALUE="FALSE" />
<PROGRAMMER_COMMAND VALUE="avrdude" />
<PROGRAMMER_NAME VALUE="AVRDUDE" />
<UISP_PARALLEL_AT89S VALUE="FALSE" />
<UISP_PARALLEL_DISABLE_RETRIES VALUE="FALSE" />
<UISP_PARALLEL_EEPROM_MAX_WRITE_DELAY VALUE="2777" />
<UISP_PARALLEL_FLASH_MAX_WRITE_DELAY VALUE="2777" />
<UISP_PARALLEL_NO_DATA_POLLING VALUE="FALSE" />
<UISP_PARALLEL_PORT VALUE="" />
<UISP_PARALLEL_RESET_HIGH_TIME VALUE="0" />
<UISP_PARALLEL_SCK_HIGH_LOW_TIME VALUE="0" />
<UISP_PARALLEL_VOLTAGE VALUE="0" />
<UISP_PROGRAMMER_TYPE VALUE="" />
<UISP_SERIAL_PORT VALUE="" />
<UISP_SERIAL_SPEED VALUE="9600" />
<UISP_SPECIFY_PART VALUE="FALSE" />
<UISP_STK500_AREF_VOLTAGE VALUE="0" />
<UISP_STK500_OSCILLATOR_FREQUENCY VALUE="14.1" />
<UISP_STK500_USE_HIGH_VOLTAGE VALUE="FALSE" />
<UISP_STK500_VTARGET_VOLTAGE VALUE="0" />
</PROGRAMMERCONFIG>
</PROJECT>
/programy/C/avr/akcelerometr/project.hex
0,0 → 1,480
:100000004AC064C063C05DC6D1C53EC603C61FC634
:10001000B0C568C55BC0AFC659C0E2C615C156C001
:1000200055C054C053C0084AD73B3BCE016E84BC78
:10003000BFFDC12F3D6C74319ABD56833DDA3D0042
:10004000C77F11BED9E4BB4C3E916BAAAABE00008B
:1000500000803F583A256420593A25642066693A61
:1000600025642E2564200D0A0030313233343536B4
:10007000373839414243444546000000010008003A
:1000800040000001000400000100080020004000C2
:1000900080000001000411241FBECFE5D4E0DEBFC4
:1000A000CDBF11E0A0E6B0E0EAEDFCE102C00590B2
:1000B0000D92A836B107D9F712E0A8E6B1E001C069
:1000C0001D92AA3DB107E1F702D005CE99CF9F92CC
:1000D000AF92BF92CF92DF92EF92FF920F931F9356
:1000E000CF93DF93EBD660E875E280E090E00BD62B
:1000F00083EA96E060D139D360D014BA15BA87E0AC
:100100006FD080E072D0CC24DD2410E0C0E0D0E0DD
:1001100033E5A32E30E0B32E9924939409C080E0F8
:1001200079D0C80FD91F81E075D0C80ED91E1F5FC6
:100130001032A8F3CE0160E270E0E3DAEB01C050C8
:10014000D240C60160E270E0DCDAC12C2EEFD22E84
:10015000C60ED71EBE01882777FD8095982F5FD8E1
:100160007B018C01B601882777FD8095982F57D8A1
:10017000A80197015CDB20E030E044E353E4B5D60E
:100180002BED3FE049E450E4A5D70ADC1F921F9213
:10019000A0D87F936F93DF92CF92DF93CF93BF92DC
:1001A000AF929F9254D210E08DB79EB70B960FB6C8
:1001B000F8949EBF0FBE8DBFB2CF379A359886B1E7
:1001C000887F866086B987B18F73806487B93D98D0
:1001D000339A1092B9027894089533983798089515
:1001E00096B1987F982B96B9089597B18295880F0C
:1001F000880F807C9F73982B97B9089597B18F7162
:10020000907E892B87B90895349A369A089586B1DD
:10021000807408951092B90297B18F71907E892BE6
:1002200087B9349A369A3699FECF24B145B1942FC6
:1002300080E030E0282B392BC9010895EBDF96953B
:1002400087959695879508951F920F920FB60F92F6
:1002500011248F938FEF8093B9028F910F900FBE6F
:100260000F901F901895FC018FB7F89471836083ED
:100270005383428317821682158214828FBF08959A
:10028000CF93DF93DC014FB7F894EC018C819D8113
:10029000892B11F4E0E01CC0FD0186819781ED916E
:1002A000FC911197E80FF91FE0810196ED019F8302
:1002B0008E832A813B818217930720F0821B930B48
:1002C0009F838E83ED018C819D8101979D838C831B
:1002D0004FBF8E2FDF91CF910895FC014FB7F89457
:1002E0008481958168177907B0F486819781860F9C
:1002F000971F97838683228133818217930720F08B
:10030000821B930B9783868384819581861B970B31
:100310009583848302C0158214824FBF0895FC0127
:10032000CB012FB7F8942FBF26813781628173816B
:10033000820F931FD2D90190F081E02DE80FF91FB1
:10034000808108951F93CF93DF93EC01162F4FB751
:10035000F8942C813D816A817B812617370790F4C0
:100360008E819F81820F931FB8D9E881F981E80FB0
:10037000F91F10838C819D8101969D838C834FBFD3
:100380008FEF02C04FBF80E0DF91CF911F910895A2
:10039000FC018FB7F8948FBF2281338184819581CE
:1003A000281B390BC9010895FC018FB7F8941582F9
:1003B00014828FBF08959093690180936801089516
:1003C0001F93182F8A3031F4E0916801F091690190
:1003D0008DE00995E0916801F0916901812F0995FF
:1003E0001F910895CF93DF93EC01009719F405C096
:1003F0002196E6DF88818823D9F7DF91CF91089590
:10040000EF92FF920F931F93CF93DF938C017A01AA
:100410000097E1F020E030E02617370738F4F801C4
:1004200081918F012F5F3F4F8823B1F7C0E0D0E06B
:100430000AC0F8018081882319F00F5F1F4F01C0A7
:1004400080E2BEDF2196CE15DF0598F3DF91CF91D4
:100450001F910F91FF90EF900895CF93DF93EC01E0
:10046000009711F406C0ACDFFE0121968491882329
:10047000D1F7DF91CF9108958AE0A2DF0895E82FA8
:10048000F0E0EF70F070E759FF4FE4918E2F98DFA6
:1004900008951F93182F82958F70F1DF812FEFDF62
:1004A0001F9108951F93182F892FF3DF812FF1DFFC
:1004B0001F910895EF92FF920F931F937B018C0180
:1004C000C801AA27BB27EEDFC701ECDF1F910F9100
:1004D000FF90EF9008952F923F924F925F926F920C
:1004E0007F928F929F92AF92BF92CF92DF92EF92C4
:1004F000FF920F931F93DF93CF93CDB7DEB7A397F0
:100500000FB6F894DEBF0FBECDBF4AA32BA33701B1
:100510004801442351F017FF08C0EE24FF2487014F
:10052000E618F7080809190902C084017301262E8C
:10053000262F215090E03AA1311191E0291B29A3E7
:1005400018A2A82EBB24A7FCB094CB2CDB2CC8018E
:10055000B701A6019501E8D8FB01EF70F070E759EB
:10056000FF4F64916F8FC801B701A6019501DCD8D8
:10057000C901DA017C018D019EE1492E512C4C0EFE
:100580005D1E39A023C0E114F10401051105B9F085
:10059000C801B701A6019501C7D8FB01EF70F07043
:1005A000E759FF4F6491F2016083C801B701A601CA
:1005B0009501BAD8C901DA017C018D0103C02BA1D4
:1005C000F20120833A940894410851083320D9F667
:1005D000CE014F968C0139A1031B11098AA18823F2
:1005E000D9F097FE05C08DE2F80182938F0114C007
:1005F000C8010197611471048104910419F08C0100
:100600008BE202C08C0180E2F801808305C0F80112
:1006100081918F01D5DE2A942220C9F7A3960FB6C7
:10062000F894DEBF0FBECDBFCF91DF911F910F9128
:10063000FF90EF90DF90CF90BF90AF909F908F9002
:100640007F906F905F904F903F902F9008957F9292
:100650008F929F92AF92BF92CF92DF92EF92FF92D2
:100660000F931F93DF93CF93CDB7DEB77888C988F8
:10067000DA8853E1E52EF12CEC0EFD1E13C0882321
:1006800081F480E090E0CF91DF911F910F91FF9076
:10069000EF90DF90CF90BF90AF909F908F907F9022
:1006A00008958EDE96012F5F3F4F772021F0F601EF
:1006B0006901849103C0F601808169018532F9F6F0
:1006C0002F5F3F4F772021F0F6016901849103C02D
:1006D000F60180816901843629F0883781F08336FC
:1006E00001F706C000E117E24AE0A42EB12C0CC0CD
:1006F000F701808122E030E0E20EF31ED2CF00E06D
:1007000010E130E1A32EB12C22E0822E912C8E0C30
:100710009F1CF701E080F1808436A1F4F7FE0FC042
:10072000F094E194F108F3948DE24ADE08C0C80128
:100730006AE070E0D2D78B016230710518F0E016E4
:10074000F106A8F3C701B801C8D7862F98DEC70104
:10075000B801C3D77C01C801B501BFD78B016115B2
:10076000710581F774019ECF089580E090E0FC014F
:10077000EE0FFF1FE659FE4F11821082019687305F
:100780009105A9F783B7887F826083BF12BE89B7BE
:10079000816089BF1092BA021092BB021092BC0213
:1007A0001092BD028EB5887F83608EBD1DBC1CBCBF
:1007B00089B7846089BF85B5887F846085BD14BC96
:1007C00089B7806489BF1092C2021092C30210924E
:1007D000C4021092C5027894089583B7887F82601E
:1007E00083BF12BE89B7816089BF1092BA0210928E
:1007F000BB021092BC021092BD0208958EB5887F94
:1008000083608EBD1DBC1CBC89B7846089BF089500
:1008100085B5887F846085BD14BC89B7806489BF35
:100820001092C2021092C3021092C4021092C5022A
:10083000089593B7987F982B93BF08959EB5987F9E
:10084000982B9EBD089595B5987F982B95BD0895DA
:1008500083B7E82FF0E0E770F070EE0FFF1FE65867
:10086000FF4F25913491C90108958EB5E82FF0E02E
:10087000E770F070EE0FFF1FE658FF4F259134919F
:10088000C901089585B5E82FF0E0E770F070EE0F2C
:10089000FF1FEA57FF4F25913491C9010895873012
:1008A00040F4E82FF0E0EE0FFF1FE659FE4F718392
:1008B00060830895873040F4E82FF0E0EE0FFF1FCB
:1008C000E659FE4F118210820895EF92FF920F9326
:1008D0001F93CF93DF93EC0112B71092BE021092D8
:1008E000BF021092C0021092C10283B7E82FF0E05D
:1008F000E770F070EE0FFF1FE658FF4F259134911F
:1009000040E050E060E072E18AE790E02FD7B90163
:10091000CA01693B2DE8720726E0820720E09207B2
:1009200090F437E2C131D30770F49E0140E050E00B
:10093000B5D628EE33E040E050E0F6D6C901DA0142
:10094000BC01CD011FC028EE33E040E050E0ECD602
:10095000CA01B9019E0140E050E0A0D613C08091C9
:10096000BE029091BF02A091C002B091C10285B7B2
:100970008F7885BF85B7806885BF889585B78F7765
:1009800085BF08C09B01AC01210F311D411D511DC8
:1009900079018A012091BE023091BF024091C002CC
:1009A0005091C10282B790E0A0E0B0E0542F432FF5
:1009B000322F2227822B932BA42BB52B8E159F052C
:1009C000A007B10760F2DF91CF911F910F91FF90C7
:1009D000EF9008951092BA021092BB021092BC02DE
:1009E0001092BD0208952091BA023091BB0240914D
:1009F000BC025091BD02B901CA0108951092C20211
:100A00001092C3021092C4021092C5020895209160
:100A1000C2023091C3024091C4025091C502B90193
:100A2000CA010895893031F48FB582608FBD8FB5CA
:100A30008E7F0AC08A3019F48FB5826002C08FB5EC
:100A40008D7F8FBD8FB581608FBD1BBC1ABC19BC5B
:100A500018BC08952FB52E7F2FBD2FB522602FBD56
:100A60002EB528602EBD2EB520612EBD97BD86BD4A
:100A70001BBC1ABC19BC18BC08958FB58D7F8FBDE7
:100A80008FB58E7F8FBD8FB58F778FBD8FB58F7BE5
:100A90008FBD8FB58F7D8FBD8FB58F7E8FBD089534
:100AA0008FB580688FBD8FB58F7B8FBD08958FB553
:100AB00080628FBD8FB58F7E8FBD08958FB58F7784
:100AC0008FBD8FB58F7B8FBD08958FB58F7D8FBD07
:100AD0008FB58F7E8FBD08959BBD8ABD089599BD4A
:100AE00088BD08951F920F920FB60F9211248F9315
:100AF0009F93AF93BF93EF93FF938091BA0290912E
:100B0000BB02A091BC02B091BD020196A11DB11D16
:100B10008093BA029093BB02A093BC02B093BD0233
:100B20008091BE029091BF02A091C002B091C1021B
:100B30000196A11DB11D8093BE029093BF02A093A8
:100B4000C002B093C10280916A0190916B01892B20
:100B500029F0E0916A01F0916B010995FF91EF9105
:100B6000BF91AF919F918F910F900FBE0F901F90EB
:100B700018951F920F920FB60F9211248F939F9387
:100B8000EF93FF9380916C0190916D01892B29F077
:100B9000E0916C01F0916D010995FF91EF919F91AA
:100BA0008F910F900FBE0F901F9018951F920F926C
:100BB0000FB60F9211248F939F93AF93BF93EF9330
:100BC000FF938091C2029091C302A091C402B091A0
:100BD000C5020196A11DB11D8093C2029093C3026C
:100BE000A093C402B093C5028091740190917501E5
:100BF000892B29F0E0917401F09175010995FF911D
:100C0000EF91BF91AF919F918F910F900FBE0F9079
:100C10001F9018951F920F920FB60F9211248F9369
:100C20009F93EF93FF9380916E0190916F01892BB9
:100C300029F0E0916E01F0916F010995FF91EF911C
:100C40009F918F910F900FBE0F901F9018951F923C
:100C50000F920FB60F9211248F939F93EF93FF93F0
:100C60008091700190917101892B29F0E0917001C0
:100C7000F09171010995FF91EF919F918F910F90E4
:100C80000FBE0F901F9018951F920F920FB60F92E4
:100C900011248F939F93EF93FF9380917201909112
:100CA0007301892B29F0E0917201F091730109958C
:100CB000FF91EF919F918F910F900FBE0F901F901A
:100CC00018951F920F920FB60F9211248F939F9336
:100CD000EF93FF938091760190917701892B29F012
:100CE000E0917601F09177010995FF91EF919F9145
:100CF0008F910F900FBE0F901F9018959093B80290
:100D00008093B70208959B01AC01605C7D4B804FDE
:100D10009F4FF3E0660F771F881F991FFA95D1F751
:100D2000E4E0220F331F441F551FEA95D1F7FCD48E
:100D30002150304029B930BD089587EC92E00895E4
:100D400080ED92E00895982F8091C6028823E1F308
:100D50009CB91092C60208951092CC021092CB0258
:100D600008958091CB029091CC02892B11F080E004
:100D700008958FEF08951F920F920FB60F921124CE
:100D80006F938F939F93EF93FF936CB18091B70212
:100D90009091B802892B39F0E091B702F091B80236
:100DA000862F09950EC087EC92E0CCDA882349F4AF
:100DB0008091D8029091D90201969093D9028093A4
:100DC000D802FF91EF919F918F916F910F900FBE7D
:100DD0000F901F901895682F80ED92E0B3DA089578
:100DE0001F920F920FB60F9211248F939F938091B1
:100DF000CF02882369F08091D4029091D502892B8B
:100E000029F080ED92E03CDA8CB905C01092CF0257
:100E10008FEF8093C6029F918F910F900FBE0F901E
:100E20001F9018958FEF8093CF0280ED92E028DA23
:100E3000982F8091C6028823E1F39CB91092C602D4
:100E40000895CF93DF93EC018091C9029091CA027B
:100E5000892B61F08091CB029091CC02892B31F0EB
:100E600087EC92E00DDA88838FEF01C080E0DF919C
:100E7000CF910895DF93CF930F92CDB7DEB7CE0118
:100E80000196DFDF882319F42FEF3FEF03C089813C
:100E9000282F30E0C9010F90CF91DF9108954FEFD7
:100EA00050E068E771E087EC92E0DDD940E450E083
:100EB00067E772E080ED92E0D6D90895F0DF1092F6
:100EC000B8021092B70288ED8AB960E875E280E056
:100ED00090E019DF8FEF8093C6021092CF0210923C
:100EE000D9021092D80278940895A0E2B0E0EAE71F
:100EF000F7E057C469837A838B839C832D833E8379
:100F00004F835887BE01675F7F4FCE01019656D34E
:100F1000BE016F5E7F4FCE01059650D3998592300A
:100F200088F089898230C8F0943019F4823051F405
:100F300004C0843029F4923081F480E690E0C6C089
:100F4000923049F420E09A858A89981321E02A8713
:100F5000CE010996BBC0823049F420E09A858A8987
:100F6000981321E02A8BCE014196B0C02D843E8497
:100F70004F8458886D887E888F88988CEE24FF2453
:100F80008701AA24BB24650140E050E060E070E0E6
:100F9000E0E0F0E0C10181709070892BE9F0E60C8F
:100FA000F71C081D191D9A01AB012A0D3B1D4C1D94
:100FB0005D1D80E090E0A0E0B0E0E614F7040805D5
:100FC000190520F481E090E0A0E0B0E0BA01A901A9
:100FD000480F591F6A1F7B1FAA0CBB1CCC1CDD1CB1
:100FE00097FE08C081E090E0A0E0B0E0A82AB92A0E
:100FF000CA2ADB2A3196E032F10549F0660C771CEB
:10100000881C991C5694479437942794C3CFFA852B
:10101000EA892B893C898B859C85280F391F2E5F97
:101020003F4F17C0CA0181709070892B61F01695EF
:101030000795F794E79480E090E0A0E0B0E8E82A14
:10104000F92A0A2B1B2B76956795579547952F5FA5
:101050003F4F77FDE7CF0CC0440F551F661F771F2A
:1010600017FD4160EE0CFF1C001F111F2150304086
:10107000403090E0590790E0690790E4790760F309
:101080002B8F3C8FDB01CA018F779070A070B070FE
:1010900080349105A105B10561F447FD0AC0E11452
:1010A000F1040105110529F0405C5F4F6F4F7F4F40
:1010B00040781A8EFE1711F081E08A8F4D8F5E8F77
:1010C0006F8F78A383E0898FCE014996A2D1A09635
:1010D000E2E183C3A8E1B0E0EFE6F8E06AC3698328
:1010E0007A838B839C832D833E834F835887B9E01B
:1010F000EB2EF12CEC0EFD1EB701CE0101965ED257
:101100008E010F5E1F4FB801CE01059657D229857B
:10111000223008F47CC03989323010F4B8017AC02A
:101120008A859A8989278A87243011F0223031F400
:10113000231709F06CC060E670E06CC0343039F4FD
:101140001D861E861F86188A1C861B8604C03230A8
:1011500021F484E08987B7015DC02B853C858B89AC
:101160009C89281B390B3C872B87ED84FE840F85D7
:101170001889AD88BE88CF88D88CEA14FB040C058A
:101180001D0540F4EE0CFF1C001F111F21503040C4
:101190003C872B8720E030E040E050E080E090E0AA
:1011A000A0E0B0E46FE170E0EA14FB040C051D055B
:1011B00040F0282B392B4A2B5B2BEA18FB080C0933
:1011C0001D09B695A79597958795EE0CFF1C001FF6
:1011D000111F6150704041F7DA01C9018F7790709B
:1011E000A070B07080349105A105B10561F427FDB0
:1011F0000AC0E114F1040105110529F0205C3F4FFC
:101200004F4F5F4F20782D873E874F87588BBE0109
:10121000675F7F4FCB01FDD06896EAE0E6C2A8E0A9
:10122000B0E0E4E1F9E0C6C29B01AC0183E0898350
:10123000DA01C9018827B7FD83959927AA27BB271B
:10124000B82E211531054105510519F482E0898335
:1012500039C08823A9F0203080E0380780E04807B3
:1012600080E8580729F460E070E080E09FEC2EC031
:10127000EE24FF248701E21AF30A040B150B02C0C7
:1012800079018A018EE1C82ED12CDC82CB82ED82DD
:10129000FE820F831887C801B7016CD0019718161A
:1012A000190684F4082E04C0EE0CFF1C001F111F49
:1012B0000A94D2F7ED82FE820F831887C81AD90AE2
:1012C000DC82CB82BA82CE010196A3D02896E9E0D7
:1012D0008DC2ACE0B0E0EEE6F9E073C269837A83D8
:1012E0008B839C83BE016B5F7F4FCE01019666D1DD
:1012F0008D81823061F1823050F1843021F48E8111
:10130000882351F12EC02F81388537FD20C06E8192
:101310002F3131051CF06623F9F023C08EE190E0F7
:10132000821B930B29853A854B855C8504C05695B5
:101330004795379527958A95D2F76623B1F0509552
:101340004095309521953F4F4F4F5F4F0EC020E0A5
:1013500030E040E050E009C02FEF3FEF4FEF5FE794
:1013600004C020E030E040E050E8B901CA012C960A
:10137000E2E043C2EF92FF920F931F937B018C0137
:1013800080E0E81680E0F80681E0080780E01807B2
:1013900088F48FEFE816F1040105110531F028F00B
:1013A00088E090E0A0E0B0E017C080E090E0A0E02E
:1013B000B0E012C080E0E81680E0F80680E00807A0
:1013C00081E0180728F088E190E0A0E0B0E004C0D8
:1013D00080E190E0A0E0B0E020E230E040E050E0CA
:1013E000281B390B4A0B5B0B04C016950795F79425
:1013F000E7948A95D2F7F701E859FF4F8081281BBF
:10140000310941095109C9011F910F91FF90EF90D6
:101410000895DF92EF92FF920F931F93FC01E480F7
:10142000F58006811781D1808081823048F480E088
:1014300090E0A0E1B0E0E82AF92A0A2B1B2BA5C016
:10144000843009F49FC0823021F4EE24FF24870108
:1014500005C0E114F1040105110519F4E0E0F0E024
:1014600096C0628173819FEF623879070CF05BC090
:1014700022E83FEF261B370B2A3131052CF020E004
:1014800030E040E050E02AC0B801A701022E04C0BD
:1014900076956795579547950A94D2F781E090E045
:1014A000A0E0B0E004C0880F991FAA1FBB1F2A95B7
:1014B000D2F70197A109B1098E219F21A023B12361
:1014C0000097A105B10521F081E090E0A0E0B0E037
:1014D0009A01AB01282B392B4A2B5B2BDA01C9016E
:1014E0008F779070A070B07080349105A105B10520
:1014F00039F427FF09C0205C3F4F4F4F5F4F04C0B6
:10150000215C3F4F4F4F5F4FE0E0F0E02030A0E024
:101510003A07A0E04A07A0E45A0710F0E1E0F0E043
:1015200079018A0127C06038710564F5FB01E15833
:10153000FF4FD801C7018F779070A070B0708034D2
:101540009105A105B10539F4E7FE0DC080E490E0F6
:10155000A0E0B0E004C08FE390E0A0E0B0E0E80ECF
:10156000F91E0A1F1B1F17FF05C016950795F79454
:10157000E794319687E016950795F794E7948A9556
:10158000D1F705C0EE24FF248701EFEFF0E06E2FC6
:10159000679566276795902F9F77D794DD24D7941A
:1015A0008E2F8695492F462B582F5D29B701CA01EA
:1015B0001F910F91FF90EF90DF900895FC01DB01E8
:1015C000408151812281622F6F7770E0221F222794
:1015D000221F9381892F880F822B282F30E0991F9B
:1015E0009927991FFD0191832115310581F5411539
:1015F00051056105710511F482E032C082E89FEF68
:10160000FD01938382839A01AB0167E0220F331FB0
:10161000441F551F6A95D1F783E08C930AC0220FAF
:10162000331F441F551FFD018281938101979383CE
:1016300082832030F0E03F07F0E04F07F0E45F07DF
:1016400070F3FD01248335834683578308952F3F2C
:10165000310581F4411551056105710519F484E0E6
:101660008C93089564FF03C081E08C9301C01C92A9
:10167000FD010FC02F573040FD013383228383E0EB
:101680008C9387E0440F551F661F771F8A95D1F70B
:10169000706444835583668377830895629FD00185
:1016A000739FF001829FE00DF11D649FE00DF11D1D
:1016B000929FF00D839FF00D749FF00D659FF00DCC
:1016C0009927729FB00DE11DF91F639FB00DE11DB9
:1016D000F91FBD01CF0111240895AA1BBB1B51E1C5
:1016E00007C0AA1FBB1FA617B70710F0A61BB70B92
:1016F000881F991F5A95A9F780959095BC01CD0137
:10170000089597FB092E07260AD077FD04D0E5DF60
:1017100006D000201AF4709561957F4F0895F6F772
:10172000909581959F4F0895A1E21A2EAA1BBB1B8D
:10173000FD010DC0AA1FBB1FEE1FFF1FA217B3079D
:10174000E407F50720F0A21BB30BE40BF50B661FB3
:10175000771F881F991F1A9469F760957095809577
:1017600090959B01AC01BD01CF01089597FB092E17
:1017700005260ED057FD04D0D7DF0AD0001C38F460
:1017800050954095309521953F4F4F4F5F4F0895AD
:10179000F6F790958095709561957F4F8F4F9F4F8D
:1017A00008952F923F924F925F926F927F928F9205
:1017B0009F92AF92BF92CF92DF92EF92FF920F93E0
:1017C0001F93CF93DF93CDB7DEB7CA1BDB0B0FB6EA
:1017D000F894DEBF0FBECDBF09942A8839884888A7
:1017E0005F846E847D848C849B84AA84B984C8843D
:1017F000DF80EE80FD800C811B81AA81B981CE0F34
:10180000D11D0FB6F894DEBF0FBECDBFED01089518
:1018100033D158F080E891E009F49EEF34D128F0FC
:1018200040E851E059F45EEF09C0FEC07DC1E92FE8
:10183000E07841D168F3092E052AC1F3261737074E
:101840004807590738F00E2E07F8E02569F0E02523
:10185000E0640AC0EF6307F8009407FADB01B901FE
:101860009D01DC01CA01AD01EF9341D013D10AD033
:101870005F91552331F02BED3FE049E450FD49ECF9
:10188000C6C10895DF93DD27B92FBF7740E85FE336
:101890001616170648075B0710F4D92F4CD19F93F3
:1018A0008F937F936F93AFD1E6E2F0E0C0D0F2D098
:1018B0002F913F914F915F914FD1DD2349F0905887
:1018C000A2EA2AED3FE049EC5FE3D0785D27B0D192
:1018D000DF91E0C0D8D040F0CFD030F021F45F3FAE
:1018E00019F071C0511121C19FC0E5D098F399231F
:1018F000C9F35523B1F3951B550BBB27AA276217D4
:101900007307840738F09F5F5F4F220F331F441F18
:10191000AA1FA9F333D00E2E3AF0E0E830D0915050
:101920005040E695001CCAF729D0FE2F27D0660F3D
:10193000771F881FBB1F261737074807AB07B0E87C
:1019400009F0BB0B802DBF01FF2793585F4F2AF092
:101950009E3F510568F037C0E8C05F3FECF3983E0A
:10196000DCF3869577956795B795F7959F5FC9F7EF
:10197000880F911D9695879597F90895E1E0660F78
:10198000771F881FBB1F621773078407BA0720F0F1
:10199000621B730B840BBA0BEE1F88F7E09508955A
:1019A000ACD080F09F3740F491110EF0BEC060E0E3
:1019B00070E080E89FEB089526F41B16611D711DF1
:1019C000811D07C021C097F99F6780E870E060E043
:1019D0000895882371F4772321F09850872B762F70
:1019E00007C0662311F499270DC09051862B70E033
:1019F00060E02AF09A95660F771F881FDAF7880F44
:101A00009695879597F908959F3F49F0915028F44E
:101A1000869577956795B7959F5F80389F4F880F1C
:101A20009695879597F908959FEF80EC0895DF9339
:101A3000CF931F930F93FF92EF92DF927B018C0164
:101A4000689405C0DA2EEF0187D0FE01E894A591D5
:101A50002591359145915591AEF3EF01E9D0FE0105
:101A60009701A801DA9479F7DF90EF90FF900F913A
:101A70001F91CF91DF91089500240A94161617063E
:101A800018060906089500240A941216130614066F
:101A900005060895092E0394000C11F4882352F0D2
:101AA000BB0F40F4BF2B11F460FF04C06F5F7F4F8A
:101AB0008F4F9F4F089557FD9058440F551F59F071
:101AC0005F3F71F04795880F97FB991F61F09F3F2B
:101AD00079F087950895121613061406551FF2CF54
:101AE0004695F1DF08C0161617061806991FF1CFA4
:101AF00086957105610508940895E5DFA0F0BEE7BD
:101B0000B91788F4BB279F3860F41616B11D672FEC
:101B1000782F8827985FF7CF869577956795B11DC1
:101B200093959639C8F30895E894BB2766277727DD
:101B3000CB0197F908959B01AC0160E070E080E86B
:101B40009FE3C8CA99DF28F09EDF18F0952309F0BB
:101B50003ACF6ACF1124E9CFAEDFA0F3959FD1F33E
:101B6000950F50E0551F629FF001729FBB27F00D4B
:101B7000B11D639FAA27F00DB11DAA1F649F6627A0
:101B8000B00DA11D661F829F2227B00DA11D621FEF
:101B9000739FB00DA11D621F839FA00D611D221FA9
:101BA000749F3327A00D611D231F849F600D211D8D
:101BB000822F762F6A2F11249F5750408AF0E1F030
:101BC00088234AF0EE0FFF1FBB1F661F771F881F79
:101BD00091505040A9F79E3F510570F0F4CEA5CF2B
:101BE0005F3FECF3983EDCF3869577956795B79564
:101BF000F795E7959F5FC1F7FE2B880F911D96958E
:101C0000879597F908959B01AC016FC95058BB2780
:101C1000AA270ED03FCF30DF30F035DF20F031F48F
:101C20009F3F11F41EF400CF0EF4E095E7FBCBCEFE
:101C3000E92F41DF80F3BA1762077307840795071E
:101C400018F071F49EF570CF0EF4E0950B2EBA2FBC
:101C5000A02D0B01B90190010C01CA01A0011124B2
:101C6000FF27591B99F0593F50F4503E68F11A165E
:101C7000F040A22F232F342F4427585FF3CF4695EF
:101C800037952795A795F0405395C9F77EF41F1611
:101C9000BA0B620B730B840BBAF09150A1F0FF0FDB
:101CA000BB1F661F771F881FC2F70EC0BA0F621FC7
:101CB000731F841F48F4879577956795B795F795B7
:101CC0009E3F08F0B3CF9395880F08F09927EE0F49
:0A1CD000979587950895F894FFCFCB
:101CDA0000000000000000000001020203030303E9
:101CEA0004040404040404040505050505050505A2
:101CFA000505050505050505060606060606060682
:101D0A000606060606060606060606060606060669
:101D1A000606060606060606070707070707070751
:101D2A000707070707070707070707070707070739
:101D3A000707070707070707070707070707070729
:101D4A000707070707070707070707070707070719
:101D5A000707070707070707080808080808080801
:101D6A0008080808080808080808080808080808E9
:101D7A0008080808080808080808080808080808D9
:101D8A0008080808080808080808080808080808C9
:101D9A0008080808080808080808080808080808B9
:101DAA0008080808080808080808080808080808A9
:101DBA000808080808080808080808080808080899
:101DCA000808080808080808080808080808080889
:081DDA000808080808080808C1
:00000001FF
/programy/C/avr/akcelerometr/project.map
0,0 → 1,771
Archive member included because of file (symbol)
 
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_mulsi3.o)
timer.o (__mulsi3)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_udivmodhi4.o)
buffer.o (__udivmodhi4)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_divmodhi4.o)
a2dtest.o (__divmodhi4)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_udivmodsi4.o)
rprintf.o (__udivmodsi4)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_divmodsi4.o)
timer.o (__divmodsi4)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_exit.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/crtm8.o (exit)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_copy_data.o)
a2dtest.o (__do_copy_data)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_clear_bss.o)
a2dtest.o (__do_clear_bss)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_fixunssfsi.o)
a2dtest.o (__fixunssfsi)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_addsub_sf.o)
a2dtest.o (__subsf3)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_mul_sf.o)
a2dtest.o (__mulsf3)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_div_sf.o)
a2dtest.o (__divsf3)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_ge_sf.o)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_fixunssfsi.o) (__gesf2)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_si_to_sf.o)
a2dtest.o (__floatsisf)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_sf_to_si.o)
a2dtest.o (__fixsfsi)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_thenan_sf.o)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_addsub_sf.o) (__thenan_sf)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_prologue.o)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_addsub_sf.o) (__prologue_saves__)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_epilogue.o)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_addsub_sf.o) (__epilogue_restores__)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_clzsi2.o)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_si_to_sf.o) (__clzsi2)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_pack_sf.o)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_addsub_sf.o) (__pack_f)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_unpack_sf.o)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_addsub_sf.o) (__unpack_f)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_fpcmp_parts_sf.o)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_ge_sf.o) (__fpcmp_parts_f)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_clz.o)
/usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_clzsi2.o) (__clz_tab)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan2.o)
a2dtest.o (atan2)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan2.o) (atan)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(divsf3x.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan2.o) (__divsf3_pse)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(floor.o)
a2dtest.o (floor)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_inf.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(divsf3x.o) (__fp_inf)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_mintl.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(floor.o) (__fp_mintl)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_mpack.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(floor.o) (__fp_mpack)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_nan.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan2.o) (__fp_nan)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_powser.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan.o) (__fp_powser)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_pscA.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan2.o) (__fp_pscA)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_pscB.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan2.o) (__fp_pscB)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_round.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan2.o) (__fp_round)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_split3.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan2.o) (__fp_split3)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_trunc.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(floor.o) (__fp_trunc)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_zero.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan2.o) (__fp_zero)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(inverse.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan.o) (inverse)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(mulsf3x.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan.o) (__mulsf3x)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(square.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan.o) (square)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(addsf3x.o)
/usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan.o) (__addsf3x)
 
Allocating common symbols
Common symbol size file
 
uartReadyTx 0x1 uart.o
Timer0Reg0 0x4 timer.o
uartRxBuffer 0x8 uart.o
TimerPauseReg 0x4 timer.o
Timer2Reg0 0x4 timer.o
uartBufferedTx 0x1 uart.o
a2dCompleteFlag 0x1 a2d.o
uartTxBuffer 0x8 uart.o
uartRxOverflow 0x2 uart.o
 
Memory Configuration
 
Name Origin Length Attributes
text 0x00000000 0x00002000 xr
data 0x00800060 0x0000ffa0 rw !x
eeprom 0x00810000 0x00010000 rw !x
fuse 0x00820000 0x00000400 rw !x
lock 0x00830000 0x00000400 rw !x
signature 0x00840000 0x00000400 rw !x
*default* 0x00000000 0xffffffff
 
Linker script and memory map
 
LOAD /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/crtm8.o
LOAD a2dtest.o
LOAD a2d.o
LOAD buffer.o
LOAD rprintf.o
LOAD timer.o
LOAD uart.o
LOAD /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a
LOAD /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a
LOAD /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a
 
.hash
*(.hash)
 
.dynsym
*(.dynsym)
 
.dynstr
*(.dynstr)
 
.gnu.version
*(.gnu.version)
 
.gnu.version_d
*(.gnu.version_d)
 
.gnu.version_r
*(.gnu.version_r)
 
.rel.init
*(.rel.init)
 
.rela.init
*(.rela.init)
 
.rel.text
*(.rel.text)
*(.rel.text.*)
*(.rel.gnu.linkonce.t*)
 
.rela.text
*(.rela.text)
*(.rela.text.*)
*(.rela.gnu.linkonce.t*)
 
.rel.fini
*(.rel.fini)
 
.rela.fini
*(.rela.fini)
 
.rel.rodata
*(.rel.rodata)
*(.rel.rodata.*)
*(.rel.gnu.linkonce.r*)
 
.rela.rodata
*(.rela.rodata)
*(.rela.rodata.*)
*(.rela.gnu.linkonce.r*)
 
.rel.data
*(.rel.data)
*(.rel.data.*)
*(.rel.gnu.linkonce.d*)
 
.rela.data
*(.rela.data)
*(.rela.data.*)
*(.rela.gnu.linkonce.d*)
 
.rel.ctors
*(.rel.ctors)
 
.rela.ctors
*(.rela.ctors)
 
.rel.dtors
*(.rel.dtors)
 
.rela.dtors
*(.rela.dtors)
 
.rel.got
*(.rel.got)
 
.rela.got
*(.rela.got)
 
.rel.bss
*(.rel.bss)
 
.rela.bss
*(.rela.bss)
 
.rel.plt
*(.rel.plt)
 
.rela.plt
*(.rela.plt)
 
.text 0x00000000 0x2186
*(.vectors)
.vectors 0x00000000 0x26 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/crtm8.o
0x00000000 __vectors
0x00000000 __vector_default
*(.vectors)
*(.progmem.gcc*)
.progmem.gcc_fplib
0x00000026 0x2d /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan.o)
*(.progmem*)
.progmem.data 0x00000053 0x16 a2dtest.o
.progmem.data 0x00000069 0x11 rprintf.o
.progmem.data 0x0000007a 0x1c timer.o
0x00000086 TimerRTCPrescaleFactor
0x0000007a TimerPrescaleFactor
0x00000096 . = ALIGN (0x2)
0x00000096 __trampolines_start = .
*(.trampolines)
.trampolines 0x00000096 0x0 linker stubs
*(.trampolines*)
0x00000096 __trampolines_end = .
*(.jumptables)
*(.jumptables*)
*(.lowtext)
*(.lowtext*)
0x00000096 __ctors_start = .
*(.ctors)
0x00000096 __ctors_end = .
0x00000096 __dtors_start = .
*(.dtors)
0x00000096 __dtors_end = .
SORT(*)(.ctors)
SORT(*)(.dtors)
*(.init0)
.init0 0x00000096 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/crtm8.o
0x00000096 __init
*(.init0)
*(.init1)
*(.init1)
*(.init2)
.init2 0x00000096 0xc /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/crtm8.o
*(.init2)
*(.init3)
*(.init3)
*(.init4)
.init4 0x000000a2 0x16 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_copy_data.o)
0x000000a2 __do_copy_data
.init4 0x000000b8 0x10 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_clear_bss.o)
0x000000b8 __do_clear_bss
*(.init4)
*(.init5)
*(.init5)
*(.init6)
*(.init6)
*(.init7)
*(.init7)
*(.init8)
*(.init8)
*(.init9)
.init9 0x000000c8 0x4 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/crtm8.o
*(.init9)
*(.text)
.text 0x000000cc 0x2 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/crtm8.o
0x000000cc __vector_1
0x000000cc __vector_12
0x000000cc __bad_interrupt
0x000000cc __vector_17
0x000000cc __vector_2
0x000000cc __vector_15
0x000000cc __vector_10
0x000000cc __vector_16
0x000000cc __vector_18
.text 0x000000ce 0x116 a2dtest.o
0x000000ce main
.text 0x000001e4 0xac a2d.o
0x00000238 a2dIsComplete
0x00000266 a2dConvert8bit
0x00000204 a2dOff
0x0000020a a2dSetPrescaler
0x0000023e a2dConvert10bit
0x000001e4 a2dInit
0x00000214 a2dSetReference
0x00000272 __vector_14
0x00000226 a2dSetChannel
0x00000232 a2dStartConvert
.text 0x00000290 0x150 buffer.o
0x000003ba bufferIsNotFull
0x000002aa bufferGetFromFront
0x00000348 bufferGetAtIndex
0x00000304 bufferDumpFromFront
0x00000290 bufferInit
0x0000036e bufferAddToEnd
0x000003d2 bufferFlush
.text 0x000003e0 0x3b2 rprintf.o
0x00000678 rprintf1RamRom
0x000004bc rprintfu08
0x000004de rprintfu32
0x0000040e rprintfStr
0x0000042a rprintfStrLen
0x00000484 rprintfProgStr
0x000004ce rprintfu16
0x000003e0 rprintfInit
0x000003ea rprintfChar
0x000004a2 rprintfCRLF
0x000004a8 rprintfu04
0x00000500 rprintfNum
.text 0x00000792 0x594 timer.o
0x00000a38 timer2GetOverflowCount
0x000008de timerDetach
0x00000866 timer1SetPrescaler
0x00000af4 timer1PWMBOff
0x000008ae timer2GetPrescaler
0x00000c3e __vector_6
0x00000804 timer0Init
0x00000ae6 timer1PWMAOff
0x00000b08 timer1PWMBSet
0x00000cec __vector_3
0x00000a7e timer1PWMInitICR
0x0000087a timer0GetPrescaler
0x00000c78 __vector_7
0x00000a10 timer0GetOverflowCount
0x00000cb2 __vector_5
0x00000794 timerInit
0x00000870 timer2SetPrescaler
0x00000aca timer1PWMAOn
0x0000085c timer0SetPrescaler
0x00000792 delay_us
0x00000bd6 __vector_4
0x000009fe timer0ClearOverflowCount
0x00000b0e __vector_9
0x00000826 timer1Init
0x00000a4e timer1PWMInit
0x00000ad8 timer1PWMBOn
0x0000083a timer2Init
0x00000b9c __vector_8
0x00000b02 timer1PWMASet
0x000008c8 timerAttach
0x00000aa4 timer1PWMOff
0x00000894 timer1GetPrescaler
0x00000a26 timer2ClearOverflowCount
0x000008f4 timerPause
.text 0x00000d26 0x1ee uart.o
0x00000e4e uartSendTxBuffer
0x00000d70 uartSendByte
0x00000ec8 uartInitBuffers
0x00000e6c uartReceiveByte
0x00000e00 uartAddToTxBuffer
0x00000da0 __vector_11
0x00000d26 uartSetRxHandler
0x00000e0a __vector_13
0x00000d82 uartFlushReceiveBuffer
0x00000ee6 uartInit
0x00000d8c uartReceiveBufferIsEmpty
0x00000d30 uartSetBaudRate
0x00000d6a uartGetTxBuffer
0x00000e9e uartGetByte
0x00000d64 uartGetRxBuffer
.text 0x00000f14 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_mulsi3.o)
.text 0x00000f14 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_udivmodhi4.o)
.text 0x00000f14 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_divmodhi4.o)
.text 0x00000f14 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_udivmodsi4.o)
.text 0x00000f14 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_divmodsi4.o)
.text 0x00000f14 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_exit.o)
.text 0x00000f14 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_copy_data.o)
.text 0x00000f14 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_clear_bss.o)
.text 0x00000f14 0x50 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_fixunssfsi.o)
0x00000f14 __fixunssfsi
.text 0x00000f64 0x332 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_addsub_sf.o)
0x000011f2 __subsf3
0x00001248 __addsf3
.text 0x00001296 0x1ea /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_mul_sf.o)
0x00001296 __mulsf3
.text 0x00001480 0x14a /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_div_sf.o)
0x00001480 __divsf3
.text 0x000015ca 0x56 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_ge_sf.o)
0x000015ca __gesf2
.text 0x00001620 0xb4 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_si_to_sf.o)
0x00001620 __floatsisf
.text 0x000016d4 0xa2 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_sf_to_si.o)
0x000016d4 __fixsfsi
.text 0x00001776 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_thenan_sf.o)
.text 0x00001776 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_prologue.o)
.text 0x00001776 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_epilogue.o)
.text 0x00001776 0x9e /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_clzsi2.o)
0x00001776 __clzsi2
.text 0x00001814 0x1aa /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_pack_sf.o)
0x00001814 __pack_f
.text 0x000019be 0xe0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_unpack_sf.o)
0x000019be __unpack_f
.text 0x00001a9e 0xb4 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_fpcmp_parts_sf.o)
0x00001a9e __fpcmp_parts_f
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_clz.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan2.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(divsf3x.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(floor.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_inf.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_mintl.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_mpack.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_nan.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_powser.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_pscA.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_pscB.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_round.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_split3.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_trunc.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_zero.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(inverse.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(mulsf3x.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(square.o)
.text 0x00001b52 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(addsf3x.o)
0x00001b52 . = ALIGN (0x2)
*(.text.*)
.text.libgcc 0x00001b52 0x3e /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_mulsi3.o)
0x00001b52 __mulsi3
.text.libgcc 0x00001b90 0x28 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_udivmodhi4.o)
0x00001b90 __udivmodhi4
.text.libgcc 0x00001bb8 0x26 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_divmodhi4.o)
0x00001bb8 __divmodhi4
0x00001bb8 _div
.text.libgcc 0x00001bde 0x44 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_udivmodsi4.o)
0x00001bde __udivmodsi4
.text.libgcc 0x00001c22 0x36 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_divmodsi4.o)
0x00001c22 __divmodsi4
.text.libgcc 0x00001c58 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_exit.o)
.text.libgcc 0x00001c58 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_copy_data.o)
.text.libgcc 0x00001c58 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_clear_bss.o)
.text.libgcc 0x00001c58 0x38 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_prologue.o)
0x00001c58 __prologue_saves__
.text.libgcc 0x00001c90 0x36 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_epilogue.o)
0x00001c90 __epilogue_restores__
.text.fplib 0x00001cc6 0x74 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan2.o)
0x00001ce4 atan2
.text.fplib 0x00001d3a 0x50 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan.o)
0x00001d3a atan
.text.fplib 0x00001d8a 0xcc /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(divsf3x.o)
0x00001da0 __divsf3x
0x00001da4 __divsf3_pse
.text.fplib 0x00001e56 0x26 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(floor.o)
0x00001e56 floor
.text.fplib 0x00001e7c 0xc /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_inf.o)
0x00001e7c __fp_inf
.text.fplib 0x00001e88 0x36 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_mintl.o)
0x00001e88 __fp_mintl
.text.fplib 0x00001ebe 0x20 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_mpack.o)
0x00001ebe __fp_mpack
.text.fplib 0x00001ede 0x6 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_nan.o)
0x00001ede __fp_nan
.text.fplib 0x00001ee4 0x4a /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_powser.o)
0x00001ee4 __fp_powser
.text.fplib 0x00001f2e 0xe /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_pscA.o)
0x00001f2e __fp_pscA
.text.fplib 0x00001f3c 0xe /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_pscB.o)
0x00001f3c __fp_pscB
.text.fplib 0x00001f4a 0x22 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_round.o)
0x00001f4a __fp_round
.text.fplib 0x00001f6c 0x44 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_split3.o)
0x00001f6c __fp_split3
0x00001f7c __fp_splitA
.text.fplib 0x00001fb0 0x2e /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_trunc.o)
0x00001fb0 __fp_trunc
.text.fplib 0x00001fde 0xe /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_zero.o)
0x00001fde __fp_zero
0x00001fe0 __fp_szero
.text.fplib 0x00001fec 0xe /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(inverse.o)
0x00001fec inverse
.text.fplib 0x00001ffa 0xc2 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(mulsf3x.o)
0x00002012 __mulsf3_pse
0x0000200e __mulsf3x
.text.fplib 0x000020bc 0x6 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(square.o)
0x000020bc square
.text.fplib 0x000020c2 0xc0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(addsf3x.o)
0x000020dc __addsf3x
0x00002182 . = ALIGN (0x2)
*(.fini9)
.fini9 0x00002182 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_exit.o)
0x00002182 exit
0x00002182 _exit
*(.fini9)
*(.fini8)
*(.fini8)
*(.fini7)
*(.fini7)
*(.fini6)
*(.fini6)
*(.fini5)
*(.fini5)
*(.fini4)
*(.fini4)
*(.fini3)
*(.fini3)
*(.fini2)
*(.fini2)
*(.fini1)
*(.fini1)
*(.fini0)
.fini0 0x00002182 0x4 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_exit.o)
*(.fini0)
0x00002186 _etext = .
 
.data 0x00800060 0x108 load address 0x00002186
0x00800060 PROVIDE (__data_start, .)
*(.data)
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/crtm8.o
.data 0x00800060 0x0 a2dtest.o
.data 0x00800060 0x0 a2d.o
.data 0x00800060 0x0 buffer.o
.data 0x00800060 0x0 rprintf.o
.data 0x00800060 0x0 timer.o
.data 0x00800060 0x0 uart.o
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_mulsi3.o)
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_udivmodhi4.o)
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_divmodhi4.o)
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_udivmodsi4.o)
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_divmodsi4.o)
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_exit.o)
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_copy_data.o)
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_clear_bss.o)
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_fixunssfsi.o)
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_addsub_sf.o)
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_mul_sf.o)
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_div_sf.o)
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_ge_sf.o)
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_si_to_sf.o)
.data 0x00800060 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_sf_to_si.o)
.data 0x00800060 0x8 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_thenan_sf.o)
0x00800060 __thenan_sf
.data 0x00800068 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_prologue.o)
.data 0x00800068 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_epilogue.o)
.data 0x00800068 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_clzsi2.o)
.data 0x00800068 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_pack_sf.o)
.data 0x00800068 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_unpack_sf.o)
.data 0x00800068 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_fpcmp_parts_sf.o)
.data 0x00800068 0x100 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_clz.o)
0x00800068 __clz_tab
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan2.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(divsf3x.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(floor.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_inf.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_mintl.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_mpack.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_nan.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_powser.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_pscA.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_pscB.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_round.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_split3.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_trunc.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_zero.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(inverse.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(mulsf3x.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(square.o)
.data 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(addsf3x.o)
*(.data*)
*(.rodata)
*(.rodata*)
*(.gnu.linkonce.d*)
0x00800168 . = ALIGN (0x2)
0x00800168 _edata = .
0x00800168 PROVIDE (__data_end, .)
 
.bss 0x00800168 0x172 load address 0x0000228e
0x00800168 PROVIDE (__bss_start, .)
*(.bss)
.bss 0x00800168 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/crtm8.o
.bss 0x00800168 0x0 a2dtest.o
.bss 0x00800168 0x0 a2d.o
.bss 0x00800168 0x0 buffer.o
.bss 0x00800168 0x2 rprintf.o
.bss 0x0080016a 0xe timer.o
.bss 0x00800178 0x141 uart.o
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_mulsi3.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_udivmodhi4.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_divmodhi4.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_udivmodsi4.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_divmodsi4.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_exit.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_copy_data.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_clear_bss.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_fixunssfsi.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_addsub_sf.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_mul_sf.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_div_sf.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_ge_sf.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_si_to_sf.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_sf_to_si.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_thenan_sf.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_prologue.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_epilogue.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_clzsi2.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_pack_sf.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_unpack_sf.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_fpcmp_parts_sf.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/avr4/libgcc.a(_clz.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan2.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(divsf3x.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(floor.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_inf.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_mintl.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_mpack.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_nan.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_powser.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_pscA.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_pscB.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_round.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_split3.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_trunc.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_zero.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(inverse.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(mulsf3x.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(square.o)
.bss 0x008002b9 0x0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(addsf3x.o)
*(.bss*)
*(COMMON)
COMMON 0x008002b9 0x1 a2d.o
0x008002b9 a2dCompleteFlag
COMMON 0x008002ba 0xc timer.o
0x008002ba Timer0Reg0
0x008002be TimerPauseReg
0x008002c2 Timer2Reg0
COMMON 0x008002c6 0x14 uart.o
0x008002c6 uartReadyTx
0x008002c7 uartRxBuffer
0x008002cf uartBufferedTx
0x008002d0 uartTxBuffer
0x008002d8 uartRxOverflow
0x008002da PROVIDE (__bss_end, .)
0x00002186 __data_load_start = LOADADDR (.data)
0x0000228e __data_load_end = (__data_load_start + SIZEOF (.data))
 
.noinit 0x008002da 0x0
0x008002da PROVIDE (__noinit_start, .)
*(.noinit*)
0x008002da PROVIDE (__noinit_end, .)
0x008002da _end = .
0x008002da PROVIDE (__heap_start, .)
 
.eeprom 0x00810000 0x0
*(.eeprom*)
0x00810000 __eeprom_end = .
 
.fuse
*(.fuse)
*(.lfuse)
*(.hfuse)
*(.efuse)
 
.lock
*(.lock*)
 
.signature
*(.signature*)
 
.stab 0x00000000 0x270c
*(.stab)
.stab 0x00000000 0x6b4 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/crtm8.o
.stab 0x000006b4 0x2f4 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan2.o)
0x300 (size before relaxing)
.stab 0x000009a8 0x210 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(atan.o)
0x21c (size before relaxing)
.stab 0x00000bb8 0x510 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(divsf3x.o)
0x51c (size before relaxing)
.stab 0x000010c8 0x114 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(floor.o)
0x120 (size before relaxing)
.stab 0x000011dc 0x78 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_inf.o)
0x84 (size before relaxing)
.stab 0x00001254 0x174 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_mintl.o)
0x180 (size before relaxing)
.stab 0x000013c8 0xf0 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_mpack.o)
0xfc (size before relaxing)
.stab 0x000014b8 0x54 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_nan.o)
0x60 (size before relaxing)
.stab 0x0000150c 0x1ec /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_powser.o)
0x1f8 (size before relaxing)
.stab 0x000016f8 0x84 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_pscA.o)
0x90 (size before relaxing)
.stab 0x0000177c 0x84 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_pscB.o)
0x90 (size before relaxing)
.stab 0x00001800 0xfc /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_round.o)
0x108 (size before relaxing)
.stab 0x000018fc 0x1d4 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_split3.o)
0x1e0 (size before relaxing)
.stab 0x00001ad0 0x144 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_trunc.o)
0x150 (size before relaxing)
.stab 0x00001c14 0x90 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(fp_zero.o)
0x9c (size before relaxing)
.stab 0x00001ca4 0x84 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(inverse.o)
0x90 (size before relaxing)
.stab 0x00001d28 0x4d4 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(mulsf3x.o)
0x4e0 (size before relaxing)
.stab 0x000021fc 0x54 /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(square.o)
0x60 (size before relaxing)
.stab 0x00002250 0x4bc /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/libc.a(addsf3x.o)
0x4c8 (size before relaxing)
 
.stabstr 0x00000000 0x3bc
*(.stabstr)
.stabstr 0x00000000 0x3bc /usr/lib/gcc/avr/4.3.0/../../../../avr/lib/avr4/crtm8.o
 
.stab.excl
*(.stab.excl)
 
.stab.exclstr
*(.stab.exclstr)
 
.stab.index
*(.stab.index)
 
.stab.indexstr
*(.stab.indexstr)
 
.comment
*(.comment)
 
.debug
*(.debug)
 
.line
*(.line)
 
.debug_srcinfo
*(.debug_srcinfo)
 
.debug_sfnames
*(.debug_sfnames)
 
.debug_aranges
*(.debug_aranges)
 
.debug_pubnames
*(.debug_pubnames)
 
.debug_info
*(.debug_info)
*(.gnu.linkonce.wi.*)
 
.debug_abbrev
*(.debug_abbrev)
 
.debug_line
*(.debug_line)
 
.debug_frame
*(.debug_frame)
 
.debug_str
*(.debug_str)
 
.debug_loc
*(.debug_loc)
 
.debug_macinfo
*(.debug_macinfo)
OUTPUT(project.out elf32-avr)
LOAD linker stubs
/programy/C/avr/akcelerometr/rprintf.c
0,0 → 1,782
/*! \file rprintf.c \brief printf routine and associated routines. */
//*****************************************************************************
//
// File Name : 'rprintf.c'
// Title : printf routine and associated routines
// Author : Pascal Stang - Copyright (C) 2000-2002
// Created : 2000.12.26
// Revised : 2003.5.1
// Version : 1.0
// Target MCU : Atmel AVR series and other targets
// Editor Tabs : 4
//
// NOTE: This code is currently below version 1.0, and therefore is considered
// to be lacking in some functionality or documentation, or may not be fully
// tested. Nonetheless, you can expect most functions to work.
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************
 
#include <avr/pgmspace.h>
//#include <string-avr.h>
//#include <stdlib.h>
#include <stdarg.h>
#include "global.h"
#include "rprintf.h"
 
#ifndef TRUE
#define TRUE -1
#define FALSE 0
#endif
 
#define INF 32766 // maximum field size to print
#define READMEMBYTE(a,char_ptr) ((a)?(pgm_read_byte(char_ptr)):(*char_ptr))
 
#ifdef RPRINTF_COMPLEX
static unsigned char buf[128];
#endif
 
// use this to store hex conversion in RAM
//static char HexChars[] = "0123456789ABCDEF";
// use this to store hex conversion in program memory
//static prog_char HexChars[] = "0123456789ABCDEF";
static char __attribute__ ((progmem)) HexChars[] = "0123456789ABCDEF";
 
#define hexchar(x) pgm_read_byte( HexChars+((x)&0x0f) )
//#define hexchar(x) ((((x)&0x0F)>9)?((x)+'A'-10):((x)+'0'))
 
// function pointer to single character output routine
static void (*rputchar)(unsigned char c);
 
// *** rprintf initialization ***
// you must call this function once and supply the character output
// routine before using other functions in this library
void rprintfInit(void (*putchar_func)(unsigned char c))
{
rputchar = putchar_func;
}
 
// *** rprintfChar ***
// send a character/byte to the current output device
void rprintfChar(unsigned char c)
{
// do LF -> CR/LF translation
if(c == '\n')
rputchar('\r');
// send character
rputchar(c);
}
 
// *** rprintfStr ***
// prints a null-terminated string stored in RAM
void rprintfStr(char str[])
{
// send a string stored in RAM
// check to make sure we have a good pointer
if (!str) return;
 
// print the string until a null-terminator
while (*str)
rprintfChar(*str++);
}
 
// *** rprintfStrLen ***
// prints a section of a string stored in RAM
// begins printing at position indicated by <start>
// prints number of characters indicated by <len>
void rprintfStrLen(char str[], unsigned int start, unsigned int len)
{
register int i=0;
 
// check to make sure we have a good pointer
if (!str) return;
// spin through characters up to requested start
// keep going as long as there's no null
while((i++<start) && (*str++));
// for(i=0; i<start; i++)
// {
// // keep steping through string as long as there's no null
// if(*str) str++;
// }
 
// then print exactly len characters
for(i=0; i<len; i++)
{
// print data out of the string as long as we haven't reached a null yet
// at the null, start printing spaces
if(*str)
rprintfChar(*str++);
else
rprintfChar(' ');
}
 
}
 
// *** rprintfProgStr ***
// prints a null-terminated string stored in program ROM
void rprintfProgStr(const prog_char str[])
{
// print a string stored in program memory
register char c;
 
// check to make sure we have a good pointer
if (!str) return;
// print the string until the null-terminator
while((c = pgm_read_byte(str++)))
rprintfChar(c);
}
 
// *** rprintfCRLF ***
// prints carriage return and line feed
void rprintfCRLF(void)
{
// print CR/LF
//rprintfChar('\r');
// LF -> CR/LF translation built-in to rprintfChar()
rprintfChar('\n');
}
 
// *** rprintfu04 ***
// prints an unsigned 4-bit number in hex (1 digit)
void rprintfu04(unsigned char data)
{
// print 4-bit hex value
// char Character = data&0x0f;
// if (Character>9)
// Character+='A'-10;
// else
// Character+='0';
rprintfChar(hexchar(data));
}
 
// *** rprintfu08 ***
// prints an unsigned 8-bit number in hex (2 digits)
void rprintfu08(unsigned char data)
{
// print 8-bit hex value
rprintfu04(data>>4);
rprintfu04(data);
}
 
// *** rprintfu16 ***
// prints an unsigned 16-bit number in hex (4 digits)
void rprintfu16(unsigned short data)
{
// print 16-bit hex value
rprintfu08(data>>8);
rprintfu08(data);
}
 
// *** rprintfu32 ***
// prints an unsigned 32-bit number in hex (8 digits)
void rprintfu32(unsigned long data)
{
// print 32-bit hex value
rprintfu16(data>>16);
rprintfu16(data);
}
 
// *** rprintfNum ***
// special printf for numbers only
// see formatting information below
// Print the number "n" in the given "base"
// using exactly "numDigits"
// print +/- if signed flag "isSigned" is TRUE
// use the character specified in "padchar" to pad extra characters
//
// Examples:
// uartPrintfNum(10, 6, TRUE, ' ', 1234); --> " +1234"
// uartPrintfNum(10, 6, FALSE, '0', 1234); --> "001234"
// uartPrintfNum(16, 6, FALSE, '.', 0x5AA5); --> "..5AA5"
void rprintfNum(char base, char numDigits, char isSigned, char padchar, long n)
{
// define a global HexChars or use line below
//static char HexChars[16] = "0123456789ABCDEF";
char *p, buf[32];
unsigned long x;
unsigned char count;
 
// prepare negative number
if( isSigned && (n < 0) )
{
x = -n;
}
else
{
x = n;
}
 
// setup little string buffer
count = (numDigits-1)-(isSigned?1:0);
p = buf + sizeof (buf);
*--p = '\0';
// force calculation of first digit
// (to prevent zero from not printing at all!!!)
*--p = hexchar(x%base); x /= base;
// calculate remaining digits
while(count--)
{
if(x != 0)
{
// calculate next digit
*--p = hexchar(x%base); x /= base;
}
else
{
// no more digits left, pad out to desired length
*--p = padchar;
}
}
 
// apply signed notation if requested
if( isSigned )
{
if(n < 0)
{
*--p = '-';
}
else if(n > 0)
{
*--p = '+';
}
else
{
*--p = ' ';
}
}
 
// print the string right-justified
count = numDigits;
while(count--)
{
rprintfChar(*p++);
}
}
 
#ifdef RPRINTF_FLOAT
// *** rprintfFloat ***
// floating-point print
void rprintfFloat(char numDigits, double x)
{
unsigned char firstplace = FALSE;
unsigned char negative;
unsigned char i, digit;
double place = 1.0;
// save sign
negative = (x<0);
// convert to absolute value
x = (x>0)?(x):(-x);
// find starting digit place
for(i=0; i<15; i++)
{
if((x/place) < 10.0)
break;
else
place *= 10.0;
}
// print polarity character
if(negative)
rprintfChar('-');
else
rprintfChar('+');
 
// print digits
for(i=0; i<numDigits; i++)
{
digit = (x/place);
 
if(digit | firstplace | (place == 1.0))
{
firstplace = TRUE;
rprintfChar(digit+0x30);
}
else
rprintfChar(' ');
if(place == 1.0)
{
rprintfChar('.');
}
x -= (digit*place);
place /= 10.0;
}
}
#endif
 
#ifdef RPRINTF_SIMPLE
// *** rprintf1RamRom ***
// called by rprintf() - does a simple printf (supports %d, %x, %c)
// Supports:
// %d - decimal
// %x - hex
// %c - character
int rprintf1RamRom(unsigned char stringInRom, const char *format, ...)
{
// simple printf routine
// define a global HexChars or use line below
//static char HexChars[16] = "0123456789ABCDEF";
char format_flag;
unsigned int u_val, div_val, base;
va_list ap;
 
va_start(ap, format);
for (;;)
{
while ((format_flag = READMEMBYTE(stringInRom,format++) ) != '%')
{ // Until '%' or '\0'
if (!format_flag)
{
va_end(ap);
return(0);
}
rprintfChar(format_flag);
}
 
switch (format_flag = READMEMBYTE(stringInRom,format++) )
{
case 'c': format_flag = va_arg(ap,int);
default: rprintfChar(format_flag); continue;
case 'd': base = 10; div_val = 10000; goto CONVERSION_LOOP;
// case 'x': base = 16; div_val = 0x10;
case 'x': base = 16; div_val = 0x1000;
 
CONVERSION_LOOP:
u_val = va_arg(ap,int);
if (format_flag == 'd')
{
if (((int)u_val) < 0)
{
u_val = - u_val;
rprintfChar('-');
}
while (div_val > 1 && div_val > u_val) div_val /= 10;
}
do
{
//rprintfChar(pgm_read_byte(HexChars+(u_val/div_val)));
rprintfu04(u_val/div_val);
u_val %= div_val;
div_val /= base;
} while (div_val);
}
}
va_end(ap);
}
#endif
 
 
#ifdef RPRINTF_COMPLEX
// *** rprintf2RamRom ***
// called by rprintf() - does a more powerful printf (supports %d, %u, %o, %x, %c, %s)
// Supports:
// %d - decimal
// %u - unsigned decimal
// %o - octal
// %x - hex
// %c - character
// %s - strings
// and the width,precision,padding modifiers
// **this printf does not support floating point numbers
int rprintf2RamRom(unsigned char stringInRom, const char *sfmt, ...)
{
register unsigned char *f, *bp;
register long l;
register unsigned long u;
register int i;
register int fmt;
register unsigned char pad = ' ';
int flush_left = 0, f_width = 0, prec = INF, hash = 0, do_long = 0;
int sign = 0;
 
va_list ap;
va_start(ap, sfmt);
 
f = (unsigned char *) sfmt;
 
for (; READMEMBYTE(stringInRom,f); f++)
{
if (READMEMBYTE(stringInRom,f) != '%')
{ // not a format character
// then just output the char
rprintfChar(READMEMBYTE(stringInRom,f));
}
else
{
f++; // if we have a "%" then skip it
if (READMEMBYTE(stringInRom,f) == '-')
{
flush_left = 1; // minus: flush left
f++;
}
if (READMEMBYTE(stringInRom,f) == '0'
|| READMEMBYTE(stringInRom,f) == '.')
{
// padding with 0 rather than blank
pad = '0';
f++;
}
if (READMEMBYTE(stringInRom,f) == '*')
{ // field width
f_width = va_arg(ap, int);
f++;
}
else if (Isdigit(READMEMBYTE(stringInRom,f)))
{
f_width = atoiRamRom(stringInRom, (char *) f);
while (Isdigit(READMEMBYTE(stringInRom,f)))
f++; // skip the digits
}
if (READMEMBYTE(stringInRom,f) == '.')
{ // precision
f++;
if (READMEMBYTE(stringInRom,f) == '*')
{
prec = va_arg(ap, int);
f++;
}
else if (Isdigit(READMEMBYTE(stringInRom,f)))
{
prec = atoiRamRom(stringInRom, (char *) f);
while (Isdigit(READMEMBYTE(stringInRom,f)))
f++; // skip the digits
}
}
if (READMEMBYTE(stringInRom,f) == '#')
{ // alternate form
hash = 1;
f++;
}
if (READMEMBYTE(stringInRom,f) == 'l')
{ // long format
do_long = 1;
f++;
}
 
fmt = READMEMBYTE(stringInRom,f);
bp = buf;
switch (fmt) { // do the formatting
case 'd': // 'd' signed decimal
if (do_long)
l = va_arg(ap, long);
else
l = (long) (va_arg(ap, int));
if (l < 0)
{
sign = 1;
l = -l;
}
do {
*bp++ = l % 10 + '0';
} while ((l /= 10) > 0);
if (sign)
*bp++ = '-';
f_width = f_width - (bp - buf);
if (!flush_left)
while (f_width-- > 0)
rprintfChar(pad);
for (bp--; bp >= buf; bp--)
rprintfChar(*bp);
if (flush_left)
while (f_width-- > 0)
rprintfChar(' ');
break;
case 'o': // 'o' octal number
case 'x': // 'x' hex number
case 'u': // 'u' unsigned decimal
if (do_long)
u = va_arg(ap, unsigned long);
else
u = (unsigned long) (va_arg(ap, unsigned));
if (fmt == 'u')
{ // unsigned decimal
do {
*bp++ = u % 10 + '0';
} while ((u /= 10) > 0);
}
else if (fmt == 'o')
{ // octal
do {
*bp++ = u % 8 + '0';
} while ((u /= 8) > 0);
if (hash)
*bp++ = '0';
}
else if (fmt == 'x')
{ // hex
do {
i = u % 16;
if (i < 10)
*bp++ = i + '0';
else
*bp++ = i - 10 + 'a';
} while ((u /= 16) > 0);
if (hash)
{
*bp++ = 'x';
*bp++ = '0';
}
}
i = f_width - (bp - buf);
if (!flush_left)
while (i-- > 0)
rprintfChar(pad);
for (bp--; bp >= buf; bp--)
rprintfChar((int) (*bp));
if (flush_left)
while (i-- > 0)
rprintfChar(' ');
break;
case 'c': // 'c' character
i = va_arg(ap, int);
rprintfChar((int) (i));
break;
case 's': // 's' string
bp = va_arg(ap, unsigned char *);
if (!bp)
bp = (unsigned char *) "(nil)";
f_width = f_width - strlen((char *) bp);
if (!flush_left)
while (f_width-- > 0)
rprintfChar(pad);
for (i = 0; *bp && i < prec; i++)
{
rprintfChar(*bp);
bp++;
}
if (flush_left)
while (f_width-- > 0)
rprintfChar(' ');
break;
case '%': // '%' character
rprintfChar('%');
break;
}
flush_left = 0, f_width = 0, prec = INF, hash = 0, do_long = 0;
sign = 0;
pad = ' ';
}
}
 
va_end(ap);
return 0;
}
 
unsigned char Isdigit(char c)
{
if((c >= 0x30) && (c <= 0x39))
return TRUE;
else
return FALSE;
}
 
int atoiRamRom(unsigned char stringInRom, char *str)
{
int num = 0;;
 
while(Isdigit(READMEMBYTE(stringInRom,str)))
{
num *= 10;
num += ((READMEMBYTE(stringInRom,str++)) - 0x30);
}
return num;
}
 
#endif
 
//******************************************************************************
// code below this line is commented out and can be ignored
//******************************************************************************
/*
char* sprintf(const char *sfmt, ...)
{
register unsigned char *f, *bp, *str;
register long l;
register unsigned long u;
register int i;
register int fmt;
register unsigned char pad = ' ';
int flush_left = 0, f_width = 0, prec = INF, hash = 0, do_long = 0;
int sign = 0;
 
va_list ap;
va_start(ap, sfmt);
 
str = bufstring;
f = (unsigned char *) sfmt;
 
for (; *f; f++)
{
if (*f != '%')
{ // not a format character
*str++ = (*f); // then just output the char
}
else
{
f++; // if we have a "%" then skip it
if (*f == '-')
{
flush_left = 1; // minus: flush left
f++;
}
if (*f == '0' || *f == '.')
{
// padding with 0 rather than blank
pad = '0';
f++;
}
if (*f == '*')
{ // field width
f_width = va_arg(ap, int);
f++;
}
else if (Isdigit(*f))
{
f_width = atoi((char *) f);
while (Isdigit(*f))
f++; // skip the digits
}
if (*f == '.')
{ // precision
f++;
if (*f == '*')
{
prec = va_arg(ap, int);
f++;
}
else if (Isdigit(*f))
{
prec = atoi((char *) f);
while (Isdigit(*f))
f++; // skip the digits
}
}
if (*f == '#')
{ // alternate form
hash = 1;
f++;
}
if (*f == 'l')
{ // long format
do_long = 1;
f++;
}
 
fmt = *f;
bp = buf;
switch (fmt) { // do the formatting
case 'd': // 'd' signed decimal
if (do_long)
l = va_arg(ap, long);
else
l = (long) (va_arg(ap, int));
if (l < 0)
{
sign = 1;
l = -l;
}
do {
*bp++ = l % 10 + '0';
} while ((l /= 10) > 0);
if (sign)
*bp++ = '-';
f_width = f_width - (bp - buf);
if (!flush_left)
while (f_width-- > 0)
*str++ = (pad);
for (bp--; bp >= buf; bp--)
*str++ = (*bp);
if (flush_left)
while (f_width-- > 0)
*str++ = (' ');
break;
case 'o': // 'o' octal number
case 'x': // 'x' hex number
case 'u': // 'u' unsigned decimal
if (do_long)
u = va_arg(ap, unsigned long);
else
u = (unsigned long) (va_arg(ap, unsigned));
if (fmt == 'u')
{ // unsigned decimal
do {
*bp++ = u % 10 + '0';
} while ((u /= 10) > 0);
}
else if (fmt == 'o')
{ // octal
do {
*bp++ = u % 8 + '0';
} while ((u /= 8) > 0);
if (hash)
*bp++ = '0';
}
else if (fmt == 'x')
{ // hex
do {
i = u % 16;
if (i < 10)
*bp++ = i + '0';
else
*bp++ = i - 10 + 'a';
} while ((u /= 16) > 0);
if (hash)
{
*bp++ = 'x';
*bp++ = '0';
}
}
i = f_width - (bp - buf);
if (!flush_left)
while (i-- > 0)
*str++ = (pad);
for (bp--; bp >= buf; bp--)
*str++ = ((int) (*bp));
if (flush_left)
while (i-- > 0)
*str++ = (' ');
break;
case 'c': // 'c' character
i = va_arg(ap, int);
*str++ = ((int) (i));
break;
case 's': // 's' string
bp = va_arg(ap, unsigned char *);
if (!bp)
bp = (unsigned char *) "(nil)";
f_width = f_width - strlen((char *) bp);
if (!flush_left)
while (f_width-- > 0)
*str++ = (pad);
for (i = 0; *bp && i < prec; i++)
{
*str++ = (*bp);
bp++;
}
if (flush_left)
while (f_width-- > 0)
*str++ = (' ');
break;
case '%': // '%' character
*str++ = ('%');
break;
}
flush_left = 0, f_width = 0, prec = INF, hash = 0, do_long = 0;
sign = 0;
pad = ' ';
}
}
 
va_end(ap);
// terminate string with null
*str++ = '\0';
return bufstring;
}
 
*/
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/C/avr/akcelerometr/rprintf.h
0,0 → 1,191
/*! \file rprintf.h \brief printf routine and associated routines. */
//****************************************************************************
//
// File Name : 'rprintf.h'
// Title : printf routine and associated routines
// Author : Pascal Stang - Copyright (C) 2000-2002
// Created : 2000.12.26
// Revised : 2003.5.1
// Version : 1.0
// Target MCU : Atmel AVR series and other targets
// Editor Tabs : 4
//
// NOTE: This code is currently below version 1.0, and therefore is considered
// to be lacking in some functionality or documentation, or may not be fully
// tested. Nonetheless, you can expect most functions to work.
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
/// \ingroup general
/// \defgroup rprintf printf() Function Library (rprintf.c)
/// \code #include "rprintf.h" \endcode
/// \par Overview
/// The rprintf function library provides a simplified (reduced) version of
/// the common C printf() function.� See the code files for details about
/// which printf features are supported.� Also in this library are a
/// variety of functions for fast printing of certain common data types
/// (variable types).� Functions include print string from RAM, print
/// string from ROM, print string snippet, print hex byte/short/long, and
/// a custom-formatted number print, as well as an optional floating-point
/// print routine.
///
/// \note All output from the rprintf library can be directed to any device
/// or software which accepts characters.� This means that rprintf output
/// can be sent to the UART (serial port) or can be used with the LCD
/// display libraries to print formatted text on the screen.
//
//****************************************************************************
//@{
 
#ifndef RPRINTF_H
#define RPRINTF_H
 
// needed for use of PSTR below
#include <avr/pgmspace.h>
 
// configuration
// defining RPRINTF_SIMPLE will compile a smaller, simpler, and faster printf() function
// defining RPRINTF_COMPLEX will compile a larger, more capable, and slower printf() function
#ifndef RPRINTF_COMPLEX
#define RPRINTF_SIMPLE
#endif
 
// Define RPRINTF_FLOAT to enable the floating-point printf function: rprintfFloat()
// (adds +4600bytes or 2.2Kwords of code)
 
// defines/constants
#define STRING_IN_RAM 0
#define STRING_IN_ROM 1
 
// make a putchar for those that are used to using it
//#define putchar(c) rprintfChar(c);
 
// functions
 
//! Initializes the rprintf library for an output stream.
/// You must call this initializer once before using any other rprintf function.
/// The argument must be a character stream output function.
void rprintfInit(void (*putchar_func)(unsigned char c));
 
//! prints a single character to the current output device
void rprintfChar(unsigned char c);
 
//! prints a null-terminated string stored in RAM
void rprintfStr(char str[]);
 
//! Prints a section of a string stored in RAM.
/// Begins printing at position indicated by <start>,
/// and prints number of characters indicated by <len>.
void rprintfStrLen(char str[], unsigned int start, unsigned int len);
 
//! prints a string stored in program rom
/// \note This function does not actually store your string in
/// program rom, but merely reads it assuming you stored it properly.
void rprintfProgStr(const prog_char str[]);
 
//! Using the function rprintfProgStrM(...) automatically causes
/// your string to be stored in ROM, thereby not wasting precious RAM.
/// Example usage:
/// \code
/// rprintfProgStrM("Hello, this string is stored in program rom");
/// \endcode
#define rprintfProgStrM(string) (rprintfProgStr(PSTR(string)))
 
//! Prints a carriage-return and line-feed.
/// Useful when printing to serial ports/terminals.
void rprintfCRLF(void);
 
// Prints the number contained in "data" in hex format
// u04,u08,u16,and u32 functions handle 4,8,16,or 32 bits respectively
void rprintfu04(unsigned char data); ///< Print 4-bit hex number. Outputs a single hex character.
void rprintfu08(unsigned char data); ///< Print 8-bit hex number. Outputs two hex characters.
void rprintfu16(unsigned short data); ///< Print 16-bit hex number. Outputs four hex characters.
void rprintfu32(unsigned long data); ///< Print 32-bit hex number. Outputs eight hex characters.
 
//! A flexible integer-number printing routine.
/// Print the number "n" in the given "base", using exactly "numDigits".
/// Print +/- if signed flag "isSigned" is TRUE.
/// The character specified in "padchar" will be used to pad extra characters.
///
/// Examples:
/// \code
/// uartPrintfNum(10, 6, TRUE, ' ', 1234); --> " +1234"
/// uartPrintfNum(10, 6, FALSE, '0', 1234); --> "001234"
/// uartPrintfNum(16, 6, FALSE, '.', 0x5AA5); --> "..5AA5"
/// \endcode
void rprintfNum(char base, char numDigits, char isSigned, char padchar, long n);
 
#ifdef RPRINTF_FLOAT
//! floating-point print routine
void rprintfFloat(char numDigits, double x);
#endif
 
// NOTE: Below you'll see the function prototypes of rprintf1RamRom and
// rprintf2RamRom. rprintf1RamRom and rprintf2RamRom are both reduced versions
// of the regular C printf() command. However, they are modified to be able
// to read their text/format strings from RAM or ROM in the Atmel microprocessors.
// Unless you really intend to, do not use the "RamRom" versions of the functions
// directly. Instead use the #defined function versions:
//
// printfx("text/format",args) ...to keep your text/format string stored in RAM
// - or -
// printfxROM("text/format",args) ...to keep your text/format string stored in ROM
//
// where x is either 1 or 2 for the simple or more powerful version of printf()
//
// Since there is much more ROM than RAM available in the Atmel microprocessors,
// and nearly all text/format strings are constant (never change in the course
// of the program), you should try to use the ROM printf version exclusively.
// This will ensure you leave as much RAM as possible for program variables and
// data.
 
//! \fn int rprintf(const char *format, ...);
/// A reduced substitute for the usual C printf() function.
/// This function actually points to either rprintf1RamRom or rprintf2RamRom
/// depending on the user's selection. Rprintf1 is a simple small fast print
/// routine while rprintf2 is larger and slower but more capable. To choose
/// the routine you would like to use, define either RPRINTF_SIMPLE or
/// RPRINTF_COMPLEX in global.h.
 
#ifdef RPRINTF_SIMPLE
//! A simple printf routine.
/// Called by rprintf() - does a simple printf (supports %d, %x, %c).
/// Supports:
/// - %d - decimal
/// - %x - hex
/// - %c - character
int rprintf1RamRom(unsigned char stringInRom, const char *format, ...);
// #defines for RAM or ROM operation
#define rprintf1(format, args...) rprintf1RamRom(STRING_IN_ROM, PSTR(format), ## args)
#define rprintf1RAM(format, args...) rprintf1RamRom(STRING_IN_RAM, format, ## args)
 
// *** Default rprintf(...) ***
// this next line determines what the the basic rprintf() defaults to:
#define rprintf(format, args...) rprintf1RamRom(STRING_IN_ROM, PSTR(format), ## args)
#endif
 
#ifdef RPRINTF_COMPLEX
//! A more powerful printf routine.
/// Called by rprintf() - does a more powerful printf (supports %d, %u, %o, %x, %c, %s).
/// Supports:
/// - %d - decimal
/// - %u - unsigned decimal
/// - %o - octal
/// - %x - hex
/// - %c - character
/// - %s - strings
/// - and the width,precision,padding modifiers
/// \note This printf does not support floating point numbers.
int rprintf2RamRom(unsigned char stringInRom, const char *sfmt, ...);
// #defines for RAM or ROM operation
#define rprintf2(format, args...) rprintf2RamRom(STRING_IN_ROM, format, ## args)
#define rprintf2RAM(format, args...) rprintf2RamRom(STRING_IN_RAM, format, ## args)
 
// *** Default rprintf(...) ***
// this next line determines what the the basic rprintf() defaults to:
#define rprintf(format, args...) rprintf2RamRom(STRING_IN_ROM, PSTR(format), ## args)
#endif
 
#endif
//@}
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/C/avr/akcelerometr/timer.c
0,0 → 1,469
/*! \file timer.c \brief System Timer function library. */
//*****************************************************************************
//
// File Name : 'timer.c'
// Title : System Timer function library
// Author : Pascal Stang - Copyright (C) 2000-2002
// Created : 11/22/2000
// Revised : 07/09/2003
// Version : 1.1
// Target MCU : Atmel AVR Series
// Editor Tabs : 4
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************
 
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/sleep.h>
 
#include "global.h"
#include "timer.h"
 
#include "rprintf.h"
 
// Program ROM constants
// the prescale division values stored in order of timer control register index
// STOP, CLK, CLK/8, CLK/64, CLK/256, CLK/1024
unsigned short __attribute__ ((progmem)) TimerPrescaleFactor[] = {0,1,8,64,256,1024};
// the prescale division values stored in order of timer control register index
// STOP, CLK, CLK/8, CLK/32, CLK/64, CLK/128, CLK/256, CLK/1024
unsigned short __attribute__ ((progmem)) TimerRTCPrescaleFactor[] = {0,1,8,32,64,128,256,1024};
 
// Global variables
// time registers
volatile unsigned long TimerPauseReg;
volatile unsigned long Timer0Reg0;
volatile unsigned long Timer2Reg0;
 
typedef void (*voidFuncPtr)(void);
volatile static voidFuncPtr TimerIntFunc[TIMER_NUM_INTERRUPTS];
 
// delay for a minimum of <us> microseconds
// the time resolution is dependent on the time the loop takes
// e.g. with 4Mhz and 5 cycles per loop, the resolution is 1.25 us
void delay_us(unsigned short time_us)
{
unsigned short delay_loops;
register unsigned short i;
 
delay_loops = (time_us+3)/5*CYCLES_PER_US; // +3 for rounding up (dirty)
 
// one loop takes 5 cpu cycles
for (i=0; i < delay_loops; i++) {};
}
/*
void delay_ms(unsigned char time_ms)
{
unsigned short delay_count = F_CPU / 4000;
 
unsigned short cnt;
asm volatile ("\n"
"L_dl1%=:\n\t"
"mov %A0, %A2\n\t"
"mov %B0, %B2\n"
"L_dl2%=:\n\t"
"sbiw %A0, 1\n\t"
"brne L_dl2%=\n\t"
"dec %1\n\t" "brne L_dl1%=\n\t":"=&w" (cnt)
:"r"(time_ms), "r"((unsigned short) (delay_count))
);
}
*/
void timerInit(void)
{
u08 intNum;
// detach all user functions from interrupts
for(intNum=0; intNum<TIMER_NUM_INTERRUPTS; intNum++)
timerDetach(intNum);
 
// initialize all timers
timer0Init();
timer1Init();
#ifdef TCNT2 // support timer2 only if it exists
timer2Init();
#endif
// enable interrupts
sei();
}
 
void timer0Init()
{
// initialize timer 0
timer0SetPrescaler( TIMER0PRESCALE ); // set prescaler
outb(TCNT0, 0); // reset TCNT0
sbi(TIMSK, TOIE0); // enable TCNT0 overflow interrupt
 
timer0ClearOverflowCount(); // initialize time registers
}
 
void timer1Init(void)
{
// initialize timer 1
timer1SetPrescaler( TIMER1PRESCALE ); // set prescaler
outb(TCNT1H, 0); // reset TCNT1
outb(TCNT1L, 0);
sbi(TIMSK, TOIE1); // enable TCNT1 overflow
}
 
#ifdef TCNT2 // support timer2 only if it exists
void timer2Init(void)
{
// initialize timer 2
timer2SetPrescaler( TIMER2PRESCALE ); // set prescaler
outb(TCNT2, 0); // reset TCNT2
sbi(TIMSK, TOIE2); // enable TCNT2 overflow
 
timer2ClearOverflowCount(); // initialize time registers
}
#endif
 
void timer0SetPrescaler(u08 prescale)
{
// set prescaler on timer 0
outb(TCCR0, (inb(TCCR0) & ~TIMER_PRESCALE_MASK) | prescale);
}
 
void timer1SetPrescaler(u08 prescale)
{
// set prescaler on timer 1
outb(TCCR1B, (inb(TCCR1B) & ~TIMER_PRESCALE_MASK) | prescale);
}
 
#ifdef TCNT2 // support timer2 only if it exists
void timer2SetPrescaler(u08 prescale)
{
// set prescaler on timer 2
outb(TCCR2, (inb(TCCR2) & ~TIMER_PRESCALE_MASK) | prescale);
}
#endif
 
u16 timer0GetPrescaler(void)
{
// get the current prescaler setting
return (pgm_read_word(TimerPrescaleFactor+(inb(TCCR0) & TIMER_PRESCALE_MASK)));
}
 
u16 timer1GetPrescaler(void)
{
// get the current prescaler setting
return (pgm_read_word(TimerPrescaleFactor+(inb(TCCR1B) & TIMER_PRESCALE_MASK)));
}
 
#ifdef TCNT2 // support timer2 only if it exists
u16 timer2GetPrescaler(void)
{
//TODO: can we assume for all 3-timer AVR processors,
// that timer2 is the RTC timer?
 
// get the current prescaler setting
return (pgm_read_word(TimerRTCPrescaleFactor+(inb(TCCR2) & TIMER_PRESCALE_MASK)));
}
#endif
 
void timerAttach(u08 interruptNum, void (*userFunc)(void) )
{
// make sure the interrupt number is within bounds
if(interruptNum < TIMER_NUM_INTERRUPTS)
{
// set the interrupt function to run
// the supplied user's function
TimerIntFunc[interruptNum] = userFunc;
}
}
 
void timerDetach(u08 interruptNum)
{
// make sure the interrupt number is within bounds
if(interruptNum < TIMER_NUM_INTERRUPTS)
{
// set the interrupt function to run nothing
TimerIntFunc[interruptNum] = 0;
}
}
/*
u32 timerMsToTics(u16 ms)
{
// calculate the prescaler division rate
u16 prescaleDiv = 1<<(pgm_read_byte(TimerPrescaleFactor+inb(TCCR0)));
// calculate the number of timer tics in x milliseconds
return (ms*(F_CPU/(prescaleDiv*256)))/1000;
}
 
u16 timerTicsToMs(u32 tics)
{
// calculate the prescaler division rate
u16 prescaleDiv = 1<<(pgm_read_byte(TimerPrescaleFactor+inb(TCCR0)));
// calculate the number of milliseconds in x timer tics
return (tics*1000*(prescaleDiv*256))/F_CPU;
}
*/
void timerPause(unsigned short pause_ms)
{
// pauses for exactly <pause_ms> number of milliseconds
u08 timerThres;
u32 ticRateHz;
u32 pause;
 
// capture current pause timer value
timerThres = inb(TCNT0);
// reset pause timer overflow count
TimerPauseReg = 0;
// calculate delay for [pause_ms] milliseconds
// prescaler division = 1<<(pgm_read_byte(TimerPrescaleFactor+inb(TCCR0)))
ticRateHz = F_CPU/timer0GetPrescaler();
// precision management
// prevent overflow and precision underflow
// -could add more conditions to improve accuracy
if( ((ticRateHz < 429497) && (pause_ms <= 10000)) )
pause = (pause_ms*ticRateHz)/1000;
else
pause = pause_ms*(ticRateHz/1000);
 
// loop until time expires
while( ((TimerPauseReg<<8) | inb(TCNT0)) < (pause+timerThres) )
{
if( TimerPauseReg < (pause>>8));
{
// save power by idling the processor
set_sleep_mode(SLEEP_MODE_IDLE);
sleep_mode();
}
}
 
/* old inaccurate code, for reference
// calculate delay for [pause_ms] milliseconds
u16 prescaleDiv = 1<<(pgm_read_byte(TimerPrescaleFactor+inb(TCCR0)));
u32 pause = (pause_ms*(F_CPU/(prescaleDiv*256)))/1000;
TimerPauseReg = 0;
while(TimerPauseReg < pause);
 
*/
}
 
void timer0ClearOverflowCount(void)
{
// clear the timer overflow counter registers
Timer0Reg0 = 0; // initialize time registers
}
 
long timer0GetOverflowCount(void)
{
// return the current timer overflow count
// (this is since the last timer0ClearOverflowCount() command was called)
return Timer0Reg0;
}
 
#ifdef TCNT2 // support timer2 only if it exists
void timer2ClearOverflowCount(void)
{
// clear the timer overflow counter registers
Timer2Reg0 = 0; // initialize time registers
}
 
long timer2GetOverflowCount(void)
{
// return the current timer overflow count
// (this is since the last timer2ClearOverflowCount() command was called)
return Timer2Reg0;
}
#endif
 
void timer1PWMInit(u08 bitRes)
{
// configures timer1 for use with PWM output
// on OC1A and OC1B pins
 
// enable timer1 as 8,9,10bit PWM
if(bitRes == 9)
{ // 9bit mode
sbi(TCCR1A,PWM11);
cbi(TCCR1A,PWM10);
}
else if( bitRes == 10 )
{ // 10bit mode
sbi(TCCR1A,PWM11);
sbi(TCCR1A,PWM10);
}
else
{ // default 8bit mode
cbi(TCCR1A,PWM11);
sbi(TCCR1A,PWM10);
}
 
// clear output compare value A
outb(OCR1AH, 0);
outb(OCR1AL, 0);
// clear output compare value B
outb(OCR1BH, 0);
outb(OCR1BL, 0);
}
 
#ifdef WGM10
// include support for arbitrary top-count PWM
// on new AVR processors that support it
void timer1PWMInitICR(u16 topcount)
{
// set PWM mode with ICR top-count
cbi(TCCR1A,WGM10);
sbi(TCCR1A,WGM11);
sbi(TCCR1B,WGM12);
sbi(TCCR1B,WGM13);
// set top count value
ICR1 = topcount;
// clear output compare value A
OCR1A = 0;
// clear output compare value B
OCR1B = 0;
 
}
#endif
 
void timer1PWMOff(void)
{
// turn off timer1 PWM mode
cbi(TCCR1A,PWM11);
cbi(TCCR1A,PWM10);
// set PWM1A/B (OutputCompare action) to none
timer1PWMAOff();
timer1PWMBOff();
}
 
void timer1PWMAOn(void)
{
// turn on channel A (OC1A) PWM output
// set OC1A as non-inverted PWM
sbi(TCCR1A,COM1A1);
cbi(TCCR1A,COM1A0);
}
 
void timer1PWMBOn(void)
{
// turn on channel B (OC1B) PWM output
// set OC1B as non-inverted PWM
sbi(TCCR1A,COM1B1);
cbi(TCCR1A,COM1B0);
}
 
void timer1PWMAOff(void)
{
// turn off channel A (OC1A) PWM output
// set OC1A (OutputCompare action) to none
cbi(TCCR1A,COM1A1);
cbi(TCCR1A,COM1A0);
}
 
void timer1PWMBOff(void)
{
// turn off channel B (OC1B) PWM output
// set OC1B (OutputCompare action) to none
cbi(TCCR1A,COM1B1);
cbi(TCCR1A,COM1B0);
}
 
void timer1PWMASet(u16 pwmDuty)
{
// set PWM (output compare) duty for channel A
// this PWM output is generated on OC1A pin
// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM
// pwmDuty should be in the range 0-511 for 9bit PWM
// pwmDuty should be in the range 0-1023 for 10bit PWM
//outp( (pwmDuty>>8), OCR1AH); // set the high 8bits of OCR1A
//outp( (pwmDuty&0x00FF), OCR1AL); // set the low 8bits of OCR1A
OCR1A = pwmDuty;
}
 
void timer1PWMBSet(u16 pwmDuty)
{
// set PWM (output compare) duty for channel B
// this PWM output is generated on OC1B pin
// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM
// pwmDuty should be in the range 0-511 for 9bit PWM
// pwmDuty should be in the range 0-1023 for 10bit PWM
//outp( (pwmDuty>>8), OCR1BH); // set the high 8bits of OCR1B
//outp( (pwmDuty&0x00FF), OCR1BL); // set the low 8bits of OCR1B
OCR1B = pwmDuty;
}
 
//! Interrupt handler for tcnt0 overflow interrupt
TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW0)
{
Timer0Reg0++; // increment low-order counter
 
// increment pause counter
TimerPauseReg++;
 
// if a user function is defined, execute it too
if(TimerIntFunc[TIMER0OVERFLOW_INT])
TimerIntFunc[TIMER0OVERFLOW_INT]();
}
 
//! Interrupt handler for tcnt1 overflow interrupt
TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW1)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER1OVERFLOW_INT])
TimerIntFunc[TIMER1OVERFLOW_INT]();
}
 
#ifdef TCNT2 // support timer2 only if it exists
//! Interrupt handler for tcnt2 overflow interrupt
TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW2)
{
Timer2Reg0++; // increment low-order counter
 
// if a user function is defined, execute it
if(TimerIntFunc[TIMER2OVERFLOW_INT])
TimerIntFunc[TIMER2OVERFLOW_INT]();
}
#endif
 
#ifdef OCR0
// include support for Output Compare 0 for new AVR processors that support it
//! Interrupt handler for OutputCompare0 match (OC0) interrupt
TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE0)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER0OUTCOMPARE_INT])
TimerIntFunc[TIMER0OUTCOMPARE_INT]();
}
#endif
 
//! Interrupt handler for CutputCompare1A match (OC1A) interrupt
TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE1A)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER1OUTCOMPAREA_INT])
TimerIntFunc[TIMER1OUTCOMPAREA_INT]();
}
 
//! Interrupt handler for OutputCompare1B match (OC1B) interrupt
TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE1B)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER1OUTCOMPAREB_INT])
TimerIntFunc[TIMER1OUTCOMPAREB_INT]();
}
 
//! Interrupt handler for InputCapture1 (IC1) interrupt
TIMER_INTERRUPT_HANDLER(SIG_INPUT_CAPTURE1)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER1INPUTCAPTURE_INT])
TimerIntFunc[TIMER1INPUTCAPTURE_INT]();
}
 
//! Interrupt handler for OutputCompare2 match (OC2) interrupt
TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE2)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER2OUTCOMPARE_INT])
TimerIntFunc[TIMER2OUTCOMPARE_INT]();
}
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/C/avr/akcelerometr/timer.h
0,0 → 1,314
/*! \file timer.h \brief System Timer function library. */
//*****************************************************************************
//
// File Name : 'timer.h'
// Title : System Timer function library
// Author : Pascal Stang - Copyright (C) 2000-2002
// Created : 11/22/2000
// Revised : 02/10/2003
// Version : 1.1
// Target MCU : Atmel AVR Series
// Editor Tabs : 4
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
/// \ingroup driver_avr
/// \defgroup timer Timer Function Library (timer.c)
/// \code #include "timer.h" \endcode
/// \par Overview
/// This library provides functions for use with the timers internal
/// to the AVR processors. Functions include initialization, set prescaler,
/// calibrated pause function (in milliseconds), attaching and detaching of
/// user functions to interrupts, overflow counters, PWM. Arbitrary
/// frequency generation has been moved to the Pulse Library.
///
/// \par About Timers
/// The Atmel AVR-series processors each contain at least one
/// hardware timer/counter. Many of the processors contain 2 or 3
/// timers. Generally speaking, a timer is a hardware counter inside
/// the processor which counts at a rate related to the main CPU clock
/// frequency. Because the counter value increasing (counting up) at
/// a precise rate, we can use it as a timer to create or measure
/// precise delays, schedule events, or generate signals of a certain
/// frequency or pulse-width.
/// \par
/// As an example, the ATmega163 processor has 3 timer/counters.
/// Timer0, Timer1, and Timer2 are 8, 16, and 8 bits wide respectively.
/// This means that they overflow, or roll over back to zero, at a
/// count value of 256 for 8bits or 65536 for 16bits. A prescaler is
/// avaiable for each timer, and the prescaler allows you to pre-divide
/// the main CPU clock rate down to a slower speed before feeding it to
/// the counting input of a timer. For example, if the CPU clock
/// frequency is 3.69MHz, and Timer0's prescaler is set to divide-by-8,
/// then Timer0 will "tic" at 3690000/8 = 461250Hz. Because Timer0 is
/// an 8bit timer, it will count to 256 in just 256/461250Hz = 0.555ms.
/// In fact, when it hits 255, it will overflow and start again at
/// zero. In this case, Timer0 will overflow 461250/256 = 1801.76
/// times per second.
/// \par
/// Timer0 can be used a number of ways simultaneously. First, the
/// value of the timer can be read by accessing the CPU register \c TCNT0.
/// We could, for example, figure out how long it takes to execute a
/// C command by recording the value of \c TCNT0 before and after
/// execution, then subtract (after-before) = time elapsed. Or we can
/// enable the overflow interrupt which goes off every time T0
/// overflows and count out longer delays (multiple overflows), or
/// execute a special periodic function at every overflow.
/// \par
/// The other timers (Timer1 and Timer2) offer all the abilities of
/// Timer0 and many more features. Both T1 and T2 can operate as
/// general-purpose timers, but T1 has special hardware allowing it to
/// generate PWM signals, while T2 is specially designed to help count
/// out real time (like hours, minutes, seconds). See the
/// Timer/Counter section of the processor datasheet for more info.
///
//*****************************************************************************
//@{
 
#ifndef TIMER_H
#define TIMER_H
 
#include "global.h"
 
// constants/macros/typdefs
 
// processor compatibility fixes
#ifdef __AVR_ATmega323__
// redefinition for the Mega323
#define CTC1 CTC10
#endif
#ifndef PWM10
// mega128 PWM bits
#define PWM10 WGM10
#define PWM11 WGM11
#endif
 
 
// Timer/clock prescaler values and timer overflow rates
// tics = rate at which the timer counts up
// 8bitoverflow = rate at which the timer overflows 8bits (or reaches 256)
// 16bit [overflow] = rate at which the timer overflows 16bits (65536)
//
// overflows can be used to generate periodic interrupts
//
// for 8MHz crystal
// 0 = STOP (Timer not counting)
// 1 = CLOCK tics= 8MHz 8bitoverflow= 31250Hz 16bit= 122.070Hz
// 2 = CLOCK/8 tics= 1MHz 8bitoverflow= 3906.25Hz 16bit= 15.259Hz
// 3 = CLOCK/64 tics= 125kHz 8bitoverflow= 488.28Hz 16bit= 1.907Hz
// 4 = CLOCK/256 tics= 31250Hz 8bitoverflow= 122.07Hz 16bit= 0.477Hz
// 5 = CLOCK/1024 tics= 7812.5Hz 8bitoverflow= 30.52Hz 16bit= 0.119Hz
// 6 = External Clock on T(x) pin (falling edge)
// 7 = External Clock on T(x) pin (rising edge)
 
// for 4MHz crystal
// 0 = STOP (Timer not counting)
// 1 = CLOCK tics= 4MHz 8bitoverflow= 15625Hz 16bit= 61.035Hz
// 2 = CLOCK/8 tics= 500kHz 8bitoverflow= 1953.125Hz 16bit= 7.629Hz
// 3 = CLOCK/64 tics= 62500Hz 8bitoverflow= 244.141Hz 16bit= 0.954Hz
// 4 = CLOCK/256 tics= 15625Hz 8bitoverflow= 61.035Hz 16bit= 0.238Hz
// 5 = CLOCK/1024 tics= 3906.25Hz 8bitoverflow= 15.259Hz 16bit= 0.060Hz
// 6 = External Clock on T(x) pin (falling edge)
// 7 = External Clock on T(x) pin (rising edge)
 
// for 3.69MHz crystal
// 0 = STOP (Timer not counting)
// 1 = CLOCK tics= 3.69MHz 8bitoverflow= 14414Hz 16bit= 56.304Hz
// 2 = CLOCK/8 tics= 461250Hz 8bitoverflow= 1801.758Hz 16bit= 7.038Hz
// 3 = CLOCK/64 tics= 57625.25Hz 8bitoverflow= 225.220Hz 16bit= 0.880Hz
// 4 = CLOCK/256 tics= 14414.063Hz 8bitoverflow= 56.305Hz 16bit= 0.220Hz
// 5 = CLOCK/1024 tics= 3603.516Hz 8bitoverflow= 14.076Hz 16bit= 0.055Hz
// 6 = External Clock on T(x) pin (falling edge)
// 7 = External Clock on T(x) pin (rising edge)
 
// for 32.768KHz crystal on timer 2 (use for real-time clock)
// 0 = STOP
// 1 = CLOCK tics= 32.768kHz 8bitoverflow= 128Hz
// 2 = CLOCK/8 tics= 4096kHz 8bitoverflow= 16Hz
// 3 = CLOCK/32 tics= 1024kHz 8bitoverflow= 4Hz
// 4 = CLOCK/64 tics= 512Hz 8bitoverflow= 2Hz
// 5 = CLOCK/128 tics= 256Hz 8bitoverflow= 1Hz
// 6 = CLOCK/256 tics= 128Hz 8bitoverflow= 0.5Hz
// 7 = CLOCK/1024 tics= 32Hz 8bitoverflow= 0.125Hz
 
#define TIMER_CLK_STOP 0x00 ///< Timer Stopped
#define TIMER_CLK_DIV1 0x01 ///< Timer clocked at F_CPU
#define TIMER_CLK_DIV8 0x02 ///< Timer clocked at F_CPU/8
#define TIMER_CLK_DIV64 0x03 ///< Timer clocked at F_CPU/64
#define TIMER_CLK_DIV256 0x04 ///< Timer clocked at F_CPU/256
#define TIMER_CLK_DIV1024 0x05 ///< Timer clocked at F_CPU/1024
#define TIMER_CLK_T_FALL 0x06 ///< Timer clocked at T falling edge
#define TIMER_CLK_T_RISE 0x07 ///< Timer clocked at T rising edge
#define TIMER_PRESCALE_MASK 0x07 ///< Timer Prescaler Bit-Mask
 
#define TIMERRTC_CLK_STOP 0x00 ///< RTC Timer Stopped
#define TIMERRTC_CLK_DIV1 0x01 ///< RTC Timer clocked at F_CPU
#define TIMERRTC_CLK_DIV8 0x02 ///< RTC Timer clocked at F_CPU/8
#define TIMERRTC_CLK_DIV32 0x03 ///< RTC Timer clocked at F_CPU/32
#define TIMERRTC_CLK_DIV64 0x04 ///< RTC Timer clocked at F_CPU/64
#define TIMERRTC_CLK_DIV128 0x05 ///< RTC Timer clocked at F_CPU/128
#define TIMERRTC_CLK_DIV256 0x06 ///< RTC Timer clocked at F_CPU/256
#define TIMERRTC_CLK_DIV1024 0x07 ///< RTC Timer clocked at F_CPU/1024
#define TIMERRTC_PRESCALE_MASK 0x07 ///< RTC Timer Prescaler Bit-Mask
 
// default prescale settings for the timers
// these settings are applied when you call
// timerInit or any of the timer<x>Init
#define TIMER0PRESCALE TIMER_CLK_DIV8 ///< timer 0 prescaler default
#define TIMER1PRESCALE TIMER_CLK_DIV64 ///< timer 1 prescaler default
#define TIMER2PRESCALE TIMERRTC_CLK_DIV64 ///< timer 2 prescaler default
 
// interrupt macros for attaching user functions to timer interrupts
// use these with timerAttach( intNum, function )
#define TIMER0OVERFLOW_INT 0
#define TIMER1OVERFLOW_INT 1
#define TIMER1OUTCOMPAREA_INT 2
#define TIMER1OUTCOMPAREB_INT 3
#define TIMER1INPUTCAPTURE_INT 4
#define TIMER2OVERFLOW_INT 5
#define TIMER2OUTCOMPARE_INT 6
#ifdef OCR0 // for processors that support output compare on Timer0
#define TIMER0OUTCOMPARE_INT 7
#define TIMER_NUM_INTERRUPTS 8
#else
#define TIMER_NUM_INTERRUPTS 7
#endif
 
// default type of interrupt handler to use for timers
// *do not change unless you know what you're doing
// Value may be SIGNAL or INTERRUPT
#ifndef TIMER_INTERRUPT_HANDLER
#define TIMER_INTERRUPT_HANDLER SIGNAL
#endif
 
// functions
#define delay delay_us
#define delay_ms timerPause
void delay_us(unsigned short time_us);
 
//! initializes timing system (all timers)
// runs all timer init functions
// sets all timers to default prescale values #defined in systimer.c
void timerInit(void);
 
// default initialization routines for each timer
void timer0Init(void); ///< initialize timer0
void timer1Init(void); ///< initialize timer1
#ifdef TCNT2 // support timer2 only if it exists
void timer2Init(void); ///< initialize timer2
#endif
 
// Clock prescaler set/get commands for each timer/counter
// For setting the prescaler, you should use one of the #defines
// above like TIMER_CLK_DIVx, where [x] is the division rate
// you want.
// When getting the current prescaler setting, the return value
// will be the [x] division value currently set.
void timer0SetPrescaler(u08 prescale); ///< set timer0 prescaler
u16 timer0GetPrescaler(void); ///< get timer0 prescaler
void timer1SetPrescaler(u08 prescale); ///< set timer1 prescaler
u16 timer1GetPrescaler(void); ///< get timer0 prescaler
#ifdef TCNT2 // support timer2 only if it exists
void timer2SetPrescaler(u08 prescale); ///< set timer2 prescaler
u16 timer2GetPrescaler(void); ///< get timer2 prescaler
#endif
 
 
// TimerAttach and Detach commands
// These functions allow the attachment (or detachment) of any user function
// to a timer interrupt. "Attaching" one of your own functions to a timer
// interrupt means that it will be called whenever that interrupt happens.
// Using attach is better than rewriting the actual INTERRUPT() function
// because your code will still work and be compatible if the timer library
// is updated. Also, using Attach allows your code and any predefined timer
// code to work together and at the same time. (ie. "attaching" your own
// function to the timer0 overflow doesn't prevent timerPause from working,
// but rather allows you to share the interrupt.)
//
// timerAttach(TIMER1OVERFLOW_INT, myOverflowFunction);
// timerDetach(TIMER1OVERFLOW_INT)
//
// timerAttach causes the myOverflowFunction() to be attached, and therefore
// execute, whenever an overflow on timer1 occurs. timerDetach removes the
// association and executes no user function when the interrupt occurs.
// myOverflowFunction must be defined with no return value and no arguments:
//
// void myOverflowFunction(void) { ... }
 
//! Attach a user function to a timer interrupt
void timerAttach(u08 interruptNum, void (*userFunc)(void) );
//! Detach a user function from a timer interrupt
void timerDetach(u08 interruptNum);
 
 
// timing commands
/// A timer-based delay/pause function
/// @param pause_ms Number of integer milliseconds to wait.
void timerPause(unsigned short pause_ms);
 
// overflow counters
void timer0ClearOverflowCount(void); ///< Clear timer0's overflow counter.
long timer0GetOverflowCount(void); ///< read timer0's overflow counter
#ifdef TCNT2 // support timer2 only if it exists
void timer2ClearOverflowCount(void); ///< clear timer2's overflow counter
long timer2GetOverflowCount(void); ///< read timer0's overflow counter
#endif
 
/// @defgroup timerpwm Timer PWM Commands
/// @ingroup timer
/// These commands control PWM functionality on timer1
// PWM initialization and set commands for timer1
// timer1PWMInit()
// configures the timer1 hardware for PWM mode on pins OC1A and OC1B.
// bitRes should be 8,9,or 10 for 8,9,or 10bit PWM resolution
//
// timer1PWMOff()
// turns off all timer1 PWM output and set timer mode to normal state
//
// timer1PWMAOn() and timer1PWMBOn()
// turn on output of PWM signals to OC1A or OC1B pins
// NOTE: Until you define the OC1A and OC1B pins as outputs, and run
// this "on" command, no PWM output will be output
//
// timer1PWMAOff() and timer1PWMBOff()
// turn off output of PWM signals to OC1A or OC1B pins
//
// timer1PWMASet() and timer1PWMBSet()
// sets the PWM duty cycle for each channel
// NOTE: <pwmDuty> should be in the range 0-255 for 8bit PWM
// <pwmDuty> should be in the range 0-511 for 9bit PWM
// <pwmDuty> should be in the range 0-1023 for 10bit PWM
// NOTE: the PWM frequency can be controlled in increments by setting the
// prescaler for timer1
//@{
 
 
/// Enter standard PWM Mode on timer1.
/// \param bitRes indicates the period/resolution to use for PWM output in timer bits.
/// Must be either 8, 9, or 10 bits corresponding to PWM periods of 256, 512, or 1024 timer tics.
void timer1PWMInit(u08 bitRes);
 
/// Enter PWM Mode on timer1 with a specific top-count value.
/// \param topcount indicates the desired PWM period in timer tics.
/// Can be a number between 1 and 65535 (16-bit).
void timer1PWMInitICR(u16 topcount);
 
/// Turn off all timer1 PWM output and set timer mode to normal.
void timer1PWMOff(void);
 
/// Turn on/off Timer1 PWM outputs.
void timer1PWMAOn(void); ///< Turn on timer1 Channel A (OC1A) PWM output.
void timer1PWMBOn(void); ///< Turn on timer1 Channel B (OC1B) PWM output.
void timer1PWMAOff(void); ///< turn off timer1 Channel A (OC1A) PWM output
void timer1PWMBOff(void); ///< turn off timer1 Channel B (OC1B) PWM output
 
void timer1PWMASet(u16 pwmDuty); ///< set duty of timer1 Channel A (OC1A) PWM output
void timer1PWMBSet(u16 pwmDuty); ///< set duty of timer1 Channel B (OC1B) PWM output
 
//@}
//@}
 
// Pulse generation commands have been moved to the pulse.c library
 
#endif
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/C/avr/akcelerometr/uart.c
0,0 → 1,283
/*! \file uart.c \brief UART driver with buffer support. */
// *****************************************************************************
//
// File Name : 'uart.c'
// Title : UART driver with buffer support
// Author : Pascal Stang - Copyright (C) 2000-2002
// Created : 11/22/2000
// Revised : 06/09/2003
// Version : 1.3
// Target MCU : ATMEL AVR Series
// Editor Tabs : 4
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
// *****************************************************************************
 
#include <avr/io.h>
#include <avr/interrupt.h>
 
#include "buffer.h"
#include "uart.h"
 
// UART global variables
// flag variables
volatile u08 uartReadyTx; ///< uartReadyTx flag
volatile u08 uartBufferedTx; ///< uartBufferedTx flag
// receive and transmit buffers
cBuffer uartRxBuffer; ///< uart receive buffer
cBuffer uartTxBuffer; ///< uart transmit buffer
unsigned short uartRxOverflow; ///< receive overflow counter
 
#ifndef UART_BUFFERS_EXTERNAL_RAM
// using internal ram,
// automatically allocate space in ram for each buffer
static char uartRxData[UART_RX_BUFFER_SIZE];
static char uartTxData[UART_TX_BUFFER_SIZE];
#endif
 
typedef void (*voidFuncPtru08)(unsigned char);
volatile static voidFuncPtru08 UartRxFunc;
 
// enable and initialize the uart
void uartInit(void)
{
// initialize the buffers
uartInitBuffers();
// initialize user receive handler
UartRxFunc = 0;
 
// enable RxD/TxD and interrupts
outb(UCR, BV(RXCIE)|BV(TXCIE)|BV(RXEN)|BV(TXEN));
 
// set default baud rate
uartSetBaudRate(UART_DEFAULT_BAUD_RATE);
// initialize states
uartReadyTx = TRUE;
uartBufferedTx = FALSE;
// clear overflow count
uartRxOverflow = 0;
// enable interrupts
sei();
}
 
// create and initialize the uart transmit and receive buffers
void uartInitBuffers(void)
{
#ifndef UART_BUFFERS_EXTERNAL_RAM
// initialize the UART receive buffer
bufferInit(&uartRxBuffer, uartRxData, UART_RX_BUFFER_SIZE);
// initialize the UART transmit buffer
bufferInit(&uartTxBuffer, uartTxData, UART_TX_BUFFER_SIZE);
#else
// initialize the UART receive buffer
bufferInit(&uartRxBuffer, (u08*) UART_RX_BUFFER_ADDR, UART_RX_BUFFER_SIZE);
// initialize the UART transmit buffer
bufferInit(&uartTxBuffer, (u08*) UART_TX_BUFFER_ADDR, UART_TX_BUFFER_SIZE);
#endif
}
 
// redirects received data to a user function
void uartSetRxHandler(void (*rx_func)(unsigned char c))
{
// set the receive interrupt to run the supplied user function
UartRxFunc = rx_func;
}
 
// set the uart baud rate
void uartSetBaudRate(u32 baudrate)
{
// calculate division factor for requested baud rate, and set it
u16 bauddiv = ((F_CPU+(baudrate*8L))/(baudrate*16L)-1);
outb(UBRRL, bauddiv);
#ifdef UBRRH
outb(UBRRH, bauddiv>>8);
#endif
}
 
// returns the receive buffer structure
cBuffer* uartGetRxBuffer(void)
{
// return rx buffer pointer
return &uartRxBuffer;
}
 
// returns the transmit buffer structure
cBuffer* uartGetTxBuffer(void)
{
// return tx buffer pointer
return &uartTxBuffer;
}
 
// transmits a byte over the uart
void uartSendByte(u08 txData)
{
// wait for the transmitter to be ready
while(!uartReadyTx);
// send byte
outb(UDR, txData);
// set ready state to FALSE
uartReadyTx = FALSE;
}
 
// gets a single byte from the uart receive buffer (getchar-style)
int uartGetByte(void)
{
u08 c;
if(uartReceiveByte(&c))
return c;
else
return -1;
}
 
// gets a byte (if available) from the uart receive buffer
u08 uartReceiveByte(u08* rxData)
{
// make sure we have a receive buffer
if(uartRxBuffer.size)
{
// make sure we have data
if(uartRxBuffer.datalength)
{
// get byte from beginning of buffer
*rxData = bufferGetFromFront(&uartRxBuffer);
return TRUE;
}
else
{
// no data
return FALSE;
}
}
else
{
// no buffer
return FALSE;
}
}
 
// flush all data out of the receive buffer
void uartFlushReceiveBuffer(void)
{
// flush all data from receive buffer
//bufferFlush(&uartRxBuffer);
// same effect as above
uartRxBuffer.datalength = 0;
}
 
// return true if uart receive buffer is empty
u08 uartReceiveBufferIsEmpty(void)
{
if(uartRxBuffer.datalength == 0)
{
return TRUE;
}
else
{
return FALSE;
}
}
 
// add byte to end of uart Tx buffer
u08 uartAddToTxBuffer(u08 data)
{
// add data byte to the end of the tx buffer
return bufferAddToEnd(&uartTxBuffer, data);
}
 
// start transmission of the current uart Tx buffer contents
void uartSendTxBuffer(void)
{
// turn on buffered transmit
uartBufferedTx = TRUE;
// send the first byte to get things going by interrupts
uartSendByte(bufferGetFromFront(&uartTxBuffer));
}
/*
// transmit nBytes from buffer out the uart
u08 uartSendBuffer(char *buffer, u16 nBytes)
{
register u08 first;
register u16 i;
 
// check if there's space (and that we have any bytes to send at all)
if((uartTxBuffer.datalength + nBytes < uartTxBuffer.size) && nBytes)
{
// grab first character
first = *buffer++;
// copy user buffer to uart transmit buffer
for(i = 0; i < nBytes-1; i++)
{
// put data bytes at end of buffer
bufferAddToEnd(&uartTxBuffer, *buffer++);
}
 
// send the first byte to get things going by interrupts
uartBufferedTx = TRUE;
uartSendByte(first);
// return success
return TRUE;
}
else
{
// return failure
return FALSE;
}
}
*/
// UART Transmit Complete Interrupt Handler
UART_INTERRUPT_HANDLER(SIG_UART_TRANS)
{
// check if buffered tx is enabled
if(uartBufferedTx)
{
// check if there's data left in the buffer
if(uartTxBuffer.datalength)
{
// send byte from top of buffer
outb(UDR, bufferGetFromFront(&uartTxBuffer));
}
else
{
// no data left
uartBufferedTx = FALSE;
// return to ready state
uartReadyTx = TRUE;
}
}
else
{
// we're using single-byte tx mode
// indicate transmit complete, back to ready
uartReadyTx = TRUE;
}
}
 
// UART Receive Complete Interrupt Handler
UART_INTERRUPT_HANDLER(SIG_UART_RECV)
{
u08 c;
// get received char
c = inb(UDR);
 
// if there's a user function to handle this receive event
if(UartRxFunc)
{
// call it and pass the received data
UartRxFunc(c);
}
else
{
// otherwise do default processing
// put received char in buffer
// check if there's space
if( !bufferAddToEnd(&uartRxBuffer, c) )
{
// no space in buffer
// count overflow
uartRxOverflow++;
}
}
}
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/C/avr/akcelerometr/uart.h
0,0 → 1,232
/*! \file uart.h \brief UART driver with buffer support. */
//*****************************************************************************
//
// File Name : 'uart.h'
// Title : UART driver with buffer support
// Author : Pascal Stang - Copyright (C) 2000-2002
// Created : 11/22/2000
// Revised : 02/01/2004
// Version : 1.3
// Target MCU : ATMEL AVR Series
// Editor Tabs : 4
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
/// \ingroup driver_avr
/// \defgroup uart UART Driver/Function Library (uart.c)
/// \code #include "uart.h" \endcode
/// \par Overview
/// This library provides both buffered and unbuffered transmit and receive
/// functions for the AVR processor UART.� Buffered access means that the
/// UART can transmit and receive data in the "background", while your code
/// continues executing.� Also included are functions to initialize the
/// UART, set the baud rate, flush the buffers, and check buffer status.
///
/// \note For full text output functionality, you may wish to use the rprintf
/// functions along with this driver.
///
/// \par About UART operations
/// Most Atmel AVR-series processors contain one or more hardware UARTs
/// (aka, serial ports). UART serial ports can communicate with other
/// serial ports of the same type, like those used on PCs. In general,
/// UARTs are used to communicate with devices that are RS-232 compatible
/// (RS-232 is a certain kind of serial port).
/// \par
/// By far, the most common use for serial communications on AVR processors
/// is for sending information and data to a PC running a terminal program.
/// Here is an exmaple:
/// \code
/// uartInit(); // initialize UART (serial port)
/// uartSetBaudRate(9600); // set UART speed to 9600 baud
/// rprintfInit(uartSendByte); // configure rprintf to use UART for output
/// rprintf("Hello World\r\n"); // send "hello world" message via serial port
/// \endcode
///
/// \warning The CPU frequency (F_CPU) must be set correctly in \c global.h
/// for the UART library to calculate correct baud rates. Furthermore,
/// certain CPU frequencies will not produce exact baud rates due to
/// integer frequency division round-off. See your AVR processor's
/// datasheet for full details.
//
//*****************************************************************************
//@{
 
#ifndef UART_H
#define UART_H
 
#include "global.h"
#include "buffer.h"
 
//! Default uart baud rate.
/// This is the default speed after a uartInit() command,
/// and can be changed by using uartSetBaudRate().
#define UART_DEFAULT_BAUD_RATE 9600
 
// buffer memory allocation defines
// buffer sizes
#ifndef UART_TX_BUFFER_SIZE
//! Number of bytes for uart transmit buffer.
/// Do not change this value in uart.h, but rather override
/// it with the desired value defined in your project's global.h
#define UART_TX_BUFFER_SIZE 0x0040
#endif
#ifndef UART_RX_BUFFER_SIZE
//! Number of bytes for uart receive buffer.
/// Do not change this value in uart.h, but rather override
/// it with the desired value defined in your project's global.h
#define UART_RX_BUFFER_SIZE 0x0040
#endif
 
// define this key if you wish to use
// external RAM for the UART buffers
//#define UART_BUFFER_EXTERNAL_RAM
#ifdef UART_BUFFER_EXTERNAL_RAM
// absolute address of uart buffers
#define UART_TX_BUFFER_ADDR 0x1000
#define UART_RX_BUFFER_ADDR 0x1100
#endif
 
//! Type of interrupt handler to use for uart interrupts.
/// Value may be SIGNAL or INTERRUPT.
/// \warning Do not change unless you know what you're doing.
#ifndef UART_INTERRUPT_HANDLER
#define UART_INTERRUPT_HANDLER SIGNAL
#endif
 
// compatibility with most newer processors
#ifdef UCSRB
#define UCR UCSRB
#endif
// compatibility with old Mega processors
#if defined(UBRR) && !defined(UBRRL)
#define UBRRL UBRR
#endif
// compatibility with megaXX8 processors
#if defined(__AVR_ATmega88__) || \
defined(__AVR_ATmega168__) || \
defined(__AVR_ATmega644__)
#define UDR UDR0
#define UCR UCSR0B
#define RXCIE RXCIE0
#define TXCIE TXCIE0
#define RXC RXC0
#define TXC TXC0
#define RXEN RXEN0
#define TXEN TXEN0
#define UBRRL UBRR0L
#define UBRRH UBRR0H
#define SIG_UART_TRANS SIG_USART_TRANS
#define SIG_UART_RECV SIG_USART_RECV
#define SIG_UART_DATA SIG_USART_DATA
#endif
// compatibility with mega169 processors
#if defined(__AVR_ATmega169__)
#define SIG_UART_TRANS SIG_USART_TRANS
#define SIG_UART_RECV SIG_USART_RECV
#define SIG_UART_DATA SIG_USART_DATA
#endif
// compatibility with dual-uart processors
// (if you need to use both uarts, please use the uart2 library)
#if defined(__AVR_ATmega161__)
#define UDR UDR0
#define UCR UCSR0B
#define UBRRL UBRR0
#define SIG_UART_TRANS SIG_UART0_TRANS
#define SIG_UART_RECV SIG_UART0_RECV
#define SIG_UART_DATA SIG_UART0_DATA
#endif
#if defined(__AVR_ATmega128__)
#ifdef UART_USE_UART1
#define UDR UDR1
#define UCR UCSR1B
#define UBRRL UBRR1L
#define UBRRH UBRR1H
#define SIG_UART_TRANS SIG_UART1_TRANS
#define SIG_UART_RECV SIG_UART1_RECV
#define SIG_UART_DATA SIG_UART1_DATA
#else
#define UDR UDR0
#define UCR UCSR0B
#define UBRRL UBRR0L
#define UBRRH UBRR0H
#define SIG_UART_TRANS SIG_UART0_TRANS
#define SIG_UART_RECV SIG_UART0_RECV
#define SIG_UART_DATA SIG_UART0_DATA
#endif
#endif
 
// functions
 
//! Initializes uart.
/// \note After running this init function, the processor
/// I/O pins that used for uart communications (RXD, TXD)
/// are no long available for general purpose I/O.
void uartInit(void);
 
//! Initializes transmit and receive buffers.
/// Automatically called from uartInit()
void uartInitBuffers(void);
 
//! Redirects received data to a user function.
///
void uartSetRxHandler(void (*rx_func)(unsigned char c));
 
//! Sets the uart baud rate.
/// Argument should be in bits-per-second, like \c uartSetBaudRate(9600);
void uartSetBaudRate(u32 baudrate);
 
//! Returns pointer to the receive buffer structure.
///
cBuffer* uartGetRxBuffer(void);
 
//! Returns pointer to the transmit buffer structure.
///
cBuffer* uartGetTxBuffer(void);
 
//! Sends a single byte over the uart.
/// \note This function waits for the uart to be ready,
/// therefore, consecutive calls to uartSendByte() will
/// go only as fast as the data can be sent over the
/// serial port.
void uartSendByte(u08 data);
 
//! Gets a single byte from the uart receive buffer.
/// Returns the byte, or -1 if no byte is available (getchar-style).
int uartGetByte(void);
 
//! Gets a single byte from the uart receive buffer.
/// Function returns TRUE if data was available, FALSE if not.
/// Actual data is returned in variable pointed to by "data".
/// Example usage:
/// \code
/// char myReceivedByte;
/// uartReceiveByte( &myReceivedByte );
/// \endcode
u08 uartReceiveByte(u08* data);
 
//! Returns TRUE/FALSE if receive buffer is empty/not-empty.
///
u08 uartReceiveBufferIsEmpty(void);
 
//! Flushes (deletes) all data from receive buffer.
///
void uartFlushReceiveBuffer(void);
 
//! Add byte to end of uart Tx buffer.
/// Returns TRUE if successful, FALSE if failed (no room left in buffer).
u08 uartAddToTxBuffer(u08 data);
 
//! Begins transmission of the transmit buffer under interrupt control.
///
void uartSendTxBuffer(void);
 
//! Sends a block of data via the uart using interrupt control.
/// \param buffer pointer to data to be sent
/// \param nBytes length of data (number of bytes to sent)
u08 uartSendBuffer(char *buffer, u16 nBytes);
 
#endif
//@}
 
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property