Subversion Repositories MK3Mag

Rev

Rev 18 | Rev 21 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18 Rev 19
Line 1... Line 1...
1
#ifndef _UART_H
1
#ifndef _UART_H_
2
 #define _UART_H
2
#define _UART_H_
-
 
3
 
-
 
4
#include <inttypes.h>
-
 
5
 
-
 
6
#define NICK 0
-
 
7
#define ROLL 1
-
 
8
 
-
 
9
 
-
 
10
#define BAUD_RATE 57600
-
 
11
 
-
 
12
 
-
 
13
extern uint16_t Debug_Timer;
-
 
14
 
-
 
15
 
-
 
16
void USART0_Init (void);
-
 
17
void USART0_EnableTXD(void);
-
 
18
void USART0_DisableTXD(void);
-
 
19
void USART0_TransmitTxData(void);
-
 
20
void USART0_ProcessRxData(void);
-
 
21
int16_t uart_putchar(int8_t c);
Line 3... Line -...
3
 
-
 
4
extern unsigned volatile char SIO_Sollwert;
-
 
5
extern unsigned volatile char UebertragungAbgeschlossen;
-
 
6
extern unsigned volatile char PC_DebugTimeout;
-
 
7
extern unsigned char MeineSlaveAdresse;
-
 
8
extern int Debug_Timer;
-
 
9
extern void UART_Init (void);
-
 
10
extern int uart_putchar (char c);
-
 
11
extern void boot_program_page (uint32_t page, uint8_t *buf);
-
 
Line 12... Line -...
12
extern void SendUart(void);
-
 
Line 13... Line 22...
13
 
22
 
14
void DatenUebertragung(void);
23
 
15
 
24
 
16
struct str_DebugOut
25
typedef struct
17
{
26
{
Line 18... Line 27...
18
 unsigned char Digital[2];
27
        uint8_t Digital[2];
-
 
28
        uint16_t Analog[32];    // Debugvalues
-
 
29
} DebugOut_t;
-
 
30
 
-
 
31
extern DebugOut_t DebugOut;
19
 unsigned int Analog[32];    // Debugwerte
32
 
20
};
33
 
21
 
34
 
22
struct str_ExternData
35
typedef struct
23
{
36
{
24
 signed int  Winkel[2]; // in 0,1 degree
-
 
25
 unsigned char UserParameter[2];
-
 
26
 unsigned char CalState;        
-
 
27
 unsigned char Orientation;
37
        int16_t Attitude[2];  // nock and roll angle in 0.1 deg
Line -... Line 38...
-
 
38
        uint8_t UserParam[2];
Line -... Line 39...
-
 
39
        uint8_t CalState;
28
};
40
        uint8_t Orientation;
29
extern struct str_ExternData  ExternData;
41
} ExternData_t;
30
#define NICK 0
42
 
31
#define ROLL 1
43
extern ExternData_t  ExternData;
32
 
44
 
33
 
45
 
34
struct str_ExternControl
46
typedef struct
35
{
47
{
36
 unsigned char Digital[2];
48
        uint8_t Digital[2];
37
 unsigned char RemoteTasten;
49
        uint8_t RemoteButtons;
38
 signed char   Nick;
50
        int8_t  Nick;
39
 signed char   Roll;
51
        int8_t  Roll;
-
 
52
        int8_t  Yaw;
40
 signed char   Gier;
53
        uint8_t Gas;
41
 unsigned char Gas;
54
        int8_t  Height;
Line -... Line 55...
-
 
55
        uint8_t Par1;
42
 signed char   Hight;
56
        uint8_t Par2;
43
 unsigned char Par1;
57
        uint8_t Par3;
44
 unsigned char Par2;
58
} ExternControl_t;
45
 unsigned char Par3;
59
 
46
};
60
extern ExternControl_t  ExternControl;
47
extern struct str_ExternControl  ExternControl;
61
 
48
 
-
 
49
struct str_VersionInfo
62
 
