1
0
Fork 0

Serial refactor (#11521)

This commit is contained in:
Ryan 2021-02-06 09:20:48 +11:00 committed by GitHub
parent 464eb7137d
commit 5ea92a9c1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
58 changed files with 162 additions and 562 deletions

View file

@ -54,25 +54,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Enable GNAP matrix serial output */ /* Enable GNAP matrix serial output */
#define GNAP_ENABLE #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

View file

@ -1,9 +1,5 @@
#include "centromere.h" #include "centromere.h"
void uart_init(void) {
SERIAL_UART_INIT();
}
void led_init(void) { void led_init(void) {
#if MCU == atmega32u2 #if MCU == atmega32u2
setPinOutput(C4); // Set red LED pin as output setPinOutput(C4); // Set red LED pin as output
@ -32,7 +28,6 @@ void matrix_init_kb(void) {
// put your keyboard start-up code here // put your keyboard start-up code here
// runs once when the firmware starts up // runs once when the firmware starts up
matrix_init_user(); matrix_init_user();
uart_init();
led_init(); led_init();
} }

View file

@ -59,17 +59,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//UART settings for communication with the RF microcontroller //UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 500000 #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_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT() do { \ #define SERIAL_UART_INIT_CUSTOM \
/* baud rate */ \
UBRR1L = SERIAL_UART_UBRR; \
/* baud rate */ \
UBRR1H = SERIAL_UART_UBRR >> 8; \
/* enable TX and RX */ \ /* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \ /* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
} while(0)

View file

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "util.h" #include "util.h"
#include "matrix.h" #include "matrix.h"
#include "timer.h" #include "timer.h"
#include "protocol/serial.h"
#if (MATRIX_COLS <= 8) #if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n") # define print_matrix_header() print("\nr/c 01234567\n")
@ -79,12 +80,11 @@ uint8_t matrix_cols(void) {
void matrix_init(void) { void matrix_init(void) {
matrix_init_quantum(); matrix_init_quantum();
serial_init();
} }
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
SERIAL_UART_INIT();
uint32_t timeout = 0; uint32_t timeout = 0;
//the s character requests the RF remote slave to send the matrix information //the s character requests the RF remote slave to send the matrix information

View file

@ -31,14 +31,7 @@ MIDI_ENABLE = no # MIDI controls
UNICODE_ENABLE = yes # Unicode UNICODE_ENABLE = yes # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID 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 # # project specific files
SRC = matrix.c SRC += matrix.c serial_uart.c
LAYOUTS = split_3x5_3 split_3x6_3 LAYOUTS = split_3x5_3 split_3x6_3

View file

@ -1,9 +1,5 @@
#include "chimera_ergo.h" #include "chimera_ergo.h"
void uart_init(void) {
SERIAL_UART_INIT();
}
void led_init(void) { void led_init(void) {
DDRD |= (1<<1); DDRD |= (1<<1);
PORTD |= (1<<1); PORTD |= (1<<1);
@ -16,16 +12,5 @@ void matrix_init_kb(void) {
// put your keyboard start-up code here // put your keyboard start-up code here
// runs once when the firmware starts up // runs once when the firmware starts up
matrix_init_user(); matrix_init_user();
uart_init();
led_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) {
}

View file

@ -60,19 +60,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//UART settings for communication with the RF microcontroller //UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000 #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_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT() do { \ #define SERIAL_UART_INIT_CUSTOM \
/* baud rate */ \
UBRR1L = SERIAL_UART_UBRR; \
/* baud rate */ \
UBRR1H = SERIAL_UART_UBRR >> 8; \
/* enable TX and RX */ \ /* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \ /* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
} while(0)
#endif #endif

View file

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "util.h" #include "util.h"
#include "matrix.h" #include "matrix.h"
#include "timer.h" #include "timer.h"
#include "protocol/serial.h"
#if (MATRIX_COLS <= 8) #if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n") # define print_matrix_header() print("\nr/c 01234567\n")
@ -88,12 +89,11 @@ uint8_t matrix_cols(void) {
void matrix_init(void) { void matrix_init(void) {
matrix_init_quantum(); matrix_init_quantum();
serial_init();
} }
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
SERIAL_UART_INIT();
uint32_t timeout = 0; uint32_t timeout = 0;
//the s character requests the RF slave to send the matrix //the s character requests the RF slave to send the matrix

View file

@ -28,12 +28,5 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
UNICODE_ENABLE = YES # Unicode UNICODE_ENABLE = YES # Unicode
# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID # 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 # # project specific files
SRC = matrix.c SRC += matrix.c serial_uart.c
USB = /dev/ttyACM0

View file

@ -1,9 +1,5 @@
#include "chimera_ls.h" #include "chimera_ls.h"
void uart_init(void) {
SERIAL_UART_INIT();
}
void led_init(void) { void led_init(void) {
DDRD |= (1<<1); DDRD |= (1<<1);
PORTD |= (1<<1); PORTD |= (1<<1);
@ -16,16 +12,5 @@ void matrix_init_kb(void) {
// put your keyboard start-up code here // put your keyboard start-up code here
// runs once when the firmware starts up // runs once when the firmware starts up
matrix_init_user(); matrix_init_user();
uart_init();
led_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) {
}

View file

@ -60,19 +60,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//UART settings for communication with the RF microcontroller //UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000 #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_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT() do { \ #define SERIAL_UART_INIT_CUSTOM \
/* baud rate */ \
UBRR1L = SERIAL_UART_UBRR; \
/* baud rate */ \
UBRR1H = SERIAL_UART_UBRR >> 8; \
/* enable TX and RX */ \ /* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \ /* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
} while(0)
#endif #endif

View file

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "util.h" #include "util.h"
#include "matrix.h" #include "matrix.h"
#include "timer.h" #include "timer.h"
#include "protocol/serial.h"
#if (MATRIX_COLS <= 8) #if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n") # define print_matrix_header() print("\nr/c 01234567\n")
@ -92,12 +93,11 @@ uint8_t matrix_cols(void) {
void matrix_init(void) { void matrix_init(void) {
matrix_init_quantum(); matrix_init_quantum();
serial_init();
} }
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
SERIAL_UART_INIT();
uint32_t timeout = 0; uint32_t timeout = 0;
//the s character requests the RF slave to send the matrix //the s character requests the RF slave to send the matrix

View file

@ -28,14 +28,8 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
UNICODE_ENABLE = YES # Unicode UNICODE_ENABLE = YES # Unicode
# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID # 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 # project specific files
SRC = matrix.c SRC += matrix.c serial_uart.c
LAYOUTS = ortho_4x12 LAYOUTS = ortho_4x12

View file

@ -1,9 +1,5 @@
#include "chimera_ortho.h" #include "chimera_ortho.h"
void uart_init(void) {
SERIAL_UART_INIT();
}
void led_init(void) { void led_init(void) {
DDRD |= (1<<1); DDRD |= (1<<1);
PORTD |= (1<<1); PORTD |= (1<<1);
@ -16,16 +12,5 @@ void matrix_init_kb(void) {
// put your keyboard start-up code here // put your keyboard start-up code here
// runs once when the firmware starts up // runs once when the firmware starts up
matrix_init_user(); matrix_init_user();
uart_init();
led_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) {
}

View file

@ -60,19 +60,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//UART settings for communication with the RF microcontroller //UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000 #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_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT() do { \ #define SERIAL_UART_INIT_CUSTOM \
/* baud rate */ \
UBRR1L = SERIAL_UART_UBRR; \
/* baud rate */ \
UBRR1H = SERIAL_UART_UBRR >> 8; \
/* enable TX and RX */ \ /* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \ /* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
} while(0)
#endif #endif

View file

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "util.h" #include "util.h"
#include "matrix.h" #include "matrix.h"
#include "timer.h" #include "timer.h"
#include "protocol/serial.h"
#if (MATRIX_COLS <= 8) #if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n") # define print_matrix_header() print("\nr/c 01234567\n")
@ -78,12 +79,11 @@ uint8_t matrix_cols(void) {
void matrix_init(void) { void matrix_init(void) {
matrix_init_quantum(); matrix_init_quantum();
serial_init();
} }
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
SERIAL_UART_INIT();
uint32_t timeout = 0; uint32_t timeout = 0;
//the s character requests the RF slave to send the matrix //the s character requests the RF slave to send the matrix

View file

@ -28,11 +28,5 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
UNICODE_ENABLE = YES # Unicode UNICODE_ENABLE = YES # Unicode
# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID # 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 # project specific files
SRC = matrix.c SRC += matrix.c serial_uart.c

View file

@ -1,9 +1,5 @@
#include "chimera_ortho_plus.h" #include "chimera_ortho_plus.h"
void uart_init(void) {
SERIAL_UART_INIT();
}
void led_init(void) { void led_init(void) {
setPinOutput(D1); setPinOutput(D1);
setPinOutput(F4); setPinOutput(F4);
@ -18,6 +14,5 @@ void matrix_init_kb(void) {
// put your keyboard start-up code here // put your keyboard start-up code here
// runs once when the firmware starts up // runs once when the firmware starts up
matrix_init_user(); matrix_init_user();
uart_init();
led_init(); led_init();
} }

View file

@ -59,17 +59,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//UART settings for communication with the RF microcontroller //UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000 #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_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT() do { \ #define SERIAL_UART_INIT_CUSTOM \
/* baud rate */ \
UBRR1L = SERIAL_UART_UBRR; \
/* baud rate */ \
UBRR1H = SERIAL_UART_UBRR >> 8; \
/* enable TX and RX */ \ /* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \ /* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
} while(0)

View file

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "util.h" #include "util.h"
#include "matrix.h" #include "matrix.h"
#include "timer.h" #include "timer.h"
#include "protocol/serial.h"
#if (MATRIX_COLS <= 8) #if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n") # define print_matrix_header() print("\nr/c 01234567\n")
@ -78,12 +79,11 @@ uint8_t matrix_cols(void) {
void matrix_init(void) { void matrix_init(void) {
matrix_init_quantum(); matrix_init_quantum();
serial_init();
} }
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
SERIAL_UART_INIT();
uint32_t timeout = 0; uint32_t timeout = 0;
//the s character requests the RF slave to send the matrix //the s character requests the RF slave to send the matrix

View file

@ -33,4 +33,4 @@ UNICODE_ENABLE = yes
CUSTOM_MATRIX = yes CUSTOM_MATRIX = yes
# project specific files # project specific files
SRC = matrix.c SRC += matrix.c serial_uart.c

View file

@ -1,22 +1 @@
#include "comet46.h" #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) {
}

View file

@ -66,19 +66,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//UART settings for communication with the RF microcontroller //UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000 #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_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT() do { \ #define SERIAL_UART_INIT_CUSTOM \
/* baud rate */ \
UBRR1L = SERIAL_UART_UBRR; \
/* baud rate */ \
UBRR1H = SERIAL_UART_UBRR >> 8; \
/* enable TX and RX */ \ /* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \ /* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
} while(0)
#endif #endif

View file

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "util.h" #include "util.h"
#include "matrix.h" #include "matrix.h"
#include "timer.h" #include "timer.h"
#include "protocol/serial.h"
#if (MATRIX_COLS <= 8) #if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n") # define print_matrix_header() print("\nr/c 01234567\n")
@ -78,12 +79,11 @@ uint8_t matrix_cols(void) {
void matrix_init(void) { void matrix_init(void) {
matrix_init_quantum(); matrix_init_quantum();
serial_init();
} }
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
SERIAL_UART_INIT();
uint32_t timeout = 0; uint32_t timeout = 0;
//the s character requests the RF slave to send the matrix //the s character requests the RF slave to send the matrix

View file

@ -28,8 +28,8 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
UNICODE_ENABLE = YES # Unicode UNICODE_ENABLE = YES # Unicode
# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID # BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
USB = /dev/ttyACM0
# project specific files # project specific files
SRC += matrix.c \ SRC += matrix.c \
i2c.c \ i2c.c \
ssd1306.c ssd1306.c \
serial_uart.c

View file

@ -60,19 +60,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//UART settings for communication with the RF microcontroller //UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000 #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_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT() do { \ #define SERIAL_UART_INIT_CUSTOM \
/* baud rate */ \
UBRR1L = SERIAL_UART_UBRR; \
/* baud rate */ \
UBRR1H = SERIAL_UART_UBRR >> 8; \
/* enable TX and RX */ \ /* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \ /* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
} while(0)
#endif #endif

View file

@ -1,12 +1,7 @@
#include "dichotomy.h" #include "dichotomy.h"
void uart_init(void) {
SERIAL_UART_INIT();
}
void pointing_device_task(void){ void pointing_device_task(void){
/*report_mouse_t currentReport = {}; /*report_mouse_t currentReport = {};
SERIAL_UART_INIT();
uint32_t timeout = 0; uint32_t timeout = 0;
//the m character requests the RF slave to send the mouse report //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 // put your keyboard start-up code here
// runs once when the firmware starts up // runs once when the firmware starts up
matrix_init_user(); matrix_init_user();
uart_init();
led_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) {
}

View file

@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dichotomy.h" #include "dichotomy.h"
#include "pointing_device.h" #include "pointing_device.h"
#include "report.h" #include "report.h"
#include "protocol/serial.h"
#if (MATRIX_COLS <= 8) #if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n") # define print_matrix_header() print("\nr/c 01234567\n")
@ -93,11 +94,11 @@ uint8_t matrix_cols(void) {
void matrix_init(void) { void matrix_init(void) {
matrix_init_quantum(); matrix_init_quantum();
serial_init();
} }
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
SERIAL_UART_INIT();
//xprintf("\r\nTRYING TO SCAN"); //xprintf("\r\nTRYING TO SCAN");
uint32_t timeout = 0; uint32_t timeout = 0;

View file

@ -29,14 +29,5 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
UNICODE_ENABLE = YES # Unicode UNICODE_ENABLE = YES # Unicode
# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID # 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 # # project specific files
SRC = matrix.c SRC += matrix.c serial_uart.c
#upload: build
# $(DICHOTOMY_UPLOAD_COMMAND)

View file

@ -52,27 +52,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define SUART_IN_PIN PIND #define SUART_IN_PIN PIND
#define SUART_IN_BIT 1 #define SUART_IN_BIT 1
#ifdef __AVR_ATmega32U4__ #define SERIAL_UART_BAUD 115200
#define SERIAL_UART_BAUD 115200 #define SERIAL_UART_INIT_CUSTOM \
#define SERIAL_UART_DATA UDR1 /* RX interrupt, RX: enable */ \
#define SERIAL_UART_UBRR ((F_CPU/(16.0*SERIAL_UART_BAUD)-1+0.5)) UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); \
#define SERIAL_UART_RXD_VECT USART1_RX_vect /* TX interrupt, TX: enable */ \
#define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1)) UCSR1B |= (0<<TXCIE1) | (1<<TXEN1); \
#define SERIAL_UART_INIT() do { \ /* parity: none(00), even(01), odd(11) */ \
UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \ UCSR1C |= (0<<UPM11) | (0<<UPM10); \
UBRR1H = ((uint16_t)SERIAL_UART_UBRR>>8); /* baud rate */ \ /* RTS, CTS(no flow control by hardware) */ \
UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); /* RX interrupt, RX: enable */ \ UCSR1D |= (0<<RTSEN) | (0<<CTSEN); \
UCSR1B |= (0<<TXCIE1) | (1<<TXEN1); /* TX interrupt, TX: enable */ \ /* RTS for flow control by firmware */ \
UCSR1C |= (0<<UPM11) | (0<<UPM10); /* parity: none(00), even(01), odd(11) */ \ DDRD |= (1<<5); PORTD &= ~(1<<5);
UCSR1D |= (0<<RTSEN) | (0<<CTSEN); /* RTS, CTS(no flow control by hardware) */ \ #define SERIAL_UART_RTS_LO() do { PORTD &= ~(1<<5); } while (0)
DDRD |= (1<<5); PORTD &= ~(1<<5); /* RTS for flow control by firmware */ \ #define SERIAL_UART_RTS_HI() do { PORTD |= (1<<5); } while (0)
sei(); \
} while(0)
#define SERIAL_UART_RTS_LO() do { PORTD &= ~(1<<5); } while (0)
#define SERIAL_UART_RTS_HI() do { PORTD |= (1<<5); } while (0)
#else
#error "USART configuration is needed."
#endif
/* power control of key switch board */ /* power control of key switch board */
#define HHKB_POWER_SAVING #define HHKB_POWER_SAVING

View file

@ -52,27 +52,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define SUART_IN_PIN PIND #define SUART_IN_PIN PIND
#define SUART_IN_BIT 1 #define SUART_IN_BIT 1
#ifdef __AVR_ATmega32U4__ #define SERIAL_UART_BAUD 115200
#define SERIAL_UART_BAUD 115200 #define SERIAL_UART_INIT_CUSTOM \
#define SERIAL_UART_DATA UDR1 /* RX interrupt, RX: enable */ \
#define SERIAL_UART_UBRR ((F_CPU/(16.0*SERIAL_UART_BAUD)-1+0.5)) UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); \
#define SERIAL_UART_RXD_VECT USART1_RX_vect /* TX interrupt, TX: enable */ \
#define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1)) UCSR1B |= (0<<TXCIE1) | (1<<TXEN1); \
#define SERIAL_UART_INIT() do { \ /* parity: none(00), even(01), odd(11) */ \
UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \ UCSR1C |= (0<<UPM11) | (0<<UPM10); \
UBRR1H = ((uint16_t)SERIAL_UART_UBRR>>8); /* baud rate */ \ /* RTS, CTS(no flow control by hardware) */ \
UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); /* RX interrupt, RX: enable */ \ UCSR1D |= (0<<RTSEN) | (0<<CTSEN); \
UCSR1B |= (0<<TXCIE1) | (1<<TXEN1); /* TX interrupt, TX: enable */ \ /* RTS for flow control by firmware */ \
UCSR1C |= (0<<UPM11) | (0<<UPM10); /* parity: none(00), even(01), odd(11) */ \ DDRD |= (1<<5); PORTD &= ~(1<<5);
UCSR1D |= (0<<RTSEN) | (0<<CTSEN); /* RTS, CTS(no flow control by hardware) */ \ #define SERIAL_UART_RTS_LO() do { PORTD &= ~(1<<5); } while (0)
DDRD |= (1<<5); PORTD &= ~(1<<5); /* RTS for flow control by firmware */ \ #define SERIAL_UART_RTS_HI() do { PORTD |= (1<<5); } while (0)
sei(); \
} while(0)
#define SERIAL_UART_RTS_LO() do { PORTD &= ~(1<<5); } while (0)
#define SERIAL_UART_RTS_HI() do { PORTD |= (1<<5); } while (0)
#else
#error "USART configuration is needed."
#endif
/* power control of key switch board */ /* power control of key switch board */
#define HHKB_POWER_SAVING #define HHKB_POWER_SAVING

