Rev 1801 | Rev 2039 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
331 | cascade | 1 | /**************************************************************************** |
1866 | - | 2 | * Copyright (C) 2009-2013 by Claas Anders "CaScAdE" Rathje * |
331 | cascade | 3 | * admiralcascade@gmail.com * |
4 | * Project-URL: http://www.mylifesucks.de/oss/c-osd/ * |
||
5 | * * |
||
6 | * This program is free software; you can redistribute it and/or modify * |
||
7 | * it under the terms of the GNU General Public License as published by * |
||
8 | * the Free Software Foundation; either version 2 of the License. * |
||
9 | * * |
||
10 | * This program is distributed in the hope that it will be useful, * |
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
13 | * GNU General Public License for more details. * |
||
14 | * * |
||
15 | * You should have received a copy of the GNU General Public License * |
||
16 | * along with this program; if not, write to the * |
||
17 | * Free Software Foundation, Inc., * |
||
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
19 | ****************************************************************************/ |
||
20 | |||
762 | - | 21 | #ifndef _USART1_H |
22 | #define _USART1_H |
||
23 | |||
1437 | - | 24 | #include <avr/io.h> |
25 | #include <avr/interrupt.h> |
||
26 | #include <util/delay.h> |
||
27 | |||
331 | cascade | 28 | #define baud 57600 |
29 | |||
835 | - | 30 | #define RXD_BUFFER_LEN 180 |
738 | cascade | 31 | #define TXD_BUFFER_LEN 20 // not so much needed |
331 | cascade | 32 | |
738 | cascade | 33 | #define REQUEST_OSD_DATA "#bo?]==EG\r" |
1801 | - | 34 | //#define REQUEST_OSD_DATA "#co?]==EH\r" |
738 | cascade | 35 | #define REQUEST_DBG_DATA "#ad?]==D{\r" |
783 | - | 36 | #define REQUEST_DBG_DISABLE "#ad====DY\r" |
37 | |||
738 | cascade | 38 | #define REQUEST_FC_VERSION "#av====Dk\r" |
39 | #define REQUEST_NC_VERSION "#bv====Dl\r" |
||
40 | |||
783 | - | 41 | #define REQUEST_CURRENT_SETTING "#bq|nZBFy\r" |
42 | #define REQUEST_UART_TO_FC "#cu=IfREv\r" |
||
43 | |||
1801 | - | 44 | #define REQUEST_3DDATA "#cc?]==D|\r" |
783 | - | 45 | |
46 | |||
346 | cascade | 47 | extern volatile uint8_t rxd_buffer_locked; |
48 | extern volatile uint8_t rxd_buffer[RXD_BUFFER_LEN]; |
||
783 | - | 49 | //extern volatile uint8_t txd_buffer[TXD_BUFFER_LEN]; |
346 | cascade | 50 | extern volatile uint8_t ReceivedBytes; |
51 | extern volatile uint8_t *pRxData; |
||
52 | extern volatile uint8_t RxDataLen; |
||
53 | |||
331 | cascade | 54 | /** |
346 | cascade | 55 | * init usart1 |
56 | */ |
||
57 | void usart1_init(); |
||
58 | |||
59 | /** |
||
331 | cascade | 60 | * disable the txd pin of usart1 |
61 | */ |
||
62 | void usart1_DisableTXD(void); |
||
63 | |||
64 | /** |
||
65 | * enable the txd pin of usart1 |
||
66 | */ |
||
67 | void usart1_EnableTXD(void); |
||
346 | cascade | 68 | |
69 | /** |
||
738 | cascade | 70 | * send a PGM<string> throught usart1 |
346 | cascade | 71 | */ |
738 | cascade | 72 | void usart1_puts_pgm(const char*); |
346 | cascade | 73 | |
74 | /** |
||
387 | cascade | 75 | * transmit interrupt handler |
76 | * unused |
||
77 | */ |
||
1773 | - | 78 | ISR(USART1_TXC_vect); |
387 | cascade | 79 | |
80 | /** |
||
346 | cascade | 81 | * receive data through usart1 |
82 | * portions taken and adapted from |
||
83 | * http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Fbranches%2FV0.72p+Code+Redesign+killagreg%2Fuart0.c |
||
84 | */ |
||
1773 | - | 85 | ISR(USART1_RXC_vect); |
346 | cascade | 86 | |
87 | /** |
||
88 | * Decode the recevied Buffer |
||
89 | * portions taken and adapted from |
||
90 | * http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c |
||
91 | */ |
||
92 | void Decode64(void); |
||
93 | |||
835 | - | 94 | /** |
95 | * Request Data through usart1 until a answer is received |
||
783 | - | 96 | */ |
97 | void usart1_request_blocking(unsigned char answer, const char* message); |
||
98 | |||
835 | - | 99 | /** |
100 | * Request UART Redirect from NC to itself |
||
783 | - | 101 | */ |
102 | void usart1_request_nc_uart(void); |
||
103 | |||
346 | cascade | 104 | /** |
105 | * request Data through USART in special MK format by adding checksum and |
||
106 | * encode data in modified Base64 |
||
107 | * portions taken and adapted from |
||
108 | * http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c |
||
109 | */ |
||
738 | cascade | 110 | //void sendMKData(unsigned char, unsigned char, unsigned char*, unsigned char); |
346 | cascade | 111 | |
112 | /** |
||
113 | * short script to directly send a request thorugh usart including en- and disabling it |
||
114 | * where <address> is the address of the receipient, <label> is which data set to request |
||
115 | * and <ms> represents the milliseconds delay between data |
||
116 | */ |
||
738 | cascade | 117 | //void usart1_request_mk_data(uint8_t, char, uint8_t); |
762 | - | 118 | |
119 | #endif |