Subversion Repositories MK3Mag

Compare Revisions

Regard whitespace Rev 18 → Rev 19

/branches/MK3Mag V0.14 Code Redesign Killagreg/uart.h
1,135 → 1,74
#ifndef _UART_H
#define _UART_H
#ifndef _UART_H_
#define _UART_H_
 
extern unsigned volatile char SIO_Sollwert;
extern unsigned volatile char UebertragungAbgeschlossen;
extern unsigned volatile char PC_DebugTimeout;
extern unsigned char MeineSlaveAdresse;
extern int Debug_Timer;
extern void UART_Init (void);
extern int uart_putchar (char c);
extern void boot_program_page (uint32_t page, uint8_t *buf);
extern void SendUart(void);
#include <inttypes.h>
 
void DatenUebertragung(void);
 
struct str_DebugOut
{
unsigned char Digital[2];
unsigned int Analog[32]; // Debugwerte
};
 
struct str_ExternData
{
signed int Winkel[2]; // in 0,1 degree
unsigned char UserParameter[2];
unsigned char CalState;
unsigned char Orientation;
};
extern struct str_ExternData ExternData;
#define NICK 0
#define ROLL 1
 
 
struct str_ExternControl
{
unsigned char Digital[2];
unsigned char RemoteTasten;
signed char Nick;
signed char Roll;
signed char Gier;
unsigned char Gas;
signed char Hight;
unsigned char Par1;
unsigned char Par2;
unsigned char Par3;
};
extern struct str_ExternControl ExternControl;
#define BAUD_RATE 57600
 
struct str_VersionInfo
 
extern uint16_t Debug_Timer;
 
 
void USART0_Init (void);
void USART0_EnableTXD(void);
void USART0_DisableTXD(void);
void USART0_TransmitTxData(void);
void USART0_ProcessRxData(void);
int16_t uart_putchar(int8_t c);
 
 
 
typedef struct
{
unsigned char Hauptversion;
unsigned char Nebenversion;
unsigned char PCKompatibel;
unsigned char Rserved[7];
};
extern struct str_VersionInfo VersionInfo;
uint8_t Digital[2];
uint16_t Analog[32]; // Debugvalues
} DebugOut_t;
 
extern DebugOut_t DebugOut;
 
extern struct str_DebugOut DebugOut;
extern struct str_DebugOut DebugOut;
//Die Baud_Rate der Seriellen Schnittstelle
//#define BAUD_RATE 9600 //Baud Rate für die Serielle Schnittstelle
//#define BAUD_RATE 14400 //Baud Rate für die Serielle Schnittstelle
//#define BAUD_RATE 28800 //Baud Rate für die Serielle Schnittstelle
 
#if X3D_SIO == 1
#define BAUD_RATE 38400 //Baud Rate für die Serielle Schnittstelle
#else
#define BAUD_RATE 57600 //Baud Rate für die Serielle Schnittstelle
#endif
 
//Anpassen der seriellen Schnittstellen Register wenn ein ATMega128 benutzt wird
#if defined (__AVR_ATmega128__)
# define USR UCSR0A
# define UCR UCSR0B
# define UDR UDR0
# define UBRR UBRR0L
# define EICR EICRB
#endif
typedef struct
{
int16_t Attitude[2]; // nock and roll angle in 0.1 deg
uint8_t UserParam[2];
uint8_t CalState;
uint8_t Orientation;
} ExternData_t;
 
#if defined (__AVR_ATmega8__)
# define USR UCSRA
# define UCR UCSRB
# define UBRR UBRRL
# define EICR EICRB
# define INT_VEC_RX SIG_UART_RECV
# define INT_VEC_TX SIG_UART_TRANS
#endif
extern ExternData_t ExternData;
 
#if defined (__AVR_ATmega168__)
# define USR UCSR0A
# define UCR UCSR0B
# define UDR UDR0
# define UBRR UBRR0L
# define EICR EICR0B
# define TXEN TXEN0
# define RXEN RXEN0
# define RXCIE RXCIE0
# define TXCIE TXCIE0
# define U2X U2X0
# define UCSRB UCSR0B
# define UDRE UDRE0
# define INT_VEC_RX SIG_USART_RECV
# define INT_VEC_TX SIG_USART_TRANS
#endif
 
typedef struct
{
uint8_t Digital[2];
uint8_t RemoteButtons;
int8_t Nick;
int8_t Roll;
int8_t Yaw;
uint8_t Gas;
int8_t Height;
uint8_t Par1;
uint8_t Par2;
uint8_t Par3;
} ExternControl_t;
 
#if defined (__AVR_ATmega32__)
# define USR UCSRA
# define UCR UCSRB
# define UBRR UBRRL
# define EICR EICRB
# define INT_VEC_RX SIG_UART_RECV
# define INT_VEC_TX SIG_UART_TRANS
#endif
extern ExternControl_t ExternControl;
 
#if defined (__AVR_ATmega644__)
# define USR UCSR0A
# define UCR UCSR0B
# define UDR UDR0
# define UBRR UBRR0L
# define EICR EICR0B
# define TXEN TXEN0
# define RXEN RXEN0
# define RXCIE RXCIE0
# define TXCIE TXCIE0
# define U2X U2X0
# define UCSRB UCSR0B
# define UDRE UDRE0
# define INT_VEC_RX SIG_USART_RECV
# define INT_VEC_TX SIG_USART_TRANS
#endif
 
typedef struct
{
uint8_t Major;
uint8_t Minor;
uint8_t PCCompatible;
uint8_t Reserved[7];
} VersionInfo_t;
 
#endif //_UART_H
extern VersionInfo_t VersionInfo;
 
 
#endif //_UART_H_