@@ -34,7 +34,7 @@ A5 PC5 PD5
34
34
35
35
#define PORTD_OFFSET 0
36
36
#define PORTB_OFFSET 8
37
- #define PORTC_OFFSET 16
37
+ #define PORTC_OFFSET 14
38
38
39
39
#undef PORTA
40
40
#undef PORTB
@@ -94,9 +94,9 @@ pinPort mapping[20] = {
94
94
/* * DDR Classes**/
95
95
class DDRClass {
96
96
public:
97
- DDRClass (uint8_t _offset):offset(_offset){}
97
+ DDRClass (uint8_t _offset, uint8_t _limit ):offset(_offset),limit(_limit ){}
98
98
DDRClass& operator =(int value){
99
- for (int i=0 ; i<6 ; i++) {
99
+ for (int i=0 ; i<limit ; i++) {
100
100
if (value & (1 << i)) {
101
101
mapping[i + offset].port ->DIR |= ( 1 << mapping[i + offset].pin );
102
102
} else {
@@ -106,19 +106,19 @@ class DDRClass {
106
106
return *this ;
107
107
}
108
108
private:
109
- uint8_t offset;
109
+ uint8_t offset, limit ;
110
110
};
111
111
112
- DDRClass DDRB (PORTB_OFFSET);
113
- DDRClass DDRC (PORTC_OFFSET);
114
- DDRClass DDRD (PORTD_OFFSET);
112
+ DDRClass DDRB (PORTB_OFFSET, 6 );
113
+ DDRClass DDRC (PORTC_OFFSET, 6 );
114
+ DDRClass DDRD (PORTD_OFFSET, 8 );
115
115
116
116
/* * PORT Classes**/
117
117
class PORTClass {
118
118
public:
119
- PORTClass (uint8_t _offset):offset(_offset){}
119
+ PORTClass (uint8_t _offset, uint8_t _limit ):offset(_offset),limit(_limit ){}
120
120
PORTClass& operator =(int value){
121
- for (int i=0 ; i<6 ; i++) {
121
+ for (int i=0 ; i<limit ; i++) {
122
122
if (value & (1 << i)) {
123
123
#ifdef COMPATIBILITY_DEBUG
124
124
printPortAndPin ((int ) mapping[i + offset].port , mapping[i + offset].pin , true );
@@ -134,9 +134,9 @@ class PORTClass {
134
134
return *this ;
135
135
}
136
136
private:
137
- uint8_t offset;
137
+ uint8_t offset, limit ;
138
138
};
139
139
140
- PORTClass PORTB (PORTB_OFFSET);
141
- PORTClass PORTC (PORTC_OFFSET);
142
- PORTClass PORTD (PORTD_OFFSET);
140
+ PORTClass PORTB (PORTB_OFFSET, 6 );
141
+ PORTClass PORTC (PORTC_OFFSET, 6 );
142
+ PORTClass PORTD (PORTD_OFFSET, 8 );
0 commit comments