1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
/*
* Copyright (c) 2009 Embedded Projects (http://www.embedded-projects.net)
* Author: Benedikt Sauter <sauter@embedded-projects.net>
* All rights reserved.
*
* Short descripton of file:
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the FH Augsburg nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES{} LOSS OF USE,
* DATA, OR PROFITS{} OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <inttypes.h>
#include <avr/io.h>
#include "pin.h"
char pin_get_conf(uint8_t i, pin_conf *p)
{
switch(i)
{
case 3: p->ox_port = &PORTC; p->ox_pin = &PINC; p->ox_ddr = &DDRC; p->ox_p = PC0; break;
case 4: p->ox_port = &PORTC; p->ox_pin = &PINC; p->ox_ddr = &DDRC; p->ox_p = PC1; break;
case 5: p->ox_port = &PORTC; p->ox_pin = &PINC; p->ox_ddr = &DDRC; p->ox_p = PC2; break;
case 6: p->ox_port = &PORTC; p->ox_pin = &PINC; p->ox_ddr = &DDRC; p->ox_p = PC3; break;
case 7: p->ox_port = &PORTC; p->ox_pin = &PINC; p->ox_ddr = &DDRC; p->ox_p = PC4; break;
case 8: p->ox_port = &PORTC; p->ox_pin = &PINC; p->ox_ddr = &DDRC; p->ox_p = PC5; break;
case 9: p->ox_port = &PORTC; p->ox_pin = &PINC; p->ox_ddr = &DDRC; p->ox_p = PC6; break;
case 10: p->ox_port = &PORTF; p->ox_pin = &PINF; p->ox_ddr = &DDRF; p->ox_p = PF7; break;
case 11: p->ox_port = &PORTF; p->ox_pin = &PINF; p->ox_ddr = &DDRF; p->ox_p = PF6; break;
case 12: p->ox_port = &PORTF; p->ox_pin = &PINF; p->ox_ddr = &DDRF; p->ox_p = PF5; break;
case 13: p->ox_port = &PORTF; p->ox_pin = &PINF; p->ox_ddr = &DDRF; p->ox_p = PF4; break;
case 14: p->ox_port = &PORTF; p->ox_pin = &PINF; p->ox_ddr = &DDRF; p->ox_p = PF3; break;
case 15: p->ox_port = &PORTF; p->ox_pin = &PINF; p->ox_ddr = &DDRF; p->ox_p = PF2; break;
case 16: p->ox_port = &PORTF; p->ox_pin = &PINF; p->ox_ddr = &DDRF; p->ox_p = PF1; break;
case 17: p->ox_port = &PORTF; p->ox_pin = &PINF; p->ox_ddr = &DDRF; p->ox_p = PF0; break;
case 18: p->ox_port = &PORTE; p->ox_pin = &PINE; p->ox_ddr = &DDRE; p->ox_p = PE0; break;
case 19: p->ox_port = &PORTE; p->ox_pin = &PINE; p->ox_ddr = &DDRE; p->ox_p = PE1; break;
case 20: p->ox_port = &PORTE; p->ox_pin = &PINE; p->ox_ddr = &DDRE; p->ox_p = PE2; break;
case 21: p->ox_port = &PORTE; p->ox_pin = &PINE; p->ox_ddr = &DDRE; p->ox_p = PE3; break;
case 22: p->ox_port = &PORTE; p->ox_pin = &PINE; p->ox_ddr = &DDRE; p->ox_p = PE5; break;
case 23: p->ox_port = &PORTE; p->ox_pin = &PINE; p->ox_ddr = &DDRE; p->ox_p = PE6; break;
case 24: p->ox_port = &PORTE; p->ox_pin = &PINE; p->ox_ddr = &DDRE; p->ox_p = PE7; break;
case 25: p->ox_port = &PORTB; p->ox_pin = &PINB; p->ox_ddr = &DDRB; p->ox_p = PB0; break;
case 26: p->ox_port = &PORTB; p->ox_pin = &PINB; p->ox_ddr = &DDRB; p->ox_p = PB1; break;
case 27: p->ox_port = &PORTB; p->ox_pin = &PINB; p->ox_ddr = &DDRB; p->ox_p = PB2; break;
case 28: p->ox_port = &PORTB; p->ox_pin = &PINB; p->ox_ddr = &DDRB; p->ox_p = PB3; break;
case 29: p->ox_port = &PORTB; p->ox_pin = &PINB; p->ox_ddr = &DDRB; p->ox_p = PB4; break;
case 30: p->ox_port = &PORTB; p->ox_pin = &PINB; p->ox_ddr = &DDRB; p->ox_p = PB5; break;
case 31: p->ox_port = &PORTB; p->ox_pin = &PINB; p->ox_ddr = &DDRB; p->ox_p = PB6; break;
case 32: p->ox_port = &PORTB; p->ox_pin = &PINB; p->ox_ddr = &DDRB; p->ox_p = PB7; break;
case 33: p->ox_port = &PORTD; p->ox_pin = &PIND; p->ox_ddr = &DDRD; p->ox_p = PD0; break;
case 34: p->ox_port = &PORTD; p->ox_pin = &PIND; p->ox_ddr = &DDRD; p->ox_p = PD1; break;
case 35: p->ox_port = &PORTD; p->ox_pin = &PIND; p->ox_ddr = &DDRD; p->ox_p = PD2; break;
case 36: p->ox_port = &PORTD; p->ox_pin = &PIND; p->ox_ddr = &DDRD; p->ox_p = PD3; break;
case 37: p->ox_port = &PORTD; p->ox_pin = &PIND; p->ox_ddr = &DDRD; p->ox_p = PD4; break;
case 38: p->ox_port = &PORTD; p->ox_pin = &PIND; p->ox_ddr = &DDRD; p->ox_p = PD5; break;
case 39: p->ox_port = &PORTD; p->ox_pin = &PIND; p->ox_ddr = &DDRD; p->ox_p = PD6; break;
case 40: p->ox_port = &PORTD; p->ox_pin = &PIND; p->ox_ddr = &DDRD; p->ox_p = PD7; break;
default: return 0;
}
return 1;
}
|