source: projects/punch-card/driver/documation-m200/src/protocol.h @ 56

Last change on this file since 56 was 56, checked in by sven-win, 14 years ago

AVR M200 Card Reader Controller Driver:

  • Improvements on Procotol implementation
  • Introduced cheap solution for uart concurrence - a simple one level fixed length buffer that is flushed after each main loop output.

-- sven @ netbook

File size: 2.5 KB
Line 
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
37enum 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
45int uart_transmit(char c, FILE* stream);
46int uart_transmit_main(char c, FILE* stream);
47
48// A char value as return value from uart_recieve
49#define NO_INPUT      0
50unsigned char uart_recieve();
51
52void print_bits(byte_t byte);
53
54void print_card();
55
56void 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
70void user_input_loop();
71
72#endif /* __M200_IO_H__ */
Note: See TracBrowser for help on using the repository browser.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License