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

Last change on this file since 86 was 86, checked in by heribert-pc, 6 years ago

Spielplan korrigiert.

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