Gearchiveerd
1
0
This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
tmk_keyboard_custom/protocol/chibios/usb_main.h
tmk 71381457fa Squashed 'tmk_core/' changes from ee8c5ba..d5c5ac6
d5c5ac6 Merge branch 'develop'
5957682 Merge branch 'hotfix-mediakey'
a478c62 Merge branch 'hotfix-vusb'
cccebfe Merge branch 'njbair-docfix'
0aaab57 Clean up wording in keymap example
dc8bbc3 Clarify layer precedence
9e0b4c1 clarify layer documentation
915eb48 core: Fix media/consumer keys
88f90f3 Fix for VUSB configuration
3e290cd Fix including board.mk in chibios.mk
32c69e0 Merge branch 'newapi' into develop
c9a56f9 Merge remote-tracking branch 'flabbergast/chibios' into develop
01e33ea Fix chibios and mbed common.mk for hook.c
bea79d9 hook: Change func name of usb events
3e97536 hook: Change file and func names(*_hook -> hook_*)
c286d8c Merge pull request #10 from fredizzimo/chibios-contrib2
062d74e Update ChibiOS instructions
d47150f Add support for new version of ChibiOS and Contrib
62b5401 Chibios: disable LTO (link-time optimisation).
c64e9aa hooks: Fix for LUFA
54e68b0 hooks: Remove led_restore_hook
325c09d Chibios: make the default bootloader_jump redefinable (weak).
078c722 Chibios: fix STM32_BOOTLOADER_ADDRESS name.
e73cfe5 hooks: Fix for keyboard LED update
e6120c5 Implement basic hooks.
7c370e9 Chibios: Update the main chibios README.
7f0198d Chibios: implement sleep LED for STM32.
afef9b4 Fix hard-coded path of CHIBIOS
95c5b19 Merge pull request #7 from fredizzimo/sysvsize
27128a8 Sysv format for ChibiOS arm-none-eabi-size
d4b8e68 core: Fix chibios user compile options
b85d462 Merge branch 'chibios' of https://github.com/flabbergast/tmk_keyboard into flabbergast_chibios
de41aa1 core: Fix ps2_mouse.c debug print
d79d925 Removed duplicate debug message code and surrounded it with IFDEF as needed
8f28589 Chibios: Revert common.mk change (fix AVR linking problem).
ec9eff2 Chibios: cleanup usb_main code.
28c4665 Chibios: Fix a HardFault bug (wait after start).

git-subtree-dir: tmk_core
git-subtree-split: d5c5ac63e60dfc6da6661a21bd968b4d577a27d5
2016-04-21 14:35:48 +09:00

140 regels
3.0 KiB
C

/*
* (c) 2015 flabberast <s3+flabbergast@sdfeu.org>
*
* Based on the following work:
* - Guillaume Duc's raw hid example (MIT License)
* https://github.com/guiduc/usb-hid-chibios-example
* - PJRC Teensy examples (MIT License)
* https://www.pjrc.com/teensy/usb_keyboard.html
* - hasu's TMK keyboard code (GPL v2 and some code Modified BSD)
* https://github.com/tmk/tmk_keyboard/
* - ChibiOS demo code (Apache 2.0 License)
* http://www.chibios.org
*
* Since some GPL'd code is used, this work is licensed under
* GPL v2 or later.
*/
#ifndef _USB_MAIN_H_
#define _USB_MAIN_H_
// TESTING
// extern uint8_t blinkLed;
#include "ch.h"
#include "hal.h"
/* -------------------------
* General USB driver header
* -------------------------
*/
/* The USB driver to use */
#define USB_DRIVER USBD1
/* Initialize the USB driver and bus */
void init_usb_driver(USBDriver *usbp);
/* Send remote wakeup packet */
void send_remote_wakeup(USBDriver *usbp);
/* ---------------
* Keyboard header
* ---------------
*/
/* main keyboard (6kro) */
#define KBD_INTERFACE 0
#define KBD_ENDPOINT 1
#define KBD_EPSIZE 8
#define KBD_REPORT_KEYS (KBD_EPSIZE - 2)
/* secondary keyboard */
#ifdef NKRO_ENABLE
#define NKRO_INTERFACE 4
#define NKRO_ENDPOINT 5
#define NKRO_EPSIZE 16
#define NKRO_REPORT_KEYS (NKRO_EPSIZE - 1)
#endif
/* extern report_keyboard_t keyboard_report_sent; */
/* keyboard IN request callback handler */
void kbd_in_cb(USBDriver *usbp, usbep_t ep);
/* start-of-frame handler */
void kbd_sof_cb(USBDriver *usbp);
#ifdef NKRO_ENABLE
/* nkro IN callback hander */
void nkro_in_cb(USBDriver *usbp, usbep_t ep);
#endif /* NKRO_ENABLE */
/* ------------
* Mouse header
* ------------
*/
#ifdef MOUSE_ENABLE
#define MOUSE_INTERFACE 1
#define MOUSE_ENDPOINT 2
#define MOUSE_EPSIZE 8
/* mouse IN request callback handler */
void mouse_in_cb(USBDriver *usbp, usbep_t ep);
#endif /* MOUSE_ENABLE */
/* ---------------
* Extrakey header
* ---------------
*/
#ifdef EXTRAKEY_ENABLE
#define EXTRA_INTERFACE 3
#define EXTRA_ENDPOINT 4
#define EXTRA_EPSIZE 8
/* extrakey IN request callback handler */
void extra_in_cb(USBDriver *usbp, usbep_t ep);
/* extra report structure */
typedef struct {
uint8_t report_id;
uint16_t usage;
} __attribute__ ((packed)) report_extra_t;
#endif /* EXTRAKEY_ENABLE */
/* --------------
* Console header
* --------------
*/
#ifdef CONSOLE_ENABLE
#define CONSOLE_INTERFACE 2
#define CONSOLE_ENDPOINT 3
#define CONSOLE_EPSIZE 16
/* Number of IN reports that can be stored inside the output queue */
#define CONSOLE_QUEUE_CAPACITY 4
/* Console flush time */
#define CONSOLE_FLUSH_MS 50
/* Putchar over the USB console */
int8_t sendchar(uint8_t c);
/* Flush output (send everything immediately) */
void console_flush_output(void);
/* console IN request callback handler */
void console_in_cb(USBDriver *usbp, usbep_t ep);
#endif /* CONSOLE_ENABLE */
void sendchar_pf(void *p, char c);
#endif /* _USB_MAIN_H_ */