Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1515 | - | 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 60 |
||
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 USART_Init (unsigned int baudrate); |
||
84 | void USART_DisableTXD (void); |
||
85 | void USART_EnableTXD (void); |
||
86 | void USART_request_mk_data (uint8_t cmd, uint8_t addr, uint8_t ms); |
||
87 | |||
88 | void USART_putc (char c); |
||
89 | void USART_puts (char *s); |
||
90 | void USART_puts_p (const char *s); |
||
91 | |||
92 | |||
93 | extern char USART_getc(void); |
||
94 | void SendOutData (uint8_t cmd, uint8_t addr, uint8_t numofbuffers, ...); // uint8_t *pdata, uint8_t len, ... |
||
95 | //void SendOutData(uint8_t cmd, uint8_t addr, uint8_t numofbuffers, uint8_t *pdata, uint8_t len); // uint8_t *pdata, uint8_t len, ... |
||
96 | void Decode64 (void); |
||
97 | |||
98 | void SwitchToNC (void); |
||
99 | void SwitchToFC (void); |
||
100 | void SwitchToMAG (void); |
||
101 | void SwitchToGPS (void); |
||
102 | void SwitchToWi232 (void); |
||
103 | void debug1(void); |
||
104 | |||
105 | uint8_t uart_getc_nb(uint8_t*); |
||
106 | |||
107 | //-------------------------------------------------------------- |
||
108 | //Anpassen der seriellen Schnittstellen Register |
||
109 | #define USART_RXC_vect USART0_RX_vect |
||
110 | //-------------------------------------------------------------- |
||
111 | #define UCSRA UCSR0A |
||
112 | #define UCSRB UCSR0B |
||
113 | #define UCSRC UCSR0C |
||
114 | #define UDR UDR0 |
||
115 | #define UBRRL UBRR0L |
||
116 | #define UBRRH UBRR0H |
||
117 | |||
118 | // UCSRA |
||
119 | #define RXC RXC0 |
||
120 | #define TXC TXC0 |
||
121 | #define UDRE UDRE0 |
||
122 | #define FE FE0 |
||
123 | #define UPE UPE0 |
||
124 | #define U2X U2X0 |
||
125 | #define MPCM MPCM0 |
||
126 | |||
127 | // UCSRB |
||
128 | #define RXCIE RXCIE0 |
||
129 | #define TXCIE TXCIE0 |
||
130 | #define UDRIE UDRIE0 |
||
131 | #define TXEN TXEN0 |
||
132 | #define RXEN RXEN0 |
||
133 | #define UCSZ2 UCSZ02 |
||
134 | #define RXB8 RXB80 |
||
135 | #define TXB8 TXB80 |
||
136 | |||
137 | // UCSRC |
||
138 | #define UMSEL1 UMSEL01 |
||
139 | #define UMSEL0 UMSEL00 |
||
140 | #define UPM1 UPM01 |
||
141 | #define UPM0 UPM00 |
||
142 | #define USBS USBS0 |
||
143 | #define UCSZ1 UCSZ01 |
||
144 | #define UCSZ0 UCSZ00 |
||
145 | #define UCPOL UCPOL0 |
||
146 | |||
147 | |||
148 | #endif |
||
149 |