keyboard: dynamically derive UBRR values from BAUDRATE

This commit is contained in:
Markus Koch 2019-10-26 22:38:51 +02:00
parent 9bed136cd5
commit 7479c9ed3f

View File

@ -12,7 +12,6 @@
#define DELAY_ROW_SWITCH() _delay_ms(1) //_delay_us(1)
#define BAUDRATE 9600
#define UBRR 51 // (F_CPU / BAUDRATE) / 32
/* Keycode from include/linux/input.h */
#define KEY_RESERVED 0
@ -259,8 +258,8 @@ int main()
MATRIX_Y1(PORT) &= ~MASK_Y1; /* Pull row low when selected */
MATRIX_Y2(PORT) &= ~MASK_Y2; /* Pull row low when selected */
UCSRB = (1 << TXEN);
UBRRH = (UBRR >> 8) & 0xFF;
UBRRL = UBRR & 0xFF;
UBRRH = ((((F_CPU / BAUDRATE) / 16) - 1) >> 8);
UBRRL = (((F_CPU / BAUDRATE) / 16) - 1);
fn_active = 0;