Details | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 29 | jimmy | 1 | /****************************************************************************** |
| 2 | * Copyright (C) 2005 Martin THOMAS, Kaiserslautern, Germany |
||
| 3 | * <eversmith@heizung-thomas.de> |
||
| 4 | * http://www.siwawi.arubi.uni-kl.de/avr_projects |
||
| 5 | ***************************************************************************** |
||
| 6 | * |
||
| 7 | * File : termio.c |
||
| 8 | * Version : 0.9 |
||
| 9 | * |
||
| 10 | * Summary : Terminal Input/Output-Functions |
||
| 11 | * |
||
| 12 | *****************************************************************************/ |
||
| 13 | |||
| 14 | #include <avr/io.h> |
||
| 15 | #include <avr/pgmspace.h> |
||
| 16 | #include <avr/interrupt.h> |
||
| 17 | |||
| 18 | #include <inttypes.h> |
||
| 19 | #include <stdlib.h> |
||
| 20 | |||
| 21 | #include "termio.h" |
||
| 22 | #include "uart.h" |
||
| 23 | |||
| 24 | #define putc_loc uart_putc |
||
| 25 | |||
| 26 | unsigned char term_timeout_flag; |
||
| 27 | |||
| 28 | void putc_cr(char c) |
||
| 29 | { |
||
| 30 | if (c == '\n') putc_loc('\r'); |
||
| 31 | putc_loc(c); |
||
| 32 | } |
||
| 33 | |||
| 34 | void term_putc(const char c) |
||
| 35 | { |
||
| 36 | putc_loc(c); |
||
| 37 | } |
||
| 38 | |||
| 39 | uint16_t term_getc() |
||
| 40 | { |
||
| 41 | // uint16_t res; |
||
| 42 | |||
| 43 | /* TODO - timeout */ |
||
| 44 | |||
| 45 | return uart_getc(); |
||
| 46 | |||
| 47 | |||
| 48 | } |
||
| 49 | |||
| 50 | void term_put_cr(void) |
||
| 51 | { |
||
| 52 | putc_cr('\n'); |
||
| 53 | } |
||
| 54 | |||
| 55 | void term_puts(const char* tx_data) |
||
| 56 | { |
||
| 57 | char c; |
||
| 58 | while( (c=*tx_data++) ) putc_cr(c); |
||
| 59 | } |
||
| 60 | |||
| 61 | void term_puts_p(const char *progmem_tx_data) |
||
| 62 | { |
||
| 63 | uint8_t c=0; |
||
| 64 | // uint8_t sreg; |
||
| 65 | |||
| 66 | // sreg=SREG; |
||
| 67 | // cli(); |
||
| 68 | while( (c=pgm_read_byte(progmem_tx_data++)) ) putc_cr(c); |
||
| 69 | // SREG=sreg; |
||
| 70 | } |
||
| 71 | |||
| 72 | void term_puti(const int num) |
||
| 73 | { |
||
| 74 | char buffer[8 * sizeof (int) + 1]; |
||
| 75 | itoa(num,buffer,10); |
||
| 76 | term_puts(buffer); |
||
| 77 | } |
||
| 78 | |||
| 79 | void term_puthex_byte(const uint8_t val) |
||
| 80 | { |
||
| 81 | uart_puthex_byte(val); |
||
| 82 | } |
||
| 83 | |||
| 84 | void term_putbin_byte(const uint8_t val) |
||
| 85 | { |
||
| 86 | uart_putbin_byte(val); |
||
| 87 | } |
||
| 88 |