source: projects/bull-anelex-project/trunk/anelex-interface/src/anelex.c @ 64

Last change on this file since 64 was 64, checked in by sven, 11 years ago

Various code modifications at experimental setup with the printer.

File size: 3.1 KB
Line 
1/**
2 * ANELEX PRINTER Interface Microcontroller
3 *
4 * anelex.c: All communication related routines to the anelex device.
5 *
6 * This file is part of the Bull Anelex Project
7 * Copyright (C) 2010, 2011 Sven Köppel, technikum29.de
8 *
9 * This program is free software; you can redistribute
10 * it and/or modify it under the terms of the GNU General
11 * Public License as published by the Free Software
12 * Foundation; either version 3 of the License, or (at
13 * your option) any later version.
14 *
15 * This program is distributed in the hope that it will
16 * be useful, but WITHOUT ANY WARRANTY; without even the
17 * implied warranty of MERCHANTABILITY or FITNESS FOR A
18 * PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
20 *
21 * You should have received a copy of the GNU General
22 * Public License along with this program; if not, see
23 * <http://www.gnu.org/licenses/>.
24 *
25 **/
26
27#include "toolchain.h"
28#include "anelex_code.h"
29#include "anelex.h"
30#include "constants.h"
31
32void print_line() {
33        // startup line printing
34        puts("Starting line transmission, waiting for CA");
35        current_line_cnt = 0;
36        print_line_feed();
37        line_state = LINE_TRANSMITTING;
38}
39
40
41void print_line_feed() {
42        // Lege Zeilenvorschub an (spaeter mal variabel)
43
44        // Experiment: RESET vor jedem Zeilenvorschub
45        // 18.02.11
46        /*
47        start_reset();
48        _delay_us(10);
49        stop_reset();
50        _delay_us(10);
51        */ 
52
53        set_data(0x01);
54        _delay_us(ANELEX_NEWLINE_WAIT);
55        start_strobe();
56        _delay_us(ANELEX_NEWLINE_LENGTH);
57        stop_strobe();
58}
59
60
61ISR(INT2_vect) {
62        // Communication Announcement steigende Flanke.
63        // je nach zustand
64        if(line_state != LINE_TRANSMITTING)
65                return;
66
67        uint8_t current_counter = current_line_cnt; // volatile lokal holen, spaeter unnoetig
68
69        if(current_counter < LINE_LENGTH) {
70                // aussage: Naechsetes Zeichen kann angelegt werden
71                char orig = current_line[ current_counter ];
72                if(orig) {
73                        // normales zeichen
74                        char transformed = anelex_code[ orig ];
75                        printf("%d: Zeichen %c, entspricht oktal %o\n", current_counter, orig, transformed);
76                        //printf("%d", current_counter, orig);
77                        putchar(orig);
78                        //_delay_us(100);
79                       
80                        // LEGE ZEICHEN AN:
81                        _delay_us(ANELEX_CHAR_WAIT);
82                        set_data(transformed);
83                        _delay_us(ANELEX_CHAR_STROBE_WAIT);
84                        start_strobe();
85                        _delay_us(ANELEX_CHAR_STROBE_LENGTH);
86                        stop_strobe();
87                        // jetzt bis zum naechsten Zeichen warten
88
89                        current_line_cnt++;
90                        return;
91                }
92        }
93
94        // Zeilenende erreicht (etwa durch \0 oder zu grossen current_counter,
95        // was nicht vorkommen sollte)
96        line_state = LINE_PRINTING;
97        set_data(0x01); // aufraeumen am DATENPORT
98        printf("Print Command\n");
99
100        start_printcmd();
101        _delay_us(ANELEX_PRINT_CMD_LENGTH);
102        stop_printcmd();
103        // warten auf auf das naechste CA.
104}
105
106ISR(INT1_vect) {
107        // Rising Edge von Line Ready = Zeile wird gedruckt!
108        if(line_state != LINE_PRINTING)
109                return;
110
111        printf("Zeile wird gedruckt...\n");
112        //puts("printing");
113        while(!is_ready()); // das ist jetzt ziemlicher ... quatsch
114        puts("line finished");
115        printf("Zeile fertig gedruckt\n");
116
117        line_state = LINE_FINISHED;
118}
119
120
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