1
0

Fix bug of col6 and pwm

This commit is contained in:
Kai Ryu 2014-04-25 00:05:25 +09:00
parent b53a8f959e
commit 0ed8af7b16
2 changed files with 11 additions and 11 deletions

View File

@ -32,21 +32,21 @@ void backlight_set(uint8_t level)
if (level > 0) { if (level > 0) {
// Turn on PWM // Turn on PWM
cli(); cli();
DDRB |= (1<<PB6); DDRB |= (1<<PB7);
TCCR1A |= ( (1<<WGM10) | (1<<COM1B1) ); TCCR1A |= ( (1<<WGM10) | (1<<COM1C1) );
TCCR1B |= ( (1<<CS11) | (1<<CS10) ); TCCR1B |= ( (1<<CS11) | (1<<CS10) );
sei(); sei();
// Set PWM // Set PWM
OCR1B = pgm_read_byte(&backlight_table[level]); OCR1C = pgm_read_byte(&backlight_table[level]);
} }
else { else {
// Turn off PWM // Turn off PWM
cli(); cli();
DDRB &= ~(1<<PB6); DDRB &= ~(1<<PB7);
TCCR1A &= ~( (1<<WGM10) | (1<<COM1B1) ); TCCR1A &= ~( (1<<WGM10) | (1<<COM1C1) );
TCCR1B &= ~( (1<<CS11) | (1<<CS10) ); TCCR1B &= ~( (1<<CS11) | (1<<CS10) );
sei(); sei();
// Set PWM // Set PWM
OCR1B = 0; OCR1C = 0;
} }
} }

View File

@ -139,7 +139,7 @@ uint8_t matrix_key_count(void)
} }
/* Column pin configuration /* Column pin configuration
* pin: F7 F1 F0 E6 D7 D6 D4 C7 C6 B7 B5 B4 B3 B1 B0 * pin: F7 F1 F0 E6 D7 D6 D4 C7 C6 B6 B5 B4 B3 B1 B0
*/ */
static void init_cols(void) static void init_cols(void)
{ {
@ -152,13 +152,13 @@ static void init_cols(void)
PORTD |= (1<<PD7 | 1<<PD6 | 1<<PD4); PORTD |= (1<<PD7 | 1<<PD6 | 1<<PD4);
DDRC &= ~(1<<PC7 | 1<<PC6); DDRC &= ~(1<<PC7 | 1<<PC6);
PORTC |= (1<<PC7 | 1<<PC6); PORTC |= (1<<PC7 | 1<<PC6);
DDRB &= ~(1<<PB7 | 1<<PB5 | 1<<PB4 | 1<<PB3 | 1<<PB1 | 1<<PB0); DDRB &= ~(1<<PB6 | 1<<PB5 | 1<<PB4 | 1<<PB3 | 1<<PB1 | 1<<PB0);
PORTB |= (1<<PB7 | 1<<PB5 | 1<<PB4 | 1<<PB3 | 1<<PB1 | 1<<PB0); PORTB |= (1<<PB6 | 1<<PB5 | 1<<PB4 | 1<<PB3 | 1<<PB1 | 1<<PB0);
} }
/* Column pin configuration /* Column pin configuration
* col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 * col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
* pin: F0 F1 E6 C7 C6 B7 D4 B1 B0 B5 B4 D7 D6 B3 F7 * pin: F0 F1 E6 C7 C6 B6 D4 B1 B0 B5 B4 D7 D6 B3 F7
*/ */
static matrix_row_t read_cols(void) static matrix_row_t read_cols(void)
{ {
@ -167,7 +167,7 @@ static matrix_row_t read_cols(void)
(PINE&(1<<PE6) ? 0 : (1<<2)) | (PINE&(1<<PE6) ? 0 : (1<<2)) |
(PINC&(1<<PC7) ? 0 : (1<<3)) | (PINC&(1<<PC7) ? 0 : (1<<3)) |
(PINC&(1<<PC6) ? 0 : (1<<4)) | (PINC&(1<<PC6) ? 0 : (1<<4)) |
(PINB&(1<<PB7) ? 0 : (1<<5)) | (PINB&(1<<PB6) ? 0 : (1<<5)) |
(PIND&(1<<PD4) ? 0 : (1<<6)) | (PIND&(1<<PD4) ? 0 : (1<<6)) |
(PINB&(1<<PB1) ? 0 : (1<<7)) | (PINB&(1<<PB1) ? 0 : (1<<7)) |
(PINB&(1<<PB0) ? 0 : (1<<8)) | (PINB&(1<<PB0) ? 0 : (1<<8)) |