-
Notifications
You must be signed in to change notification settings - Fork 5
/
uart.h
139 lines (121 loc) · 3.72 KB
/
uart.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#ifndef _UART_H
#define _UART_H
#define printf_P(format, args...) _printf_P(&uart_putchar, format , ## args)
#define printf(format, args...) _printf_P(&uart_putchar, PSTR(format) , ## args)
void BearbeiteRxDaten(void);
extern unsigned char DebugGetAnforderung;
extern unsigned volatile char ReceiverUpdateModeActive;
extern unsigned volatile char UebertragungAbgeschlossen;
extern unsigned volatile char PC_DebugTimeout;
extern unsigned volatile char NeueKoordinateEmpfangen;
extern unsigned volatile char PC_MotortestActive;
extern unsigned char MeineSlaveAdresse;
extern unsigned char PcZugriff;
extern unsigned char RemotePollDisplayLine;
extern unsigned volatile char RxdBuffer[];
extern int Debug_Timer,Kompass_Timer;
extern void UART_Init (void);
extern void uart_putchar (char c);
//extern void boot_program_page (uint32_t page, uint8_t *buf);
extern void DatenUebertragung(void);
extern void Uart1Init(void);
extern void BearbeiteRxDaten(void);
extern unsigned char MotorTest[16];
struct str_DebugOut
{
unsigned char Status[2];
signed int Analog[32]; // Debugwerte
};
extern struct str_DebugOut DebugOut;
struct str_WinkelOut
{
signed int Winkel[2];
unsigned char UserParameter[2];
unsigned char CalcState;
unsigned char Orientation;
};
extern struct str_WinkelOut WinkelOut;
struct str_Data3D
{
signed int Winkel[3]; // nick, roll, compass in 0,1°
signed char Centroid[3];
// signed char reserve[5];
unsigned int AccZ;
signed char reserve[3];
};
extern struct str_Data3D Data3D;
/*
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 free;
unsigned char Frame;
unsigned char Config;
};
extern struct str_ExternControl ExternControl;
*/
// defines for ExternalControl.Config
#define EC_VALID 0x01 // only valid if this is 1
#define EC_GAS_ADD 0x02 // if 1 -> use the GAS Value not as MAX
#define EC_IGNORE_RC 0x80 // if 1 -> for Flying without RC-Control
struct str_ExternControl
{
signed char Nick;
signed char Roll;
signed char Gier;
signed char Gas;
unsigned char Frame; // will return a confirm frame with this value
unsigned char Config;
unsigned char free;
};
extern struct str_ExternControl ExternalControl;
extern unsigned char ExternalControlTimeout;
// FC hardware errors
// bitmask for UART_VersionInfo_t.HardwareError[0]
#define FC_ERROR0_GYRO_NICK 0x01
#define FC_ERROR0_GYRO_ROLL 0x02
#define FC_ERROR0_GYRO_YAW 0x04
#define FC_ERROR0_ACC_NICK 0x08
#define FC_ERROR0_ACC_ROLL 0x10
#define FC_ERROR0_ACC_TOP 0x20
#define FC_ERROR0_PRESSURE 0x40
#define FC_ERROR0_CAREFREE 0x80
// bitmask for UART_VersionInfo_t.HardwareError[1]
#define FC_ERROR1_I2C 0x01
#define FC_ERROR1_BL_MISSING 0x02
#define FC_ERROR1_SPI_RX 0x04
#define FC_ERROR1_PPM 0x08
#define FC_ERROR1_MIXER 0x10
#define FC_ERROR1_RES1 0x20
#define FC_ERROR1_RES2 0x40
#define FC_ERROR1_RES3 0x80
// for FlightCtrl
//VersionInfo.Flags
#define FC_VERSION_FLAG_NC_PRESENT 0x01
// for NaviCtrl
#define NC_VERSION_FLAG_MK3MAG_PRESENT 0x01
struct str_VersionInfo
{
unsigned char SWMajor;
unsigned char SWMinor;
unsigned char ProtoMajor;
unsigned char LabelTextCRC;
unsigned char SWPatch;
unsigned char HardwareError[2];
unsigned char HWMajor;
unsigned char BL_Firmware;
unsigned char Flags;
};
extern struct str_VersionInfo VersionInfo;
//#define USART0_BAUD 9600
//#define USART0_BAUD 14400
//#define USART0_BAUD 28800
//#define USART0_BAUD 38400
#define USART0_BAUD 57600
#endif //_UART_H