Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1915 - 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
#ifndef _USART_H
36
#define _USART_H
37
 
38
//--------------------------------------------------------------
39
//
40
#ifndef FALSE
41
#define FALSE   0
42
#endif
43
#ifndef TRUE
44
#define TRUE    1
45
#endif
46
 
47
// addresses
48
#define ADDRESS_ANY     0
49
#define ADDRESS_FC      1
50
#define ADDRESS_NC      2
51
#define ADDRESS_MAG     3
52
 
53
// must be at least 4('#'+Addr+'CmdID'+'\r')+ (80 * 4)/3 = 111 bytes
54
#define TXD_BUFFER_LEN  180
55
#define RXD_BUFFER_LEN  180
56
 
57
// Baud rate of the USART
58
#define USART_BAUD 57600
59
//#define USART_BAUD 125000
60
 
61
//--------------------------------------------------------------
62
//
63
extern uint8_t buffer[30];
64
 
65
extern volatile uint8_t txd_buffer[TXD_BUFFER_LEN];
66
extern volatile uint8_t txd_complete;
67
extern volatile uint8_t txd1_buffer[TXD_BUFFER_LEN];
68
extern volatile uint8_t txd1_complete;
69
extern volatile uint8_t rxd_buffer[RXD_BUFFER_LEN];
70
extern volatile uint8_t rxd_buffer_locked;
71
extern volatile uint8_t ReceivedBytes;
72
extern volatile uint8_t *pRxData;
73
extern volatile uint8_t RxDataLen;
74
 
75
extern volatile uint16_t stat_crc_error;
76
extern volatile uint16_t stat_overflow_error;
77
 
78
extern volatile uint8_t rxFlag;
79
extern volatile uint8_t rx_byte;
80
 
81
//--------------------------------------------------------------
82
//
83
void SetBaudUart0(uint8_t Baudrate);
84
void USART_Init (unsigned int baudrate);
85
void USART_DisableTXD (void);
86
void USART_EnableTXD (void);
87
void USART_request_mk_data (uint8_t cmd, uint8_t addr, uint8_t ms);
88
 
89
void USART_putc (char c);
90
void USART_puts (char *s);
91
void USART_puts_p (const char *s);
92
 
93
 
94
extern char USART_getc(void);
95
void SendOutData (uint8_t cmd, uint8_t addr, uint8_t numofbuffers, ...); // uint8_t *pdata, uint8_t len, ...
96
//void SendOutData(uint8_t cmd, uint8_t addr, uint8_t numofbuffers, uint8_t *pdata, uint8_t len); // uint8_t *pdata, uint8_t len, ...
97
void Decode64 (void);
98
 
99
void SwitchToNC (void);
100
void SwitchToFC (void);
101
void SwitchToMAG (void);
102
void SwitchToGPS (void);
103
void SwitchToWi232 (void);
104
void debug1(void);
105
 
106
uint8_t uart_getc_nb(uint8_t*);
107
 
108
//--------------------------------------------------------------
109
//Anpassen der seriellen Schnittstellen Register
110
#define USART_RXC_vect USART0_RX_vect
111
//--------------------------------------------------------------
112
#define UCSRA   UCSR0A
113
#define UCSRB   UCSR0B
114
#define UCSRC   UCSR0C
115
#define UDR             UDR0
116
#define UBRRL   UBRR0L
117
#define UBRRH   UBRR0H
118
 
119
// UCSRA
120
#define RXC             RXC0
121
#define TXC             TXC0
122
#define UDRE    UDRE0
123
#define FE              FE0
124
#define UPE             UPE0
125
#define U2X             U2X0
126
#define MPCM    MPCM0
127
 
128
// UCSRB
129
#define RXCIE   RXCIE0
130
#define TXCIE   TXCIE0
131
#define UDRIE   UDRIE0
132
#define TXEN    TXEN0
133
#define RXEN    RXEN0
134
#define UCSZ2   UCSZ02
135
#define RXB8    RXB80
136
#define TXB8    TXB80
137
 
138
// UCSRC
139
#define UMSEL1  UMSEL01
140
#define UMSEL0  UMSEL00
141
#define UPM1    UPM01
142
#define UPM0    UPM00
143
#define USBS    USBS0
144
#define UCSZ1   UCSZ01
145
#define UCSZ0   UCSZ00
146
#define UCPOL   UCPOL0
147
 
148
 
149
#endif
150