news: Remove news.c and use serial_uart.c instead
This commit is contained in:
parent
b7188acd4f
commit
b072fb26de
5 changed files with 18 additions and 245 deletions
|
|
@ -10,7 +10,7 @@ TARGET_DIR = .
|
|||
# keyboard dependent files
|
||||
SRC = matrix.c \
|
||||
tone.c \
|
||||
news.c
|
||||
protocol/serial_uart.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2016 Jun Wako <wakojun@gmail.com>
|
||||
Copyright 2016,2023 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -21,8 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x5021
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER t.m.k.
|
||||
#define DEVICE_VER 0x0101
|
||||
#define MANUFACTURER TMK
|
||||
#define PRODUCT SONY NEWS keyboard converter
|
||||
#define DESCRIPTION converts SONY NEWS protocol into USB
|
||||
|
||||
|
|
@ -47,18 +47,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
* 8-data bit, non parity, 1-stop bit, no flow control
|
||||
*/
|
||||
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__)
|
||||
# define NEWS_KBD_RX_VECT USART1_RX_vect
|
||||
# define NEWS_KBD_RX_DATA UDR1
|
||||
# define NEWS_KBD_RX_BAUD 9600
|
||||
# define NEWS_KBD_RX_UBBR ((F_CPU/(16UL*NEWS_KBD_RX_BAUD))-1)
|
||||
# define NEWS_KBD_RX_INIT() do { \
|
||||
UBRR1L = (uint8_t) NEWS_KBD_RX_UBBR; \
|
||||
UBRR1H = (uint8_t) (NEWS_KBD_RX_UBBR>>8); \
|
||||
# define SERIAL_UART_BAUD 9600
|
||||
# define SERIAL_UART_DATA UDR1
|
||||
# define SERIAL_UART_UBBR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1)
|
||||
# define SERIAL_UART_RXD_VECT USART1_RX_vect
|
||||
# define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1))
|
||||
# define SERIAL_UART_INIT() do { \
|
||||
UBRR1L = (uint8_t) SERIAL_UART_UBBR; \
|
||||
UBRR1H = (uint8_t) (SERIAL_UART_UBBR>>8); \
|
||||
UCSR1B |= (1<<RXCIE1) | (1<<RXEN1) | (1<<TXEN1); \
|
||||
sei(); \
|
||||
} while(0)
|
||||
# define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1))
|
||||
# define SERIAL_UART_DATA UDR1
|
||||
#else
|
||||
# error "USART configuration is needed."
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2012 Jun Wako <wakojun@gmail.com>
|
||||
Copyright 2012,2023 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "util.h"
|
||||
#include "news.h"
|
||||
#include "serial.h"
|
||||
#include "matrix.h"
|
||||
#include "debug.h"
|
||||
#include "led.h"
|
||||
|
|
@ -55,7 +55,7 @@ static uint8_t news_led = 0;
|
|||
|
||||
void matrix_init(void)
|
||||
{
|
||||
news_init();
|
||||
serial_init();
|
||||
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
|
||||
|
|
@ -68,11 +68,11 @@ static uint16_t send_cmd(uint8_t cmd)
|
|||
int16_t ret = 0;
|
||||
|
||||
xprintf("s%02X ", cmd);
|
||||
news_send(cmd);
|
||||
serial_send(cmd);
|
||||
wait_ms(10);
|
||||
|
||||
int16_t c;
|
||||
while ((c = news_recv()) != -1) {
|
||||
while ((c = serial_recv2()) != -1) {
|
||||
if ((c != 0x7B) && (c != 0xFB)) {
|
||||
ret <<= 8;
|
||||
ret |= c & 0xFF;
|
||||
|
|
@ -112,7 +112,7 @@ uint8_t matrix_scan(void)
|
|||
static uint8_t sent_led = 0;
|
||||
int16_t code;
|
||||
|
||||
code = news_recv();
|
||||
code = serial_recv2();
|
||||
if (code == -1) {
|
||||
// update LED
|
||||
if (news_led != sent_led) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue