aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2021-02-06 09:20:48 +1100
committerGitHub <noreply@github.com>2021-02-06 09:20:48 +1100
commit5ea92a9c1cbe3e20bf4830d550d797a8e9650da8 (patch)
tree75ea1413ae4fa23bd0b1230629b6a3b3e215c5eb
parent464eb7137d27e3a31e85032c85c9fda627a8b33f (diff)
downloadqmk_firmware-5ea92a9c1cbe3e20bf4830d550d797a8e9650da8.tar.gz
qmk_firmware-5ea92a9c1cbe3e20bf4830d550d797a8e9650da8.zip
Serial refactor (#11521)
-rw-r--r--keyboards/40percentclub/ut47/config.h22
-rw-r--r--keyboards/centromere/centromere.c5
-rw-r--r--keyboards/centromere/config.h18
-rw-r--r--keyboards/centromere/matrix.c4
-rw-r--r--keyboards/centromere/rules.mk9
-rw-r--r--keyboards/chimera_ergo/chimera_ergo.c15
-rw-r--r--keyboards/chimera_ergo/config.h18
-rw-r--r--keyboards/chimera_ergo/matrix.c4
-rw-r--r--keyboards/chimera_ergo/rules.mk9
-rw-r--r--keyboards/chimera_ls/chimera_ls.c15
-rw-r--r--keyboards/chimera_ls/config.h18
-rw-r--r--keyboards/chimera_ls/matrix.c4
-rw-r--r--keyboards/chimera_ls/rules.mk8
-rw-r--r--keyboards/chimera_ortho/chimera_ortho.c15
-rw-r--r--keyboards/chimera_ortho/config.h18
-rw-r--r--keyboards/chimera_ortho/matrix.c4
-rw-r--r--keyboards/chimera_ortho/rules.mk8
-rw-r--r--keyboards/chimera_ortho_plus/chimera_ortho_plus.c5
-rw-r--r--keyboards/chimera_ortho_plus/config.h18
-rw-r--r--keyboards/chimera_ortho_plus/matrix.c4
-rw-r--r--keyboards/chimera_ortho_plus/rules.mk2
-rw-r--r--keyboards/comet46/comet46.c21
-rw-r--r--keyboards/comet46/config.h18
-rw-r--r--keyboards/comet46/matrix.c4
-rw-r--r--keyboards/comet46/rules.mk4
-rw-r--r--keyboards/dichotomy/config.h18
-rwxr-xr-xkeyboards/dichotomy/dichotomy.c16
-rwxr-xr-xkeyboards/dichotomy/matrix.c3
-rwxr-xr-xkeyboards/dichotomy/rules.mk11
-rw-r--r--keyboards/hhkb/ansi/config.h35
-rw-r--r--keyboards/hhkb/jp/config.h35
-rwxr-xr-xkeyboards/honeycomb/config.h18
-rwxr-xr-xkeyboards/honeycomb/honeycomb.c16
-rwxr-xr-xkeyboards/honeycomb/matrix.c4
-rwxr-xr-xkeyboards/honeycomb/rules.mk7
-rw-r--r--keyboards/mitosis/config.h18
-rw-r--r--keyboards/mitosis/matrix.c4
-rw-r--r--keyboards/mitosis/mitosis.c5
-rw-r--r--keyboards/mitosis/rules.mk11
-rw-r--r--keyboards/planck/keymaps/thermal_printer/config.h17
-rw-r--r--keyboards/redox_w/config.h18
-rw-r--r--keyboards/redox_w/matrix.c4
-rw-r--r--keyboards/redox_w/redox_w.c15
-rw-r--r--keyboards/redox_w/rules.mk11
-rw-r--r--keyboards/sirius/uni660/rev1/config.h16
-rw-r--r--keyboards/sirius/uni660/rev1/matrix.c4
-rw-r--r--keyboards/sirius/uni660/rev1/rev1.c5
-rw-r--r--keyboards/sirius/uni660/rev2/ansi/config.h16
-rw-r--r--keyboards/sirius/uni660/rev2/iso/config.h16
-rw-r--r--keyboards/sirius/uni660/rev2/matrix.c4
-rw-r--r--keyboards/sirius/uni660/rev2/rev2.c5
-rw-r--r--keyboards/telophase/config.h18
-rw-r--r--keyboards/telophase/matrix.c4
-rw-r--r--keyboards/telophase/rules.mk13
-rw-r--r--keyboards/telophase/telophase.c15
-rw-r--r--quantum/config_common.h45
-rw-r--r--tmk_core/protocol/serial.h2
-rw-r--r--tmk_core/protocol/serial_uart.c25
58 files changed, 162 insertions, 562 deletions
diff --git a/keyboards/40percentclub/ut47/config.h b/keyboards/40percentclub/ut47/config.h
index 197d6cd18..9622f58bb 100644
--- a/keyboards/40percentclub/ut47/config.h
+++ b/keyboards/40percentclub/ut47/config.h
@@ -54,25 +54,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
54 54
55/* Enable GNAP matrix serial output */ 55/* Enable GNAP matrix serial output */
56#define GNAP_ENABLE 56#define GNAP_ENABLE
57
58/* USART configuration */
59#ifdef __AVR_ATmega32U4__
60# define SERIAL_UART_BAUD 9600
61# define SERIAL_UART_DATA UDR1
62# define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
63# define SERIAL_UART_RXD_VECT USART1_RX_vect
64# define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
65# define SERIAL_UART_INIT() do { \
66 /* baud rate */ \
67 UBRR1L = SERIAL_UART_UBRR; \
68 /* baud rate */ \
69 UBRR1H = SERIAL_UART_UBRR >> 8; \
70 /* enable TX */ \
71 UCSR1B = _BV(TXEN1); \
72 /* 8-bit data */ \
73 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
74 sei(); \
75 } while(0)
76# else
77# error "USART configuration is needed."
78#endif
diff --git a/keyboards/centromere/centromere.c b/keyboards/centromere/centromere.c
index 8800e2ce6..269c60fd7 100644
--- a/keyboards/centromere/centromere.c
+++ b/keyboards/centromere/centromere.c
@@ -1,9 +1,5 @@
1#include "centromere.h" 1#include "centromere.h"
2 2
3void uart_init(void) {
4 SERIAL_UART_INIT();
5}
6
7void led_init(void) { 3void led_init(void) {
8#if MCU == atmega32u2 4#if MCU == atmega32u2
9 setPinOutput(C4); // Set red LED pin as output 5 setPinOutput(C4); // Set red LED pin as output
@@ -32,7 +28,6 @@ void matrix_init_kb(void) {
32 // put your keyboard start-up code here 28 // put your keyboard start-up code here
33 // runs once when the firmware starts up 29 // runs once when the firmware starts up
34 matrix_init_user(); 30 matrix_init_user();
35 uart_init();
36 led_init(); 31 led_init();
37} 32}
38 33
diff --git a/keyboards/centromere/config.h b/keyboards/centromere/config.h
index 0a908f60f..e502e2534 100644
--- a/keyboards/centromere/config.h
+++ b/keyboards/centromere/config.h
@@ -59,17 +59,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
59 59
60//UART settings for communication with the RF microcontroller 60//UART settings for communication with the RF microcontroller
61#define SERIAL_UART_BAUD 500000 61#define SERIAL_UART_BAUD 500000
62#define SERIAL_UART_DATA UDR1
63#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
64#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
65#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) 62#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
66#define SERIAL_UART_INIT() do { \ 63#define SERIAL_UART_INIT_CUSTOM \
67 /* baud rate */ \ 64 /* enable TX and RX */ \
68 UBRR1L = SERIAL_UART_UBRR; \ 65 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
69 /* baud rate */ \ 66 /* 8-bit data */ \
70 UBRR1H = SERIAL_UART_UBRR >> 8; \ 67 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
71 /* enable TX and RX */ \
72 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
73 /* 8-bit data */ \
74 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
75 } while(0)
diff --git a/keyboards/centromere/matrix.c b/keyboards/centromere/matrix.c
index c5fc8db6c..5ca083b43 100644
--- a/keyboards/centromere/matrix.c
+++ b/keyboards/centromere/matrix.c
@@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
26#include "util.h" 26#include "util.h"
27#include "matrix.h" 27#include "matrix.h"
28#include "timer.h" 28#include "timer.h"
29#include "protocol/serial.h"
29 30
30#if (MATRIX_COLS <= 8) 31#if (MATRIX_COLS <= 8)
31# define print_matrix_header() print("\nr/c 01234567\n") 32# define print_matrix_header() print("\nr/c 01234567\n")
@@ -79,12 +80,11 @@ uint8_t matrix_cols(void) {
79void matrix_init(void) { 80void matrix_init(void) {
80 81
81 matrix_init_quantum(); 82 matrix_init_quantum();
83 serial_init();
82} 84}
83 85
84uint8_t matrix_scan(void) 86uint8_t matrix_scan(void)
85{ 87{
86 SERIAL_UART_INIT();
87
88 uint32_t timeout = 0; 88 uint32_t timeout = 0;
89 89
90 //the s character requests the RF remote slave to send the matrix information 90 //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 f08f6e6eb..2469d244a 100644
--- a/keyboards/centromere/rules.mk
+++ b/keyboards/centromere/rules.mk
@@ -31,14 +31,7 @@ MIDI_ENABLE = no # MIDI controls
31UNICODE_ENABLE = yes # Unicode 31UNICODE_ENABLE = yes # Unicode
32BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID 32BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
33 33
34USB = /dev/ttyACM0
35
36# upload: build
37# $(CENTROMERE_UPLOAD_COMMAND)
38
39OPT_DEFS += -DCENTROMERE_PROMICRO
40
41# # project specific files 34# # project specific files
42SRC = matrix.c 35SRC += matrix.c serial_uart.c
43 36
44LAYOUTS = split_3x5_3 split_3x6_3 37LAYOUTS = split_3x5_3 split_3x6_3
diff --git a/keyboards/chimera_ergo/chimera_ergo.c b/keyboards/chimera_ergo/chimera_ergo.c
index 29470f908..47653c2e4 100644
--- a/keyboards/chimera_ergo/chimera_ergo.c
+++ b/keyboards/chimera_ergo/chimera_ergo.c
@@ -1,9 +1,5 @@
1#include "chimera_ergo.h" 1#include "chimera_ergo.h"
2 2
3void uart_init(void) {
4 SERIAL_UART_INIT();
5}
6
7void led_init(void) { 3void led_init(void) {
8 DDRD |= (1<<1); 4 DDRD |= (1<<1);
9 PORTD |= (1<<1); 5 PORTD |= (1<<1);
@@ -16,16 +12,5 @@ void matrix_init_kb(void) {
16 // put your keyboard start-up code here 12 // put your keyboard start-up code here
17 // runs once when the firmware starts up 13 // runs once when the firmware starts up
18 matrix_init_user(); 14 matrix_init_user();
19 uart_init();
20 led_init(); 15 led_init();
21} 16}
22
23void matrix_scan_kb(void) {
24 // put your looping keyboard code here
25 // runs every cycle (a lot)
26 matrix_scan_user();
27}
28
29void led_set_kb(uint8_t usb_led) {
30
31}
diff --git a/keyboards/chimera_ergo/config.h b/keyboards/chimera_ergo/config.h
index 262f287a5..4021cdcd5 100644
--- a/keyboards/chimera_ergo/config.h
+++ b/keyboards/chimera_ergo/config.h
@@ -60,19 +60,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
60 60
61//UART settings for communication with the RF microcontroller 61//UART settings for communication with the RF microcontroller
62#define SERIAL_UART_BAUD 1000000 62#define SERIAL_UART_BAUD 1000000
63#define SERIAL_UART_DATA UDR1
64#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
65#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
66#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) 63#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
67#define SERIAL_UART_INIT() do { \ 64#define SERIAL_UART_INIT_CUSTOM \
68 /* baud rate */ \ 65 /* enable TX and RX */ \
69 UBRR1L = SERIAL_UART_UBRR; \ 66 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
70 /* baud rate */ \ 67 /* 8-bit data */ \
71 UBRR1H = SERIAL_UART_UBRR >> 8; \ 68 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
72 /* enable TX and RX */ \
73 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
74 /* 8-bit data */ \
75 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
76 } while(0)
77 69
78#endif 70#endif
diff --git a/keyboards/chimera_ergo/matrix.c b/keyboards/chimera_ergo/matrix.c
index d512a51d9..112b9a40d 100644
--- a/keyboards/chimera_ergo/matrix.c
+++ b/keyboards/chimera_ergo/matrix.c
@@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
26#include "util.h" 26#include "util.h"
27#include "matrix.h" 27#include "matrix.h"
28#include "timer.h" 28#include "timer.h"
29#include "protocol/serial.h"
29 30
30#if (MATRIX_COLS <= 8) 31#if (MATRIX_COLS <= 8)
31# define print_matrix_header() print("\nr/c 01234567\n") 32# define print_matrix_header() print("\nr/c 01234567\n")
@@ -88,12 +89,11 @@ uint8_t matrix_cols(void) {
88void matrix_init(void) { 89void matrix_init(void) {
89 90
90 matrix_init_quantum(); 91 matrix_init_quantum();
92 serial_init();
91} 93}
92 94
93uint8_t matrix_scan(void) 95uint8_t matrix_scan(void)
94{ 96{
95 SERIAL_UART_INIT();
96
97 uint32_t timeout = 0; 97 uint32_t timeout = 0;
98 98
99 //the s character requests the RF slave to send the matrix 99 //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 f37d14107..01d5c3c70 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
28UNICODE_ENABLE = YES # Unicode 28UNICODE_ENABLE = YES # Unicode
29# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID 29# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
30 30
31
32OPT_DEFS += -DCHIMERA_ERGO_PROMICRO
33CHIMERA_ERGO_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \
34 avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB)
35
36# # project specific files 31# # project specific files
37SRC = matrix.c 32SRC += matrix.c serial_uart.c
38
39USB = /dev/ttyACM0
diff --git a/keyboards/chimera_ls/chimera_ls.c b/keyboards/chimera_ls/chimera_ls.c
index 588b02b2d..f88e9a4f1 100644
--- a/keyboards/chimera_ls/chimera_ls.c
+++ b/keyboards/chimera_ls/chimera_ls.c
@@ -1,9 +1,5 @@
1#include "chimera_ls.h" 1#include "chimera_ls.h"
2 2
3void uart_init(void) {
4 SERIAL_UART_INIT();
5}
6
7void led_init(void) { 3void led_init(void) {
8 DDRD |= (1<<1); 4 DDRD |= (1<<1);
9 PORTD |= (1<<1); 5 PORTD |= (1<<1);
@@ -16,16 +12,5 @@ void matrix_init_kb(void) {
16 // put your keyboard start-up code here 12 // put your keyboard start-up code here
17 // runs once when the firmware starts up 13 // runs once when the firmware starts up
18 matrix_init_user(); 14 matrix_init_user();
19 uart_init();
20 led_init(); 15 led_init();
21} 16}
22
23void matrix_scan_kb(void) {
24 // put your looping keyboard code here
25 // runs every cycle (a lot)
26 matrix_scan_user();
27}
28
29void led_set_kb(uint8_t usb_led) {
30
31}
diff --git a/keyboards/chimera_ls/config.h b/keyboards/chimera_ls/config.h
index 87e919609..d9c14a3fc 100644
--- a/keyboards/chimera_ls/config.h
+++ b/keyboards/chimera_ls/config.h
@@ -60,19 +60,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
60 60
61//UART settings for communication with the RF microcontroller 61//UART settings for communication with the RF microcontroller
62#define SERIAL_UART_BAUD 1000000 62#define SERIAL_UART_BAUD 1000000
63#define SERIAL_UART_DATA UDR1
64#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
65#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
66#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) 63#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
67#define SERIAL_UART_INIT() do { \ 64#define SERIAL_UART_INIT_CUSTOM \
68 /* baud rate */ \ 65 /* enable TX and RX */ \
69 UBRR1L = SERIAL_UART_UBRR; \ 66 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
70 /* baud rate */ \ 67 /* 8-bit data */ \
71 UBRR1H = SERIAL_UART_UBRR >> 8; \ 68 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
72 /* enable TX and RX */ \
73 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
74 /* 8-bit data */ \
75 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
76 } while(0)
77 69
78#endif 70#endif
diff --git a/keyboards/chimera_ls/matrix.c b/keyboards/chimera_ls/matrix.c
index 72fe44137..7208d971e 100644
--- a/keyboards/chimera_ls/matrix.c
+++ b/keyboards/chimera_ls/matrix.c
@@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
26#include "util.h" 26#include "util.h"
27#include "matrix.h" 27#include "matrix.h"
28#include "timer.h" 28#include "timer.h"
29#include "protocol/serial.h"
29 30
30#if (MATRIX_COLS <= 8) 31#if (MATRIX_COLS <= 8)
31# define print_matrix_header() print("\nr/c 01234567\n") 32# define print_matrix_header() print("\nr/c 01234567\n")
@@ -92,12 +93,11 @@ uint8_t matrix_cols(void) {
92 93
93void matrix_init(void) { 94void matrix_init(void) {
94 matrix_init_quantum(); 95 matrix_init_quantum();
96 serial_init();
95} 97}
96 98
97uint8_t matrix_scan(void) 99uint8_t matrix_scan(void)
98{ 100{
99 SERIAL_UART_INIT();
100
101 uint32_t timeout = 0; 101 uint32_t timeout = 0;
102 102
103 //the s character requests the RF slave to send the matrix 103 //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 162e06aaf..536e6053a 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
28UNICODE_ENABLE = YES # Unicode 28UNICODE_ENABLE = YES # Unicode
29# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID 29# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
30 30
31USB = /dev/ttyACM0
32
33OPT_DEFS += -DCHIMERA_LS_PROMICRO
34CHIMERA_LS_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \
35 avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB)
36
37# project specific files 31# project specific files
38SRC = matrix.c 32SRC += matrix.c serial_uart.c
39 33
40LAYOUTS = ortho_4x12 34LAYOUTS = ortho_4x12
41 35
diff --git a/keyboards/chimera_ortho/chimera_ortho.c b/keyboards/chimera_ortho/chimera_ortho.c
index 2a602cf2f..2cdc3d933 100644
--- a/keyboards/chimera_ortho/chimera_ortho.c
+++ b/keyboards/chimera_ortho/chimera_ortho.c
@@ -1,9 +1,5 @@
1#include "chimera_ortho.h" 1#include "chimera_ortho.h"
2 2
3void uart_init(void) {
4 SERIAL_UART_INIT();
5}
6
7void led_init(void) { 3void led_init(void) {
8 DDRD |= (1<<1); 4 DDRD |= (1<<1);
9 PORTD |= (1<<1); 5 PORTD |= (1<<1);
@@ -16,16 +12,5 @@ void matrix_init_kb(void) {
16 // put your keyboard start-up code here 12 // put your keyboard start-up code here
17 // runs once when the firmware starts up 13 // runs once when the firmware starts up
18 matrix_init_user(); 14 matrix_init_user();
19 uart_init();
20 led_init(); 15 led_init();
21} 16}
22
23void matrix_scan_kb(void) {
24 // put your looping keyboard code here
25 // runs every cycle (a lot)
26 matrix_scan_user();
27}
28
29void led_set_kb(uint8_t usb_led) {
30
31}
diff --git a/keyboards/chimera_ortho/config.h b/keyboards/chimera_ortho/config.h
index 4ce70e68b..b10358987 100644
--- a/keyboards/chimera_ortho/config.h
+++ b/keyboards/chimera_ortho/config.h
@@ -60,19 +60,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
60 60
61//UART settings for communication with the RF microcontroller 61//UART settings for communication with the RF microcontroller
62#define SERIAL_UART_BAUD 1000000 62#define SERIAL_UART_BAUD 1000000
63#define SERIAL_UART_DATA UDR1
64#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
65#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
66#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) 63#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
67#define SERIAL_UART_INIT() do { \ 64#define SERIAL_UART_INIT_CUSTOM \
68 /* baud rate */ \ 65 /* enable TX and RX */ \
69 UBRR1L = SERIAL_UART_UBRR; \ 66 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
70 /* baud rate */ \ 67 /* 8-bit data */ \
71 UBRR1H = SERIAL_UART_UBRR >> 8; \ 68 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
72 /* enable TX and RX */ \
73 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
74 /* 8-bit data */ \
75 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
76 } while(0)
77 69
78#endif 70#endif
diff --git a/keyboards/chimera_ortho/matrix.c b/keyboards/chimera_ortho/matrix.c
index dc38ba74f..eb2f18473 100644
--- a/keyboards/chimera_ortho/matrix.c
+++ b/keyboards/chimera_ortho/matrix.c
@@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
26#include "util.h" 26#include "util.h"
27#include "matrix.h" 27#include "matrix.h"
28#include "timer.h" 28#include "timer.h"
29#include "protocol/serial.h"
29 30
30#if (MATRIX_COLS <= 8) 31#if (MATRIX_COLS <= 8)
31# define print_matrix_header() print("\nr/c 01234567\n") 32# define print_matrix_header() print("\nr/c 01234567\n")
@@ -78,12 +79,11 @@ uint8_t matrix_cols(void) {
78void matrix_init(void) { 79void matrix_init(void) {
79 80
80 matrix_init_quantum(); 81 matrix_init_quantum();
82 serial_init();
81} 83}
82 84
83uint8_t matrix_scan(void) 85uint8_t matrix_scan(void)
84{ 86{
85 SERIAL_UART_INIT();
86
87 uint32_t timeout = 0; 87 uint32_t timeout = 0;
88 88
89 //the s character requests the RF slave to send the matrix 89 //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 bf341ab5d..e3bbaa39d 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
28UNICODE_ENABLE = YES # Unicode 28UNICODE_ENABLE = YES # Unicode
29# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID 29# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
30 30
31USB = /dev/ttyACM0
32
33OPT_DEFS += -DCHIMERA_ORTHO_PROMICRO
34CHIMERA_ORTHO_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \
35 avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB)
36
37# project specific files 31# project specific files
38SRC = matrix.c 32SRC += 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 1972f2a9c..6d87ed705 100644
--- a/keyboards/chimera_ortho_plus/chimera_ortho_plus.c
+++ b/keyboards/chimera_ortho_plus/chimera_ortho_plus.c
@@ -1,9 +1,5 @@
1#include "chimera_ortho_plus.h" 1#include "chimera_ortho_plus.h"
2 2
3void uart_init(void) {
4 SERIAL_UART_INIT();
5}
6
7void led_init(void) { 3void led_init(void) {
8 setPinOutput(D1); 4 setPinOutput(D1);
9 setPinOutput(F4); 5 setPinOutput(F4);
@@ -18,6 +14,5 @@ void matrix_init_kb(void) {
18 // put your keyboard start-up code here 14 // put your keyboard start-up code here
19 // runs once when the firmware starts up 15 // runs once when the firmware starts up
20 matrix_init_user(); 16 matrix_init_user();
21 uart_init();
22 led_init(); 17 led_init();
23} 18}
diff --git a/keyboards/chimera_ortho_plus/config.h b/keyboards/chimera_ortho_plus/config.h
index e060e196a..4b12796e9 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 <http://www.gnu.org/licenses/>.
59 59
60//UART settings for communication with the RF microcontroller 60//UART settings for communication with the RF microcontroller
61#define SERIAL_UART_BAUD 1000000 61#define SERIAL_UART_BAUD 1000000
62#define SERIAL_UART_DATA UDR1
63#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
64#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
65#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) 62#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
66#define SERIAL_UART_INIT() do { \ 63#define SERIAL_UART_INIT_CUSTOM \
67 /* baud rate */ \ 64 /* enable TX and RX */ \
68 UBRR1L = SERIAL_UART_UBRR; \ 65 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
69 /* baud rate */ \ 66 /* 8-bit data */ \
70 UBRR1H = SERIAL_UART_UBRR >> 8; \ 67 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
71 /* enable TX and RX */ \
72 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
73 /* 8-bit data */ \
74 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
75 } while(0)
diff --git a/keyboards/chimera_ortho_plus/matrix.c b/keyboards/chimera_ortho_plus/matrix.c
index ed6eac2b0..2bdc97991 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 <http://www.gnu.org/licenses/>.
26#include "util.h" 26#include "util.h"
27#include "matrix.h" 27#include "matrix.h"
28#include "timer.h" 28#include "timer.h"
29#include "protocol/serial.h"
29 30
30#if (MATRIX_COLS <= 8) 31#if (MATRIX_COLS <= 8)
31# define print_matrix_header() print("\nr/c 01234567\n") 32# define print_matrix_header() print("\nr/c 01234567\n")
@@ -78,12 +79,11 @@ uint8_t matrix_cols(void) {
78void matrix_init(void) { 79void matrix_init(void) {
79 80
80 matrix_init_quantum(); 81 matrix_init_quantum();
82 serial_init();
81} 83}
82 84
83uint8_t matrix_scan(void) 85uint8_t matrix_scan(void)
84{ 86{
85 SERIAL_UART_INIT();
86
87 uint32_t timeout = 0; 87 uint32_t timeout = 0;
88 88
89 //the s character requests the RF slave to send the matrix 89 //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 2dd6c3e1f..fec1bef73 100644
--- a/keyboards/chimera_ortho_plus/rules.mk
+++ b/keyboards/chimera_ortho_plus/rules.mk
@@ -33,4 +33,4 @@ UNICODE_ENABLE = yes
33CUSTOM_MATRIX = yes 33CUSTOM_MATRIX = yes
34 34
35# project specific files 35# project specific files
36SRC = matrix.c 36SRC += matrix.c serial_uart.c
diff --git a/keyboards/comet46/comet46.c b/keyboards/comet46/comet46.c
index 0710b8e33..7c7edba93 100644
--- a/keyboards/comet46/comet46.c
+++ b/keyboards/comet46/comet46.c
@@ -1,22 +1 @@
1#include "comet46.h" #include "comet46.h"
2
3void uart_init(void) {
4 SERIAL_UART_INIT();
5}
6
7void matrix_init_kb(void) {
8 // put your keyboard start-up code here
9 // runs once when the firmware starts up
10 matrix_init_user();
11 uart_init();
12}
13
14void matrix_scan_kb(void) {
15 // put your looping keyboard code here
16 // runs every cycle (a lot)
17 matrix_scan_user();
18}
19
20void led_set_kb(uint8_t usb_led) {
21
22}
diff --git a/keyboards/comet46/config.h b/keyboards/comet46/config.h
index d50224eb6..5ae026f92 100644
--- a/keyboards/comet46/config.h
+++ b/keyboards/comet46/config.h
@@ -66,19 +66,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
66 66
67//UART settings for communication with the RF microcontroller 67//UART settings for communication with the RF microcontroller
68#define SERIAL_UART_BAUD 1000000 68#define SERIAL_UART_BAUD 1000000
69#define SERIAL_UART_DATA UDR1
70#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
71#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
72#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) 69#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
73#define SERIAL_UART_INIT() do { \ 70#define SERIAL_UART_INIT_CUSTOM \
74 /* baud rate */ \ 71 /* enable TX and RX */ \
75 UBRR1L = SERIAL_UART_UBRR; \ 72 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
76 /* baud rate */ \ 73 /* 8-bit data */ \
77 UBRR1H = SERIAL_UART_UBRR >> 8; \ 74 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
78 /* enable TX and RX */ \
79 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
80 /* 8-bit data */ \
81 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
82 } while(0)
83 75
84#endif 76#endif
diff --git a/keyboards/comet46/matrix.c b/keyboards/comet46/matrix.c
index dc38ba74f..eb2f18473 100644
--- a/keyboards/comet46/matrix.c
+++ b/keyboards/comet46/matrix.c
@@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
26#include "util.h" 26#include "util.h"
27#include "matrix.h" 27#include "matrix.h"
28#include "timer.h" 28#include "timer.h"
29#include "protocol/serial.h"
29 30
30#if (MATRIX_COLS <= 8) 31#if (MATRIX_COLS <= 8)
31# define print_matrix_header() print("\nr/c 01234567\n") 32# define print_matrix_header() print("\nr/c 01234567\n")
@@ -78,12 +79,11 @@ uint8_t matrix_cols(void) {
78void matrix_init(void) { 79void matrix_init(void) {
79 80
80 matrix_init_quantum(); 81 matrix_init_quantum();
82 serial_init();
81} 83}
82 84
83uint8_t matrix_scan(void) 85uint8_t matrix_scan(void)
84{ 86{
85 SERIAL_UART_INIT();
86
87 uint32_t timeout = 0; 87 uint32_t timeout = 0;
88 88
89 //the s character requests the RF slave to send the matrix 89 //the s character requests the RF slave to send the matrix
diff --git a/keyboards/comet46/rules.mk b/keyboards/comet46/rules.mk
index 2aaa5483c..1f22b7535 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
28UNICODE_ENABLE = YES # Unicode 28UNICODE_ENABLE = YES # Unicode
29# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID 29# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
30 30
31USB = /dev/ttyACM0
32# project specific files 31# project specific files
33SRC += matrix.c \ 32SRC += matrix.c \
34 i2c.c \ 33 i2c.c \
35 ssd1306.c 34 ssd1306.c \
35 serial_uart.c
diff --git a/keyboards/dichotomy/config.h b/keyboards/dichotomy/config.h
index 05210198c..0cdaf776b 100644
--- a/keyboards/dichotomy/config.h
+++ b/keyboards/dichotomy/config.h
@@ -60,19 +60,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
60 60
61//UART settings for communication with the RF microcontroller 61//UART settings for communication with the RF microcontroller
62#define SERIAL_UART_BAUD 1000000 62#define SERIAL_UART_BAUD 1000000
63#define SERIAL_UART_DATA UDR1
64#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
65#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
66#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) 63#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
67#define SERIAL_UART_INIT() do { \ 64#define SERIAL_UART_INIT_CUSTOM \
68 /* baud rate */ \ 65 /* enable TX and RX */ \
69 UBRR1L = SERIAL_UART_UBRR; \ 66 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
70 /* baud rate */ \ 67 /* 8-bit data */ \
71 UBRR1H = SERIAL_UART_UBRR >> 8; \ 68 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
72 /* enable TX and RX */ \
73 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
74 /* 8-bit data */ \
75 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
76 } while(0)
77 69
78#endif 70#endif
diff --git a/keyboards/dichotomy/dichotomy.c b/keyboards/dichotomy/dichotomy.c
index b94030a37..967d7e603 100755
--- a/keyboards/dichotomy/dichotomy.c
+++ b/keyboards/dichotomy/dichotomy.c
@@ -1,12 +1,7 @@
1#include "dichotomy.h" 1#include "dichotomy.h"
2 2
3void uart_init(void) {
4 SERIAL_UART_INIT();
5}
6
7void pointing_device_task(void){ 3void pointing_device_task(void){
8 /*report_mouse_t currentReport = {}; 4 /*report_mouse_t currentReport = {};
9 SERIAL_UART_INIT();
10 uint32_t timeout = 0; 5 uint32_t timeout = 0;
11 6
12 //the m character requests the RF slave to send the mouse report 7 //the m character requests the RF slave to send the mouse report
@@ -77,16 +72,5 @@ void matrix_init_kb(void) {
77 // put your keyboard start-up code here 72 // put your keyboard start-up code here
78 // runs once when the firmware starts up 73 // runs once when the firmware starts up
79 matrix_init_user(); 74 matrix_init_user();
80 uart_init();
81 led_init(); 75 led_init();
82} 76}
83
84void matrix_scan_kb(void) {
85 // put your looping keyboard code here
86 // runs every cycle (a lot)
87 matrix_scan_user();
88}
89
90void led_set_kb(uint8_t usb_led) {
91
92}
diff --git a/keyboards/dichotomy/matrix.c b/keyboards/dichotomy/matrix.c
index d93889e6a..2400753cc 100755
--- a/keyboards/dichotomy/matrix.c
+++ b/keyboards/dichotomy/matrix.c
@@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
29#include "dichotomy.h" 29#include "dichotomy.h"
30#include "pointing_device.h" 30#include "pointing_device.h"
31#include "report.h" 31#include "report.h"
32#include "protocol/serial.h"
32 33
33#if (MATRIX_COLS <= 8) 34#if (MATRIX_COLS <= 8)
34# define print_matrix_header() print("\nr/c 01234567\n") 35# define print_matrix_header() print("\nr/c 01234567\n")
@@ -93,11 +94,11 @@ uint8_t matrix_cols(void) {
93 94
94void matrix_init(void) { 95void matrix_init(void) {
95 matrix_init_quantum(); 96 matrix_init_quantum();
97 serial_init();
96} 98}
97 99
98uint8_t matrix_scan(void) 100uint8_t matrix_scan(void)
99{ 101{
100 SERIAL_UART_INIT();
101 //xprintf("\r\nTRYING TO SCAN"); 102 //xprintf("\r\nTRYING TO SCAN");
102 103
103 uint32_t timeout = 0; 104 uint32_t timeout = 0;
diff --git a/keyboards/dichotomy/rules.mk b/keyboards/dichotomy/rules.mk
index 14dc47435..d6f98125e 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
29UNICODE_ENABLE = YES # Unicode 29UNICODE_ENABLE = YES # Unicode
30# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID 30# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
31 31
32USB = /dev/ttyACM0
33
34OPT_DEFS += -DDICHOTOMY_PROMICRO
35DICHOTOMY_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \
36 avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB)
37
38# # project specific files 32# # project specific files
39SRC = matrix.c 33SRC += matrix.c serial_uart.c
40
41#upload: build
42# $(DICHOTOMY_UPLOAD_COMMAND)
diff --git a/keyboards/hhkb/ansi/config.h b/keyboards/hhkb/ansi/config.h
index 5e4fece17..78fe0c47a 100644
--- a/keyboards/hhkb/ansi/config.h
+++ b/keyboards/hhkb/ansi/config.h
@@ -52,27 +52,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
52#define SUART_IN_PIN PIND 52#define SUART_IN_PIN PIND
53#define SUART_IN_BIT 1 53#define SUART_IN_BIT 1
54 54
55#ifdef __AVR_ATmega32U4__ 55#define SERIAL_UART_BAUD 115200
56 #define SERIAL_UART_BAUD 115200 56#define SERIAL_UART_INIT_CUSTOM \
57 #define SERIAL_UART_DATA UDR1 57 /* RX interrupt, RX: enable */ \
58 #define SERIAL_UART_UBRR ((F_CPU/(16.0*SERIAL_UART_BAUD)-1+0.5)) 58 UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); \
59 #define SERIAL_UART_RXD_VECT USART1_RX_vect 59 /* TX interrupt, TX: enable */ \
60 #define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1)) 60 UCSR1B |= (0<<TXCIE1) | (1<<TXEN1); \
61 #define SERIAL_UART_INIT() do { \ 61 /* parity: none(00), even(01), odd(11) */ \
62 UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \ 62 UCSR1C |= (0<<UPM11) | (0<<UPM10); \
63 UBRR1H = ((uint16_t)SERIAL_UART_UBRR>>8); /* baud rate */ \ 63 /* RTS, CTS(no flow control by hardware) */ \
64 UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); /* RX interrupt, RX: enable */ \ 64 UCSR1D |= (0<<RTSEN) | (0<<CTSEN); \
65 UCSR1B |= (0<<TXCIE1) | (1<<TXEN1); /* TX interrupt, TX: enable */ \ 65 /* RTS for flow control by firmware */ \
66 UCSR1C |= (0<<UPM11) | (0<<UPM10); /* parity: none(00), even(01), odd(11) */ \ 66 DDRD |= (1<<5); PORTD &= ~(1<<5);
67 UCSR1D |= (0<<RTSEN) | (0<<CTSEN); /* RTS, CTS(no flow control by hardware) */ \ 67#define SERIAL_UART_RTS_LO() do { PORTD &= ~(1<<5); } while (0)
68 DDRD |= (1<<5); PORTD &= ~(1<<5); /* RTS for flow control by firmware */ \ 68#define SERIAL_UART_RTS_HI() do { PORTD |= (1<<5); } while (0)
69 sei(); \
70 } while(0)
71 #define SERIAL_UART_RTS_LO() do { PORTD &= ~(1<<5); } while (0)
72 #define SERIAL_UART_RTS_HI() do { PORTD |= (1<<5); } while (0)
73#else
74 #error "USART configuration is needed."
75#endif
76 69
77/* power control of key switch board */ 70/* power control of key switch board */
78#define HHKB_POWER_SAVING 71#define HHKB_POWER_SAVING
diff --git a/keyboards/hhkb/jp/config.h b/keyboards/hhkb/jp/config.h
index c06c554b2..22ac6aa62 100644
--- a/keyboards/hhkb/jp/config.h
+++ b/keyboards/hhkb/jp/config.h
@@ -52,27 +52,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
52#define SUART_IN_PIN PIND 52#define SUART_IN_PIN PIND
53#define SUART_IN_BIT 1 53#define SUART_IN_BIT 1
54 54
55#ifdef __AVR_ATmega32U4__ 55#define SERIAL_UART_BAUD 115200
56 #define SERIAL_UART_BAUD 115200 56#define SERIAL_UART_INIT_CUSTOM \
57 #define SERIAL_UART_DATA UDR1 57 /* RX interrupt, RX: enable */ \
58 #define SERIAL_UART_UBRR ((F_CPU/(16.0*SERIAL_UART_BAUD)-1+0.5)) 58 UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); \
59 #define SERIAL_UART_RXD_VECT USART1_RX_vect 59 /* TX interrupt, TX: enable */ \
60 #define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1)) 60 UCSR1B |= (0<<TXCIE1) | (1<<TXEN1); \
61 #define SERIAL_UART_INIT() do { \ 61 /* parity: none(00), even(01), odd(11) */ \
62 UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \ 62 UCSR1C |= (0<<UPM11) | (0<<UPM10); \
63 UBRR1H = ((uint16_t)SERIAL_UART_UBRR>>8); /* baud rate */ \ 63 /* RTS, CTS(no flow control by hardware) */ \
64 UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); /* RX interrupt, RX: enable */ \ 64 UCSR1D |= (0<<RTSEN) | (0<<CTSEN); \
65 UCSR1B |= (0<<TXCIE1) | (1<<TXEN1); /* TX interrupt, TX: enable */ \ 65 /* RTS for flow control by firmware */ \
66 UCSR1C |= (0<<UPM11) | (0<<UPM10); /* parity: none(00), even(01), odd(11) */ \ 66 DDRD |= (1<<5); PORTD &= ~(1<<5);
67 UCSR1D |= (0<<RTSEN) | (0<<CTSEN); /* RTS, CTS(no flow control by hardware) */ \ 67#define SERIAL_UART_RTS_LO() do { PORTD &= ~(1<<5); } while (0)
68 DDRD |= (1<<5); PORTD &= ~(1<<5); /* RTS for flow control by firmware */ \ 68#define SERIAL_UART_RTS_HI() do { PORTD |= (1<<5); } while (0)
69 sei(); \
70 } while(0)
71 #define SERIAL_UART_RTS_LO() do { PORTD &= ~(1<<5); } while (0)
72 #define SERIAL_UART_RTS_HI() do { PORTD |= (1<<5); } while (0)
73#else
74 #error "USART configuration is needed."
75#endif
76 69
77/* power control of key switch board */ 70/* power control of key switch board */
78#define HHKB_POWER_SAVING 71#define HHKB_POWER_SAVING
diff --git a/keyboards/honeycomb/config.h b/keyboards/honeycomb/config.h
index 4991c8a0e..725f9490c 100755
--- a/keyboards/honeycomb/config.h
+++ b/keyboards/honeycomb/config.h
@@ -48,17 +48,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
48 48
49//UART settings for communication with the RF microcontroller 49//UART settings for communication with the RF microcontroller
50#define SERIAL_UART_BAUD 1000000 50#define SERIAL_UART_BAUD 1000000
51#define SERIAL_UART_DATA UDR1
52#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
53#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
54#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) 51#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
55#define SERIAL_UART_INIT() do { \ 52#define SERIAL_UART_INIT_CUSTOM \
56 /* baud rate */ \ 53 /* enable TX and RX */ \
57 UBRR1L = SERIAL_UART_UBRR; \ 54 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
58 /* baud rate */ \ 55 /* 8-bit data */ \
59 UBRR1H = SERIAL_UART_UBRR >> 8; \ 56 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
60 /* enable TX and RX */ \
61 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
62 /* 8-bit data */ \
63 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
64} while(0)
diff --git a/keyboards/honeycomb/honeycomb.c b/keyboards/honeycomb/honeycomb.c
index add4af153..1254196d3 100755
--- a/keyboards/honeycomb/honeycomb.c
+++ b/keyboards/honeycomb/honeycomb.c
@@ -2,13 +2,8 @@
2#include "pointing_device.h" 2#include "pointing_device.h"
3#include "report.h" 3#include "report.h"
4 4
5void uart_init(void) {
6 SERIAL_UART_INIT();
7}
8
9void pointing_device_task(void){ 5void pointing_device_task(void){
10 /*report_mouse_t currentReport = {}; 6 /*report_mouse_t currentReport = {};
11 SERIAL_UART_INIT();
12 uint32_t timeout = 0; 7 uint32_t timeout = 0;
13 8
14 //the m character requests the RF slave to send the mouse report 9 //the m character requests the RF slave to send the mouse report
@@ -77,16 +72,5 @@ void matrix_init_kb(void) {
77 // put your keyboard start-up code here 72 // put your keyboard start-up code here
78 // runs once when the firmware starts up 73 // runs once when the firmware starts up
79 matrix_init_user(); 74 matrix_init_user();
80 uart_init();
81 led_init(); 75 led_init();
82} 76}
83
84void matrix_scan_kb(void) {
85 // put your looping keyboard code here
86 // runs every cycle (a lot)
87 matrix_scan_user();
88}
89
90void led_set_kb(uint8_t usb_led) {
91
92}
diff --git a/keyboards/honeycomb/matrix.c b/keyboards/honeycomb/matrix.c
index a06afb6d9..2bed69068 100755
--- a/keyboards/honeycomb/matrix.c
+++ b/keyboards/honeycomb/matrix.c
@@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
30#include "honeycomb.h" 30#include "honeycomb.h"
31#include "pointing_device.h" 31#include "pointing_device.h"
32#include "report.h" 32#include "report.h"
33#include "protocol/serial.h"
33 34
34#if (MATRIX_COLS <= 8) 35#if (MATRIX_COLS <= 8)
35# define print_matrix_header() print("\nr/c 01234567\n") 36# define print_matrix_header() print("\nr/c 01234567\n")
@@ -94,12 +95,11 @@ uint8_t matrix_cols(void) {
94void matrix_init(void) { 95void matrix_init(void) {
95 96
96 matrix_init_quantum(); 97 matrix_init_quantum();
98 serial_init();
97} 99}
98 100
99uint8_t matrix_scan(void) 101uint8_t matrix_scan(void)
100{ 102{
101 SERIAL_UART_INIT();
102
103 uint32_t timeout = 0; 103 uint32_t timeout = 0;
104 104
105 // The 's' character requests the RF slave to send the matrix 105 // The 's' character requests the RF slave to send the matrix
diff --git a/keyboards/honeycomb/rules.mk b/keyboards/honeycomb/rules.mk
index 19852d7ec..d6f98125e 100755
--- a/keyboards/honeycomb/rules.mk
+++ b/keyboards/honeycomb/rules.mk
@@ -30,9 +30,4 @@ UNICODE_ENABLE = YES # Unicode
30# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID 30# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
31 31
32# # project specific files 32# # project specific files
33SRC += matrix.c 33SRC += matrix.c serial_uart.c
34
35USB = /dev/ttyACM0
36
37#upload: build
38# $(honeycomb_UPLOAD_COMMAND)
diff --git a/keyboards/mitosis/config.h b/keyboards/mitosis/config.h
index b4499d0d6..0e089269e 100644
--- a/keyboards/mitosis/config.h
+++ b/keyboards/mitosis/config.h
@@ -60,19 +60,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
60 60
61//UART settings for communication with the RF microcontroller 61//UART settings for communication with the RF microcontroller
62#define SERIAL_UART_BAUD 1000000 62#define SERIAL_UART_BAUD 1000000
63#define SERIAL_UART_DATA UDR1
64#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
65#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
66#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) 63#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
67#define SERIAL_UART_INIT() do { \ 64#define SERIAL_UART_INIT_CUSTOM \
68 /* baud rate */ \ 65 /* enable TX and RX */ \
69 UBRR1L = SERIAL_UART_UBRR; \ 66 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
70 /* baud rate */ \ 67 /* 8-bit data */ \
71 UBRR1H = SERIAL_UART_UBRR >> 8; \ 68 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
72 /* enable TX and RX */ \
73 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
74 /* 8-bit data */ \
75 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
76 } while(0)
77 69
78#endif 70#endif
diff --git a/keyboards/mitosis/matrix.c b/keyboards/mitosis/matrix.c
index e149b68bd..717a81067 100644
--- a/keyboards/mitosis/matrix.c
+++ b/keyboards/mitosis/matrix.c
@@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
26#include "util.h" 26#include "util.h"
27#include "matrix.h" 27#include "matrix.h"
28#include "timer.h" 28#include "timer.h"
29#include "protocol/serial.h"
29 30
30#if (MATRIX_COLS <= 8) 31#if (MATRIX_COLS <= 8)
31# define print_matrix_header() print("\nr/c 01234567\n") 32# define print_matrix_header() print("\nr/c 01234567\n")
@@ -79,12 +80,11 @@ uint8_t matrix_cols(void) {
79void matrix_init(void) { 80void matrix_init(void) {
80 81
81 matrix_init_quantum(); 82 matrix_init_quantum();
83 serial_init();
82} 84}
83 85
84uint8_t matrix_scan(void) 86uint8_t matrix_scan(void)
85{ 87{
86 SERIAL_UART_INIT();
87
88 uint32_t timeout = 0; 88 uint32_t timeout = 0;
89 89
90 //the s character requests the RF slave to send the matrix 90 //the s character requests the RF slave to send the matrix
diff --git a/keyboards/mitosis/mitosis.c b/keyboards/mitosis/mitosis.c
index 1ca7276e4..50b6d8452 100644
--- a/keyboards/mitosis/mitosis.c
+++ b/keyboards/mitosis/mitosis.c
@@ -1,9 +1,5 @@
1#include "mitosis.h" 1#include "mitosis.h"
2 2
3void uart_init(void) {
4 SERIAL_UART_INIT();
5}
6
7void led_init(void) { 3void led_init(void) {
8 DDRD |= (1<<1); // Pin to green, set as output 4 DDRD |= (1<<1); // Pin to green, set as output
9 PORTD |= (1<<1); // Turn it off 5 PORTD |= (1<<1); // Turn it off
@@ -15,7 +11,6 @@ void matrix_init_kb(void) {
15 // put your keyboard start-up code here 11 // put your keyboard start-up code here
16 // runs once when the firmware starts up 12 // runs once when the firmware starts up
17 matrix_init_user(); 13 matrix_init_user();
18 uart_init();
19 led_init(); 14 led_init();
20} 15}
21 16
diff --git a/keyboards/mitosis/rules.mk b/keyboards/mitosis/rules.mk
index 466987e8c..4cb6d8c9b 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
28UNICODE_ENABLE = yes # Unicode 28UNICODE_ENABLE = yes # Unicode
29# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID 29# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
30 30
31USB = /dev/ttyACM0
32
33# upload: build
34# $(MITOSIS_UPLOAD_COMMAND)
35
36OPT_DEFS += -DMITOSIS_PROMICRO
37MITOSIS_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \
38 avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB)
39
40# # project specific files 31# # project specific files
41SRC = matrix.c 32SRC += matrix.c serial_uart.c
diff --git a/keyboards/planck/keymaps/thermal_printer/config.h b/keyboards/planck/keymaps/thermal_printer/config.h
index 4460cdbbe..4ae9ced25 100644
--- a/keyboards/planck/keymaps/thermal_printer/config.h
+++ b/keyboards/planck/keymaps/thermal_printer/config.h
@@ -3,22 +3,7 @@
3 3
4#include "../../config.h" 4#include "../../config.h"
5 5
6# define SERIAL_UART_BAUD 19200 6#define SERIAL_UART_BAUD 19200
7# define SERIAL_UART_DATA UDR1
8# define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
9# define SERIAL_UART_RXD_VECT USART1_RX_vect
10# define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
11# define SERIAL_UART_INIT() do { \
12 /* baud rate */ \
13 UBRR1L = SERIAL_UART_UBRR; \
14 /* baud rate */ \
15 UBRR1H = SERIAL_UART_UBRR >> 8; \
16 /* enable TX */ \
17 UCSR1B = _BV(TXEN1); \
18 /* 8-bit data */ \
19 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
20 sei(); \
21 } while(0)
22 7
23/* 8/*
24 * MIDI options 9 * MIDI options
diff --git a/keyboards/redox_w/config.h b/keyboards/redox_w/config.h
index 1f40a694d..b480b072f 100644
--- a/keyboards/redox_w/config.h
+++ b/keyboards/redox_w/config.h
@@ -58,17 +58,9 @@
58 58
59//UART settings for communication with the RF microcontroller 59//UART settings for communication with the RF microcontroller
60#define SERIAL_UART_BAUD 1000000 60#define SERIAL_UART_BAUD 1000000
61#define SERIAL_UART_DATA UDR1
62#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
63#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
64#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) 61#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
65#define SERIAL_UART_INIT() do { \ 62#define SERIAL_UART_INIT_CUSTOM \
66 /* baud rate */ \ 63 /* enable TX and RX */ \
67 UBRR1L = SERIAL_UART_UBRR; \ 64 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
68 /* baud rate */ \ 65 /* 8-bit data */ \
69 UBRR1H = SERIAL_UART_UBRR >> 8; \ 66 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
70 /* enable TX and RX */ \
71 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
72 /* 8-bit data */ \
73 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
74 } while(0)
diff --git a/keyboards/redox_w/matrix.c b/keyboards/redox_w/matrix.c
index 31233af10..15ca66e34 100644
--- a/keyboards/redox_w/matrix.c
+++ b/keyboards/redox_w/matrix.c
@@ -24,6 +24,7 @@
24#include "util.h" 24#include "util.h"
25#include "matrix.h" 25#include "matrix.h"
26#include "timer.h" 26#include "timer.h"
27#include "protocol/serial.h"
27 28
28#if (MATRIX_COLS <= 8) 29#if (MATRIX_COLS <= 8)
29# define print_matrix_header() print("\nr/c 01234567\n") 30# define print_matrix_header() print("\nr/c 01234567\n")
@@ -86,12 +87,11 @@ uint8_t matrix_cols(void) {
86void matrix_init(void) { 87void matrix_init(void) {
87 88
88 matrix_init_quantum(); 89 matrix_init_quantum();
90 serial_init();
89} 91}
90 92
91uint8_t matrix_scan(void) 93uint8_t matrix_scan(void)
92{ 94{
93 SERIAL_UART_INIT();
94
95 uint32_t timeout = 0; 95 uint32_t timeout = 0;
96 96
97 //the s character requests the RF slave to send the matrix 97 //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 75df91066..05fa33957 100644
--- a/keyboards/redox_w/redox_w.c
+++ b/keyboards/redox_w/redox_w.c
@@ -1,9 +1,5 @@
1#include "redox_w.h" 1#include "redox_w.h"
2 2
3void uart_init(void) {
4 SERIAL_UART_INIT();
5}
6
7void led_init(void) { 3void led_init(void) {
8 DDRD |= (1<<1); 4 DDRD |= (1<<1);
9 PORTD |= (1<<1); 5 PORTD |= (1<<1);
@@ -16,20 +12,9 @@ void matrix_init_kb(void) {
16 // put your keyboard start-up code here 12 // put your keyboard start-up code here
17 // runs once when the firmware starts up 13 // runs once when the firmware starts up
18 matrix_init_user(); 14 matrix_init_user();
19 uart_init();
20 led_init(); 15 led_init();
21} 16}
22 17
23void matrix_scan_kb(void) {
24 // put your looping keyboard code here
25 // runs every cycle (a lot)
26 matrix_scan_user();
27}
28
29void led_set_kb(uint8_t usb_led) {
30
31}
32
33#ifdef ONEHAND_ENABLE 18#ifdef ONEHAND_ENABLE
34__attribute__ ((weak)) 19__attribute__ ((weak))
35const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = { 20const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
diff --git a/keyboards/redox_w/rules.mk b/keyboards/redox_w/rules.mk
index 8b171f717..01d5c3c70 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
28UNICODE_ENABLE = YES # Unicode 28UNICODE_ENABLE = YES # Unicode
29# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID 29# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
30 30
31USB = /dev/ttyACM0
32
33OPT_DEFS += -DREDOX_W_PROMICRO
34INTERPHASE_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \
35 avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB)
36
37# # project specific files 31# # project specific files
38SRC = matrix.c 32SRC += matrix.c serial_uart.c
39
40# upload: build
41# $(REDOX_W_UPLOAD_COMMAND)
diff --git a/keyboards/sirius/uni660/rev1/config.h b/keyboards/sirius/uni660/rev1/config.h
index 98269d426..91d7c5d7a 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 <http://www.gnu.org/licenses/>.
59 59
60//UART settings for communication with the RF microcontroller 60//UART settings for communication with the RF microcontroller
61#define SERIAL_UART_BAUD 1000000 61#define SERIAL_UART_BAUD 1000000
62#define SERIAL_UART_DATA UDR1
63#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
64#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
65#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) 62#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
66#define SERIAL_UART_INIT() do { \ 63#define SERIAL_UART_INIT_CUSTOM \
67 /* baud rate */ \ 64 /* enable TX and RX */ \
68 UBRR1L = SERIAL_UART_UBRR; \
69 /* baud rate */ \
70 UBRR1H = SERIAL_UART_UBRR >> 8; \
71 /* enable TX and RX */ \
72 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ 65 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
73 /* 8-bit data */ \ 66 /* 8-bit data */ \
74 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ 67 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
75} while (0)
76 68
77#define DYNAMIC_KEYMAP_LAYER_COUNT 4 69#define DYNAMIC_KEYMAP_LAYER_COUNT 4
diff --git a/keyboards/sirius/uni660/rev1/matrix.c b/keyboards/sirius/uni660/rev1/matrix.c
index 3e231b33b..355fa7e5e 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 <http://www.gnu.org/licenses/>.
27#include "matrix.h" 27#include "matrix.h"
28#include "timer.h" 28#include "timer.h"
29#include "debounce.h" 29#include "debounce.h"
30#include "protocol/serial.h"
30 31
31#if (MATRIX_COLS <= 8) 32#if (MATRIX_COLS <= 8)
32# define print_matrix_header() print("\nr/c 01234567\n") 33# define print_matrix_header() print("\nr/c 01234567\n")
@@ -80,14 +81,13 @@ uint8_t matrix_cols(void) {
80void matrix_init(void) { 81void matrix_init(void) {
81 debounce_init(MATRIX_ROWS); 82 debounce_init(MATRIX_ROWS);
82 matrix_init_quantum(); 83 matrix_init_quantum();
84 serial_init();
83} 85}
84 86
85uint8_t matrix_scan(void) 87uint8_t matrix_scan(void)
86{ 88{
87 bool matrix_has_changed = false; 89 bool matrix_has_changed = false;
88 90
89 SERIAL_UART_INIT();
90
91 uint32_t timeout = 0; 91 uint32_t timeout = 0;
92 92
93 //the s character requests the RF slave to send the matrix 93 //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 872004355..d4adac24b 100644
--- a/keyboards/sirius/uni660/rev1/rev1.c
+++ b/keyboards/sirius/uni660/rev1/rev1.c
@@ -1,9 +1,5 @@
1#include "rev1.h" 1#include "rev1.h"
2 2
3void uart_init(void) {
4 SERIAL_UART_INIT();
5}
6
7void led_init(void) { 3void led_init(void) {
8 setPinOutput(D1); // Pin to green, set as output 4 setPinOutput(D1); // Pin to green, set as output
9 writePinHigh(D1); // Turn it off 5 writePinHigh(D1); // Turn it off
@@ -17,7 +13,6 @@ void matrix_init_kb(void) {
17 // put your keyboard start-up code here 13 // put your keyboard start-up code here
18 // runs once when the firmware starts up 14 // runs once when the firmware starts up
19 matrix_init_user(); 15 matrix_init_user();
20 uart_init();
21 led_init(); 16 led_init();
22} 17}
23 18
diff --git a/keyboards/sirius/uni660/rev2/ansi/config.h b/keyboards/sirius/uni660/rev2/ansi/config.h
index 7bca74363..13e33ebf1 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 <http://www.gnu.org/licenses/>.
59 59
60//UART settings for communication with the RF microcontroller 60//UART settings for communication with the RF microcontroller
61#define SERIAL_UART_BAUD 1000000 61#define SERIAL_UART_BAUD 1000000
62#define SERIAL_UART_DATA UDR1
63#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
64#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
65#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) 62#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
66#define SERIAL_UART_INIT() do { \ 63#define SERIAL_UART_INIT_CUSTOM \
67 /* baud rate */ \ 64 /* enable TX and RX */ \
68 UBRR1L = SERIAL_UART_UBRR; \
69 /* baud rate */ \
70 UBRR1H = SERIAL_UART_UBRR >> 8; \
71 /* enable TX and RX */ \
72 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ 65 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
73 /* 8-bit data */ \ 66 /* 8-bit data */ \
74 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ 67 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
75} while (0)
76 68
77#define DYNAMIC_KEYMAP_LAYER_COUNT 4 69#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 0cbbe0c5b..3283f0cd6 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 <http://www.gnu.org/licenses/>.
59 59
60//UART settings for communication with the RF microcontroller 60//UART settings for communication with the RF microcontroller
61#define SERIAL_UART_BAUD 1000000 61#define SERIAL_UART_BAUD 1000000
62#define SERIAL_UART_DATA UDR1
63#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
64#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
65#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) 62#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
66#define SERIAL_UART_INIT() do { \ 63#define SERIAL_UART_INIT_CUSTOM \
67 /* baud rate */ \ 64 /* enable TX and RX */ \
68 UBRR1L = SERIAL_UART_UBRR; \
69 /* baud rate */ \
70 UBRR1H = SERIAL_UART_UBRR >> 8; \
71 /* enable TX and RX */ \
72 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ 65 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
73 /* 8-bit data */ \ 66 /* 8-bit data */ \
74 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ 67 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
75} while (0)
76 68
77#define DYNAMIC_KEYMAP_LAYER_COUNT 4 69#define DYNAMIC_KEYMAP_LAYER_COUNT 4
diff --git a/keyboards/sirius/uni660/rev2/matrix.c b/keyboards/sirius/uni660/rev2/matrix.c
index 3e231b33b..355fa7e5e 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 <http://www.gnu.org/licenses/>.
27#include "matrix.h" 27#include "matrix.h"
28#include "timer.h" 28#include "timer.h"
29#include "debounce.h" 29#include "debounce.h"
30#include "protocol/serial.h"
30 31
31#if (MATRIX_COLS <= 8) 32#if (MATRIX_COLS <= 8)
32# define print_matrix_header() print("\nr/c 01234567\n") 33# define print_matrix_header() print("\nr/c 01234567\n")
@@ -80,14 +81,13 @@ uint8_t matrix_cols(void) {
80void matrix_init(void) { 81void matrix_init(void) {
81 debounce_init(MATRIX_ROWS); 82 debounce_init(MATRIX_ROWS);
82 matrix_init_quantum(); 83 matrix_init_quantum();
84 serial_init();
83} 85}
84 86
85uint8_t matrix_scan(void) 87uint8_t matrix_scan(void)
86{ 88{
87 bool matrix_has_changed = false; 89 bool matrix_has_changed = false;
88 90
89 SERIAL_UART_INIT();
90
91 uint32_t timeout = 0; 91 uint32_t timeout = 0;
92 92
93 //the s character requests the RF slave to send the matrix 93 //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 e19240ccc..048495b99 100644
--- a/keyboards/sirius/uni660/rev2/rev2.c
+++ b/keyboards/sirius/uni660/rev2/rev2.c
@@ -1,9 +1,5 @@
1#include "rev2.h" 1#include "rev2.h"
2 2
3void uart_init(void) {
4 SERIAL_UART_INIT();
5}
6
7void led_init(void) { 3void led_init(void) {
8 setPinOutput(D1); // Pin to green, set as output 4 setPinOutput(D1); // Pin to green, set as output
9 writePinHigh(D1); // Turn it off 5 writePinHigh(D1); // Turn it off
@@ -17,7 +13,6 @@ void matrix_init_kb(void) {
17 // put your keyboard start-up code here 13 // put your keyboard start-up code here
18 // runs once when the firmware starts up 14 // runs once when the firmware starts up
19 matrix_init_user(); 15 matrix_init_user();
20 uart_init();
21 led_init(); 16 led_init();
22} 17}
23 18
diff --git a/keyboards/telophase/config.h b/keyboards/telophase/config.h
index e9329c573..c67dd939b 100644
--- a/keyboards/telophase/config.h
+++ b/keyboards/telophase/config.h
@@ -60,19 +60,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
60 60
61//UART settings for communication with the RF microcontroller 61//UART settings for communication with the RF microcontroller
62#define SERIAL_UART_BAUD 1000000 62#define SERIAL_UART_BAUD 1000000
63#define SERIAL_UART_DATA UDR1
64#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
65#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
66#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1)) 63#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
67#define SERIAL_UART_INIT() do { \ 64#define SERIAL_UART_INIT_CUSTOM \
68 /* baud rate */ \ 65 /* enable TX and RX */ \
69 UBRR1L = SERIAL_UART_UBRR; \ 66 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
70 /* baud rate */ \ 67 /* 8-bit data */ \
71 UBRR1H = SERIAL_UART_UBRR >> 8; \ 68 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
72 /* enable TX and RX */ \
73 UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
74 /* 8-bit data */ \
75 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
76 } while(0)
77 69
78#endif 70#endif
diff --git a/keyboards/telophase/matrix.c b/keyboards/telophase/matrix.c
index c332eba55..8edfce62d 100644
--- a/keyboards/telophase/matrix.c
+++ b/keyboards/telophase/matrix.c
@@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
26#include "util.h" 26#include "util.h"
27#include "matrix.h" 27#include "matrix.h"
28#include "timer.h" 28#include "timer.h"
29#include "protocol/serial.h"
29 30
30#if (MATRIX_COLS <= 8) 31#if (MATRIX_COLS <= 8)
31# define print_matrix_header() print("\nr/c 01234567\n") 32# define print_matrix_header() print("\nr/c 01234567\n")
@@ -88,12 +89,11 @@ uint8_t matrix_cols(void) {
88void matrix_init(void) { 89void matrix_init(void) {
89 90
90 matrix_init_quantum(); 91 matrix_init_quantum();
92 serial_init();
91} 93}
92 94
93uint8_t matrix_scan(void) 95uint8_t matrix_scan(void)
94{ 96{
95 SERIAL_UART_INIT();
96
97 uint32_t timeout = 0; 97 uint32_t timeout = 0;
98 98
99 //the s character requests the RF slave to send the matrix 99 //the s character requests the RF slave to send the matrix
diff --git a/keyboards/telophase/rules.mk b/keyboards/telophase/rules.mk
index f2ac0adb6..65cac9364 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
27# MIDI_ENABLE = YES # MIDI controls 27# MIDI_ENABLE = YES # MIDI controls
28UNICODE_ENABLE = YES # Unicode 28UNICODE_ENABLE = YES # Unicode
29# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID 29# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
30LAYOUTS = ortho_4x12
31USB = /dev/ttyACM0
32
33# upload: build
34# $(MITOSIS_UPLOAD_COMMAND)
35
36OPT_DEFS += -DMITOSIS_PROMICRO
37MITOSIS_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \
38 avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB)
39 30
40# # project specific files 31# # project specific files
41SRC = matrix.c 32SRC = matrix.c serial_uart.c
42 33
43# Disable unsupported hardware 34# Disable unsupported hardware
44RGBLIGHT_SUPPORTED = no 35RGBLIGHT_SUPPORTED = no
45AUDIO_SUPPORTED = no 36AUDIO_SUPPORTED = no
46BACKLIGHT_SUPPORTED = no 37BACKLIGHT_SUPPORTED = no
38
39LAYOUTS = ortho_4x12
diff --git a/keyboards/telophase/telophase.c b/keyboards/telophase/telophase.c
index c77a43389..0e04debeb 100644
--- a/keyboards/telophase/telophase.c
+++ b/keyboards/telophase/telophase.c
@@ -1,9 +1,5 @@
1#include "telophase.h" 1#include "telophase.h"
2 2
3void uart_init(void) {
4 SERIAL_UART_INIT();
5}
6
7void led_init(void) { 3void led_init(void) {
8 DDRD |= (1<<1); 4 DDRD |= (1<<1);
9 PORTD |= (1<<1); 5 PORTD |= (1<<1);
@@ -16,20 +12,9 @@ void matrix_init_kb(void) {
16 // put your keyboard start-up code here 12 // put your keyboard start-up code here
17 // runs once when the firmware starts up 13 // runs once when the firmware starts up
18 matrix_init_user(); 14 matrix_init_user();
19 uart_init();
20 led_init(); 15 led_init();
21} 16}
22 17
23void matrix_scan_kb(void) {
24 // put your looping keyboard code here
25 // runs every cycle (a lot)
26 matrix_scan_user();
27}
28
29void led_set_kb(uint8_t usb_led) {
30
31}
32
33#ifdef SWAP_HANDS_ENABLE 18#ifdef SWAP_HANDS_ENABLE
34__attribute__ ((weak)) 19__attribute__ ((weak))
35const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = { 20const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
diff --git a/quantum/config_common.h b/quantum/config_common.h
index 2d9c70b08..5973232ef 100644
--- a/quantum/config_common.h
+++ b/quantum/config_common.h
@@ -367,51 +367,6 @@
367# endif 367# endif
368#endif 368#endif
369 369
370/* USART configuration */
371#ifdef BLUETOOTH_ENABLE
372# ifdef __AVR_ATmega32U4__
373# define SERIAL_UART_BAUD 9600
374# define SERIAL_UART_DATA UDR1
375# define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
376# define SERIAL_UART_RXD_VECT USART1_RX_vect
377# define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
378# define SERIAL_UART_INIT() \
379 do { \
380 /* baud rate */ \
381 UBRR1L = SERIAL_UART_UBRR; \
382 /* baud rate */ \
383 UBRR1H = SERIAL_UART_UBRR >> 8; \
384 /* enable TX */ \
385 UCSR1B = _BV(TXEN1); \
386 /* 8-bit data */ \
387 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
388 sei(); \
389 } while (0)
390# elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
391# define SERIAL_UART_BAUD 115200
392# define SERIAL_UART_DATA UDR1
393/* UBRR should result in ~16 and set UCSR1A = _BV(U2X1) as per rn42 documentation. HC05 needs baudrate configured accordingly */
394# define SERIAL_UART_UBRR (F_CPU / (8UL * SERIAL_UART_BAUD) - 1)
395# define SERIAL_UART_RXD_VECT USART1_RX_vect
396# define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
397# define SERIAL_UART_INIT() \
398 do { \
399 UCSR1A = _BV(U2X1); \
400 /* baud rate */ \
401 UBRR1L = SERIAL_UART_UBRR; \
402 /* baud rate */ \
403 UBRR1H = SERIAL_UART_UBRR >> 8; \
404 /* enable TX */ \
405 UCSR1B = _BV(TXEN1); \
406 /* 8-bit data */ \
407 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \
408 sei(); \
409 } while (0)
410# else
411# error "USART configuration is needed."
412# endif
413#endif
414
415#define API_SYSEX_MAX_SIZE 32 370#define API_SYSEX_MAX_SIZE 32
416 371
417#include "song_list.h" 372#include "song_list.h"
diff --git a/tmk_core/protocol/serial.h b/tmk_core/protocol/serial.h
index b70d117d7..0204b84a9 100644
--- a/tmk_core/protocol/serial.h
+++ b/tmk_core/protocol/serial.h
@@ -37,6 +37,8 @@ POSSIBILITY OF SUCH DAMAGE.
37 37
38#pragma once 38#pragma once
39 39
40#define SERIAL_UART_DATA UDR1
41
40/* host role */ 42/* host role */
41void serial_init(void); 43void serial_init(void);
42uint8_t serial_recv(void); 44uint8_t serial_recv(void);
diff --git a/tmk_core/protocol/serial_uart.c b/tmk_core/protocol/serial_uart.c
index a15124193..4fe059e7d 100644
--- a/tmk_core/protocol/serial_uart.c
+++ b/tmk_core/protocol/serial_uart.c
@@ -40,6 +40,22 @@ POSSIBILITY OF SUCH DAMAGE.
40#include <avr/interrupt.h> 40#include <avr/interrupt.h>
41#include "serial.h" 41#include "serial.h"
42 42
43#ifndef SERIAL_UART_BAUD
44# define SERIAL_UART_BAUD 9600
45#endif
46
47#define SERIAL_UART_UBRR (F_CPU / (16UL * SERIAL_UART_BAUD) - 1)
48#define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1))
49#define SERIAL_UART_RXD_VECT USART1_RX_vect
50
51#ifndef SERIAL_UART_INIT_CUSTOM
52# define SERIAL_UART_INIT_CUSTOM \
53 /* enable TX */ \
54 UCSR1B = _BV(TXEN1); \
55 /* 8-bit data */ \
56 UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
57#endif
58
43#if defined(SERIAL_UART_RTS_LO) && defined(SERIAL_UART_RTS_HI) 59#if defined(SERIAL_UART_RTS_LO) && defined(SERIAL_UART_RTS_HI)
44// Buffer state 60// Buffer state
45// Empty: RBUF_SPACE == RBUF_SIZE(head==tail) 61// Empty: RBUF_SPACE == RBUF_SIZE(head==tail)
@@ -61,7 +77,14 @@ POSSIBILITY OF SUCH DAMAGE.
61# define rbuf_check_rts_hi() 77# define rbuf_check_rts_hi()
62#endif 78#endif
63 79
64void serial_init(void) { SERIAL_UART_INIT(); } 80void serial_init(void) {
81 do {
82 // Set baud rate
83 UBRR1L = SERIAL_UART_UBRR;
84 UBRR1L = SERIAL_UART_UBRR >> 8;
85 SERIAL_UART_INIT_CUSTOM;
86 } while (0);
87}
65 88
66// RX ring buffer 89// RX ring buffer
67#define RBUF_SIZE 256 90#define RBUF_SIZE 256