Subversion Repositories Projects

Rev

Rev 783 | Rev 902 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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