Merge branch 'iwrap5'

This commit is contained in:
tmk
2013-04-20 00:46:48 +09:00
12 changed files with 454 additions and 31 deletions

View File

@ -29,8 +29,6 @@ OPT_DEFS = -DDEBUG_LEVEL=0
# MCU name, you MUST set this to match the board you are using
# type "make clean" after changing this, so all files will be rebuilt
MCU = atmega328p
# avrdude doesn't know atmega168p
AVRDUDE_MCU = $(MCU)
# Processor frequency.
@ -41,6 +39,15 @@ AVRDUDE_MCU = $(MCU)
F_CPU = 12000000
# Boot Section Size in *bytes*
# Teensy halfKay 512
# Teensy++ halfKay 1024
# Atmel DFU loader 4096
# LUFA bootloader 4096
# USBaspLoader 2048
OPT_DEFS += -DBOOTLOADER_SIZE=2048
# Build Options
# comment out to disable the options.
#
@ -75,8 +82,8 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
# to submit bug reports.
#AVRDUDE_VERBOSE = -v -v
#AVRDUDE_FLAGS = -p $(AVRDUDE_MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
AVRDUDE_FLAGS = -p $(AVRDUDE_MCU) -c $(AVRDUDE_PROGRAMMER)
#AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER)
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
@ -89,9 +96,8 @@ PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE
VPATH += $(TARGET_DIR)
VPATH += $(TOP_DIR)
#include $(TOP_DIR)/protocol/iwrap.mk
# To be swatchable btween Bluetooth and USB. Comment out if you don't need USB.
include $(TOP_DIR)/protocol/vusb.mk
#include $(TOP_DIR)/protocol.mk
include $(TOP_DIR)/protocol/iwrap.mk
# TODO: to be selectable: V-USB, LUFA or PJRC
#include $(TOP_DIR)/protocol/vusb.mk
include $(TOP_DIR)/common.mk
include $(TOP_DIR)/rules.mk

View File

@ -2,10 +2,22 @@ IWRAP_DIR = protocol/iwrap
OPT_DEFS += -DPROTOCOL_IWRAP
SRC += $(IWRAP_DIR)/iwrap.c \
SRC += $(IWRAP_DIR)/main.c \
$(IWRAP_DIR)/iwrap.c \
$(IWRAP_DIR)/suart.S \
$(IWRAP_DIR)/sendchar_uart.c \
$(IWRAP_DIR)/uart.c
$(COMMON_DIR)/sendchar_uart.c \
$(COMMON_DIR)/uart.c
# TODO: compatible with LUFA and PJRC
# V-USB
#
#VUSB_DIR = protocol/vusb
#OPT_DEFS += -DPROTOCOL_VUSB
#SRC += $(VUSB_DIR)/vusb.c \
# $(VUSB_DIR)/usbdrv/usbdrv.c \
# $(VUSB_DIR)/usbdrv/usbdrvasm.S \
# $(VUSB_DIR)/usbdrv/oddebug.c
#VPATH += $(TOP_DIR)/protocol/vusb:$(TOP_DIR)/protocol/vusb/usbdrv
# Search Path

View File

@ -0,0 +1 @@
05010906a1010507850119e029e715002501750195088102950175088101950575010508850119012905910295017503910395067508150025650507190029658100c005010902a1010901a1008502050919012903150025019503750181020501093815f1250f9501750581060501093009311581257f750895028106c0c0050c0901a1018503050c1500250109e909ea09e209cd19b529b87501950881020a8a010a21020a2a021a23022a27027501950881020a83010a96010a92010a9e010a94010a060209b209b4750195088102c0

View File

@ -0,0 +1 @@
050c0901a1018503050c1500250109e909ea09e209cd19b529b87501950881020a8a010a21020a2a021a23022a27027501950881020a83010a96010a92010a9e010a94010a060209b209b4750195088102c0

352
protocol/iwrap/iWRAP5.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -334,8 +334,8 @@ static void send_keyboard(report_keyboard_t *report)
// HID raw mode header
xmit(0x9f);
xmit(0x0a); // Length
xmit(0xa1); // keyboard report
xmit(0x01);
xmit(0xa1); // DATA(Input)
xmit(0x01); // Report ID
xmit(report->mods);
xmit(0x00); // reserved byte(always 0)
xmit(report->keys[0]);
@ -351,15 +351,17 @@ static void send_mouse(report_mouse_t *report)
{
#if defined(MOUSEKEY_ENABLE) || defined(PS2_MOUSE_ENABLE)
if (!iwrap_connected() && !iwrap_check_connection()) return;
MUX_HEADER(0x01, 0x07);
MUX_HEADER(0x01, 0x09);
// HID raw mode header
xmit(0x9f);
xmit(0x05); // Length
xmit(0xa1); // mouse report
xmit(0x02);
xmit(0x07); // Length
xmit(0xa1); // DATA(Input)
xmit(0x02); // Report ID
xmit(report->buttons);
xmit(report->x);
xmit(report->y);
xmit(report->v);
xmit(report->h);
MUX_FOOTER(0x01);
#endif
}
@ -457,8 +459,8 @@ static void send_consumer(uint16_t data)
MUX_HEADER(0x01, 0x07);
xmit(0x9f);
xmit(0x05); // Length
xmit(0xa1); // consumer report
xmit(0x03);
xmit(0xa1); // DATA(Input)
xmit(0x03); // Report ID
xmit(bits1);
xmit(bits2);
xmit(bits3);

