Subversion Repositories Projects

Rev

Rev 728 | Rev 761 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 728 Rev 738
Line 81... Line 81...
81
}
81
}
Line 82... Line 82...
82
 
82
 
83
/**
83
/**
84
 * send a <string> throught usart1
84
 * send a <string> throught usart1
85
 */
85
 */
86
void usart1_puts(char *s) {
86
/*void usart1_puts(char *s) {
87
    while (*s) {
87
    while (*s) {
88
        usart1_putc(*s);
88
        usart1_putc(*s);
89
        s++;
89
        s++;
-
 
90
    }
-
 
91
}*/
-
 
92
 
-
 
93
 
-
 
94
/**
-
 
95
 * send a PGM<string> throught usart1
-
 
96
 */
-
 
97
void usart1_puts_pgm(const char* string) {
-
 
98
        while (pgm_read_byte(string) != 0x00)
90
    }
99
                usart1_putc(pgm_read_byte(string++));
Line 91... Line 100...
91
}
100
}
92
 
101
 
93
/**
102
/**
94
 * transmit interrupt handler
103
 * transmit interrupt handler
Line 112... Line 121...
112
    static uint8_t c1 = 0;
121
    static uint8_t c1 = 0;
113
    static uint8_t c2 = 0;
122
    static uint8_t c2 = 0;
114
    static uint8_t usart_rx_ok = 0;
123
    static uint8_t usart_rx_ok = 0;
115
    uint8_t crc1, crc2;
124
    uint8_t crc1, crc2;
116
    // the rxd buffer is unlocked
125
    // the rxd buffer is unlocked
117
    if (usart_rx_ok == 0) {
126
    if (usart_rx_ok == 0) {
118
        if ((c2 == '#') && (c1 == 'b' || c1 == 'c') && (c == 'D' || c == 'V' || c == 'O')) {
127
                // if ((c2 == '#') && (c1 == 'b' || c1 == 'c') && (c == 'D' || c == 'V' || c == 'O')) {
-
 
128
        if ((c2 == '#') && (c1 == 'b' || c1 == 'c') &&
-
 
129
                        #if FCONLY
-
 
130
                                (c == 'V' || c == 'D')) { // version and debug
-
 
131
                        #else
-
 
132
                                (c == 'V' || c == 'O')) { // version and OSD
-
 
133
                        #endif
119
            usart_rx_ok = 1;
134
            usart_rx_ok = 1;
120
            rxd_buffer[ptr_rxd_buffer++] = c2;
135
            rxd_buffer[ptr_rxd_buffer++] = c2;
121
            crc = c2;
136
            crc = c2;
122
            rxd_buffer[ptr_rxd_buffer++] = c1;
137
            rxd_buffer[ptr_rxd_buffer++] = c1;
123
            crc += c1;
138
            crc += c1;
Line 202... Line 217...
202
 * request Data through USART in special MK format by adding checksum and
217
 * request Data through USART in special MK format by adding checksum and
203
 * encode data in modified Base64
218
 * encode data in modified Base64
204
 * portions taken and adapted from
219
 * portions taken and adapted from
205
 * http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c
220
 * http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c
206
 */
221
 */
207
void sendMKData(unsigned char cmd, unsigned char addr, unsigned char *snd, unsigned char len) {
222
/*void sendMKData(unsigned char cmd, unsigned char addr, unsigned char *snd, unsigned char len) {
208
    unsigned int pt = 0;
223
    unsigned int pt = 0;
209
    unsigned char a, b, c;
224
    unsigned char a, b, c;
210
    unsigned char ptr = 0;
225
    unsigned char ptr = 0;
Line 211... Line 226...
211
 
226
 
Line 240... Line 255...
240
    txd_buffer[i++] = '=' + tmpCRC / 64;
255
    txd_buffer[i++] = '=' + tmpCRC / 64;
241
    txd_buffer[i++] = '=' + tmpCRC % 64;
256
    txd_buffer[i++] = '=' + tmpCRC % 64;
242
    txd_buffer[i++] = '\r';
257
    txd_buffer[i++] = '\r';
Line 243... Line 258...
243
 
258
 
244
    usart1_puts((char*) txd_buffer);
259
    usart1_puts((char*) txd_buffer);
Line 245... Line 260...
245
}
260
}*/
246
 
261
 
247
/**
262
/**
248
 * short script to directly send a request thorugh usart including en- and disabling it
263
 * short script to directly send a request thorugh usart including en- and disabling it
249
 * where <address> is the address of the receipient, <label> is which data set to request
264
 * where <address> is the address of the receipient, <label> is which data set to request
250
 * and <ms> represents the milliseconds delay between data
265
 * and <ms> represents the milliseconds delay between data
251
 */
266
 */
252
void usart1_request_mk_data(uint8_t address, char label, uint8_t ms) {
267
/*void usart1_request_mk_data(uint8_t address, char label, uint8_t ms) {
Line 253... Line 268...
253
    // re-enable TXD pin
268
    // re-enable TXD pin
254
    usart1_EnableTXD();
269
    usart1_EnableTXD();
255
 
270
 
256
    unsigned char mstenth = ms / 10;
271
    unsigned char mstenth = ms / 10;
257
    sendMKData(label, address, &mstenth, 1);
272
    sendMKData(label, address, &mstenth, 1);
258
    // wait until UDR ready
273
    // wait until UDR ready
259
    while (!(UCSR1A & (1 << UDRE1)));
274
    while (!(UCSR1A & (1 << UDRE1)));
Line 260... Line 275...
260
    // disable TXD pin again
275
    // disable TXD pin again