1
0

Merge remote-tracking branch 'refs/remotes/tmk/master'

This commit is contained in:
di0ib 2017-01-14 17:56:30 -10:00
commit 5cff692d79
13 changed files with 2292 additions and 2282 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -225,7 +225,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
K36,K3A,K37, K31, K3B,K3C,K3D, K52, K41,K4C \
) { \
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
{ KC_##K08, KC_##K09, KC_##K0A KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \
{ KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
{ KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \

View File

@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "matrix.h"
#include "report.h"
#include "host.h"
#include "led.h"
@ -64,7 +65,7 @@ void matrix_init(void)
// Determine ISO keyboard by handler id
// http://lxr.free-electrons.com/source/drivers/macintosh/adbhid.c?v=4.4#L815
uint16_t handler_id = adb_host_talk(ADB_ADDR_KEYBOARD, ADB_REG_3);
uint8_t handler_id = (uint8_t) adb_host_talk(ADB_ADDR_KEYBOARD, ADB_REG_3);
switch (handler_id) {
case 0x04: case 0x05: case 0x07: case 0x09: case 0x0D:
case 0x11: case 0x14: case 0x19: case 0x1D: case 0xC1:
@ -101,6 +102,8 @@ void matrix_init(void)
// initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
led_set(host_keyboard_leds());
debug_enable = true;
//debug_matrix = true;
//debug_keyboard = true;

View File

@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Sun type 5 keyboard
,-------. ,---, ,---------------. ,---------------. ,---------------. ,-----------. ,---------------.
| 76 | | | | 05| 06| 08| 0A| | 0C| 0E| 10| 11| | 12| 07| 09| 0B| | 16| 17| 15| | 2D| 02| 04| 30|
| 76 | | 0F| | 05| 06| 08| 0A| | 0C| 0E| 10| 11| | 12| 07| 09| 0B| | 16| 17| 15| | 2D| 02| 04| 30|
`-------' `---' `---------------' `---------------' `---------------' `-----------' `---------------'
,-------. ,-----------------------------------------------------------. ,-----------. ,---------------.
| 01| 03| | 1D| 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| 28| 29| 58| 2A| | 2C| 34| 60| | 62| 2E| 2F| 47|
@ -41,7 +41,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
`-------' `-----------------------------------------------------------' `-----------' `---------------'
*/
#define KEYMAP( \
K76, K05,K06,K08,K0A, K0C,K0E,K10,K11, K12,K07,K09,K0B, K16,K17,K15, K2D,K02,K04,K30, \
K76, K0F, K05,K06,K08,K0A, K0C,K0E,K10,K11, K12,K07,K09,K0B, K16,K17,K15, K2D,K02,K04,K30, \
K01,K03, K1D,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K58,K2A, K2C,K34,K60, K62,K2E,K2F,K47, \
K19,K1A, K35, K36,K37,K38,K39,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41, K2B, K42,K4A,K7B, K44,K45,K46,K7D, \
K31,K33, K4C, K4D,K4E,K4F,K50,K51,K52,K53,K54,K55,K56,K57, K59, K5B,K5C,K5D, \
@ -49,7 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
K5F,K61, K77,K13, K78, K73, K79, K74, K75, K7A, K43, K0D, K18,K1B,K1C, K5E, K32 \
) { \
{ KC_NO, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
{ KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_NO, }, \
{ KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F,}, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
{ KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \
@ -76,12 +76,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
K63, K64,K65,K66,K67,K68,K69,K6A,K6B,K6C,K6D, K0D,K14,K6E, \
K77,K13, K78, K79, K7A,K43,K62,K18,K1B,K1C \
) KEYMAP( \
HELP, K05,K06,K08,K0A, K0C,K0E,K10,K11, K12,K07,K09,K0B, PSCR,SLCK,PAUS, MUTE,VOLD,VOLU,K30, \
HELP, NO, K05,K06,K08,K0A, K0C,K0E,K10,K11, K12,K07,K09,K0B, PSCR,SLCK,PAUS, MUTE,VOLD,VOLU,K30, \
K01, AGAIN, K1D,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K58,K2A, K2C, K34, K60, K62, PSLS,PAST,PMNS, \
MENU, UNDO, K35, K36,K37,K38,K39,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41, K2B, K42, K4A, K7B, P7, P8, P9, PPLS, \
SELECT, K33, K4C, K4D,K4E,K4F,K50,K51,K52,K53,K54,K55,K56,K57, K59, P4, P5, P6, \
EXECUTE,K49, K63, K64,K65,K66,K67,K68,K69,K6A,K6B,K6C,K6D, K6E, K14, P1, P2, P3, PENT, \
FIND, K61, K77,K13, K78, HENK, K79, MHEN, KANA, K7A,K43,K0D, K18, K1B, K1C, P0, PDOT \
MENU, UNDO, K35, K36,K37,K38,K39,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41, K2B, K42, K4A, K7B, P7, P8, P9, PPLS, \
SELECT, K33, K4C, K4D,K4E,K4F,K50,K51,K52,K53,K54,K55,K56,K57, K59, P4, P5, P6, \
EXECUTE,K49, K63, K64,K65,K66,K67,K68,K69,K6A,K6B,K6C,K6D, K6E, K14, P1, P2, P3, PENT, \
FIND, K61, K77,K13, K78, HENK, K79, MHEN, KANA, K7A,K43,K0D, K18, K1B, K1C, P0, PDOT \
)

View File

@ -75,6 +75,8 @@ void matrix_init(void)
}
}
print(" Done\n");
PORTD &= ~(1<<6);
return;
}

View File

@ -71,6 +71,10 @@ static inline void KEY_INIT(void)
/* row extention for HHKB JP */
DDRC |= (1<<6|1<<7);
PORTC |= (1<<6|1<<7);
#else
/* input with pull up to save power */
DDRC &= ~(1<<6|1<<7);
PORTC |= (1<<6|1<<7);
#endif
KEY_UNABLE();
KEY_PREV_OFF();

View File

@ -134,6 +134,34 @@ static uint8_t leds = 0;
static uint8_t keyboard_leds(void) { return leds; }
void rn42_set_leds(uint8_t l) { leds = l; }
void rn42_send_str(const char *str)
{
uint8_t c;
while ((c = pgm_read_byte(str++)))
rn42_putc(c);
}
const char *rn42_send_command(const char *cmd)
{
static const char *s;
rn42_send_str(cmd);
wait_ms(500);
s = rn42_gets(100);
xprintf("%s\r\n", s);
rn42_print_response();
return s;
}
void rn42_print_response(void)
{
int16_t c;
while ((c = rn42_getc()) != -1) {
xprintf("%c", c);
}
}
static void send_keyboard(report_keyboard_t *report)
{
// wake from deep sleep

View File

@ -2,6 +2,7 @@
#define RN42_H
#include <stdbool.h>
#include "host_driver.h"
host_driver_t rn42_driver;
host_driver_t rn42_config_driver;
@ -20,4 +21,10 @@ void rn42_cts_lo(void);
bool rn42_linked(void);
void rn42_set_leds(uint8_t l);
const char *rn42_send_command(const char *cmd);
void rn42_send_str(const char *str);
void rn42_print_response(void);
#define SEND_STR(str) rn42_send_str(PSTR(str))
#define SEND_COMMAND(cmd) rn42_send_command(PSTR(cmd))
#endif

View File

@ -125,40 +125,6 @@ void rn42_task(void)
******************************************************************************/
static host_driver_t *prev_driver = &rn42_driver;
static void print_rn42(void)
{
int16_t c;
while ((c = rn42_getc()) != -1) {
xprintf("%c", c);
}
}
static void clear_rn42(void)
{
while (rn42_getc() != -1) ;
}
#define SEND_STR(str) send_str(PSTR(str))
#define SEND_COMMAND(cmd) send_command(PSTR(cmd))
static void send_str(const char *str)
{
uint8_t c;
while ((c = pgm_read_byte(str++)))
rn42_putc(c);
}
static const char *send_command(const char *cmd)
{
static const char *s;
send_str(cmd);
wait_ms(500);
s = rn42_gets(100);
xprintf("%s\r\n", s);
print_rn42();
return s;
}
static void enter_command_mode(void)
{
prev_driver = host_get_driver();
@ -171,7 +137,7 @@ static void enter_command_mode(void)
wait_ms(1100); // need 1 sec
SEND_COMMAND("$$$");
wait_ms(600); // need 1 sec
print_rn42();
rn42_print_response();
const char *s = SEND_COMMAND("v\r\n");
if (strncmp("v", s, 1) != 0) SEND_COMMAND("+\r\n"); // local echo on
}

View File

@ -94,7 +94,7 @@ void host_consumer_send(uint16_t report)
}
}
uint16_t host_last_sysytem_report(void)
uint16_t host_last_system_report(void)
{
return last_system_report;
}

View File

@ -47,7 +47,7 @@ void host_mouse_send(report_mouse_t *report);
void host_system_send(uint16_t data);
void host_consumer_send(uint16_t data);
uint16_t host_last_sysytem_report(void);
uint16_t host_last_system_report(void);
uint16_t host_last_consumer_report(void);
#ifdef __cplusplus

View File

@ -1033,7 +1033,7 @@ void init_usb_driver(USBDriver *usbp) {
chVTObjectInit(&keyboard_idle_timer);
#ifdef CONSOLE_ENABLE
obqObjectInit(&console_buf_queue, console_queue_buffer, CONSOLE_EPSIZE, CONSOLE_QUEUE_CAPACITY, console_queue_onotify, (void*)usbp);
obqObjectInit(&console_buf_queue, true, console_queue_buffer, CONSOLE_EPSIZE, CONSOLE_QUEUE_CAPACITY, console_queue_onotify, (void*)usbp);
chVTObjectInit(&console_flush_timer);
#endif
}