Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2136 - 1
/*****************************************************************************
2
 *   Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de                  *
3
 *   Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net                  *
4
 *   Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net *
5
 *   Copyright (C) 2011 Harald Bongartz                                      *
6
 *                                                                           *
7
 *   This program is free software; you can redistribute it and/or modify    *
8
 *   it under the terms of the GNU General Public License as published by    *
9
 *   the Free Software Foundation; either version 2 of the License.          *
10
 *                                                                           *
11
 *   This program is distributed in the hope that it will be useful,         *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
14
 *   GNU General Public License for more details.                            *
15
 *                                                                           *
16
 *   You should have received a copy of the GNU General Public License       *
17
 *   along with this program; if not, write to the                           *
18
 *   Free Software Foundation, Inc.,                                         *
19
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.               *
20
 *                                                                           *
21
 *                                                                           *
22
 *   Credits to:                                                             *
23
 *   Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN  *
24
 *                          http://www.mikrokopter.de                        *
25
 *   Gregor "killagreg" Stobrawa for his version of the MK code              *
26
 *   Thomas Kaiser "thkais" for the original project. See                    *
27
 *                          http://www.ft-fanpage.de/mikrokopter/            *
28
 *                          http://forum.mikrokopter.de/topic-4061-1.html    *
29
 *   Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code *
30
 *                          http://www.mylifesucks.de/oss/c-osd/             *
31
 *   Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility*
32
 *****************************************************************************/
33
 
34
//############################################################################
35
//# HISTORY  usart.h
36
//#
37
//# 24.01.2014 OG
38
//# - fix: RXD_BUFFER_LEN und TXD_BUFFER_LEN vergroessert 180 auf 230 wegen 
39
//#        neuer FC-Version (FC v2.03)
40
//# - add: Source-History
41
//############################################################################
42
 
43
 
44
#ifndef _USART_H
45
#define _USART_H
46
 
47
//--------------------------------------------------------------
48
//
49
#ifndef FALSE
50
#define FALSE   0
51
#endif
52
#ifndef TRUE
53
#define TRUE    1
54
#endif
55
 
56
// addresses
57
#define ADDRESS_ANY     0
58
#define ADDRESS_FC      1
59
#define ADDRESS_NC      2
60
#define ADDRESS_MAG     3
61
 
62
// must be at least 4('#'+Addr+'CmdID'+'\r')+ (80 * 4)/3 = 111 bytes
63
//#define TXD_BUFFER_LEN  180
64
//#define RXD_BUFFER_LEN  180
65
 
66
#define TXD_BUFFER_LEN  230
67
#define RXD_BUFFER_LEN  230
68
 
69
// Baud rate of the USART
70
#define USART_BAUD 57600
71
//#define USART_BAUD 125000
72
 
73
//--------------------------------------------------------------
74
//
75
extern uint8_t buffer[30];
76
 
77
extern volatile uint8_t txd_buffer[TXD_BUFFER_LEN];
78
extern volatile uint8_t txd_complete;
79
extern volatile uint8_t txd1_buffer[TXD_BUFFER_LEN];
80
extern volatile uint8_t txd1_complete;
81
extern volatile uint8_t rxd_buffer[RXD_BUFFER_LEN];
82
extern volatile uint8_t rxd_buffer_locked;
83
extern volatile uint8_t ReceivedBytes;
84
extern volatile uint8_t *pRxData;
85
extern volatile uint8_t RxDataLen;
86
 
87
extern volatile uint16_t stat_crc_error;
88
extern volatile uint16_t stat_overflow_error;
89
 
90
extern volatile uint8_t rxFlag;
91
extern volatile uint8_t rx_byte;
92
 
93
//--------------------------------------------------------------
94
//
95
void SetBaudUart0(uint8_t Baudrate);
96
void USART_Init (unsigned int baudrate);
97
void USART_DisableTXD (void);
98
void USART_EnableTXD (void);
99
void USART_request_mk_data (uint8_t cmd, uint8_t addr, uint8_t ms);
100
 
101
void USART_putc (char c);
102
void USART_puts (char *s);
103
void USART_puts_p (const char *s);
104
 
105
 
106
extern char USART_getc(void);
107
void SendOutData (uint8_t cmd, uint8_t addr, uint8_t numofbuffers, ...); // uint8_t *pdata, uint8_t len, ...
108
//void SendOutData(uint8_t cmd, uint8_t addr, uint8_t numofbuffers, uint8_t *pdata, uint8_t len); // uint8_t *pdata, uint8_t len, ...
109
void Decode64 (void);
110
 
111
void SwitchToNC (void);
112
void SwitchToFC (void);
113
void SwitchToMAG (void);
114
void SwitchToGPS (void);
115
void SwitchToWi232 (void);
116
void debug1(void);
117
 
118
uint8_t uart_getc_nb(uint8_t*);
119
 
120
//--------------------------------------------------------------
121
//Anpassen der seriellen Schnittstellen Register
122
#define USART_RXC_vect USART0_RX_vect
123
//--------------------------------------------------------------
124
#define UCSRA   UCSR0A
125
#define UCSRB   UCSR0B
126
#define UCSRC   UCSR0C
127
#define UDR             UDR0
128
#define UBRRL   UBRR0L
129
#define UBRRH   UBRR0H
130
 
131
// UCSRA
132
#define RXC             RXC0
133
#define TXC             TXC0
134
#define UDRE    UDRE0
135
#define FE              FE0
136
#define UPE             UPE0
137
#define U2X             U2X0
138
#define MPCM    MPCM0
139
 
140
// UCSRB
141
#define RXCIE   RXCIE0
142
#define TXCIE   TXCIE0
143
#define UDRIE   UDRIE0
144
#define TXEN    TXEN0
145
#define RXEN    RXEN0
146
#define UCSZ2   UCSZ02
147
#define RXB8    RXB80
148
#define TXB8    TXB80
149
 
150
// UCSRC
151
#define UMSEL1  UMSEL01
152
#define UMSEL0  UMSEL00
153
#define UPM1    UPM01
154
#define UPM0    UPM00
155
#define USBS    USBS0
156
#define UCSZ1   UCSZ01
157
#define UCSZ0   UCSZ00
158
#define UCPOL   UCPOL0
159
 
160
 
161
#endif
162