diff --git a/keyboards/40percentclub/ut47/config.h b/keyboards/40percentclub/ut47/config.h index 197d6cd181b..9622f58bb32 100644 --- a/keyboards/40percentclub/ut47/config.h +++ b/keyboards/40percentclub/ut47/config.h @@ -54,25 +54,3 @@ along with this program. If not, see . /* Enable GNAP matrix serial output */ #define GNAP_ENABLE - -/* USART configuration */ -#ifdef __AVR_ATmega32U4__ -# define SERIAL_UART_BAUD 9600 -# define SERIAL_UART_DATA UDR1 -# define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -# define SERIAL_UART_RXD_VECT USART1_RX_vect -# define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) -# define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX */ \ - UCSR1B = _BV(TXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ - sei(); \ - } while(0) -# else -# error "USART configuration is needed." -#endif diff --git a/keyboards/centromere/centromere.c b/keyboards/centromere/centromere.c index 8800e2ce6ad..269c60fd750 100644 --- a/keyboards/centromere/centromere.c +++ b/keyboards/centromere/centromere.c @@ -1,9 +1,5 @@ #include "centromere.h" -void uart_init(void) { - SERIAL_UART_INIT(); -} - void led_init(void) { #if MCU == atmega32u2 setPinOutput(C4); // Set red LED pin as output @@ -32,7 +28,6 @@ void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up matrix_init_user(); - uart_init(); led_init(); } diff --git a/keyboards/centromere/config.h b/keyboards/centromere/config.h index 0a908f60f9c..e502e2534bc 100644 --- a/keyboards/centromere/config.h +++ b/keyboards/centromere/config.h @@ -59,17 +59,9 @@ along with this program. If not, see . //UART settings for communication with the RF microcontroller #define SERIAL_UART_BAUD 500000 -#define SERIAL_UART_DATA UDR1 -#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) #define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) -#define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX and RX */ \ - UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ - } while(0) +#define SERIAL_UART_INIT_CUSTOM \ + /* enable TX and RX */ \ + UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); diff --git a/keyboards/centromere/matrix.c b/keyboards/centromere/matrix.c index c5fc8db6ce9..5ca083b4350 100644 --- a/keyboards/centromere/matrix.c +++ b/keyboards/centromere/matrix.c @@ -26,6 +26,7 @@ along with this program. If not, see . #include "util.h" #include "matrix.h" #include "timer.h" +#include "protocol/serial.h" #if (MATRIX_COLS <= 8) # define print_matrix_header() print("\nr/c 01234567\n") @@ -79,12 +80,11 @@ uint8_t matrix_cols(void) { void matrix_init(void) { matrix_init_quantum(); + serial_init(); } uint8_t matrix_scan(void) { - SERIAL_UART_INIT(); - uint32_t timeout = 0; //the s character requests the RF remote slave to send the matrix information diff --git a/keyboards/centromere/rules.mk b/keyboards/centromere/rules.mk index f08f6e6ebd4..2469d244a64 100644 --- a/keyboards/centromere/rules.mk +++ b/keyboards/centromere/rules.mk @@ -31,14 +31,7 @@ MIDI_ENABLE = no # MIDI controls UNICODE_ENABLE = yes # Unicode BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -USB = /dev/ttyACM0 - -# upload: build -# $(CENTROMERE_UPLOAD_COMMAND) - -OPT_DEFS += -DCENTROMERE_PROMICRO - # # project specific files -SRC = matrix.c +SRC += matrix.c serial_uart.c LAYOUTS = split_3x5_3 split_3x6_3 diff --git a/keyboards/chimera_ergo/chimera_ergo.c b/keyboards/chimera_ergo/chimera_ergo.c index 29470f90805..47653c2e4b6 100644 --- a/keyboards/chimera_ergo/chimera_ergo.c +++ b/keyboards/chimera_ergo/chimera_ergo.c @@ -1,9 +1,5 @@ #include "chimera_ergo.h" -void uart_init(void) { - SERIAL_UART_INIT(); -} - void led_init(void) { DDRD |= (1<<1); PORTD |= (1<<1); @@ -16,16 +12,5 @@ void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up matrix_init_user(); - uart_init(); led_init(); } - -void matrix_scan_kb(void) { - // put your looping keyboard code here - // runs every cycle (a lot) - matrix_scan_user(); -} - -void led_set_kb(uint8_t usb_led) { - -} diff --git a/keyboards/chimera_ergo/config.h b/keyboards/chimera_ergo/config.h index 262f287a507..4021cdcd507 100644 --- a/keyboards/chimera_ergo/config.h +++ b/keyboards/chimera_ergo/config.h @@ -60,19 +60,11 @@ along with this program. If not, see . //UART settings for communication with the RF microcontroller #define SERIAL_UART_BAUD 1000000 -#define SERIAL_UART_DATA UDR1 -#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) #define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) -#define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX and RX */ \ - UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ - } while(0) +#define SERIAL_UART_INIT_CUSTOM \ + /* enable TX and RX */ \ + UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); #endif diff --git a/keyboards/chimera_ergo/matrix.c b/keyboards/chimera_ergo/matrix.c index d512a51d973..112b9a40d17 100644 --- a/keyboards/chimera_ergo/matrix.c +++ b/keyboards/chimera_ergo/matrix.c @@ -26,6 +26,7 @@ along with this program. If not, see . #include "util.h" #include "matrix.h" #include "timer.h" +#include "protocol/serial.h" #if (MATRIX_COLS <= 8) # define print_matrix_header() print("\nr/c 01234567\n") @@ -88,12 +89,11 @@ uint8_t matrix_cols(void) { void matrix_init(void) { matrix_init_quantum(); + serial_init(); } uint8_t matrix_scan(void) { - SERIAL_UART_INIT(); - uint32_t timeout = 0; //the s character requests the RF slave to send the matrix diff --git a/keyboards/chimera_ergo/rules.mk b/keyboards/chimera_ergo/rules.mk index f37d14107b7..01d5c3c70ce 100644 --- a/keyboards/chimera_ergo/rules.mk +++ b/keyboards/chimera_ergo/rules.mk @@ -28,12 +28,5 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA UNICODE_ENABLE = YES # Unicode # BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID - -OPT_DEFS += -DCHIMERA_ERGO_PROMICRO -CHIMERA_ERGO_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \ - avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB) - # # project specific files -SRC = matrix.c - -USB = /dev/ttyACM0 +SRC += matrix.c serial_uart.c diff --git a/keyboards/chimera_ls/chimera_ls.c b/keyboards/chimera_ls/chimera_ls.c index 588b02b2d15..f88e9a4f122 100644 --- a/keyboards/chimera_ls/chimera_ls.c +++ b/keyboards/chimera_ls/chimera_ls.c @@ -1,9 +1,5 @@ #include "chimera_ls.h" -void uart_init(void) { - SERIAL_UART_INIT(); -} - void led_init(void) { DDRD |= (1<<1); PORTD |= (1<<1); @@ -16,16 +12,5 @@ void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up matrix_init_user(); - uart_init(); led_init(); } - -void matrix_scan_kb(void) { - // put your looping keyboard code here - // runs every cycle (a lot) - matrix_scan_user(); -} - -void led_set_kb(uint8_t usb_led) { - -} diff --git a/keyboards/chimera_ls/config.h b/keyboards/chimera_ls/config.h index 87e9196095a..d9c14a3fce6 100644 --- a/keyboards/chimera_ls/config.h +++ b/keyboards/chimera_ls/config.h @@ -60,19 +60,11 @@ along with this program. If not, see . //UART settings for communication with the RF microcontroller #define SERIAL_UART_BAUD 1000000 -#define SERIAL_UART_DATA UDR1 -#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) #define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) -#define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX and RX */ \ - UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ - } while(0) +#define SERIAL_UART_INIT_CUSTOM \ + /* enable TX and RX */ \ + UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); #endif diff --git a/keyboards/chimera_ls/matrix.c b/keyboards/chimera_ls/matrix.c index 72fe4413704..7208d971e12 100644 --- a/keyboards/chimera_ls/matrix.c +++ b/keyboards/chimera_ls/matrix.c @@ -26,6 +26,7 @@ along with this program. If not, see . #include "util.h" #include "matrix.h" #include "timer.h" +#include "protocol/serial.h" #if (MATRIX_COLS <= 8) # define print_matrix_header() print("\nr/c 01234567\n") @@ -92,12 +93,11 @@ uint8_t matrix_cols(void) { void matrix_init(void) { matrix_init_quantum(); + serial_init(); } uint8_t matrix_scan(void) { - SERIAL_UART_INIT(); - uint32_t timeout = 0; //the s character requests the RF slave to send the matrix diff --git a/keyboards/chimera_ls/rules.mk b/keyboards/chimera_ls/rules.mk index 162e06aaf75..536e6053a16 100644 --- a/keyboards/chimera_ls/rules.mk +++ b/keyboards/chimera_ls/rules.mk @@ -28,14 +28,8 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA UNICODE_ENABLE = YES # Unicode # BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID -USB = /dev/ttyACM0 - -OPT_DEFS += -DCHIMERA_LS_PROMICRO -CHIMERA_LS_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \ - avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB) - # project specific files -SRC = matrix.c +SRC += matrix.c serial_uart.c LAYOUTS = ortho_4x12 diff --git a/keyboards/chimera_ortho/chimera_ortho.c b/keyboards/chimera_ortho/chimera_ortho.c index 2a602cf2f7c..2cdc3d9331d 100644 --- a/keyboards/chimera_ortho/chimera_ortho.c +++ b/keyboards/chimera_ortho/chimera_ortho.c @@ -1,9 +1,5 @@ #include "chimera_ortho.h" -void uart_init(void) { - SERIAL_UART_INIT(); -} - void led_init(void) { DDRD |= (1<<1); PORTD |= (1<<1); @@ -16,16 +12,5 @@ void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up matrix_init_user(); - uart_init(); led_init(); } - -void matrix_scan_kb(void) { - // put your looping keyboard code here - // runs every cycle (a lot) - matrix_scan_user(); -} - -void led_set_kb(uint8_t usb_led) { - -} diff --git a/keyboards/chimera_ortho/config.h b/keyboards/chimera_ortho/config.h index 4ce70e68ba3..b103589879a 100644 --- a/keyboards/chimera_ortho/config.h +++ b/keyboards/chimera_ortho/config.h @@ -60,19 +60,11 @@ along with this program. If not, see . //UART settings for communication with the RF microcontroller #define SERIAL_UART_BAUD 1000000 -#define SERIAL_UART_DATA UDR1 -#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) #define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) -#define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX and RX */ \ - UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ - } while(0) +#define SERIAL_UART_INIT_CUSTOM \ + /* enable TX and RX */ \ + UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); #endif diff --git a/keyboards/chimera_ortho/matrix.c b/keyboards/chimera_ortho/matrix.c index dc38ba74f86..eb2f18473ef 100644 --- a/keyboards/chimera_ortho/matrix.c +++ b/keyboards/chimera_ortho/matrix.c @@ -26,6 +26,7 @@ along with this program. If not, see . #include "util.h" #include "matrix.h" #include "timer.h" +#include "protocol/serial.h" #if (MATRIX_COLS <= 8) # define print_matrix_header() print("\nr/c 01234567\n") @@ -78,12 +79,11 @@ uint8_t matrix_cols(void) { void matrix_init(void) { matrix_init_quantum(); + serial_init(); } uint8_t matrix_scan(void) { - SERIAL_UART_INIT(); - uint32_t timeout = 0; //the s character requests the RF slave to send the matrix diff --git a/keyboards/chimera_ortho/rules.mk b/keyboards/chimera_ortho/rules.mk index bf341ab5dd0..e3bbaa39d41 100644 --- a/keyboards/chimera_ortho/rules.mk +++ b/keyboards/chimera_ortho/rules.mk @@ -28,11 +28,5 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA UNICODE_ENABLE = YES # Unicode # BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID -USB = /dev/ttyACM0 - -OPT_DEFS += -DCHIMERA_ORTHO_PROMICRO -CHIMERA_ORTHO_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \ - avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB) - # project specific files -SRC = matrix.c +SRC += matrix.c serial_uart.c diff --git a/keyboards/chimera_ortho_plus/chimera_ortho_plus.c b/keyboards/chimera_ortho_plus/chimera_ortho_plus.c index 1972f2a9c33..6d87ed7053f 100644 --- a/keyboards/chimera_ortho_plus/chimera_ortho_plus.c +++ b/keyboards/chimera_ortho_plus/chimera_ortho_plus.c @@ -1,9 +1,5 @@ #include "chimera_ortho_plus.h" -void uart_init(void) { - SERIAL_UART_INIT(); -} - void led_init(void) { setPinOutput(D1); setPinOutput(F4); @@ -18,6 +14,5 @@ void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up matrix_init_user(); - uart_init(); led_init(); } diff --git a/keyboards/chimera_ortho_plus/config.h b/keyboards/chimera_ortho_plus/config.h index e060e196aa9..4b12796e95b 100644 --- a/keyboards/chimera_ortho_plus/config.h +++ b/keyboards/chimera_ortho_plus/config.h @@ -59,17 +59,9 @@ along with this program. If not, see . //UART settings for communication with the RF microcontroller #define SERIAL_UART_BAUD 1000000 -#define SERIAL_UART_DATA UDR1 -#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) #define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) -#define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX and RX */ \ - UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ - } while(0) +#define SERIAL_UART_INIT_CUSTOM \ + /* enable TX and RX */ \ + UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); diff --git a/keyboards/chimera_ortho_plus/matrix.c b/keyboards/chimera_ortho_plus/matrix.c index ed6eac2b093..2bdc97991cf 100644 --- a/keyboards/chimera_ortho_plus/matrix.c +++ b/keyboards/chimera_ortho_plus/matrix.c @@ -26,6 +26,7 @@ along with this program. If not, see . #include "util.h" #include "matrix.h" #include "timer.h" +#include "protocol/serial.h" #if (MATRIX_COLS <= 8) # define print_matrix_header() print("\nr/c 01234567\n") @@ -78,12 +79,11 @@ uint8_t matrix_cols(void) { void matrix_init(void) { matrix_init_quantum(); + serial_init(); } uint8_t matrix_scan(void) { - SERIAL_UART_INIT(); - uint32_t timeout = 0; //the s character requests the RF slave to send the matrix diff --git a/keyboards/chimera_ortho_plus/rules.mk b/keyboards/chimera_ortho_plus/rules.mk index 2dd6c3e1f04..fec1bef7308 100644 --- a/keyboards/chimera_ortho_plus/rules.mk +++ b/keyboards/chimera_ortho_plus/rules.mk @@ -33,4 +33,4 @@ UNICODE_ENABLE = yes CUSTOM_MATRIX = yes # project specific files -SRC = matrix.c +SRC += matrix.c serial_uart.c diff --git a/keyboards/comet46/comet46.c b/keyboards/comet46/comet46.c index 0710b8e330d..7c7edba93e1 100644 --- a/keyboards/comet46/comet46.c +++ b/keyboards/comet46/comet46.c @@ -1,22 +1 @@ #include "comet46.h" - -void uart_init(void) { - SERIAL_UART_INIT(); -} - -void matrix_init_kb(void) { - // put your keyboard start-up code here - // runs once when the firmware starts up - matrix_init_user(); - uart_init(); -} - -void matrix_scan_kb(void) { - // put your looping keyboard code here - // runs every cycle (a lot) - matrix_scan_user(); -} - -void led_set_kb(uint8_t usb_led) { - -} diff --git a/keyboards/comet46/config.h b/keyboards/comet46/config.h index d50224eb60f..5ae026f9238 100644 --- a/keyboards/comet46/config.h +++ b/keyboards/comet46/config.h @@ -66,19 +66,11 @@ along with this program. If not, see . //UART settings for communication with the RF microcontroller #define SERIAL_UART_BAUD 1000000 -#define SERIAL_UART_DATA UDR1 -#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) #define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) -#define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX and RX */ \ - UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ - } while(0) +#define SERIAL_UART_INIT_CUSTOM \ + /* enable TX and RX */ \ + UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); #endif diff --git a/keyboards/comet46/matrix.c b/keyboards/comet46/matrix.c index dc38ba74f86..eb2f18473ef 100644 --- a/keyboards/comet46/matrix.c +++ b/keyboards/comet46/matrix.c @@ -26,6 +26,7 @@ along with this program. If not, see . #include "util.h" #include "matrix.h" #include "timer.h" +#include "protocol/serial.h" #if (MATRIX_COLS <= 8) # define print_matrix_header() print("\nr/c 01234567\n") @@ -78,12 +79,11 @@ uint8_t matrix_cols(void) { void matrix_init(void) { matrix_init_quantum(); + serial_init(); } uint8_t matrix_scan(void) { - SERIAL_UART_INIT(); - uint32_t timeout = 0; //the s character requests the RF slave to send the matrix diff --git a/keyboards/comet46/rules.mk b/keyboards/comet46/rules.mk index 2aaa5483c80..1f22b7535eb 100644 --- a/keyboards/comet46/rules.mk +++ b/keyboards/comet46/rules.mk @@ -28,8 +28,8 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA UNICODE_ENABLE = YES # Unicode # BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID -USB = /dev/ttyACM0 # project specific files SRC += matrix.c \ i2c.c \ - ssd1306.c + ssd1306.c \ + serial_uart.c diff --git a/keyboards/dichotomy/config.h b/keyboards/dichotomy/config.h index 05210198c8b..0cdaf776b46 100644 --- a/keyboards/dichotomy/config.h +++ b/keyboards/dichotomy/config.h @@ -60,19 +60,11 @@ along with this program. If not, see . //UART settings for communication with the RF microcontroller #define SERIAL_UART_BAUD 1000000 -#define SERIAL_UART_DATA UDR1 -#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) #define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) -#define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX and RX */ \ - UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ - } while(0) +#define SERIAL_UART_INIT_CUSTOM \ + /* enable TX and RX */ \ + UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); #endif diff --git a/keyboards/dichotomy/dichotomy.c b/keyboards/dichotomy/dichotomy.c index b94030a3763..967d7e603ce 100755 --- a/keyboards/dichotomy/dichotomy.c +++ b/keyboards/dichotomy/dichotomy.c @@ -1,12 +1,7 @@ #include "dichotomy.h" -void uart_init(void) { - SERIAL_UART_INIT(); -} - void pointing_device_task(void){ /*report_mouse_t currentReport = {}; - SERIAL_UART_INIT(); uint32_t timeout = 0; //the m character requests the RF slave to send the mouse report @@ -77,16 +72,5 @@ void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up matrix_init_user(); - uart_init(); led_init(); } - -void matrix_scan_kb(void) { - // put your looping keyboard code here - // runs every cycle (a lot) - matrix_scan_user(); -} - -void led_set_kb(uint8_t usb_led) { - -} diff --git a/keyboards/dichotomy/matrix.c b/keyboards/dichotomy/matrix.c index d93889e6ad4..2400753cc1e 100755 --- a/keyboards/dichotomy/matrix.c +++ b/keyboards/dichotomy/matrix.c @@ -29,6 +29,7 @@ along with this program. If not, see . #include "dichotomy.h" #include "pointing_device.h" #include "report.h" +#include "protocol/serial.h" #if (MATRIX_COLS <= 8) # define print_matrix_header() print("\nr/c 01234567\n") @@ -93,11 +94,11 @@ uint8_t matrix_cols(void) { void matrix_init(void) { matrix_init_quantum(); + serial_init(); } uint8_t matrix_scan(void) { - SERIAL_UART_INIT(); //xprintf("\r\nTRYING TO SCAN"); uint32_t timeout = 0; diff --git a/keyboards/dichotomy/rules.mk b/keyboards/dichotomy/rules.mk index 14dc4743591..d6f98125eed 100755 --- a/keyboards/dichotomy/rules.mk +++ b/keyboards/dichotomy/rules.mk @@ -29,14 +29,5 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA UNICODE_ENABLE = YES # Unicode # BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID -USB = /dev/ttyACM0 - -OPT_DEFS += -DDICHOTOMY_PROMICRO -DICHOTOMY_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \ - avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB) - # # project specific files -SRC = matrix.c - -#upload: build -# $(DICHOTOMY_UPLOAD_COMMAND) +SRC += matrix.c serial_uart.c diff --git a/keyboards/hhkb/ansi/config.h b/keyboards/hhkb/ansi/config.h index 5e4fece17df..78fe0c47aeb 100644 --- a/keyboards/hhkb/ansi/config.h +++ b/keyboards/hhkb/ansi/config.h @@ -52,27 +52,20 @@ along with this program. If not, see . #define SUART_IN_PIN PIND #define SUART_IN_BIT 1 -#ifdef __AVR_ATmega32U4__ - #define SERIAL_UART_BAUD 115200 - #define SERIAL_UART_DATA UDR1 - #define SERIAL_UART_UBRR ((F_CPU/(16.0*SERIAL_UART_BAUD)-1+0.5)) - #define SERIAL_UART_RXD_VECT USART1_RX_vect - #define SERIAL_UART_TXD_READY (UCSR1A&(1<>8); /* baud rate */ \ - UCSR1B |= (1<. #define SUART_IN_PIN PIND #define SUART_IN_BIT 1 -#ifdef __AVR_ATmega32U4__ - #define SERIAL_UART_BAUD 115200 - #define SERIAL_UART_DATA UDR1 - #define SERIAL_UART_UBRR ((F_CPU/(16.0*SERIAL_UART_BAUD)-1+0.5)) - #define SERIAL_UART_RXD_VECT USART1_RX_vect - #define SERIAL_UART_TXD_READY (UCSR1A&(1<>8); /* baud rate */ \ - UCSR1B |= (1<. //UART settings for communication with the RF microcontroller #define SERIAL_UART_BAUD 1000000 -#define SERIAL_UART_DATA UDR1 -#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) #define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) -#define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX and RX */ \ - UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ -} while(0) +#define SERIAL_UART_INIT_CUSTOM \ + /* enable TX and RX */ \ + UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); diff --git a/keyboards/honeycomb/honeycomb.c b/keyboards/honeycomb/honeycomb.c index add4af15365..1254196d39c 100755 --- a/keyboards/honeycomb/honeycomb.c +++ b/keyboards/honeycomb/honeycomb.c @@ -2,13 +2,8 @@ #include "pointing_device.h" #include "report.h" -void uart_init(void) { - SERIAL_UART_INIT(); -} - void pointing_device_task(void){ /*report_mouse_t currentReport = {}; - SERIAL_UART_INIT(); uint32_t timeout = 0; //the m character requests the RF slave to send the mouse report @@ -77,16 +72,5 @@ void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up matrix_init_user(); - uart_init(); led_init(); } - -void matrix_scan_kb(void) { - // put your looping keyboard code here - // runs every cycle (a lot) - matrix_scan_user(); -} - -void led_set_kb(uint8_t usb_led) { - -} diff --git a/keyboards/honeycomb/matrix.c b/keyboards/honeycomb/matrix.c index a06afb6d968..2bed690689c 100755 --- a/keyboards/honeycomb/matrix.c +++ b/keyboards/honeycomb/matrix.c @@ -30,6 +30,7 @@ along with this program. If not, see . #include "honeycomb.h" #include "pointing_device.h" #include "report.h" +#include "protocol/serial.h" #if (MATRIX_COLS <= 8) # define print_matrix_header() print("\nr/c 01234567\n") @@ -94,12 +95,11 @@ uint8_t matrix_cols(void) { void matrix_init(void) { matrix_init_quantum(); + serial_init(); } uint8_t matrix_scan(void) { - SERIAL_UART_INIT(); - uint32_t timeout = 0; // The 's' character requests the RF slave to send the matrix diff --git a/keyboards/honeycomb/rules.mk b/keyboards/honeycomb/rules.mk index 19852d7ec3f..d6f98125eed 100755 --- a/keyboards/honeycomb/rules.mk +++ b/keyboards/honeycomb/rules.mk @@ -30,9 +30,4 @@ UNICODE_ENABLE = YES # Unicode # BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID # # project specific files -SRC += matrix.c - -USB = /dev/ttyACM0 - -#upload: build -# $(honeycomb_UPLOAD_COMMAND) +SRC += matrix.c serial_uart.c diff --git a/keyboards/mitosis/config.h b/keyboards/mitosis/config.h index b4499d0d6c5..0e089269e8b 100644 --- a/keyboards/mitosis/config.h +++ b/keyboards/mitosis/config.h @@ -60,19 +60,11 @@ along with this program. If not, see . //UART settings for communication with the RF microcontroller #define SERIAL_UART_BAUD 1000000 -#define SERIAL_UART_DATA UDR1 -#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) #define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) -#define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX and RX */ \ - UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ - } while(0) +#define SERIAL_UART_INIT_CUSTOM \ + /* enable TX and RX */ \ + UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); #endif diff --git a/keyboards/mitosis/matrix.c b/keyboards/mitosis/matrix.c index e149b68bd7d..717a810678f 100644 --- a/keyboards/mitosis/matrix.c +++ b/keyboards/mitosis/matrix.c @@ -26,6 +26,7 @@ along with this program. If not, see . #include "util.h" #include "matrix.h" #include "timer.h" +#include "protocol/serial.h" #if (MATRIX_COLS <= 8) # define print_matrix_header() print("\nr/c 01234567\n") @@ -79,12 +80,11 @@ uint8_t matrix_cols(void) { void matrix_init(void) { matrix_init_quantum(); + serial_init(); } uint8_t matrix_scan(void) { - SERIAL_UART_INIT(); - uint32_t timeout = 0; //the s character requests the RF slave to send the matrix diff --git a/keyboards/mitosis/mitosis.c b/keyboards/mitosis/mitosis.c index 1ca7276e410..50b6d8452f5 100644 --- a/keyboards/mitosis/mitosis.c +++ b/keyboards/mitosis/mitosis.c @@ -1,9 +1,5 @@ #include "mitosis.h" -void uart_init(void) { - SERIAL_UART_INIT(); -} - void led_init(void) { DDRD |= (1<<1); // Pin to green, set as output PORTD |= (1<<1); // Turn it off @@ -15,7 +11,6 @@ void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up matrix_init_user(); - uart_init(); led_init(); } diff --git a/keyboards/mitosis/rules.mk b/keyboards/mitosis/rules.mk index 466987e8c1e..4cb6d8c9b4f 100644 --- a/keyboards/mitosis/rules.mk +++ b/keyboards/mitosis/rules.mk @@ -28,14 +28,5 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA UNICODE_ENABLE = yes # Unicode # BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID -USB = /dev/ttyACM0 - -# upload: build -# $(MITOSIS_UPLOAD_COMMAND) - -OPT_DEFS += -DMITOSIS_PROMICRO -MITOSIS_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \ - avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB) - # # project specific files -SRC = matrix.c +SRC += matrix.c serial_uart.c diff --git a/keyboards/planck/keymaps/thermal_printer/config.h b/keyboards/planck/keymaps/thermal_printer/config.h index 4460cdbbe29..4ae9ced2581 100644 --- a/keyboards/planck/keymaps/thermal_printer/config.h +++ b/keyboards/planck/keymaps/thermal_printer/config.h @@ -3,22 +3,7 @@ #include "../../config.h" -# define SERIAL_UART_BAUD 19200 -# define SERIAL_UART_DATA UDR1 -# define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -# define SERIAL_UART_RXD_VECT USART1_RX_vect -# define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) -# define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX */ \ - UCSR1B = _BV(TXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ - sei(); \ - } while(0) +#define SERIAL_UART_BAUD 19200 /* * MIDI options diff --git a/keyboards/redox_w/config.h b/keyboards/redox_w/config.h index 1f40a694daf..b480b072f99 100644 --- a/keyboards/redox_w/config.h +++ b/keyboards/redox_w/config.h @@ -58,17 +58,9 @@ //UART settings for communication with the RF microcontroller #define SERIAL_UART_BAUD 1000000 -#define SERIAL_UART_DATA UDR1 -#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) #define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) -#define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX and RX */ \ - UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ - } while(0) +#define SERIAL_UART_INIT_CUSTOM \ + /* enable TX and RX */ \ + UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); diff --git a/keyboards/redox_w/matrix.c b/keyboards/redox_w/matrix.c index 31233af1018..15ca66e34d2 100644 --- a/keyboards/redox_w/matrix.c +++ b/keyboards/redox_w/matrix.c @@ -24,6 +24,7 @@ #include "util.h" #include "matrix.h" #include "timer.h" +#include "protocol/serial.h" #if (MATRIX_COLS <= 8) # define print_matrix_header() print("\nr/c 01234567\n") @@ -86,12 +87,11 @@ uint8_t matrix_cols(void) { void matrix_init(void) { matrix_init_quantum(); + serial_init(); } uint8_t matrix_scan(void) { - SERIAL_UART_INIT(); - uint32_t timeout = 0; //the s character requests the RF slave to send the matrix diff --git a/keyboards/redox_w/redox_w.c b/keyboards/redox_w/redox_w.c index 75df91066cd..05fa3395717 100644 --- a/keyboards/redox_w/redox_w.c +++ b/keyboards/redox_w/redox_w.c @@ -1,9 +1,5 @@ #include "redox_w.h" -void uart_init(void) { - SERIAL_UART_INIT(); -} - void led_init(void) { DDRD |= (1<<1); PORTD |= (1<<1); @@ -16,20 +12,9 @@ void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up matrix_init_user(); - uart_init(); led_init(); } -void matrix_scan_kb(void) { - // put your looping keyboard code here - // runs every cycle (a lot) - matrix_scan_user(); -} - -void led_set_kb(uint8_t usb_led) { - -} - #ifdef ONEHAND_ENABLE __attribute__ ((weak)) const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = { diff --git a/keyboards/redox_w/rules.mk b/keyboards/redox_w/rules.mk index 8b171f717b0..01d5c3c70ce 100644 --- a/keyboards/redox_w/rules.mk +++ b/keyboards/redox_w/rules.mk @@ -28,14 +28,5 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA UNICODE_ENABLE = YES # Unicode # BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID -USB = /dev/ttyACM0 - -OPT_DEFS += -DREDOX_W_PROMICRO -INTERPHASE_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \ - avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB) - # # project specific files -SRC = matrix.c - -# upload: build -# $(REDOX_W_UPLOAD_COMMAND) +SRC += matrix.c serial_uart.c diff --git a/keyboards/sirius/uni660/rev1/config.h b/keyboards/sirius/uni660/rev1/config.h index 98269d4261e..91d7c5d7a3a 100644 --- a/keyboards/sirius/uni660/rev1/config.h +++ b/keyboards/sirius/uni660/rev1/config.h @@ -59,19 +59,11 @@ along with this program. If not, see . //UART settings for communication with the RF microcontroller #define SERIAL_UART_BAUD 1000000 -#define SERIAL_UART_DATA UDR1 -#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) #define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) -#define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX and RX */ \ +#define SERIAL_UART_INIT_CUSTOM \ + /* enable TX and RX */ \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ -} while (0) + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); #define DYNAMIC_KEYMAP_LAYER_COUNT 4 diff --git a/keyboards/sirius/uni660/rev1/matrix.c b/keyboards/sirius/uni660/rev1/matrix.c index 3e231b33bc3..355fa7e5e91 100644 --- a/keyboards/sirius/uni660/rev1/matrix.c +++ b/keyboards/sirius/uni660/rev1/matrix.c @@ -27,6 +27,7 @@ along with this program. If not, see . #include "matrix.h" #include "timer.h" #include "debounce.h" +#include "protocol/serial.h" #if (MATRIX_COLS <= 8) # define print_matrix_header() print("\nr/c 01234567\n") @@ -80,14 +81,13 @@ uint8_t matrix_cols(void) { void matrix_init(void) { debounce_init(MATRIX_ROWS); matrix_init_quantum(); + serial_init(); } uint8_t matrix_scan(void) { bool matrix_has_changed = false; - SERIAL_UART_INIT(); - uint32_t timeout = 0; //the s character requests the RF slave to send the matrix diff --git a/keyboards/sirius/uni660/rev1/rev1.c b/keyboards/sirius/uni660/rev1/rev1.c index 872004355e8..d4adac24b57 100644 --- a/keyboards/sirius/uni660/rev1/rev1.c +++ b/keyboards/sirius/uni660/rev1/rev1.c @@ -1,9 +1,5 @@ #include "rev1.h" -void uart_init(void) { - SERIAL_UART_INIT(); -} - void led_init(void) { setPinOutput(D1); // Pin to green, set as output writePinHigh(D1); // Turn it off @@ -17,7 +13,6 @@ void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up matrix_init_user(); - uart_init(); led_init(); } diff --git a/keyboards/sirius/uni660/rev2/ansi/config.h b/keyboards/sirius/uni660/rev2/ansi/config.h index 7bca743633f..13e33ebf118 100644 --- a/keyboards/sirius/uni660/rev2/ansi/config.h +++ b/keyboards/sirius/uni660/rev2/ansi/config.h @@ -59,19 +59,11 @@ along with this program. If not, see . //UART settings for communication with the RF microcontroller #define SERIAL_UART_BAUD 1000000 -#define SERIAL_UART_DATA UDR1 -#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) #define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) -#define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX and RX */ \ +#define SERIAL_UART_INIT_CUSTOM \ + /* enable TX and RX */ \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ -} while (0) + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); #define DYNAMIC_KEYMAP_LAYER_COUNT 4 diff --git a/keyboards/sirius/uni660/rev2/iso/config.h b/keyboards/sirius/uni660/rev2/iso/config.h index 0cbbe0c5ba4..3283f0cd677 100644 --- a/keyboards/sirius/uni660/rev2/iso/config.h +++ b/keyboards/sirius/uni660/rev2/iso/config.h @@ -59,19 +59,11 @@ along with this program. If not, see . //UART settings for communication with the RF microcontroller #define SERIAL_UART_BAUD 1000000 -#define SERIAL_UART_DATA UDR1 -#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) #define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) -#define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX and RX */ \ +#define SERIAL_UART_INIT_CUSTOM \ + /* enable TX and RX */ \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ -} while (0) + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); #define DYNAMIC_KEYMAP_LAYER_COUNT 4 diff --git a/keyboards/sirius/uni660/rev2/matrix.c b/keyboards/sirius/uni660/rev2/matrix.c index 3e231b33bc3..355fa7e5e91 100644 --- a/keyboards/sirius/uni660/rev2/matrix.c +++ b/keyboards/sirius/uni660/rev2/matrix.c @@ -27,6 +27,7 @@ along with this program. If not, see . #include "matrix.h" #include "timer.h" #include "debounce.h" +#include "protocol/serial.h" #if (MATRIX_COLS <= 8) # define print_matrix_header() print("\nr/c 01234567\n") @@ -80,14 +81,13 @@ uint8_t matrix_cols(void) { void matrix_init(void) { debounce_init(MATRIX_ROWS); matrix_init_quantum(); + serial_init(); } uint8_t matrix_scan(void) { bool matrix_has_changed = false; - SERIAL_UART_INIT(); - uint32_t timeout = 0; //the s character requests the RF slave to send the matrix diff --git a/keyboards/sirius/uni660/rev2/rev2.c b/keyboards/sirius/uni660/rev2/rev2.c index e19240ccc35..048495b9928 100644 --- a/keyboards/sirius/uni660/rev2/rev2.c +++ b/keyboards/sirius/uni660/rev2/rev2.c @@ -1,9 +1,5 @@ #include "rev2.h" -void uart_init(void) { - SERIAL_UART_INIT(); -} - void led_init(void) { setPinOutput(D1); // Pin to green, set as output writePinHigh(D1); // Turn it off @@ -17,7 +13,6 @@ void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up matrix_init_user(); - uart_init(); led_init(); } diff --git a/keyboards/telophase/config.h b/keyboards/telophase/config.h index e9329c5736c..c67dd939bff 100644 --- a/keyboards/telophase/config.h +++ b/keyboards/telophase/config.h @@ -60,19 +60,11 @@ along with this program. If not, see . //UART settings for communication with the RF microcontroller #define SERIAL_UART_BAUD 1000000 -#define SERIAL_UART_DATA UDR1 -#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) #define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) -#define SERIAL_UART_INIT() do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX and RX */ \ - UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ - } while(0) +#define SERIAL_UART_INIT_CUSTOM \ + /* enable TX and RX */ \ + UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); #endif diff --git a/keyboards/telophase/matrix.c b/keyboards/telophase/matrix.c index c332eba556c..8edfce62d2a 100644 --- a/keyboards/telophase/matrix.c +++ b/keyboards/telophase/matrix.c @@ -26,6 +26,7 @@ along with this program. If not, see . #include "util.h" #include "matrix.h" #include "timer.h" +#include "protocol/serial.h" #if (MATRIX_COLS <= 8) # define print_matrix_header() print("\nr/c 01234567\n") @@ -88,12 +89,11 @@ uint8_t matrix_cols(void) { void matrix_init(void) { matrix_init_quantum(); + serial_init(); } uint8_t matrix_scan(void) { - SERIAL_UART_INIT(); - uint32_t timeout = 0; //the s character requests the RF slave to send the matrix diff --git a/keyboards/telophase/rules.mk b/keyboards/telophase/rules.mk index f2ac0adb6c7..65cac9364b8 100644 --- a/keyboards/telophase/rules.mk +++ b/keyboards/telophase/rules.mk @@ -27,20 +27,13 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA # MIDI_ENABLE = YES # MIDI controls UNICODE_ENABLE = YES # Unicode # BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID -LAYOUTS = ortho_4x12 -USB = /dev/ttyACM0 - -# upload: build -# $(MITOSIS_UPLOAD_COMMAND) - -OPT_DEFS += -DMITOSIS_PROMICRO -MITOSIS_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \ - avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB) # # project specific files -SRC = matrix.c +SRC = matrix.c serial_uart.c # Disable unsupported hardware RGBLIGHT_SUPPORTED = no AUDIO_SUPPORTED = no BACKLIGHT_SUPPORTED = no + +LAYOUTS = ortho_4x12 diff --git a/keyboards/telophase/telophase.c b/keyboards/telophase/telophase.c index c77a43389f4..0e04debeb80 100644 --- a/keyboards/telophase/telophase.c +++ b/keyboards/telophase/telophase.c @@ -1,9 +1,5 @@ #include "telophase.h" -void uart_init(void) { - SERIAL_UART_INIT(); -} - void led_init(void) { DDRD |= (1<<1); PORTD |= (1<<1); @@ -16,20 +12,9 @@ void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up matrix_init_user(); - uart_init(); led_init(); } -void matrix_scan_kb(void) { - // put your looping keyboard code here - // runs every cycle (a lot) - matrix_scan_user(); -} - -void led_set_kb(uint8_t usb_led) { - -} - #ifdef SWAP_HANDS_ENABLE __attribute__ ((weak)) const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = { diff --git a/quantum/config_common.h b/quantum/config_common.h index 2d9c70b08de..5973232ef62 100644 --- a/quantum/config_common.h +++ b/quantum/config_common.h @@ -367,51 +367,6 @@ # endif #endif -/* USART configuration */ -#ifdef BLUETOOTH_ENABLE -# ifdef __AVR_ATmega32U4__ -# define SERIAL_UART_BAUD 9600 -# define SERIAL_UART_DATA UDR1 -# define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) -# define SERIAL_UART_RXD_VECT USART1_RX_vect -# define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) -# define SERIAL_UART_INIT() \ - do { \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX */ \ - UCSR1B = _BV(TXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ - sei(); \ - } while (0) -# elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) -# define SERIAL_UART_BAUD 115200 -# define SERIAL_UART_DATA UDR1 -/* UBRR should result in ~16 and set UCSR1A = _BV(U2X1) as per rn42 documentation. HC05 needs baudrate configured accordingly */ -# define SERIAL_UART_UBRR (F_CPU / (8UL * SERIAL_UART_BAUD) - 1) -# define SERIAL_UART_RXD_VECT USART1_RX_vect -# define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) -# define SERIAL_UART_INIT() \ - do { \ - UCSR1A = _BV(U2X1); \ - /* baud rate */ \ - UBRR1L = SERIAL_UART_UBRR; \ - /* baud rate */ \ - UBRR1H = SERIAL_UART_UBRR >> 8; \ - /* enable TX */ \ - UCSR1B = _BV(TXEN1); \ - /* 8-bit data */ \ - UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ - sei(); \ - } while (0) -# else -# error "USART configuration is needed." -# endif -#endif - #define API_SYSEX_MAX_SIZE 32 #include "song_list.h" diff --git a/tmk_core/protocol/serial.h b/tmk_core/protocol/serial.h index b70d117d7c7..0204b84a921 100644 --- a/tmk_core/protocol/serial.h +++ b/tmk_core/protocol/serial.h @@ -37,6 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #pragma once +#define SERIAL_UART_DATA UDR1 + /* host role */ void serial_init(void); uint8_t serial_recv(void); diff --git a/tmk_core/protocol/serial_uart.c b/tmk_core/protocol/serial_uart.c index a15124193af..4fe059e7d9d 100644 --- a/tmk_core/protocol/serial_uart.c +++ b/tmk_core/protocol/serial_uart.c @@ -40,6 +40,22 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "serial.h" +#ifndef SERIAL_UART_BAUD +# define SERIAL_UART_BAUD 9600 +#endif + +#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1) +#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) +#define SERIAL_UART_RXD_VECT USART1_RX_vect + +#ifndef SERIAL_UART_INIT_CUSTOM +# define SERIAL_UART_INIT_CUSTOM \ + /* enable TX */ \ + UCSR1B = _BV(TXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); +#endif + #if defined(SERIAL_UART_RTS_LO) && defined(SERIAL_UART_RTS_HI) // Buffer state // Empty: RBUF_SPACE == RBUF_SIZE(head==tail) @@ -61,7 +77,14 @@ POSSIBILITY OF SUCH DAMAGE. # define rbuf_check_rts_hi() #endif -void serial_init(void) { SERIAL_UART_INIT(); } +void serial_init(void) { + do { + // Set baud rate + UBRR1L = SERIAL_UART_UBRR; + UBRR1L = SERIAL_UART_UBRR >> 8; + SERIAL_UART_INIT_CUSTOM; + } while (0); +} // RX ring buffer #define RBUF_SIZE 256