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

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

Wiring/PSeudosprache fertiggeschrieben.

File size: 2.9 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#define RELAIS_02  PORTA1
37#define RELAIS_03  PORTA2
38#define RELAIS_04  PORTA3
39#define RELAIS_05  PORTA4
40#define RELAIS_06  PORTA5
41#define RELAIS_07  PORTA6
42#define RELAIS_08  PORTA7
43// PORT B: LED
44#define PORTB_LED  PORTB0
45// PORT C: Relais Output 9-16, sic umverdrehung!
46#define RELAIS_09  PORTC7
47#define RELAIS_10  PORTC6
48#define RELAIS_11  PORTC5
49#define RELAIS_12  PORTC4
50#define RELAIS_13  PORTC3
51#define RELAIS_14  PORTC2
52#define RELAIS_15  PORTC1
53#define RELAIS_16  PORTC0
54// PORT D: No RS232
55
56// Relais zu daran angeschlossenen Geraete-Mapping:
57//Rel. 1-4 (+15)    TAPE1   (ON, FORWARD, REWIND, OFF, LP=LOAD-POINT, READ)
58//Rel. 5-8              TAPE2   (ebenso)
59//Rel. 9-14             Tape0   (pneumatisches Laufwerk)
60
61// C99..
62#define TRUE  1
63#define FALSE 0
64
65#define set_bit(PORTi, RELAISj, WERT) (\
66        (WERT == TRUE) ? \
67          (PORTi &= ~(1 << RELAISj)) : \
68          (PORTi |=  (1 << RELAISj))  )
69         
70// ON und OFF gehen immer in 1sec-Impulsen. Abkuerzen!
71
72#define  set_impuls(PORTi, RELAISj)  ({ \
73        set_bit(PORTi, RELAISj, TRUE); \
74        _delay_ms(1000); \
75        set_bit(PORTi, RELAISj, FALSE); \
76        })
77
78
79#define tape1_on()                      set_impuls(PORTA, RELAIS_01)
80#define tape1_for(v)            set_bit(PORTA, RELAIS_02, v)
81#define tape1_rew(v)            set_bit(PORTA, RELAIS_03, v)
82#define tape1_off()                     set_impuls(PORTA, RELAIS_04)
83#define tape1_read(v)           set_bit(PORTA, RELAIS_15, v)
84
85#define tape2_on()                      set_impuls(PORTA, RELAIS_05)
86#define tape2_for(v)            set_bit(PORTA, RELAIS_06, v)
87#define tape2_rew(v)            set_bit(PORTA, RELAIS_07, v)
88#define tape2_off()                     set_impuls(PORTA, RELAIS_08)
89
90#define tape0_on()                      set_impuls(PORTC, RELAIS_09)
91#define tape0_for(v)            set_bit(PORTC, RELAIS_10, v)
92#define tape0_read(v)           set_bit(PORTC, RELAIS_11, v)
93#define tape0_rew(v)            set_bit(PORTC, RELAIS_12, v)
94#define tape0_lp(v)                     set_bit(PORTC, RELAIS_13, v)
95#define tape0_off()                     set_impuls(PORTC, RELAIS_14)
96
97#define sound_start(v)          set_bit(PORTC, RELAIS_16, v)
98
99
100
101// sic! LED on Olimex devel board
102#define start_led()     ( PORTB &= ~(1 << PORTB_LED) )
103#define stop_led()      ( PORTB |= (1 << PORTB_LED) )
104#define is_led()        ( !(PINB & (1 << PINB0)) )
105#define toggle_led()    ( is_led() ? stop_led() : start_led() )
106
107
108
109#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