Skip to content

Commit

Permalink
Migrate serial_uart usages to UART driver (#15479)
Browse files Browse the repository at this point in the history
* Migrate Thermal Printer feature to UART driver

* Migrate 40percentclub UT47 to UART driver

* Migrate Centromere to UART driver

* Migrate Chimera Ergo to UART driver

* Migrate Chimera Let's Split to UART driver

* Migrate Chimera Ortho to UART driver

* Migrate Chimera Ortho Plus to UART driver

* Migrate Comet46 to UART driver

* Migrate Palm USB converter to UART driver

* Migrate Sun USB converter to UART driver

* Migrate Dichotomy to UART driver

* Migrate Honeycomb to UART driver

* Migrate Mitosis to UART driver

* Migrate Redox W to UART driver

* Migrate Uni660 to UART driver

* Migrate Telophase to UART driver
  • Loading branch information
fauxpark authored Dec 15, 2021
1 parent c0bb153 commit c122688
Show file tree
Hide file tree
Showing 63 changed files with 154 additions and 393 deletions.
2 changes: 1 addition & 1 deletion common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ endif
ifeq ($(strip $(PRINTING_ENABLE)), yes)
OPT_DEFS += -DPRINTING_ENABLE
SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c
SRC += $(TMK_DIR)/protocol/serial_uart.c
QUANTUM_LIB_SRC += uart.c
endif

VARIABLE_TRACE ?= no
Expand Down
6 changes: 3 additions & 3 deletions keyboards/40percentclub/ut47/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
#include QMK_KEYBOARD_H
#ifdef LED_ENABLE
#include "protocol/serial.h"
#include "uart.h"
#endif

#define LT3_TAB LT(3, KC_TAB)
Expand Down Expand Up @@ -108,11 +108,11 @@ LAYOUT( /* Tab */
//LED keymap functions
#ifdef LED_ENABLE
void led_chmode(void) {
serial_send(101);
uart_write(0x65);
}

void led_toggle(void) {
serial_send(100);
uart_write(0x64);
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
Expand Down
6 changes: 3 additions & 3 deletions keyboards/40percentclub/ut47/keymaps/non-us/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
#include QMK_KEYBOARD_H
#ifdef LED_ENABLE
#include "protocol/serial.h"
#include "uart.h"
#endif

#define LT3_TAB LT(3, KC_TAB)
Expand Down Expand Up @@ -108,11 +108,11 @@ LAYOUT( /* Tab */
//LED keymap functions
#ifdef LED_ENABLE
void led_chmode(void) {
serial_send(101);
uart_write(0x65);
}

void led_toggle(void) {
serial_send(100);
uart_write(0x64);
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
Expand Down
6 changes: 3 additions & 3 deletions keyboards/40percentclub/ut47/keymaps/nordic/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
#include QMK_KEYBOARD_H
#ifdef LED_ENABLE
#include "protocol/serial.h"
#include "uart.h"

#endif

Expand Down Expand Up @@ -151,11 +151,11 @@ LAYOUT( /* GAMING, toggled on and off - L5 */
//LED keymap functions
#ifdef LED_ENABLE
void led_chmode(void) {
serial_send(101);
uart_write(0x65);
}

void led_toggle(void) {
serial_send(100);
uart_write(0x64);
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
Expand Down
6 changes: 3 additions & 3 deletions keyboards/40percentclub/ut47/keymaps/rgb/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
#include QMK_KEYBOARD_H
#ifdef LED_ENABLE
#include "protocol/serial.h"
#include "uart.h"
#endif

#define LT3_TAB LT(3, KC_TAB)
Expand Down Expand Up @@ -60,11 +60,11 @@ LAYOUT( /* Tab */
//LED keymap functions
#ifdef LED_ENABLE
void led_chmode(void) {
serial_send(101);
uart_write(0x65);
}

void led_toggle(void) {
serial_send(100);
uart_write(0x64);
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
Expand Down
8 changes: 0 additions & 8 deletions keyboards/40percentclub/ut47/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "debug.h"
#include "util.h"
#include "matrix.h"
#ifdef LED_ENABLE
#include "protocol/serial.h"
#endif


#ifndef DEBOUNCE
# define DEBOUNCE 5
Expand Down Expand Up @@ -69,10 +65,6 @@ void matrix_init(void)
matrix[i] = 0;
matrix_debouncing[i] = 0;
}

#ifdef LED_ENABLE
serial_init();
#endif
}

uint8_t matrix_scan(void)
Expand Down
3 changes: 2 additions & 1 deletion keyboards/40percentclub/ut47/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ AUDIO_ENABLE = no # Audio output

# custom matrix setup
CUSTOM_MATRIX = yes
SRC += matrix.c protocol/serial_uart.c
SRC += matrix.c
QUANTUM_LIB_SRC += uart.c
8 changes: 6 additions & 2 deletions keyboards/40percentclub/ut47/ut47.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@
*/
#include "ut47.h"
#ifdef LED_ENABLE
#include "protocol/serial.h"
#include "uart.h"
#endif

void matrix_init_kb() {
uart_init(9600);
}

bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
// put your per-action keyboard code here
// runs for every action, just before processing by the firmware
if (record->event.pressed) {
#ifdef LED_ENABLE
serial_send((record->event.key.row*16)+record->event.key.col);
uart_write((record->event.key.row*16)+record->event.key.col);
#endif
}
return process_record_user(keycode, record);
Expand Down
9 changes: 0 additions & 9 deletions keyboards/centromere/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION

//UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 500000
#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT_CUSTOM \
/* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
10 changes: 5 additions & 5 deletions keyboards/centromere/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "util.h"
#include "matrix.h"
#include "timer.h"
#include "protocol/serial.h"
#include "uart.h"

#if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n")
Expand Down Expand Up @@ -80,29 +80,29 @@ uint8_t matrix_cols(void) {
void matrix_init(void) {

matrix_init_quantum();
serial_init();
uart_init(500000);
}

uint8_t matrix_scan(void)
{
uint32_t timeout = 0;

//the s character requests the RF remote slave to send the matrix information
SERIAL_UART_DATA = 's';
uart_write('s');

//trust the external keystates, erase the last set of data
uint8_t uart_data[11] = {0};

//there are 10 bytes corresponding to 1w columns, and an end byte
for (uint8_t i = 0; i < 11; i++) {
//wait for the serial data, timeout if it's been too long
while(!SERIAL_UART_RXD_PRESENT){
while(!uart_available()){
timeout++;
if (timeout > 10000){
break;
}
}
uart_data[i] = SERIAL_UART_DATA;
uart_data[i] = uart_read();
}

//check for the end packet, the key state bytes use the LSBs, so 0xE0
Expand Down
3 changes: 2 additions & 1 deletion keyboards/centromere/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
UNICODE_ENABLE = yes # Unicode

# # project specific files
SRC += matrix.c serial_uart.c
SRC += matrix.c
QUANTUM_LIB_SRC += uart.c

LAYOUTS = split_3x5_3 split_3x6_3
9 changes: 0 additions & 9 deletions keyboards/chimera_ergo/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION

//UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000
#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT_CUSTOM \
/* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
10 changes: 5 additions & 5 deletions keyboards/chimera_ergo/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "util.h"
#include "matrix.h"
#include "timer.h"
#include "protocol/serial.h"
#include "uart.h"

#if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n")
Expand Down Expand Up @@ -89,15 +89,15 @@ uint8_t matrix_cols(void) {
void matrix_init(void) {

matrix_init_quantum();
serial_init();
uart_init(1000000);
}

uint8_t matrix_scan(void)
{
uint32_t timeout = 0;

//the s character requests the RF slave to send the matrix
SERIAL_UART_DATA = 's';
uart_write('s');

//trust the external keystates entirely, erase the last data
uint8_t uart_data[14] = {0};
Expand All @@ -107,13 +107,13 @@ uint8_t matrix_scan(void)
//wait for the serial data, timeout if it's been too long
//this only happened in testing with a loose wire, but does no
//harm to leave it in here
while(!SERIAL_UART_RXD_PRESENT){
while(!uart_available()){
timeout++;
if (timeout > 10000){
break;
}
}
uart_data[i] = SERIAL_UART_DATA;
uart_data[i] = uart_read();
}

//check for the end packet, the key state bytes use the LSBs, so 0xE0
Expand Down
3 changes: 2 additions & 1 deletion keyboards/chimera_ergo/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ NKRO_ENABLE = yes # Enable N-Key Rollover
# BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality

# # project specific files
SRC += matrix.c serial_uart.c
SRC += matrix.c
QUANTUM_LIB_SRC += uart.c
9 changes: 0 additions & 9 deletions keyboards/chimera_ls/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION

//UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000
#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT_CUSTOM \
/* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
10 changes: 5 additions & 5 deletions keyboards/chimera_ls/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "util.h"
#include "matrix.h"
#include "timer.h"
#include "protocol/serial.h"
#include "uart.h"

#if (MATRIX_COLS <= 8)
# define print_matrix_header() print("\nr/c 01234567\n")
Expand Down Expand Up @@ -93,15 +93,15 @@ uint8_t matrix_cols(void) {

void matrix_init(void) {
matrix_init_quantum();
serial_init();
uart_init(1000000);
}

uint8_t matrix_scan(void)
{
uint32_t timeout = 0;

//the s character requests the RF slave to send the matrix
SERIAL_UART_DATA = 's';
uart_write('s');

//trust the external keystates entirely, erase the last data
uint8_t uart_data[11] = {0};
Expand All @@ -111,13 +111,13 @@ uint8_t matrix_scan(void)
//wait for the serial data, timeout if it's been too long
//this only happened in testing with a loose wire, but does no
//harm to leave it in here
while(!SERIAL_UART_RXD_PRESENT){
while(!uart_available()){
timeout++;
if (timeout > 10000){
break;
}
}
uart_data[i] = SERIAL_UART_DATA;
uart_data[i] = uart_read();
}

//check for the end packet, the key state bytes use the LSBs, so 0xE0
Expand Down
3 changes: 2 additions & 1 deletion keyboards/chimera_ls/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ NKRO_ENABLE = yes # Enable N-Key Rollover
# BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality

# project specific files
SRC += matrix.c serial_uart.c
SRC += matrix.c
QUANTUM_LIB_SRC += uart.c

LAYOUTS = ortho_4x12

Expand Down
9 changes: 0 additions & 9 deletions keyboards/chimera_ortho/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION

//UART settings for communication with the RF microcontroller
#define SERIAL_UART_BAUD 1000000
#define SERIAL_UART_RXD_PRESENT (UCSR1A & _BV(RXC1))
#define SERIAL_UART_INIT_CUSTOM \
/* enable TX and RX */ \
UCSR1B = _BV(TXEN1) | _BV(RXEN1); \
/* 8-bit data */ \
UCSR1C = _BV(UCSZ11) | _BV(UCSZ10);
Loading

0 comments on commit c122688

Please sign in to comment.