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

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

Various code modifications at experimental setup with the printer.

File size: 3.5 KB
Line 
1/*
2 * ANELEX Interface Microcontroller
3 * Test program level
4 * Started: 28. August 2010, im Museum
5 * Codebase: Gamma10 test program level
6 *
7 */
8
9#include "wiring.h"
10#include "anelex.h"
11#include "toolchain.h"
12#include "frontend.h"
13#include "constants.h"
14
15
16static FILE output = FDEV_SETUP_STREAM(stdout_transmit, NULL, _FDEV_SETUP_WRITE);
17
18void Initialize()
19{
20        // negierte Ausgaenge schalten
21        PORTA = 0x00;
22        PORTB = 0x00; // LED (auslassen, an=0x01)
23        PORTC = 0x00;
24        PORTD = 0x00;
25
26        // DDRA: DATA-Anschluss von 0..5
27        DDRA = (1 << DDA0) | (1 << DDA1) | (1 << DDA2) | (1 << DDA3) | (1 << DDA4) | (1 << DDA5);
28        // DDRB: LED als output, CA ist input, IB2 ist input
29        DDRB = (1 << DDB0);
30        // DDRC: STROBE, CP, PRINTCM, RESET sind output, ERRORS input
31        DDRC = (1 << DDC0) | (1 << DDC1) | (1 << DDC2) | (1 << DDC3);
32        // DDRD: AI und KI sind Output, IB1, IB2 input, RTS input, CTS output
33        DDRD = (1 << DDD6) | (1 << DDD5) | (1 << DDD7);
34
35        // jetzt erst default values setzen
36        PORTC = (1 << PORTC0) | (1 << PORTC1) | (1 << PORTC2) | (1 << PORTC3);
37
38        // Pin Change Intterupts aufsetzen
39        // PCMSK*: Pin Change Masks (welche Pins tragen zum Intterupt bei)
40        // PORT C:
41          //PCMSK2 = (1 << PCINT16) | (1 << PCINT17) | (1 << PCINT18) | (1 << PCINT19);
42        // Pin Change Interrupt Control Register: PC Interrupt Enable for Port C
43          //PCICR = (1 << PCIE2);
44
45        // INTTERUPTS AUFSETZEN
46        EICRA = (1 << ISC20) | (1 << ISC21) // rising FLANKE von INT2 (CA = Load Cycle) erzeugt intterrupt
47                        | (1 << ISC11) | (1 << ISC10); // rising edge von INT1 (LINE READY) erzeugt intteruupt
48
49        EIMSK = (1 << INT2) | (1 << INT1); // interrupt fuer INT1,2 anschalten
50
51
52        // Interrupt enable
53        sei();
54}
55
56
57
58
59int main() {
60        start_led();
61
62        Initialize();
63        uart_init(38400);
64        stdout = &output;
65
66        // startwerte fuer strukturen:
67        line_state = LINE_FINISHED; // Startwert
68        input_line_end = CR;
69
70        _delay_ms(800);
71       
72        puts("ANELEX Interface Microcontroller  (c) 2010 Sven Koeppel");
73        puts("This program is part of the Bull Anelex Project at technikum29");
74        puts("Options: 1. Enter text to print. 2. Type ?help for available commands.");
75        puts("3. Press Button to print default text. 4. Obey RS232 hardware flow control.");
76        stop_led();
77
78       
79        for(;;) {
80                start_led();
81                readline();
82                stop_led();
83
84                // process user input
85                if(current_line[0] == '?') {
86                        exec_command();
87                        continue;
88                }
89
90                // if readline() went to fast:
91                while(line_state != LINE_FINISHED) {
92                        puts("Wait for printer finished...");
93                        _delay_ms(ANELEX_WAIT_PRINTER_FINISHED);
94                }
95
96                print_line(); // returns immediately
97
98                while(line_state == LINE_TRANSMITTING);
99                puts("accepting new line");
100        }
101
102        printf("End of main!\n");
103        return 0; // ende.
104}
105
106/*
107        byte_t y;
108        for(y=0;;y++) {
109                // warten, bis BUTTON gedrueckt ist
110                if(PINB & (1 << PORTB4)) {
111                        start_led();
112                        for(;;) {
113                                if((PINB & (1 << PORTB4)) == 0)
114                                        break;
115                        }
116                        printf("%d: Button gedrueckt\n", counter++);
117
118                        for(int zzz=0; zzz < 1; zzz++) {
119
120                        // hier koennen wir jetzt mal arbeiten
121                        // alle strings durchdrucken
122                        for(int s=0; tests[s][0]; s++) {
123                                current_string = tests[s];
124                                printf("%d. Drucke %s\n", s, current_string);
125
126                                print_line_feed();
127                                current_counter = 0;
128
129                                for(;;) {
130                                        if(current_counter == LINE_PRINTED) {
131                                                printf("Zeile fertig! :-)\n");
132                                                break;
133                                        }
134                                }
135
136                                stop_led();
137
138                        } // for tests
139
140                        } // mehrfachtests
141                } // for buton
142                //printf("%d: Sleeping...\n", counter);
143                //counter++;
144                //_delay_ms(10);
145                // endlosschleife
146        }
147
148        return 0;
149}
150*/
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