View file

@ -48,17 +48,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//UART settings for communication with the RF microcontroller //UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000 #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_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT() do { \ #define SERIAL_UART_INIT_CUSTOM \
/* baud rate */ \
UBRR1L = SERIAL_UART_UBRR; \
/* baud rate */ \
UBRR1H = SERIAL_UART_UBRR >> 8; \
/* enable TX and RX */ \ /* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \ /* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
} while(0)

View file

@ -2,13 +2,8 @@
#include "pointing_device.h" #include "pointing_device.h"
#include "report.h" #include "report.h"
void uart_init(void) {
SERIAL_UART_INIT();
}
void pointing_device_task(void){ void pointing_device_task(void){
/*report_mouse_t currentReport = {}; /*report_mouse_t currentReport = {};
SERIAL_UART_INIT();
uint32_t timeout = 0; uint32_t timeout = 0;
//the m character requests the RF slave to send the mouse report //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 // put your keyboard start-up code here
// runs once when the firmware starts up // runs once when the firmware starts up
matrix_init_user(); matrix_init_user();
uart_init();
led_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) {
}

View file

@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "honeycomb.h" #include "honeycomb.h"
#include "pointing_device.h" #include "pointing_device.h"
#include "report.h" #include "report.h"
#include "protocol/serial.h"
#if (MATRIX_COLS <= 8) #if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n") # define print_matrix_header() print("\nr/c 01234567\n")
@ -94,12 +95,11 @@ uint8_t matrix_cols(void) {
void matrix_init(void) { void matrix_init(void) {
matrix_init_quantum(); matrix_init_quantum();
serial_init();
} }
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
SERIAL_UART_INIT();
uint32_t timeout = 0; uint32_t timeout = 0;
// The 's' character requests the RF slave to send the matrix // The 's' character requests the RF slave to send the matrix

View file

@ -30,9 +30,4 @@ UNICODE_ENABLE = YES # Unicode
# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID # BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
# # project specific files # # project specific files
SRC += matrix.c SRC += matrix.c serial_uart.c
USB = /dev/ttyACM0
#upload: build
# $(honeycomb_UPLOAD_COMMAND)

View file

@ -60,19 +60,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//UART settings for communication with the RF microcontroller //UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000 #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_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT() do { \ #define SERIAL_UART_INIT_CUSTOM \
/* baud rate */ \
UBRR1L = SERIAL_UART_UBRR; \
/* baud rate */ \
UBRR1H = SERIAL_UART_UBRR >> 8; \
/* enable TX and RX */ \ /* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \ /* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
} while(0)
#endif #endif

View file

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "util.h" #include "util.h"
#include "matrix.h" #include "matrix.h"
#include "timer.h" #include "timer.h"
#include "protocol/serial.h"
#if (MATRIX_COLS <= 8) #if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n") # define print_matrix_header() print("\nr/c 01234567\n")
@ -79,12 +80,11 @@ uint8_t matrix_cols(void) {
void matrix_init(void) { void matrix_init(void) {
matrix_init_quantum(); matrix_init_quantum();
serial_init();
} }
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
SERIAL_UART_INIT();
uint32_t timeout = 0; uint32_t timeout = 0;
//the s character requests the RF slave to send the matrix //the s character requests the RF slave to send the matrix

View file

@ -1,9 +1,5 @@
#include "mitosis.h" #include "mitosis.h"
void uart_init(void) {
SERIAL_UART_INIT();
}
void led_init(void) { void led_init(void) {
DDRD |= (1<<1); // Pin to green, set as output DDRD |= (1<<1); // Pin to green, set as output
PORTD |= (1<<1); // Turn it off PORTD |= (1<<1); // Turn it off
@ -15,7 +11,6 @@ void matrix_init_kb(void) {
// put your keyboard start-up code here // put your keyboard start-up code here
// runs once when the firmware starts up // runs once when the firmware starts up
matrix_init_user(); matrix_init_user();
uart_init();
led_init(); led_init();
} }

View file

@ -28,14 +28,5 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
UNICODE_ENABLE = yes # Unicode UNICODE_ENABLE = yes # Unicode
# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID # 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 # # project specific files
SRC = matrix.c SRC += matrix.c serial_uart.c

View file

@ -3,22 +3,7 @@
#include "../../config.h" #include "../../config.h"
# define SERIAL_UART_BAUD 19200 #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)
/* /*
* MIDI options * MIDI options

View file

@ -58,17 +58,9 @@
//UART settings for communication with the RF microcontroller //UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000 #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_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT() do { \ #define SERIAL_UART_INIT_CUSTOM \
/* baud rate */ \
UBRR1L = SERIAL_UART_UBRR; \
/* baud rate */ \
UBRR1H = SERIAL_UART_UBRR >> 8; \
/* enable TX and RX */ \ /* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \ /* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
} while(0)

View file

@ -24,6 +24,7 @@
#include "util.h" #include "util.h"
#include "matrix.h" #include "matrix.h"
#include "timer.h" #include "timer.h"
#include "protocol/serial.h"
#if (MATRIX_COLS <= 8) #if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n") # define print_matrix_header() print("\nr/c 01234567\n")
@ -86,12 +87,11 @@ uint8_t matrix_cols(void) {
void matrix_init(void) { void matrix_init(void) {
matrix_init_quantum(); matrix_init_quantum();
serial_init();
} }
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
SERIAL_UART_INIT();
uint32_t timeout = 0; uint32_t timeout = 0;
//the s character requests the RF slave to send the matrix //the s character requests the RF slave to send the matrix

View file

@ -1,9 +1,5 @@
#include "redox_w.h" #include "redox_w.h"
void uart_init(void) {
SERIAL_UART_INIT();
}
void led_init(void) { void led_init(void) {
DDRD |= (1<<1); DDRD |= (1<<1);
PORTD |= (1<<1); PORTD |= (1<<1);
@ -16,20 +12,9 @@ void matrix_init_kb(void) {
// put your keyboard start-up code here // put your keyboard start-up code here
// runs once when the firmware starts up // runs once when the firmware starts up
matrix_init_user(); matrix_init_user();
uart_init();
led_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 #ifdef ONEHAND_ENABLE
__attribute__ ((weak)) __attribute__ ((weak))
const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = { const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {

View file

@ -28,14 +28,5 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
UNICODE_ENABLE = YES # Unicode UNICODE_ENABLE = YES # Unicode
# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID # 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 # # project specific files
SRC = matrix.c SRC += matrix.c serial_uart.c
# upload: build
# $(REDOX_W_UPLOAD_COMMAND)

View file

@ -59,19 +59,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//UART settings for communication with the RF microcontroller //UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000 #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_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT() do { \ #define SERIAL_UART_INIT_CUSTOM \
/* baud rate */ \
UBRR1L = SERIAL_UART_UBRR; \
/* baud rate */ \
UBRR1H = SERIAL_UART_UBRR >> 8; \
/* enable TX and RX */ \ /* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \ /* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
} while (0)
#define DYNAMIC_KEYMAP_LAYER_COUNT 4 #define DYNAMIC_KEYMAP_LAYER_COUNT 4

View file

@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "matrix.h" #include "matrix.h"
#include "timer.h" #include "timer.h"
#include "debounce.h" #include "debounce.h"
#include "protocol/serial.h"
#if (MATRIX_COLS <= 8) #if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n") # define print_matrix_header() print("\nr/c 01234567\n")
@ -80,14 +81,13 @@ uint8_t matrix_cols(void) {
void matrix_init(void) { void matrix_init(void) {
debounce_init(MATRIX_ROWS); debounce_init(MATRIX_ROWS);
matrix_init_quantum(); matrix_init_quantum();
serial_init();
} }
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
bool matrix_has_changed = false; bool matrix_has_changed = false;
SERIAL_UART_INIT();
uint32_t timeout = 0; uint32_t timeout = 0;
//the s character requests the RF slave to send the matrix //the s character requests the RF slave to send the matrix

View file

@ -1,9 +1,5 @@
#include "rev1.h" #include "rev1.h"
void uart_init(void) {
SERIAL_UART_INIT();
}
void led_init(void) { void led_init(void) {
setPinOutput(D1); // Pin to green, set as output setPinOutput(D1); // Pin to green, set as output
writePinHigh(D1); // Turn it off writePinHigh(D1); // Turn it off
@ -17,7 +13,6 @@ void matrix_init_kb(void) {
// put your keyboard start-up code here // put your keyboard start-up code here
// runs once when the firmware starts up // runs once when the firmware starts up
matrix_init_user(); matrix_init_user();
uart_init();
led_init(); led_init();
} }

View file

@ -59,19 +59,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//UART settings for communication with the RF microcontroller //UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000 #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_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT() do { \ #define SERIAL_UART_INIT_CUSTOM \
/* baud rate */ \
UBRR1L = SERIAL_UART_UBRR; \
/* baud rate */ \
UBRR1H = SERIAL_UART_UBRR >> 8; \
/* enable TX and RX */ \ /* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \ /* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
} while (0)
#define DYNAMIC_KEYMAP_LAYER_COUNT 4 #define DYNAMIC_KEYMAP_LAYER_COUNT 4

View file

@ -59,19 +59,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//UART settings for communication with the RF microcontroller //UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000 #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_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT() do { \ #define SERIAL_UART_INIT_CUSTOM \
/* baud rate */ \
UBRR1L = SERIAL_UART_UBRR; \
/* baud rate */ \
UBRR1H = SERIAL_UART_UBRR >> 8; \
/* enable TX and RX */ \ /* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \ /* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
} while (0)
#define DYNAMIC_KEYMAP_LAYER_COUNT 4 #define DYNAMIC_KEYMAP_LAYER_COUNT 4

View file

@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "matrix.h" #include "matrix.h"
#include "timer.h" #include "timer.h"
#include "debounce.h" #include "debounce.h"
#include "protocol/serial.h"
#if (MATRIX_COLS <= 8) #if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n") # define print_matrix_header() print("\nr/c 01234567\n")
@ -80,14 +81,13 @@ uint8_t matrix_cols(void) {
void matrix_init(void) { void matrix_init(void) {
debounce_init(MATRIX_ROWS); debounce_init(MATRIX_ROWS);
matrix_init_quantum(); matrix_init_quantum();
serial_init();
} }
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
bool matrix_has_changed = false; bool matrix_has_changed = false;
SERIAL_UART_INIT();
uint32_t timeout = 0; uint32_t timeout = 0;
//the s character requests the RF slave to send the matrix //the s character requests the RF slave to send the matrix

View file

@ -1,9 +1,5 @@
#include "rev2.h" #include "rev2.h"
void uart_init(void) {
SERIAL_UART_INIT();
}
void led_init(void) { void led_init(void) {
setPinOutput(D1); // Pin to green, set as output setPinOutput(D1); // Pin to green, set as output
writePinHigh(D1); // Turn it off writePinHigh(D1); // Turn it off
@ -17,7 +13,6 @@ void matrix_init_kb(void) {
// put your keyboard start-up code here // put your keyboard start-up code here
// runs once when the firmware starts up // runs once when the firmware starts up
matrix_init_user(); matrix_init_user();
uart_init();
led_init(); led_init();
} }

View file

@ -60,19 +60,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//UART settings for communication with the RF microcontroller //UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000 #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_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT() do { \ #define SERIAL_UART_INIT_CUSTOM \
/* baud rate */ \
UBRR1L = SERIAL_UART_UBRR; \
/* baud rate */ \
UBRR1H = SERIAL_UART_UBRR >> 8; \
/* enable TX and RX */ \ /* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \ UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \ /* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
} while(0)
#endif #endif

View file

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "util.h" #include "util.h"
#include "matrix.h" #include "matrix.h"
#include "timer.h" #include "timer.h"
#include "protocol/serial.h"
#if (MATRIX_COLS <= 8) #if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n") # define print_matrix_header() print("\nr/c 01234567\n")
@ -88,12 +89,11 @@ uint8_t matrix_cols(void) {
void matrix_init(void) { void matrix_init(void) {
matrix_init_quantum(); matrix_init_quantum();
serial_init();
} }
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
SERIAL_UART_INIT();
uint32_t timeout = 0; uint32_t timeout = 0;
//the s character requests the RF slave to send the matrix //the s character requests the RF slave to send the matrix

View file

@ -27,20 +27,13 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
# MIDI_ENABLE = YES # MIDI controls # MIDI_ENABLE = YES # MIDI controls
UNICODE_ENABLE = YES # Unicode UNICODE_ENABLE = YES # Unicode
# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID # 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 # # project specific files
SRC = matrix.c SRC = matrix.c serial_uart.c
# Disable unsupported hardware # Disable unsupported hardware
RGBLIGHT_SUPPORTED = no RGBLIGHT_SUPPORTED = no
AUDIO_SUPPORTED = no AUDIO_SUPPORTED = no
BACKLIGHT_SUPPORTED = no BACKLIGHT_SUPPORTED = no
LAYOUTS = ortho_4x12

View file

@ -1,9 +1,5 @@
#include "telophase.h" #include "telophase.h"
void uart_init(void) {
SERIAL_UART_INIT();
}
void led_init(void) { void led_init(void) {
DDRD |= (1<<1); DDRD |= (1<<1);
PORTD |= (1<<1); PORTD |= (1<<1);
@ -16,20 +12,9 @@ void matrix_init_kb(void) {
// put your keyboard start-up code here // put your keyboard start-up code here
// runs once when the firmware starts up // runs once when the firmware starts up
matrix_init_user(); matrix_init_user();
uart_init();
led_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 #ifdef SWAP_HANDS_ENABLE
__attribute__ ((weak)) __attribute__ ((weak))
const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = { const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {

View file

@ -367,51 +367,6 @@
# endif # endif
#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 #define API_SYSEX_MAX_SIZE 32
#include "song_list.h" #include "song_list.h"

View file

@ -37,6 +37,8 @@ POSSIBILITY OF SUCH DAMAGE.
#pragma once #pragma once
#define SERIAL_UART_DATA UDR1
/* host role */ /* host role */
void serial_init(void); void serial_init(void);
uint8_t serial_recv(void); uint8_t serial_recv(void);

View file

@ -40,6 +40,22 @@ POSSIBILITY OF SUCH DAMAGE.
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include "serial.h" #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) #if defined(SERIAL_UART_RTS_LO) && defined(SERIAL_UART_RTS_HI)
// Buffer state // Buffer state
// Empty: RBUF_SPACE == RBUF_SIZE(head==tail) // Empty: RBUF_SPACE == RBUF_SIZE(head==tail)
@ -61,7 +77,14 @@ POSSIBILITY OF SUCH DAMAGE.
# define rbuf_check_rts_hi() # define rbuf_check_rts_hi()
#endif #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 // RX ring buffer
#define RBUF_SIZE 256 #define RBUF_SIZE 256