1 | #ifndef __M200_IO_H__ |
---|
2 | #define __M200_IO_H__ |
---|
3 | |
---|
4 | /** |
---|
5 | * AVR M200 Punch card reader controller |
---|
6 | * PC Documation M200 uC Serial Communication Protocol |
---|
7 | * |
---|
8 | * The protocol.c file implements all the stdio.h stuff (USART input/output) |
---|
9 | * and the communication with the client (PC) as well as the main loop. |
---|
10 | * |
---|
11 | * This file is part of the Punched Paper Project - Punch Card Device Drivers |
---|
12 | * Copyright (C) 2009 Sven Koeppel |
---|
13 | * |
---|
14 | * This program is free software; you can redistribute it and/or |
---|
15 | * modify it under the terms of the GNU General Public License as |
---|
16 | * published by the Free Software Foundation; either version 3 of |
---|
17 | * the License, or (at your option) any later version. |
---|
18 | * |
---|
19 | * This program is distributed in the hope that it will be useful, |
---|
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
22 | * GNU General Public License for more details. |
---|
23 | * |
---|
24 | * You should have received a copy of the GNU General Public License |
---|
25 | * along with this program; if not, see |
---|
26 | * <http://www.gnu.org/licenses/>. |
---|
27 | **/ |
---|
28 | |
---|
29 | |
---|
30 | #include "pc-uc-protocol.h" |
---|
31 | #include "punchcard.h" |
---|
32 | // #include "driver.h" |
---|
33 | |
---|
34 | #include <stdio.h> |
---|
35 | |
---|
36 | // Modeling the format to be used for output |
---|
37 | enum format_t { |
---|
38 | HEX = M200_CLIENT_HEX, |
---|
39 | DEBUG = M200_CLIENT_DEBUG, |
---|
40 | BINARY = M200_CLIENT_BINARY |
---|
41 | }; |
---|
42 | |
---|
43 | #define is_valid_format(f) ( f == HEX || f == DEBUG || f == BINARY ) |
---|
44 | |
---|
45 | int uart_transmit(char c, FILE* stream); |
---|
46 | int uart_transmit_main(char c, FILE* stream); |
---|
47 | |
---|
48 | // A char value as return value from uart_recieve |
---|
49 | #define NO_INPUT 0 |
---|
50 | unsigned char uart_recieve(); |
---|
51 | |
---|
52 | void print_bits(byte_t byte); |
---|
53 | |
---|
54 | void print_card(); |
---|
55 | |
---|
56 | void flush_concurrent_printing_buffer(); |
---|
57 | |
---|
58 | #define set_main_loop_printing(val) { status.main_loop_is_printing = val; if(!val) flush_concurrent_printing_buffer(); } |
---|
59 | #define main_loop_puts(arg) { set_main_loop_printing(TRUE); puts(arg); set_main_loop_printing(FALSE); } |
---|
60 | #define main_loop_puts_P(arg) { set_main_loop_printing(TRUE); puts_P(arg); set_main_loop_printing(FALSE); } |
---|
61 | #define main_loop_printf(arg...) { set_main_loop_printing(TRUE); printf(arg); set_main_loop_printing(FALSE); } |
---|
62 | |
---|
63 | |
---|
64 | #define info_puts(arg) fputs(arg, stderr) |
---|
65 | #define info_puts_P(arg) fputs_P(arg, stderr) |
---|
66 | #define info_printf(arg...) fprintf(stderr, arg) |
---|
67 | #define dprintf(arg...) { if(status.debug_output) { fprintf(stderr, "400 "); fprintf(stderr, arg); fputs("", stderr); } } |
---|
68 | #define fatal_printf(arg...) { fprintf(stderr, "900"); fprintf(stderr, arg); fputs("", stderr); } |
---|
69 | |
---|
70 | void user_input_loop(); |
---|
71 | |
---|
72 | #endif /* __M200_IO_H__ */ |
---|