50
{
-
 
51
  unsigned char Hauptversion;
63
typedef struct
52
  unsigned char Nebenversion;
-
 
53
  unsigned char PCKompatibel;
64
{
54
  unsigned char Rserved[7];
-
 
55
};  
-
 
56
extern struct str_VersionInfo VersionInfo;
-
 
57
 
-
 
58
 
-
 
59
extern struct str_DebugOut    DebugOut;
-
 
60
extern struct str_DebugOut    DebugOut;
-
 
61
//Die Baud_Rate der Seriellen Schnittstelle 
-
 
62
//#define BAUD_RATE 9600                //Baud Rate für die Serielle Schnittstelle      
-
 
63
//#define BAUD_RATE 14400               //Baud Rate für die Serielle Schnittstelle      
-
 
64
//#define BAUD_RATE 28800               //Baud Rate für die Serielle Schnittstelle      
-
 
65
 
-
 
66
#if X3D_SIO == 1
-
 
67
 #define BAUD_RATE 38400                //Baud Rate für die Serielle Schnittstelle      
-
 
68
#else
-
 
69
 #define BAUD_RATE 57600                //Baud Rate für die Serielle Schnittstelle      
-
 
70
#endif
-
 
71
 
-
 
72
//Anpassen der seriellen Schnittstellen Register wenn ein ATMega128 benutzt wird
-
 
73
#if defined (__AVR_ATmega128__)
-
 
74
#       define USR UCSR0A
-
 
75
#       define UCR UCSR0B
-
 
76
#       define UDR UDR0
-
 
77
#       define UBRR UBRR0L
-
 
78
#       define EICR EICRB
-
 
79
#endif
-
 
80
 
-
 
81
#if defined (__AVR_ATmega8__)
-
 
82
#       define USR UCSRA
-
 
83
#       define UCR UCSRB
-
 
84
#       define UBRR UBRRL
-
 
85
#       define EICR EICRB
-
 
86
#   define INT_VEC_RX  SIG_UART_RECV
-
 
87
#   define INT_VEC_TX  SIG_UART_TRANS
-
 
88
#endif
-
 
89
 
-
 
90
#if defined (__AVR_ATmega168__)
-
 
91
#       define USR  UCSR0A
-
 
92
#       define UCR  UCSR0B
-
 
93
#       define UDR  UDR0
-
 
94
#       define UBRR UBRR0L
-
 
95
#       define EICR EICR0B
-
 
96
#   define TXEN TXEN0
-
 
97
#   define RXEN RXEN0
-
 
98
#   define RXCIE RXCIE0
-
 
99
#   define TXCIE TXCIE0
-
 
100
#   define U2X  U2X0
-
 
101
#   define UCSRB UCSR0B
-
 
102
#   define UDRE UDRE0
-
 
103
#   define INT_VEC_RX  SIG_USART_RECV
-
 
104
#   define INT_VEC_TX  SIG_USART_TRANS
-
 
105
#endif
-
 
106
 
-
 
107
 
-
 
108
#if defined (__AVR_ATmega32__)
-
 
109
#       define USR UCSRA
-
 
110
#       define UCR UCSRB
-
 
111
#       define UBRR UBRRL
-
 
112
#       define EICR EICRB
-
 
113
#   define INT_VEC_RX  SIG_UART_RECV
-
 
114
#   define INT_VEC_TX  SIG_UART_TRANS
-
 
115
#endif
-
 
116
 
-
 
117
#if defined (__AVR_ATmega644__)
-
 
118
#       define USR  UCSR0A
-
 
119
#       define UCR  UCSR0B
-
 
120
#       define UDR  UDR0
-
 
121
#       define UBRR UBRR0L
-
 
122
#       define EICR EICR0B
-
 
123
#   define TXEN TXEN0
-
 
124
#   define RXEN RXEN0
-
 
125
#   define RXCIE RXCIE0
-
 
Line 126... Line 65...
126
#   define TXCIE TXCIE0
65
        uint8_t Major;