Rev 41 | Rev 61 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 41 | Rev 54 | ||
---|---|---|---|
1 | #ifndef _UART1_H |
1 | #ifndef _UART1_H |
2 | #define _UART1_H |
2 | #define _UART1_H |
3 | 3 | ||
4 | #define UART_FLIGHTCTRL 0 |
4 | #define UART_FLIGHTCTRL 0 |
5 | #define UART_MK3MAG 1 |
5 | #define UART_MK3MAG 1 |
6 | #define UART_MKGPS 2 |
6 | #define UART_MKGPS 2 |
7 | 7 | ||
8 | #define TXD_BUFFER_LEN 150 |
8 | #define TXD_BUFFER_LEN 150 |
9 | #define RXD_BUFFER_LEN 150 |
9 | #define RXD_BUFFER_LEN 150 |
10 | #define BAUD_RATE 57600 //Baud Rate for the serial interfaces |
10 | #define BAUD_RATE 57600 //Baud Rate for the serial interfaces |
11 | 11 | ||
12 | #include "ubx.h" |
12 | #include "ubx.h" |
13 | 13 | ||
14 | typedef struct |
14 | typedef struct |
15 | { |
15 | { |
16 | u8 Digital[2]; |
16 | u8 Digital[2]; |
17 | u16 Analog[32]; // Debugwerte |
17 | u16 Analog[32]; // Debugwerte |
18 | } __attribute__((packed)) DebugOut_t; |
18 | } __attribute__((packed)) DebugOut_t; |
19 | 19 | ||
20 | extern DebugOut_t DebugOut; |
20 | extern DebugOut_t DebugOut; |
21 | 21 | ||
22 | typedef struct |
22 | typedef struct |
23 | { |
23 | { |
24 | u8 Digital[2]; |
24 | u8 Digital[2]; |
25 | u8 RemoteButtons; |
25 | u8 RemoteButtons; |
26 | s8 Nick; |
26 | s8 Nick; |
27 | s8 Roll; |
27 | s8 Roll; |
28 | s8 Yaw; |
28 | s8 Yaw; |
29 | u8 Gas; |
29 | u8 Gas; |
30 | s8 Height; |
30 | s8 Height; |
31 | u8 free; |
31 | u8 free; |
32 | u8 Frame; |
32 | u8 Frame; |
33 | u8 Config; |
33 | u8 Config; |
34 | } __attribute__((packed)) ExternControl_t; |
34 | } __attribute__((packed)) ExternControl_t; |
35 | 35 | ||
36 | extern ExternControl_t ExternControl; |
36 | extern ExternControl_t ExternControl; |
37 | 37 | ||
38 | typedef struct |
38 | typedef struct |
39 | { |
39 | { |
40 | s16 Nick; |
40 | s16 Nick; |
41 | s16 Roll; |
41 | s16 Roll; |
42 | s16 Compass; // angle between north and head of the MK |
42 | s16 Compass; // angle between north and head of the MK |
43 | } __attribute__((packed)) Attitude_t; |
43 | } __attribute__((packed)) Attitude_t; |
44 | 44 | ||
45 | typedef struct |
45 | typedef struct |
46 | { |
46 | { |
47 | s16 Distance; // distance to target in cm |
47 | s16 Distance; // distance to target in cm |
48 | s16 Bearing; // course to target in deg |
48 | s16 Bearing; // course to target in deg |
49 | } __attribute__((packed)) GPS_PosDev_t; |
49 | } __attribute__((packed)) GPS_PosDev_t; |
50 | 50 | ||
51 | typedef struct |
51 | typedef struct |
52 | { |
52 | { |
53 | GPS_Pos_t CurrentPosition; // see ubx.h for details |
53 | GPS_Pos_t CurrentPosition; // see ubx.h for details |
54 | GPS_Pos_t TargetPosition; |
54 | GPS_Pos_t TargetPosition; |
55 | GPS_PosDev_t TargetPositionDeviation; |
55 | GPS_PosDev_t TargetPositionDeviation; |
56 | GPS_Pos_t HomePosition; |
56 | GPS_Pos_t HomePosition; |
57 | GPS_PosDev_t HomePositionDeviation; |
57 | GPS_PosDev_t HomePositionDeviation; |
58 | u8 WaypointIndex; // index of current waypoints running from 0 to WaypointNumber-1 |
58 | u8 WaypointIndex; // index of current waypoints running from 0 to WaypointNumber-1 |
59 | u8 WaypointNumber; // number of stored waypoints |
59 | u8 WaypointNumber; // number of stored waypoints |
60 | u8 SatsInUse; // no of satellites used for position solution |
60 | u8 SatsInUse; // no of satellites used for position solution |
61 | s16 Altimeter; // hight according to air pressure |
61 | s16 Altimeter; // hight according to air pressure |
62 | s16 Variometer; // climb(+) and sink(-) rate |
62 | s16 Variometer; // climb(+) and sink(-) rate |
63 | u16 FlyingTime; // in seconds |
63 | u16 FlyingTime; // in seconds |
64 | u8 UBat; // Battery Voltage in 0.1 Volts |
64 | u8 UBat; // Battery Voltage in 0.1 Volts |
65 | u16 GroundSpeed; // speed over ground in cm/s (2D) |
65 | u16 GroundSpeed; // speed over ground in cm/s (2D) |
66 | s16 Heading; // current flight direction in deg as angle to north |
66 | s16 Heading; // current flight direction in deg as angle to north |
67 | s16 CompassHeading; // current compass value |
67 | s16 CompassHeading; // current compass value |
68 | s8 AngleNick; // current Nick angle in 1° |
68 | s8 AngleNick; // current Nick angle in 1° |
69 | s8 AngleRoll; // current Rick angle in 1° |
69 | s8 AngleRoll; // current Rick angle in 1° |
70 | u8 RC_Quality; // RC_Quality |
70 | u8 RC_Quality; // RC_Quality |
71 | u8 MKFlags; // Flags from FC |
71 | u8 MKFlags; // Flags from FC |
72 | u8 NCFlags; // Flags from NC |
72 | u8 NCFlags; // Flags from NC |
73 | u8 Errorcode; // 0 --> okay |
73 | u8 Errorcode; // 0 --> okay |
74 | u8 Reserve[8]; // for future use |
74 | u8 Reserve[8]; // for future use |
75 | } __attribute__((packed)) NaviData_t; |
75 | } __attribute__((packed)) NaviData_t; |
76 | 76 | ||
77 | extern NaviData_t NaviData; |
77 | extern NaviData_t NaviData; |
78 | extern u8 Request_NaviData; |
78 | extern u8 Request_NaviData; |
79 | 79 | ||
80 | #define NC_FLAG_FREE 1 |
80 | #define NC_FLAG_FREE 1 |
81 | #define NC_FLAG_PH 2 |
81 | #define NC_FLAG_PH 2 |
82 | #define NC_FLAG_CH 4 |
82 | #define NC_FLAG_CH 4 |
83 | #define NC_FLAG_RANGE_LIMIT 8 |
83 | #define NC_FLAG_RANGE_LIMIT 8 |
84 | 84 | ||
85 | typedef struct |
85 | typedef struct |
86 | { |
86 | { |
87 | u8 SWMajor; |
87 | u8 SWMajor; |
88 | u8 SWMinor; |
88 | u8 SWMinor; |
89 | u8 ProtoMajor; |
89 | u8 ProtoMajor; |
90 | u8 ProtoMinor; |
90 | u8 ProtoMinor; |
91 | u8 SWPatch; |
91 | u8 SWPatch; |
92 | u8 Reserved[5]; |
92 | u8 Reserved[5]; |
93 | } __attribute__((packed)) UART_VersionInfo_t; |
93 | } __attribute__((packed)) UART_VersionInfo_t; |
94 | 94 | ||
95 | extern volatile u8 rxd_buffer[RXD_BUFFER_LEN]; |
95 | extern volatile u8 rxd_buffer[RXD_BUFFER_LEN]; |
96 | extern volatile u8 ReceivedBytes; |
96 | extern volatile u8 ReceivedBytes; |
97 | extern volatile u8 rxd_buffer_locked; |
97 | extern volatile u8 rxd_buffer_locked; |
98 | extern UART_TypeDef *DebugUART; |
98 | extern UART_TypeDef *DebugUART; |
99 | 99 | ||
100 | 100 | ||
101 | void UART1_Init(void); |
101 | void UART1_Init(void); |
102 | void UART1_Transmit(void); |
102 | void UART1_Transmit(void); |
103 | void UART1_TransmitTxData(void); |
103 | void UART1_TransmitTxData(void); |
104 | void UART1_ProcessRxData(void); |
104 | void UART1_ProcessRxData(void); |
105 | 105 | ||
106 | s16 uart_putchar (char c); |
106 | s16 uart_putchar (char c); |
107 | void SerialPutString(u8 *s); |
107 | void SerialPutString(u8 *s); |
108 | extern u8 text[100]; |
108 | extern u8 text[100]; |
109 | extern u32 Request_NaviData_Intervall; // in 1ms |
109 | extern u32 Request_NaviData_Intervall; // in ms |
110 | extern u8 Request_SendFollowMe; |
110 | extern u8 Request_SendFollowMe; |
111 | #endif //_UART1_H |
111 | #endif //_UART1_H |
112 | 112 |