source: projects/magnetic-tape-show/wiring.h @ 87

Last change on this file since 87 was 87, checked in by sven, 6 years ago

Implementierung und Testen des Geraetes und neusten Spielplans im Musem am Di 10.09.2013.

File size: 3.6 KB
Line 
1/*
2 * wiring.h
3 *
4 * Created: 10.08.2013 13:55:53
5 *  Author: Sven
6 */ 
7
8
9#ifndef WIRING_H_
10#define WIRING_H_
11
12#define __AVR_ATmega644__       1
13/* Standard-8Mhz-Quarz des Boards */
14#define OSCSPEED        8000000UL               /* in Hz */
15#define F_CPU       OSCSPEED
16
17// Time scaling, 1 = Original
18#define SCALING  1.2
19
20#include "avr/io.h"
21#include "avr/interrupt.h"
22#include "util/delay.h"
23
24// code copied mostly from PTNG2013
25
26// 1. Pin Input Names
27
28// PIN A: Relais Output
29// PIN B: Button
30#define PINB_BUT    PINB4
31#define is_button()  (!( PINB & (1 << PINB_BUT) ))
32// PIN C: Relais Output
33// PIN D: No RS232
34
35// 2. Port Output Names
36
37// PORT A: Realais Output 1-8, sic
38#define RELAIS_01  PORTA0
39
40// PORTA1 und PORTA2 scheinen defekt zu sein, umgelegt auf PORTD2, PORTD3
41//#define RELAIS_02  PORTA1
42//#define RELAIS_03  PORTA2
43#define RELAIS_02  PORTD3
44#define RELAIS_03  PORTD4
45
46#define RELAIS_04  PORTA3
47#define RELAIS_05  PORTA4
48#define RELAIS_06  PORTA5
49#define RELAIS_07  PORTA6
50#define RELAIS_08  PORTA7
51// PORT B: LED
52#define PORTB_LED  PORTB0
53// PORT C: Relais Output 9-16, sic umverdrehung!
54#define RELAIS_09  PORTC7
55#define RELAIS_10  PORTC6
56#define RELAIS_11  PORTC5
57#define RELAIS_12  PORTC4
58#define RELAIS_13  PORTC3
59#define RELAIS_14  PORTC2
60#define RELAIS_15  PORTC1
61#define RELAIS_16  PORTC0
62// PORT D: No RS232
63
64// Relais zu daran angeschlossenen Geraete-Mapping:
65//Rel. 1-4 (+15)    TAPE1   (ON, FORWARD, REWIND, OFF, LP=LOAD-POINT, READ)
66//Rel. 5-8              TAPE2   (ebenso)
67//Rel. 9-14             Tape0   (pneumatisches Laufwerk)
68
69// C99..
70#define TRUE  1
71#define FALSE 0
72
73#define set_bit(PORTi, RELAISj, WERT) (\
74        (WERT == TRUE) ? \
75          (PORTi &= ~(1 << RELAISj)) : \
76          (PORTi |=  (1 << RELAISj))  )
77         
78// ON und OFF gehen immer in 1sec-Impulsen. Abkuerzen!
79
80#define  set_impuls(PORTi, RELAISj)  ({ \
81        set_bit(PORTi, RELAISj, TRUE); \
82        _delay_ms(1000 * SCALING); \
83        set_bit(PORTi, RELAISj, FALSE); \
84        })
85
86
87#define sound_on                        set_impuls(PORTC, RELAIS_16)
88
89#define tape1_on                        set_impuls(PORTA, RELAIS_01)
90#define tape1_on_set(v)     set_bit(PORTA, RELAIS_01, v)
91#define tape1_for(v)            set_bit(PORTD, RELAIS_02, v)
92#define tape1_rew                       set_impuls(PORTD, RELAIS_03)
93#define tape1_rew_set(v)        set_bit(PORTD, RELAIS_03, v)
94#define tape1_off                       set_impuls(PORTA, RELAIS_04)
95#define tape1_off_set(v)    set_bit(PORTA, RELAIS_04, v)
96#define tape1_read(v)           set_bit(PORTC, RELAIS_15, v)
97
98#define tape2_on                        set_impuls(PORTA, RELAIS_05)
99#define tape2_on_set(v)         set_bit(PORTA, RELAIS_05, v)
100#define tape2_for(v)            set_bit(PORTA, RELAIS_06, v)
101#define tape2_rew                       set_impuls(PORTA, RELAIS_07)
102#define tape2_rew_set(v)        set_bit(PORTA, RELAIS_07, v)
103#define tape2_off                       set_impuls(PORTA, RELAIS_08)
104#define tape2_off_set(v)        set_bit(PORTA, RELAIS_08, v)
105
106#define tape0_on                        set_impuls(PORTC, RELAIS_09)
107#define tape0_on_set(v)         set_bit(PORTC, RELAIS_09, v)
108#define tape0_for(v)            set_bit(PORTC, RELAIS_10, v)
109#define tape0_read(v)           set_bit(PORTC, RELAIS_11, v)
110#define tape0_rew                       set_impuls(PORTC, RELAIS_12)
111#define tape0_rew_set(v)        set_bit(PORTC, RELAIS_12, v)
112#define tape0_lp                        set_impuls(PORTC, RELAIS_13)
113#define tape0_lp_set(v)         set_bit(PORTC, RELAIS_13, v)
114#define tape0_off                       set_impuls(PORTC, RELAIS_14)
115#define tape0_off_set(v)        set_bit(PORTC, RELAIS_14, v)
116
117#define sound_start(v)          set_bit(PORTC, RELAIS_16, v)
118
119
120
121// sic! LED on Olimex devel board
122#define start_led()     ( PORTB &= ~(1 << PORTB_LED) )
123#define stop_led()      ( PORTB |= (1 << PORTB_LED) )
124#define is_led()        ( !(PINB & (1 << PINB0)) )
125#define toggle_led()    ( is_led() ? stop_led() : start_led() )
126
127
128
129#endif /* WIRING_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