View File

@ -0,0 +1 @@
05010906a1010507850119e029e715002501750195088102950175088101950575010508850119012905910295017503910395067508150025650507190029658100c0

View File

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "keyboard.h"
#include "matrix.h"
#include "host.h"
#include "action.h"
#include "iwrap.h"
#ifdef PROTOCOL_VUSB
# include "vusb.h"
@ -40,7 +41,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
static void sleep(uint8_t term);
static bool console(void);
static uint8_t console_command(uint8_t c);
static bool console_command(uint8_t c);
static uint8_t key2asc(uint8_t key);
@ -108,10 +109,13 @@ static void init_vusb(void)
void change_driver(host_driver_t *driver)
{
/*
host_clear_keyboard_report();
host_swap_keyboard_report();
host_clear_keyboard_report();
host_send_keyboard_report();
*/
clear_keyboard();
_delay_ms(1000);
host_set_driver(driver);
}
@ -168,6 +172,7 @@ int main(void)
if (host_get_driver() == vusb_driver())
vusb_transfer_keyboard();
#endif
// TODO: depricated
if (matrix_is_modified() || console()) {
last_timer = timer_read();
sleeping = false;
@ -176,6 +181,7 @@ int main(void)
iwrap_check_connection();
}
// TODO: suspend.h
if (host_get_driver() == iwrap_driver()) {
if (sleeping && !insomniac) {
_delay_ms(1); // wait for UART to send
@ -201,11 +207,6 @@ static void sleep(uint8_t term)
WD_SET(WD_OFF);
}
ISR(WDT_vect)
{
// wake up
}
static bool console(void)
{
// Send to Bluetoot module WT12
@ -244,12 +245,12 @@ static bool console(void)
}
}
uint8_t command_extra()
bool command_extra(uint8_t code)
{
return console_command(key2asc(host_get_first_key()));
return console_command(key2asc(code));
}
static uint8_t console_command(uint8_t c)
static bool console_command(uint8_t c)
{
switch (c) {
case 'h':

40
protocol/iwrap/mouse.desc Normal file
View File

@ -0,0 +1,40 @@
05010902a1010901a1008502050919012908150025017501950881020501093009311581257f750895028106093895018106050c0a380295018106c0c0
Length: 67(0x43)
virtical/horizontal wheel support
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x02, // USAGE (Mouse)
0xa1, 0x01, // COLLECTION (Application)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x85, 0x02, // REPORT_ID (2)
// ---------------------------- Buttons
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x08, // USAGE_MAXIMUM (Button 8)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x08, // REPORT_COUNT (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
// ---------------------------- X,Y position
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x06, // INPUT (Data,Var,Rel)
// ---------------------------- Vertical wheel
0x09, 0x38, // USAGE (Wheel)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x06, // INPUT (Data,Var,Rel)
// ---------------------------- Horizontal wheel
0x05, 0x0c, // USAGE_PAGE (Consumer Devices)
0x0a, 0x38, 0x02, // USAGE (AC Pan)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x06, // INPUT (Data,Var,Rel)
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION

View File

@ -0,0 +1,7 @@
#
# Rescue from Bluegiga iWRAP MUX mode
# 6.75 of iWRAP5_User_Guid.pdf
#
[0xBF, 0xFF, 0x00, 0x11, 0x53, 0x45, 0x54, 0x20, 0x43, 0x4f, 0x4e, 0x54, 0x52, 0x4f, 0x4c, 0x20, 0x4d, 0x55, 0x58, 0x20, 0x30, 0x00].each do |x|
print x.chr
end

View File

@ -10,10 +10,10 @@ SRC += $(VUSB_DIR)/main.c \
ifdef NO_UART
SRC += sendchar_null.c
SRC += $(COMMON_DIR)/sendchar_null.c
else
SRC += sendchar_uart.c \
uart.c
SRC += $(COMMON_DIR)/sendchar_uart.c \
$(COMMON_DIR)/uart.c
endif