Rev 1199 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1199 | Rev 1437 | ||
---|---|---|---|
1 | /**************************************************************************** |
1 | /**************************************************************************** |
2 | * Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje * |
2 | * Copyright (C) 2011-2012 by Claas Anders "CaScAdE" Rathje * |
3 | * admiralcascade@gmail.com * |
3 | * admiralcascade@gmail.com * |
4 | * Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ * |
4 | * Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ * |
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 | #include "main.h" |
21 | #include "main.h" |
22 | 22 | ||
23 | #ifndef _USART0_H |
23 | #ifndef _USART0_H |
24 | #define _USART0_H |
24 | #define _USART0_H |
25 | 25 | ||
26 | #ifndef USART0_BAUD |
26 | #ifndef USART0_BAUD |
27 | #define USART0_BAUD 57600 |
27 | #define USART0_BAUD 57600 |
28 | #endif |
28 | #endif |
29 | 29 | ||
30 | 30 | ||
31 | #define RXD_BUFFER_LEN 180 |
31 | #define RXD_BUFFER_LEN 180 |
32 | #define TXD_BUFFER_LEN 20 // not so much needed since only requesting stuff |
32 | #define TXD_BUFFER_LEN 20 // not so much needed since only requesting stuff |
33 | 33 | ||
34 | extern volatile uint8_t rxd_buffer_locked; |
34 | extern volatile uint8_t rxd_buffer_locked; |
35 | extern volatile uint8_t rxd_buffer[RXD_BUFFER_LEN]; |
35 | extern volatile uint8_t rxd_buffer[RXD_BUFFER_LEN]; |
36 | extern volatile uint8_t txd_buffer[TXD_BUFFER_LEN]; |
36 | extern volatile uint8_t txd_buffer[TXD_BUFFER_LEN]; |
37 | extern volatile uint8_t ReceivedBytes; |
37 | extern volatile uint8_t ReceivedBytes; |
38 | extern volatile uint8_t *pRxData; |
38 | extern volatile uint8_t *pRxData; |
39 | extern volatile uint8_t RxDataLen; |
39 | extern volatile uint8_t RxDataLen; |
40 | 40 | ||
41 | /** |
41 | /** |
42 | * init usart0 |
42 | * init usart0 |
43 | */ |
43 | */ |
44 | void usart0_init(); |
44 | void usart0_init(); |
45 | 45 | ||
46 | 46 | ||
47 | /** |
47 | /** |
48 | * send a single <character> through usart0 |
48 | * send a single <character> through usart0 |
49 | */ |
49 | */ |
50 | void usart0_putc(unsigned char character); |
50 | void usart0_putc(unsigned char character); |
51 | 51 | ||
52 | /** |
52 | /** |
53 | * send a <string> throught usart0 |
53 | * send a <string> throught usart0 |
54 | */ |
54 | */ |
55 | void usart0_puts(char *s); |
55 | void usart0_puts(char *s); |
56 | 56 | ||
57 | /** |
57 | /** |
58 | * send a PGM<string> throught usart0 |
58 | * send a PGM<string> throught usart0 |
59 | */ |
59 | */ |
60 | void usart0_puts_pgm(const char* string); |
60 | void usart0_puts_pgm(const char* string); |
61 | 61 | ||
62 | 62 | ||
63 | /** |
63 | /** |
64 | * Decode the recevied Buffer |
64 | * Decode the recevied Buffer |
65 | * portions taken and adapted from |
65 | * portions taken and adapted from |
66 | * http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c |
66 | * http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c |
67 | */ |
67 | */ |
68 | void Decode64(void); |
68 | void Decode64(void); |
69 | 69 | ||
70 | 70 | ||
71 | /** |
71 | /** |
72 | * request Data through USART in special MK format by adding checksum and |
72 | * request Data through USART in special MK format by adding checksum and |
73 | * encode data in modified Base64 |
73 | * encode data in modified Base64 |
74 | * portions taken and adapted from |
74 | * portions taken and adapted from |
75 | * http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c |
75 | * http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c |
76 | */ |
76 | */ |
77 | void sendMKData(unsigned char, unsigned char, unsigned char*, unsigned char); |
77 | void sendMKData(unsigned char, unsigned char, unsigned char*, unsigned char); |
78 | 78 | ||
79 | /** |
79 | /** |
80 | * short script to directly send a request thorugh usart including en- and disabling it |
80 | * short script to directly send a request thorugh usart including en- and disabling it |
81 | * where <address> is the address of the receipient, <label> is which data set to request |
81 | * where <address> is the address of the receipient, <label> is which data set to request |
82 | * and <ms> represents the milliseconds delay between data |
82 | * and <ms> represents the milliseconds delay between data |
83 | */ |
83 | */ |
84 | void usart0_request_mk_data(uint8_t, char, uint8_t); |
84 | void usart0_request_mk_data(uint8_t, char, uint8_t); |
85 | 85 | ||
86 | 86 | ||
87 | #endif |
87 | #endif |
88 | 88 |