forked from mirror/qmk_firmware
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -10,7 +10,6 @@ SRC += $(ARM_ATSAM_DIR)/spi.c
|
||||
SRC += $(ARM_ATSAM_DIR)/startup.c
|
||||
|
||||
SRC += $(ARM_ATSAM_DIR)/usb/main_usb.c
|
||||
SRC += $(ARM_ATSAM_DIR)/usb/spfssf.c
|
||||
SRC += $(ARM_ATSAM_DIR)/usb/udc.c
|
||||
SRC += $(ARM_ATSAM_DIR)/usb/udi_cdc.c
|
||||
SRC += $(ARM_ATSAM_DIR)/usb/udi_hid.c
|
||||
|
||||
@@ -36,7 +36,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "issi3733_driver.h"
|
||||
#include "./usb/compiler.h"
|
||||
#include "./usb/udc.h"
|
||||
#include "./usb/spfssf.h"
|
||||
#include "./usb/udi_cdc.h"
|
||||
|
||||
#endif //MD_BOOTLOADER
|
||||
|
||||
@@ -41,8 +41,8 @@ void m15_print(uint32_t x)
|
||||
|
||||
//Display unsigned 32-bit number through debug led
|
||||
//Read as follows: 1230 = [*] [* *] [* * *] [**] (note zero is fast double flash)
|
||||
#define DLED_ONTIME 600000
|
||||
#define DLED_PAUSE 1000000
|
||||
#define DLED_ONTIME 1000000
|
||||
#define DLED_PAUSE 1500000
|
||||
volatile uint32_t w;
|
||||
void dled_print(uint32_t x, uint8_t long_pause)
|
||||
{
|
||||
|
||||
@@ -32,6 +32,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define m15_on REG_PORT_OUTSET1 = 0x40000000 //PB30 High
|
||||
#define m15_off REG_PORT_OUTCLR1 = 0x40000000 //PB30 Low
|
||||
|
||||
//Debug Port PB23
|
||||
#define m27_ena REG_PORT_DIRSET1 = 0x800000 //PB23 Output
|
||||
#define m27_on REG_PORT_OUTSET1 = 0x800000 //PB23 High
|
||||
#define m27_off REG_PORT_OUTCLR1 = 0x800000 //PB23 Low
|
||||
|
||||
//Debug Port PB31
|
||||
#define m28_ena REG_PORT_DIRSET1 = 0x80000000 //PB31 Output
|
||||
#define m28_on REG_PORT_OUTSET1 = 0x80000000 //PB31 High
|
||||
#define m28_off REG_PORT_OUTCLR1 = 0x80000000 //PB31 Low
|
||||
|
||||
#define m15_loop(M15X) {uint8_t M15L=M15X; while(M15L--){m15_on;CLK_delay_us(1);m15_off;}}
|
||||
|
||||
void m15_print(uint32_t x);
|
||||
|
||||
@@ -289,12 +289,12 @@ uint8_t I2C3733_Init_Drivers(void)
|
||||
//Set up master device
|
||||
i2c_led_send_CRWL(0);
|
||||
i2c_led_select_page(0, 3);
|
||||
i2c_led_send_mode_op_gcr(0, ISSI3733_CR_SYNC_MASTER, ISSI3733_CR_SSD_NORMAL);
|
||||
i2c_led_send_mode_op_gcr(0, 0, ISSI3733_CR_SSD_NORMAL); //No SYNC due to brightness mismatch with second driver
|
||||
|
||||
//Set up slave device
|
||||
i2c_led_send_CRWL(1);
|
||||
i2c_led_select_page(1, 3);
|
||||
i2c_led_send_mode_op_gcr(1, ISSI3733_CR_SYNC_SLAVE, ISSI3733_CR_SSD_NORMAL);
|
||||
i2c_led_send_mode_op_gcr(1, 0, ISSI3733_CR_SSD_NORMAL); //No SYNC due to brightness mismatch with first driver and slight flicker at rgb values 1,2
|
||||
|
||||
i2c_led_send_CRWL(0);
|
||||
i2c_led_select_page(0, 3);
|
||||
|
||||
@@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//From keyboard's directory
|
||||
#include "config_led.h"
|
||||
|
||||
void main_subtasks(void);
|
||||
uint8_t keyboard_leds(void);
|
||||
void send_keyboard(report_keyboard_t *report);
|
||||
void send_mouse(report_mouse_t *report);
|
||||
@@ -65,7 +66,7 @@ void send_keyboard(report_keyboard_t *report)
|
||||
if (!keymap_config.nkro)
|
||||
{
|
||||
#endif //NKRO_ENABLE
|
||||
dprint("s-kbd\r\n");
|
||||
while (udi_hid_kbd_b_report_trans_ongoing) { main_subtasks(); } //Run other tasks while waiting for USB to be free
|
||||
|
||||
irqflags = __get_PRIMASK();
|
||||
__disable_irq();
|
||||
@@ -81,7 +82,7 @@ void send_keyboard(report_keyboard_t *report)
|
||||
}
|
||||
else
|
||||
{
|
||||
dprint("s-nkro\r\n");
|
||||
while (udi_hid_nkro_b_report_trans_ongoing) { main_subtasks(); } //Run other tasks while waiting for USB to be free
|
||||
|
||||
irqflags = __get_PRIMASK();
|
||||
__disable_irq();
|
||||
@@ -102,8 +103,6 @@ void send_mouse(report_mouse_t *report)
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
uint32_t irqflags;
|
||||
|
||||
dprint("s-mou\r\n");
|
||||
|
||||
irqflags = __get_PRIMASK();
|
||||
__disable_irq();
|
||||
__DMB();
|
||||
@@ -120,8 +119,6 @@ void send_mouse(report_mouse_t *report)
|
||||
void send_system(uint16_t data)
|
||||
{
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
dprintf("s-exks %i\r\n", data);
|
||||
|
||||
uint32_t irqflags;
|
||||
|
||||
irqflags = __get_PRIMASK();
|
||||
@@ -142,8 +139,6 @@ void send_system(uint16_t data)
|
||||
void send_consumer(uint16_t data)
|
||||
{
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
dprintf("s-exkc %i\r\n",data);
|
||||
|
||||
uint32_t irqflags;
|
||||
|
||||
irqflags = __get_PRIMASK();
|
||||
@@ -160,6 +155,77 @@ void send_consumer(uint16_t data)
|
||||
#endif //EXTRAKEY_ENABLE
|
||||
}
|
||||
|
||||
uint8_t g_drvid;
|
||||
|
||||
void main_subtask_usb_state(void)
|
||||
{
|
||||
if (usb_state == USB_STATE_POWERDOWN)
|
||||
{
|
||||
uint32_t timer_led = timer_read32();
|
||||
|
||||
led_on;
|
||||
if (led_enabled)
|
||||
{
|
||||
for (g_drvid = 0; g_drvid < ISSI3733_DRIVER_COUNT; g_drvid++)
|
||||
{
|
||||
I2C3733_Control_Set(0);
|
||||
}
|
||||
}
|
||||
while (usb_state == USB_STATE_POWERDOWN)
|
||||
{
|
||||
if (timer_read32() - timer_led > 1000) led_off; //Good to indicate went to sleep, but only for a second
|
||||
}
|
||||
if (led_enabled)
|
||||
{
|
||||
for (g_drvid = 0; g_drvid < ISSI3733_DRIVER_COUNT; g_drvid++)
|
||||
{
|
||||
I2C3733_Control_Set(1);
|
||||
}
|
||||
}
|
||||
led_off;
|
||||
}
|
||||
}
|
||||
|
||||
void main_subtask_led(void)
|
||||
{
|
||||
led_matrix_task();
|
||||
}
|
||||
|
||||
void main_subtask_power_check(void)
|
||||
{
|
||||
static uint64_t next_5v_checkup = 0;
|
||||
|
||||
if (CLK_get_ms() > next_5v_checkup)
|
||||
{
|
||||
next_5v_checkup = CLK_get_ms() + 5;
|
||||
|
||||
v_5v = adc_get(ADC_5V);
|
||||
v_5v_avg = 0.9 * v_5v_avg + 0.1 * v_5v;
|
||||
|
||||
gcr_compute();
|
||||
}
|
||||
}
|
||||
|
||||
void main_subtask_usb_extra_device(void)
|
||||
{
|
||||
static uint64_t next_usb_checkup = 0;
|
||||
|
||||
if (CLK_get_ms() > next_usb_checkup)
|
||||
{
|
||||
next_usb_checkup = CLK_get_ms() + 10;
|
||||
|
||||
USB_HandleExtraDevice();
|
||||
}
|
||||
}
|
||||
|
||||
void main_subtasks(void)
|
||||
{
|
||||
main_subtask_usb_state();
|
||||
main_subtask_led();
|
||||
main_subtask_power_check();
|
||||
main_subtask_usb_extra_device();
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
led_ena;
|
||||
@@ -201,9 +267,8 @@ int main(void)
|
||||
|
||||
i2c_led_q_init();
|
||||
|
||||
uint8_t drvid;
|
||||
for (drvid=0;drvid<ISSI3733_DRIVER_COUNT;drvid++)
|
||||
I2C_LED_Q_ONOFF(drvid); //Queue data
|
||||
for (g_drvid = 0; g_drvid < ISSI3733_DRIVER_COUNT; g_drvid++)
|
||||
I2C_LED_Q_ONOFF(g_drvid); //Queue data
|
||||
|
||||
keyboard_setup();
|
||||
|
||||
@@ -211,11 +276,9 @@ int main(void)
|
||||
|
||||
host_set_driver(&arm_atsam_driver);
|
||||
|
||||
#ifdef VIRTSER_ENABLE
|
||||
#ifdef CONSOLE_ENABLE
|
||||
uint64_t next_print = 0;
|
||||
#endif //VIRTSER_ENABLE
|
||||
uint64_t next_usb_checkup = 0;
|
||||
uint64_t next_5v_checkup = 0;
|
||||
#endif //CONSOLE_ENABLE
|
||||
|
||||
v_5v_avg = adc_get(ADC_5V);
|
||||
|
||||
@@ -223,57 +286,21 @@ int main(void)
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (usb_state == USB_STATE_POWERDOWN)
|
||||
{
|
||||
led_on;
|
||||
if (led_enabled)
|
||||
{
|
||||
for (drvid=0;drvid<ISSI3733_DRIVER_COUNT;drvid++)
|
||||
{
|
||||
I2C3733_Control_Set(0);
|
||||
}
|
||||
}
|
||||
while (usb_state == USB_STATE_POWERDOWN) {}
|
||||
if (led_enabled)
|
||||
{
|
||||
for (drvid=0;drvid<ISSI3733_DRIVER_COUNT;drvid++)
|
||||
{
|
||||
I2C3733_Control_Set(1);
|
||||
}
|
||||
}
|
||||
led_off;
|
||||
}
|
||||
|
||||
keyboard_task();
|
||||
|
||||
led_matrix_task();
|
||||
main_subtasks(); //Note these tasks will also be run while waiting for USB keyboard polling intervals
|
||||
|
||||
if (CLK_get_ms() > next_5v_checkup)
|
||||
{
|
||||
next_5v_checkup = CLK_get_ms() + 5;
|
||||
|
||||
v_5v = adc_get(ADC_5V);
|
||||
v_5v_avg = 0.9 * v_5v_avg + 0.1 * v_5v;
|
||||
|
||||
gcr_compute();
|
||||
}
|
||||
|
||||
if (CLK_get_ms() > next_usb_checkup)
|
||||
{
|
||||
next_usb_checkup = CLK_get_ms() + 10;
|
||||
|
||||
USB_HandleExtraDevice();
|
||||
}
|
||||
|
||||
#ifdef VIRTSER_ENABLE
|
||||
#ifdef CONSOLE_ENABLE
|
||||
if (CLK_get_ms() > next_print)
|
||||
{
|
||||
next_print = CLK_get_ms() + 250;
|
||||
//dpf("5v=%i 5vu=%i dlow=%i dhi=%i gca=%i gcd=%i\r\n",v_5v,v_5v_avg,v_5v_avg-V5_LOW,v_5v_avg-V5_HIGH,gcr_actual,gcr_desired);
|
||||
//Add any debug information here that you want to see very often
|
||||
//dprintf("5v=%u 5vu=%u dlow=%u dhi=%u gca=%u gcd=%u\r\n", v_5v, v_5v_avg, v_5v_avg - V5_LOW, v_5v_avg - V5_HIGH, gcr_actual, gcr_desired);
|
||||
}
|
||||
#endif //VIRTSER_ENABLE
|
||||
#endif //CONSOLE_ENABLE
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,13 @@ extern uint32_t _erom;
|
||||
|
||||
#define BOOTLOADER_SERIAL_MAX_SIZE 20 //DO NOT MODIFY!
|
||||
|
||||
#ifdef KEYBOARD_massdrop_ctrl
|
||||
//WARNING: These are only for CTRL bootloader release "v2.18Jun 22 2018 17:28:08" for bootloader_jump support
|
||||
extern uint32_t _eram;
|
||||
#define BOOTLOADER_MAGIC 0x3B9ACA00
|
||||
#define MAGIC_ADDR (uint32_t *)(&_eram - 4)
|
||||
#endif
|
||||
|
||||
#ifdef MD_BOOTLOADER
|
||||
|
||||
#define MCU_HZ 48000000
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
*/
|
||||
|
||||
#include "samd51.h"
|
||||
#include "md_bootloader.h"
|
||||
|
||||
/* Initialize segments */
|
||||
extern uint32_t _sfixed;
|
||||
@@ -500,6 +501,16 @@ const DeviceVectors exception_table = {
|
||||
*/
|
||||
void Reset_Handler(void)
|
||||
{
|
||||
#ifdef KEYBOARD_massdrop_ctrl
|
||||
/* WARNING: This is only for CTRL bootloader release "v2.18Jun 22 2018 17:28:08" for bootloader_jump support */
|
||||
if (*MAGIC_ADDR == BOOTLOADER_MAGIC) {
|
||||
/* At this point, the bootloader's memory is initialized properly, so undo the jump to here, then jump back */
|
||||
*MAGIC_ADDR = 0x00000000; /* Change value to prevent potential bootloader entrance loop */
|
||||
__set_MSP(0x20008818); /* MSP according to bootloader */
|
||||
SCB->VTOR = 0x00000000; /* Vector table back to bootloader's */
|
||||
asm("bx %0"::"r"(0x00001267)); /* Jump past bootloader RCAUSE check using THUMB */
|
||||
}
|
||||
#endif
|
||||
uint32_t *pSrc, *pDest;
|
||||
|
||||
/* Initialize the relocate segment */
|
||||
|
||||
@@ -134,6 +134,11 @@
|
||||
#define UDI_HID_EXK_DISABLE_EXT() main_exk_disable()
|
||||
#endif
|
||||
|
||||
#ifdef CON
|
||||
#define UDI_HID_CON_ENABLE_EXT() main_con_enable()
|
||||
#define UDI_HID_CON_DISABLE_EXT() main_con_disable()
|
||||
#endif
|
||||
|
||||
#ifdef MOU
|
||||
#define UDI_HID_MOU_ENABLE_EXT() main_mou_enable()
|
||||
#define UDI_HID_MOU_DISABLE_EXT() main_mou_disable()
|
||||
|
||||
@@ -88,6 +88,20 @@ void main_exk_disable(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CON
|
||||
volatile bool main_b_con_enable = false;
|
||||
bool main_con_enable(void)
|
||||
{
|
||||
main_b_con_enable = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void main_con_disable(void)
|
||||
{
|
||||
main_b_con_enable = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOU
|
||||
volatile bool main_b_mou_enable = false;
|
||||
bool main_mou_enable(void)
|
||||
|
||||
@@ -1,268 +0,0 @@
|
||||
#include "samd51j18a.h"
|
||||
#include "stdarg.h"
|
||||
#include "spfssf.h"
|
||||
#include "usb_util.h"
|
||||
|
||||
int vspf(char *_Dest, const char *_Format, va_list va)
|
||||
{
|
||||
//va_list va; //Variable argument list variable
|
||||
char *d = _Dest; //Pointer to dest
|
||||
|
||||
//va_start(va,_Format); //Initialize the variable argument list
|
||||
while (*_Format) //While not end of format string
|
||||
{
|
||||
if (*_Format == SPF_SPEC_START) //If current format string character is the specifier start character
|
||||
{
|
||||
_Format++; //Skip over the character
|
||||
while (*_Format && *_Format <= 64) _Format++; //Forward past any options
|
||||
if (*_Format == SPF_SPEC_START) *d++ = *_Format; //If the character is the specifier start character, output the character and advance dest
|
||||
else if (*_Format == SPF_SPEC_LONG) //If the character is the long type
|
||||
{
|
||||
_Format++; //Skip over the character
|
||||
if (*_Format == SPF_SPEC_DECIMAL) //If the character is the decimal type
|
||||
{
|
||||
int64_t buf = va_arg(va,int64_t); //Get the next value from the va list
|
||||
//if (buf < 0) { *d++ = '-'; buf = -buf; } //If the given number is negative, add a negative sign to the dest and invert number
|
||||
//spf_uint2str_32_3t(&d,buf,32); //Perform the conversion
|
||||
d += UTIL_ltoa_radix(buf, d, 10);
|
||||
}
|
||||
else if (*_Format == SPF_SPEC_UNSIGNED) //If the character is the unsigned type
|
||||
{
|
||||
uint64_t num = va_arg(va,uint64_t); //Get the next value from the va list
|
||||
//spf_uint2str_32_3t(&d,num,32); //Perform the conversion
|
||||
d += UTIL_ltoa_radix(num, d, 10);
|
||||
}
|
||||
else if (*_Format == SPF_SPEC_UHINT || *_Format == SPF_SPEC_UHINT_UP) //If the character is the unsigned type
|
||||
{
|
||||
uint64_t buf = va_arg(va,uint64_t); //Get the next value from the va list
|
||||
//spf_uint2hex_32(&d,(unsigned long) buf);
|
||||
d += UTIL_ltoa_radix(buf, d, 16);
|
||||
}
|
||||
else //If the character was not a known type
|
||||
{
|
||||
*d++ = SPF_SPEC_START; //Output the start specifier
|
||||
*d++ = SPF_SPEC_LONG; //Output the long type
|
||||
*d++ = *_Format; //Output the unknown type
|
||||
}
|
||||
}
|
||||
else if (*_Format == SPF_SPEC_DECIMAL) //If the character is the decimal type
|
||||
{
|
||||
int buf = va_arg(va,int); //Get the next value from the va list
|
||||
//if (buf < 0) { *d++ = '-'; buf = -buf; } //If the given number is negative, add a negative sign to the dest and invert number
|
||||
//spf_uint2str_32_3t(&d,buf,16); //Perform the conversion
|
||||
d += UTIL_itoa(buf, d);
|
||||
}
|
||||
else if (*_Format == SPF_SPEC_INT) //If the character is the integer type
|
||||
{
|
||||
int buf = va_arg(va,int); //Get the next value from the va list
|
||||
//if (buf < 0) { *d++ = '-'; buf = -buf; } //If the given number is negative, add a negative sign to the dest and inverted number
|
||||
//spf_uint2str_32_3t(&d,buf,16); //Perform the conversion
|
||||
d += UTIL_itoa(buf, d);
|
||||
}
|
||||
else if (*_Format == SPF_SPEC_UINT) //If the character is the unsigned integer type
|
||||
{
|
||||
int buf = va_arg(va,int); //Get the next value from the va list
|
||||
//spf_uint2str_32_3t(&d,buf,16); //Perform the conversion
|
||||
d += UTIL_utoa(buf, d);
|
||||
}
|
||||
else if (*_Format == SPF_SPEC_STRING) //If the character is the string type
|
||||
{
|
||||
char *buf = va_arg(va,char*); //Get the next value from the va list
|
||||
while (*buf) *d++ = *buf++; //Perform the conversion (simply output characters and adcance pointers)
|
||||
}
|
||||
else if (*_Format == SPF_SPEC_UHINT || *_Format == SPF_SPEC_UHINT_UP) //If the character is the short type
|
||||
{
|
||||
int buf = va_arg(va,unsigned int); //Get the next value from the va list
|
||||
//spf_uint2hex_32(&d,(unsigned long) buf); //Perform the conversion
|
||||
d += UTIL_utoa(buf, d);
|
||||
}
|
||||
else //If the character type is unknown
|
||||
{
|
||||
*d++ = SPF_SPEC_START; //Output the start specifier
|
||||
*d++ = *_Format; //Output the unknown type
|
||||
}
|
||||
}
|
||||
else *d++ = *_Format; //If the character is unknown, output it to dest and advance dest
|
||||
_Format++; //Advance the format buffer pointer to next character
|
||||
}
|
||||
//va_end(va); //End the variable argument list
|
||||
|
||||
*d = '\0'; //Cap off the destination string with a zero
|
||||
|
||||
return d - _Dest; //Return the length of the destintion buffer
|
||||
}
|
||||
|
||||
int spf(char *_Dest, const char *_Format, ...)
|
||||
{
|
||||
va_list va; //Variable argument list variable
|
||||
int result;
|
||||
|
||||
va_start(va,_Format); //Initialize the variable argument list
|
||||
result = vspf(_Dest, _Format, va);
|
||||
va_end(va);
|
||||
return result;
|
||||
}
|
||||
|
||||
//sscanf string to number (integer types)
|
||||
int64_t ssf_ston(const char **_Src, uint32_t count, uint32_t *conv_count)
|
||||
{
|
||||
int64_t value = 0; //Return value accumulator
|
||||
uint32_t counter=count; //Counter to keep track of numbers converted
|
||||
const char* p; //Pointer to first non space character
|
||||
|
||||
while (*(*_Src) == SSF_SKIP_SPACE) (*_Src)++; //Forward through the whitespace to next non whitespace
|
||||
|
||||
p = (*_Src); //Set pointer to first non space character
|
||||
if (*p == '+' || *p == '-') (*_Src)++; //Skip over sign if any
|
||||
while (*(*_Src) >= ASCII_NUM_START &&
|
||||
*(*_Src) <= ASCII_NUM_END &&
|
||||
counter) //While the source character is a digit and counter is not zero
|
||||
{
|
||||
value *= 10; //Multiply result by 10 to make room for next 1's place number
|
||||
value += *(*_Src)++ - ASCII_NUM_START; //Add source number to value
|
||||
counter--; //Decrement counter
|
||||
}
|
||||
if (counter - count == 0) return 0; //If no number conversion were performed, return 0
|
||||
if (*p == '-') value = -value; //If the number given was negative, make the result negative
|
||||
|
||||
if (conv_count) (*conv_count)++; //Increment the converted count
|
||||
return value; //Return the value
|
||||
}
|
||||
|
||||
uint64_t ssf_hton(const char **_Src, uint32_t count,uint32_t *conv_count)
|
||||
{
|
||||
int64_t value=0; //Return value accumulator
|
||||
uint32_t counter=count; //Counter to keep track of numbers converted
|
||||
//const char* p; //Pointer to first non space character
|
||||
char c;
|
||||
|
||||
while (*(*_Src) == SSF_SKIP_SPACE) (*_Src)++; //Forward through the whitespace to next non whitespace
|
||||
|
||||
//p = (*_Src); //Set pointer to first non space character
|
||||
|
||||
while (counter)
|
||||
{
|
||||
c = *(*_Src)++;
|
||||
if (c >= 'a' && c <= 'f') c -= ('a'-'A'); //toupper
|
||||
if (c < '0' || (c > '9' && c < 'A') || c > 'F') break;
|
||||
value *= 16; //Multiply result by 10 to make room for next 1's place number
|
||||
c = c - '0';
|
||||
if (c > 9) c -= 7;
|
||||
value += c; //Add source number to value
|
||||
counter--; //Decrement counter
|
||||
}
|
||||
|
||||
if (counter - count == 0) return 0; //If no number conversion were performed, return 0
|
||||
//if (*p == '-') value = -value; //If the number given was negative, make the result negative
|
||||
|
||||
if (conv_count) (*conv_count)++; //Increment the converted count
|
||||
return value;
|
||||
}
|
||||
|
||||
//sscanf
|
||||
int ssf(const char *_Src, const char *_Format, ...)
|
||||
{
|
||||
va_list va; //Variable argument list variable
|
||||
unsigned char looking_for=0; //Static char specified in format to be found in source
|
||||
uint32_t conv_count=0; //Count of conversions made
|
||||
|
||||
va_start(va,_Format); //Initialize the variable argument list
|
||||
while (*_Format) //While the format string has not been fully read
|
||||
{
|
||||
if (looking_for != 0) //If we are looking for a matching character in the source string
|
||||
{
|
||||
while (*_Src != looking_for && *_Src) _Src++; //While the character is not found in the source string and not the end of the source
|
||||
// string, increment the pointer position
|
||||
if (*_Src == looking_for) _Src++; //If the character was found, step over it
|
||||
else break; //Else the end was reached and the scan is now invalid (Could not find static character)
|
||||
looking_for = 0; //Clear the looking for character
|
||||
}
|
||||
if (*_Format == SSF_SPEC_START) //If the current format character is the specifier start character
|
||||
{
|
||||
_Format++; //Step over the specifier start character
|
||||
if (*_Format == SSF_SPEC_DECIMAL) //If the decimal specifier type is found
|
||||
{
|
||||
int *value=va_arg(va,int*); //User given destination address
|
||||
//*value = (int)ssf_ston(&_Src,5,&conv_count); //Run conversion
|
||||
*value = (int)ssf_ston(&_Src,10,&conv_count); //Run conversion
|
||||
}
|
||||
else if (*_Format == SSF_SPEC_LONG) //If the long specifier type is found
|
||||
{
|
||||
_Format++; //Skip over the specifier type
|
||||
if (*_Format == SSF_SPEC_DECIMAL) //If the decimal specifier type is found
|
||||
{
|
||||
int64_t *value=va_arg(va,int64_t*); //User given destination address
|
||||
//*value = (int64_t)ssf_ston(&_Src,10,&conv_count); //Run conversion
|
||||
*value = (int64_t)ssf_ston(&_Src,19,&conv_count); //Run conversion
|
||||
}
|
||||
else if (*_Format == SSF_SPEC_UHINT) //If the decimal specifier type is found
|
||||
{
|
||||
uint64_t *value=va_arg(va,uint64_t *); //User given destination address
|
||||
//*value = (uint64_t int)ssf_hton(&_Src,12,&conv_count); //Run conversion
|
||||
*value = (uint64_t)ssf_hton(&_Src,16,&conv_count); //Run conversion
|
||||
}
|
||||
}
|
||||
else if (*_Format == SSF_SPEC_SHORTINT) //If the short int specifier type is found
|
||||
{
|
||||
_Format++; //Skip over the specifier type
|
||||
if (*_Format == SSF_SPEC_SHORTINT) //If the short int specifier type is found
|
||||
{
|
||||
_Format++; //Skip over the specifier type
|
||||
if (*_Format == SSF_SPEC_DECIMAL) //If the decimal specifier type is found
|
||||
{
|
||||
unsigned char *value=va_arg(va,unsigned char*); //User given destination address
|
||||
//*value = (unsigned char)ssf_ston(&_Src,3,&conv_count); //Run conversion
|
||||
*value = (unsigned char)ssf_ston(&_Src,5,&conv_count); //Run conversion
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (*_Format == SSF_SPEC_STRING) //If the specifier type is string
|
||||
{
|
||||
char *value=va_arg(va,char*); //User given destination address, max chars read pointer
|
||||
while (*_Src == SSF_SKIP_SPACE) _Src++; //Forward through the whitespace to next non whitespace
|
||||
while (*_Src != SSF_SKIP_SPACE && *_Src) *value++ = *_Src++; //While any character but space and not end of string and not end location, copy char to dest
|
||||
*value = 0; //Cap off the string pointer with zero
|
||||
conv_count++; //Increment the converted count
|
||||
}
|
||||
else if (*_Format == SSF_SPEC_VERSION) //If the specifier type is string
|
||||
{
|
||||
char *value=va_arg(va,char*); //User given destination address, max chars read pointer
|
||||
while (*_Src == SSF_SKIP_SPACE) _Src++; //Forward through the whitespace to next non whitespace
|
||||
while (*_Src != SSF_DELIM_COMMA && *_Src) *value++ = *_Src++; //While any character but space and not end of string and not end location, copy char to dest
|
||||
*value = 0; //Cap off the string pointer with zero
|
||||
conv_count++; //Increment the converted count
|
||||
}
|
||||
else if (*_Format >= ASCII_NUM_START && *_Format <= ASCII_NUM_END)
|
||||
{
|
||||
uint32_t len = (uint32_t)ssf_ston(&_Format,3,NULL); //Convert the given length
|
||||
if (*_Format == SSF_SPEC_STRING) //If the specifier type is string
|
||||
{
|
||||
char *value=va_arg(va,char*),*e; //User given destination address, max chars read pointer
|
||||
while (*_Src == SSF_SKIP_SPACE) _Src++; //Forward through the whitespace to next non whitespace
|
||||
e = (char*)_Src+len; //Set a maximum length pointer location
|
||||
while (*_Src != SSF_SKIP_SPACE && *_Src && _Src != e) *value++ = *_Src++; //While any character but space and not end of string and not end location, copy char to dest
|
||||
*value = 0; //Cap off the string pointer with zero
|
||||
conv_count++; //Increment the converted count
|
||||
}
|
||||
else if (*_Format == SSF_SPEC_VERSION) //If the specifier type is string
|
||||
{
|
||||
char *value=va_arg(va,char*),*e; //User given destination address, max chars read pointer
|
||||
while (*_Src == SSF_SKIP_SPACE) _Src++; //Forward through the whitespace to next non whitespace
|
||||
e = (char*)_Src+len; //Set a maximum length pointer location
|
||||
while (*_Src != SSF_DELIM_COMMA && *_Src && _Src != e) *value++ = *_Src++; //While any character but space and not end of string and not end location, copy char to dest
|
||||
*value = 0; //Cap off the string pointer with zero
|
||||
conv_count++; //Increment the converted count
|
||||
}
|
||||
}
|
||||
else if (*_Format == SSF_SPEC_START) looking_for = *_Format; //If another start specifier character is found, output a specifier character
|
||||
else break; //Scan is now invalid (Uknown type specified)
|
||||
}
|
||||
else if (*_Format == SSF_SKIP_SPACE) { } //If a space is found, ignore it
|
||||
else looking_for = *_Format; //If any other character is found, it is static and should be found in src as well
|
||||
_Format++; //Skip over current format character
|
||||
}
|
||||
|
||||
va_end(va); //End the variable argument list
|
||||
return conv_count; //Return the number of conversions made
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#ifndef ____spfssf_h
|
||||
#define ____spfssf_h
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define sprintf spf
|
||||
#define sscanf ssf
|
||||
|
||||
#define SIZEOF_OFFSET 1
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#define SPF_NONE 0
|
||||
|
||||
#define SPF_SPEC_START 37 //%
|
||||
#define SPF_SPEC_DECIMAL 100 //d 16bit dec signed (-32767 to 32767) DONE same as i
|
||||
#define SPF_SPEC_INT 105 //i 16bit dec signed (-32767 to 32767) DONE same as d
|
||||
#define SPF_SPEC_UINT 117 //u 16bit dec unsigned (0 to 65535) DONE
|
||||
#define SPF_SPEC_STRING 115 //s variable length (abcd...) DONE
|
||||
#define SPF_SPEC_UHINT 120 //x 16bit hex lwrc (7fa) DONE
|
||||
#define SPF_SPEC_UHINT_UP 88 //x 16bit hex lwrc (7fa) DONE
|
||||
#define SPF_SPEC_LONG 108 //l start of either ld or lu DONE
|
||||
#define SPF_SPEC_DECIMAL 100 //ld 32bit dec signed (-2147483647 to 2147483647) DONE
|
||||
#define SPF_SPEC_UNSIGNED 117 //lu 32bit dec unsigned (0 to 4294967295) DONE
|
||||
#define SPF_SPEC_UHINT 120 //lx 32bit hex unsigned (0 to ffffffff) DONE
|
||||
|
||||
#define SSF_SPEC_START 37 //%
|
||||
#define SSF_SPEC_SHORTINT 104 //h 8bit dec signed (-127 to 127) DONE
|
||||
#define SSF_LEN_SHORTINT 3 //hhd
|
||||
#define SSF_SPEC_DECIMAL 100 //d 16bit dec signed (-32767 to 32767) DONE
|
||||
#define SSF_LEN_DECIMAL 5 //32767
|
||||
#define SSF_SPEC_INT 105 //i 16bit dec signed (-32767 to 32767) DONE
|
||||
#define SSF_LEN_INT 5 //32767
|
||||
#define SSF_SPEC_LONG 108 //l start of either ld or lu DONE
|
||||
#define SSF_SPEC_DECIMAL 100 //ld 32bit dec signed (-2147483647 to 2147483647) DONE
|
||||
#define SSF_SPEC_UHINT 120 //lx 32bit hex unsigned DONE
|
||||
#define SSF_LEN_LDECIMAL 10 //2147483647
|
||||
#define SSF_SPEC_STRING 115 //s variable length (abcd...) DONE
|
||||
#define SSF_SKIP_SPACE 32 //space
|
||||
|
||||
#define SSF_SPEC_VERSION 118 //v collect to comma delimiter - special
|
||||
#define SSF_DELIM_COMMA 44 //,
|
||||
|
||||
#define ASCII_NUM_START 48 //0
|
||||
#define ASCII_NUM_END 58 //9
|
||||
|
||||
#define T_UINT32_0_LIMIT 14
|
||||
#define T_UINT32_1_LIMIT 27
|
||||
|
||||
int vspf(char *_Dest, const char *_Format, va_list va);
|
||||
int spf(char *_Dest, const char *_Format, ...);
|
||||
int ssf(const char *_Src, const char *_Format, ...);
|
||||
|
||||
#endif //____spfssf_h
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
#include <string.h>
|
||||
#include "udi_cdc_conf.h"
|
||||
#include "udi_device_conf.h"
|
||||
#include "spfssf.h"
|
||||
#include "stdarg.h"
|
||||
#include "tmk_core/protocol/arm_atsam/clks.h"
|
||||
|
||||
@@ -1259,16 +1258,15 @@ uint32_t CDC_print(char *printbuf)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
char printbuf[CDC_PRINTBUF_SIZE];
|
||||
|
||||
int dpf(const char *_Format, ...)
|
||||
int CDC_printf(const char *_Format, ...)
|
||||
{
|
||||
va_list va; //Variable argument list variable
|
||||
int result;
|
||||
|
||||
va_start(va,_Format); //Initialize the variable argument list
|
||||
result = vspf(printbuf, _Format, va);
|
||||
va_start(va, _Format); //Initialize the variable argument list
|
||||
result = vsnprintf(printbuf, CDC_PRINTBUF_SIZE, _Format, va);
|
||||
va_end(va);
|
||||
|
||||
CDC_print(printbuf);
|
||||
@@ -1358,7 +1356,7 @@ uint32_t CDC_print(char *printbuf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dpf(const char *_Format, ...)
|
||||
int CDC_printf(const char *_Format, ...)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -1377,8 +1375,6 @@ void CDC_init(void)
|
||||
printbuf[0]=0;
|
||||
}
|
||||
|
||||
char printbuf[CDC_PRINTBUF_SIZE];
|
||||
|
||||
#endif //CDC line 62
|
||||
|
||||
//@}
|
||||
|
||||
@@ -57,8 +57,8 @@
|
||||
#include "udi.h"
|
||||
|
||||
// Check the number of port
|
||||
#ifndef UDI_CDC_PORT_NB
|
||||
# define UDI_CDC_PORT_NB 1
|
||||
#ifndef UDI_CDC_PORT_NB
|
||||
# define UDI_CDC_PORT_NB 1
|
||||
#endif
|
||||
#if (UDI_CDC_PORT_NB > 1)
|
||||
# error UDI_CDC_PORT_NB must be at most 1
|
||||
@@ -86,9 +86,6 @@ extern UDC_DESC_STORAGE udi_api_t udi_api_cdc_data;
|
||||
//! CDC data endpoints size for FS speed (8B, 16B, 32B, 64B)
|
||||
#define UDI_CDC_DATA_EPS_FS_SIZE CDC_RX_SIZE
|
||||
|
||||
#define CDC_PRINT_BUF_SIZE 256
|
||||
extern char printbuf[CDC_PRINT_BUF_SIZE];
|
||||
|
||||
//@}
|
||||
|
||||
/**
|
||||
@@ -368,12 +365,10 @@ extern inbuf_t inbuf;
|
||||
#endif //CDC
|
||||
|
||||
uint32_t CDC_print(char *printbuf);
|
||||
int CDC_printf(const char *_Format, ...);
|
||||
uint32_t CDC_input(void);
|
||||
void CDC_init(void);
|
||||
|
||||
#define __xprintf dpf
|
||||
int dpf(const char *_Format, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -44,10 +44,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define RAW
|
||||
#endif
|
||||
|
||||
//#define CONSOLE_ENABLE //deferred implementation
|
||||
//#ifdef CONSOLE_ENABLE
|
||||
//#define CON
|
||||
//#endif
|
||||
//#define CONSOLE_ENABLE //rules.mk
|
||||
#ifdef CONSOLE_ENABLE
|
||||
#define CON
|
||||
#endif
|
||||
|
||||
//#define NKRO_ENABLE //rules.mk
|
||||
#ifdef NKRO_ENABLE
|
||||
@@ -110,8 +110,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endif
|
||||
|
||||
#ifdef CON
|
||||
#define CONSOLE_INTERFACE NEXT_INTERFACE_4
|
||||
#define NEXT_INTERFACE_5 (CONSOLE_INTERFACE + 1)
|
||||
#define CON_INTERFACE NEXT_INTERFACE_4
|
||||
#define NEXT_INTERFACE_5 (CON_INTERFACE + 1)
|
||||
#define UDI_HID_CON_IFACE_NUMBER CON_INTERFACE
|
||||
#else
|
||||
#define NEXT_INTERFACE_5 NEXT_INTERFACE_4
|
||||
#endif
|
||||
@@ -211,11 +212,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endif
|
||||
|
||||
#ifdef CON
|
||||
#define CONSOLE_IN_EPNUM NEXT_IN_EPNUM_4
|
||||
#define NEXT_IN_EPNUM_5 (CONSOLE_IN_EPNUM + 1)
|
||||
#define CONSOLE_OUT_EPNUM NEXT_OUT_EPNUM_1
|
||||
#define NEXT_OUT_EPNUM_2 (CONSOLE_OUT_EPNUM + 1)
|
||||
#define CONSOLE_POLLING_INTERVAL 1
|
||||
#define CON_IN_EPNUM NEXT_IN_EPNUM_4
|
||||
#define UDI_HID_CON_EP_IN CON_IN_EPNUM
|
||||
#define NEXT_IN_EPNUM_5 (CON_IN_EPNUM + 1)
|
||||
#define CON_OUT_EPNUM NEXT_OUT_EPNUM_1
|
||||
#define UDI_HID_CON_EP_OUT CON_OUT_EPNUM
|
||||
#define NEXT_OUT_EPNUM_2 (CON_OUT_EPNUM + 1)
|
||||
#define CON_POLLING_INTERVAL 1
|
||||
#ifndef UDI_HID_CON_STRING_ID
|
||||
#define UDI_HID_CON_STRING_ID 0
|
||||
#endif
|
||||
#else
|
||||
#define NEXT_IN_EPNUM_5 NEXT_IN_EPNUM_4
|
||||
#define NEXT_OUT_EPNUM_2 NEXT_OUT_EPNUM_1
|
||||
@@ -558,6 +564,66 @@ COMPILER_PACK_RESET()
|
||||
|
||||
#endif //RAW
|
||||
|
||||
// **********************************************************************
|
||||
// CON Descriptor structure and content
|
||||
// **********************************************************************
|
||||
#ifdef CON
|
||||
|
||||
COMPILER_PACK_SET(1)
|
||||
|
||||
typedef struct {
|
||||
usb_iface_desc_t iface;
|
||||
usb_hid_descriptor_t hid;
|
||||
usb_ep_desc_t ep_out;
|
||||
usb_ep_desc_t ep_in;
|
||||
} udi_hid_con_desc_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t array[34];
|
||||
} udi_hid_con_report_desc_t;
|
||||
|
||||
#define UDI_HID_CON_DESC {\
|
||||
.iface.bLength = sizeof(usb_iface_desc_t),\
|
||||
.iface.bDescriptorType = USB_DT_INTERFACE,\
|
||||
.iface.bInterfaceNumber = UDI_HID_CON_IFACE_NUMBER,\
|
||||
.iface.bAlternateSetting = 0,\
|
||||
.iface.bNumEndpoints = 2,\
|
||||
.iface.bInterfaceClass = HID_CLASS,\
|
||||
.iface.bInterfaceSubClass = HID_SUB_CLASS_NOBOOT,\
|
||||
.iface.bInterfaceProtocol = HID_SUB_CLASS_NOBOOT,\
|
||||
.iface.iInterface = UDI_HID_CON_STRING_ID,\
|
||||
.hid.bLength = sizeof(usb_hid_descriptor_t),\
|
||||
.hid.bDescriptorType = USB_DT_HID,\
|
||||
.hid.bcdHID = LE16(USB_HID_BDC_V1_11),\
|
||||
.hid.bCountryCode = USB_HID_NO_COUNTRY_CODE,\
|
||||
.hid.bNumDescriptors = USB_HID_NUM_DESC,\
|
||||
.hid.bRDescriptorType = USB_DT_HID_REPORT,\
|
||||
.hid.wDescriptorLength = LE16(sizeof(udi_hid_con_report_desc_t)),\
|
||||
.ep_out.bLength = sizeof(usb_ep_desc_t),\
|
||||
.ep_out.bDescriptorType = USB_DT_ENDPOINT,\
|
||||
.ep_out.bEndpointAddress = UDI_HID_CON_EP_OUT | USB_EP_DIR_OUT,\
|
||||
.ep_out.bmAttributes = USB_EP_TYPE_INTERRUPT,\
|
||||
.ep_out.wMaxPacketSize = LE16(CONSOLE_EPSIZE),\
|
||||
.ep_out.bInterval = CON_POLLING_INTERVAL,\
|
||||
.ep_in.bLength = sizeof(usb_ep_desc_t),\
|
||||
.ep_in.bDescriptorType = USB_DT_ENDPOINT,\
|
||||
.ep_in.bEndpointAddress = UDI_HID_CON_EP_IN | USB_EP_DIR_IN,\
|
||||
.ep_in.bmAttributes = USB_EP_TYPE_INTERRUPT,\
|
||||
.ep_in.wMaxPacketSize = LE16(CONSOLE_EPSIZE),\
|
||||
.ep_in.bInterval = CON_POLLING_INTERVAL,\
|
||||
}
|
||||
|
||||
#define UDI_HID_CON_REPORT_SIZE CONSOLE_EPSIZE
|
||||
|
||||
extern uint8_t udi_hid_con_report_set[UDI_HID_CON_REPORT_SIZE];
|
||||
|
||||
//report buffer
|
||||
extern uint8_t udi_hid_con_report[UDI_HID_CON_REPORT_SIZE];
|
||||
|
||||
COMPILER_PACK_RESET()
|
||||
|
||||
#endif //CON
|
||||
|
||||
// **********************************************************************
|
||||
// CDC Descriptor structure and content
|
||||
// **********************************************************************
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
*/
|
||||
|
||||
#include "samd51j18a.h"
|
||||
#include "d51_util.h"
|
||||
#include "conf_usb.h"
|
||||
#include "usb_protocol.h"
|
||||
#include "udd.h"
|
||||
@@ -86,7 +87,7 @@ bool udi_hid_kbd_b_report_valid;
|
||||
COMPILER_WORD_ALIGNED
|
||||
uint8_t udi_hid_kbd_report[UDI_HID_KBD_REPORT_SIZE];
|
||||
|
||||
static bool udi_hid_kbd_b_report_trans_ongoing;
|
||||
volatile bool udi_hid_kbd_b_report_trans_ongoing;
|
||||
|
||||
COMPILER_WORD_ALIGNED
|
||||
static uint8_t udi_hid_kbd_report_trans[UDI_HID_KBD_REPORT_SIZE];
|
||||
@@ -186,8 +187,7 @@ bool udi_hid_kbd_send_report(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(udi_hid_kbd_report_trans, udi_hid_kbd_report,
|
||||
UDI_HID_KBD_REPORT_SIZE);
|
||||
memcpy(udi_hid_kbd_report_trans, udi_hid_kbd_report, UDI_HID_KBD_REPORT_SIZE);
|
||||
udi_hid_kbd_b_report_valid = false;
|
||||
udi_hid_kbd_b_report_trans_ongoing =
|
||||
udd_ep_run(UDI_HID_KBD_EP_IN | USB_EP_DIR_IN,
|
||||
@@ -249,7 +249,7 @@ bool udi_hid_nkro_b_report_valid;
|
||||
COMPILER_WORD_ALIGNED
|
||||
uint8_t udi_hid_nkro_report[UDI_HID_NKRO_REPORT_SIZE];
|
||||
|
||||
static bool udi_hid_nkro_b_report_trans_ongoing;
|
||||
volatile bool udi_hid_nkro_b_report_trans_ongoing;
|
||||
|
||||
COMPILER_WORD_ALIGNED
|
||||
static uint8_t udi_hid_nkro_report_trans[UDI_HID_NKRO_REPORT_SIZE];
|
||||
@@ -355,7 +355,7 @@ bool udi_hid_nkro_send_report(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(udi_hid_nkro_report_trans, udi_hid_nkro_report,UDI_HID_NKRO_REPORT_SIZE);
|
||||
memcpy(udi_hid_nkro_report_trans, udi_hid_nkro_report, UDI_HID_NKRO_REPORT_SIZE);
|
||||
udi_hid_nkro_b_report_valid = false;
|
||||
udi_hid_nkro_b_report_trans_ongoing =
|
||||
udd_ep_run(UDI_HID_NKRO_EP_IN | USB_EP_DIR_IN,
|
||||
@@ -843,3 +843,149 @@ static void udi_hid_raw_setreport_valid(void)
|
||||
}
|
||||
|
||||
#endif //RAW
|
||||
|
||||
//********************************************************************************************
|
||||
// CON
|
||||
//********************************************************************************************
|
||||
#ifdef CON
|
||||
|
||||
bool udi_hid_con_enable(void);
|
||||
void udi_hid_con_disable(void);
|
||||
bool udi_hid_con_setup(void);
|
||||
uint8_t udi_hid_con_getsetting(void);
|
||||
|
||||
UDC_DESC_STORAGE udi_api_t udi_api_hid_con = {
|
||||
.enable = (bool(*)(void))udi_hid_con_enable,
|
||||
.disable = (void (*)(void))udi_hid_con_disable,
|
||||
.setup = (bool(*)(void))udi_hid_con_setup,
|
||||
.getsetting = (uint8_t(*)(void))udi_hid_con_getsetting,
|
||||
.sof_notify = NULL,
|
||||
};
|
||||
|
||||
COMPILER_WORD_ALIGNED
|
||||
static uint8_t udi_hid_con_rate;
|
||||
|
||||
COMPILER_WORD_ALIGNED
|
||||
static uint8_t udi_hid_con_protocol;
|
||||
|
||||
COMPILER_WORD_ALIGNED
|
||||
uint8_t udi_hid_con_report_set[UDI_HID_CON_REPORT_SIZE];
|
||||
|
||||
bool udi_hid_con_b_report_valid;
|
||||
|
||||
COMPILER_WORD_ALIGNED
|
||||
uint8_t udi_hid_con_report[UDI_HID_CON_REPORT_SIZE];
|
||||
|
||||
volatile bool udi_hid_con_b_report_trans_ongoing;
|
||||
|
||||
COMPILER_WORD_ALIGNED
|
||||
static uint8_t udi_hid_con_report_trans[UDI_HID_CON_REPORT_SIZE];
|
||||
|
||||
COMPILER_WORD_ALIGNED
|
||||
UDC_DESC_STORAGE udi_hid_con_report_desc_t udi_hid_con_report_desc = {
|
||||
{
|
||||
0x06, 0x31, 0xFF, // Vendor Page (PJRC Teensy compatible)
|
||||
0x09, 0x74, // Vendor Usage (PJRC Teensy compatible)
|
||||
0xA1, 0x01, // Collection (Application)
|
||||
0x09, 0x75, // Usage (Vendor)
|
||||
0x15, 0x00, // Logical Minimum (0x00)
|
||||
0x26, 0xFF, 0x00, // Logical Maximum (0x00FF)
|
||||
0x95, CONSOLE_EPSIZE, // Report Count
|
||||
0x75, 0x08, // Report Size (8)
|
||||
0x81, 0x02, // Input (Data)
|
||||
0x09, 0x76, // Usage (Vendor)
|
||||
0x15, 0x00, // Logical Minimum (0x00)
|
||||
0x26, 0xFF, 0x00, // Logical Maximum (0x00FF)
|
||||
0x95, CONSOLE_EPSIZE, // Report Count
|
||||
0x75, 0x08, // Report Size (8)
|
||||
0x91, 0x02, // Output (Data)
|
||||
0xC0, // End Collection
|
||||
}
|
||||
};
|
||||
|
||||
static bool udi_hid_con_setreport(void);
|
||||
static void udi_hid_con_setreport_valid(void);
|
||||
|
||||
static void udi_hid_con_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep);
|
||||
|
||||
bool udi_hid_con_enable(void)
|
||||
{
|
||||
// Initialize internal values
|
||||
udi_hid_con_rate = 0;
|
||||
udi_hid_con_protocol = 0;
|
||||
udi_hid_con_b_report_trans_ongoing = false;
|
||||
memset(udi_hid_con_report, 0, UDI_HID_CON_REPORT_SIZE);
|
||||
udi_hid_con_b_report_valid = false;
|
||||
return UDI_HID_CON_ENABLE_EXT();
|
||||
}
|
||||
|
||||
void udi_hid_con_disable(void)
|
||||
{
|
||||
UDI_HID_CON_DISABLE_EXT();
|
||||
}
|
||||
|
||||
bool udi_hid_con_setup(void)
|
||||
{
|
||||
return udi_hid_setup(&udi_hid_con_rate,
|
||||
&udi_hid_con_protocol,
|
||||
(uint8_t *) &udi_hid_con_report_desc,
|
||||
udi_hid_con_setreport);
|
||||
}
|
||||
|
||||
uint8_t udi_hid_con_getsetting(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool udi_hid_con_setreport(void)
|
||||
{
|
||||
if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8))
|
||||
&& (0 == (0xFF & udd_g_ctrlreq.req.wValue))
|
||||
&& (UDI_HID_CON_REPORT_SIZE == udd_g_ctrlreq.req.wLength)) {
|
||||
udd_g_ctrlreq.payload = udi_hid_con_report_set;
|
||||
udd_g_ctrlreq.callback = udi_hid_con_setreport_valid;
|
||||
udd_g_ctrlreq.payload_size = UDI_HID_CON_REPORT_SIZE;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool udi_hid_con_send_report(void)
|
||||
{
|
||||
if (!main_b_con_enable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (udi_hid_con_b_report_trans_ongoing) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(udi_hid_con_report_trans, udi_hid_con_report,UDI_HID_CON_REPORT_SIZE);
|
||||
udi_hid_con_b_report_valid = false;
|
||||
udi_hid_con_b_report_trans_ongoing =
|
||||
udd_ep_run(UDI_HID_CON_EP_IN | USB_EP_DIR_IN,
|
||||
false,
|
||||
udi_hid_con_report_trans,
|
||||
UDI_HID_CON_REPORT_SIZE,
|
||||
udi_hid_con_report_sent);
|
||||
|
||||
return udi_hid_con_b_report_trans_ongoing;
|
||||
}
|
||||
|
||||
static void udi_hid_con_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep)
|
||||
{
|
||||
UNUSED(status);
|
||||
UNUSED(nb_sent);
|
||||
UNUSED(ep);
|
||||
udi_hid_con_b_report_trans_ongoing = false;
|
||||
if (udi_hid_con_b_report_valid) {
|
||||
udi_hid_con_send_report();
|
||||
}
|
||||
}
|
||||
|
||||
static void udi_hid_con_setreport_valid(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif //CON
|
||||
|
||||
@@ -60,6 +60,7 @@ extern "C" {
|
||||
#ifdef KBD
|
||||
extern UDC_DESC_STORAGE udi_api_t udi_api_hid_kbd;
|
||||
extern bool udi_hid_kbd_b_report_valid;
|
||||
extern volatile bool udi_hid_kbd_b_report_trans_ongoing;
|
||||
extern uint8_t udi_hid_kbd_report_set;
|
||||
bool udi_hid_kbd_send_report(void);
|
||||
#endif //KBD
|
||||
@@ -70,6 +71,7 @@ bool udi_hid_kbd_send_report(void);
|
||||
#ifdef NKRO
|
||||
extern UDC_DESC_STORAGE udi_api_t udi_api_hid_nkro;
|
||||
extern bool udi_hid_nkro_b_report_valid;
|
||||
extern volatile bool udi_hid_nkro_b_report_trans_ongoing;
|
||||
bool udi_hid_nkro_send_report(void);
|
||||
#endif //NKRO
|
||||
|
||||
@@ -83,6 +85,17 @@ extern uint8_t udi_hid_exk_report_set;
|
||||
bool udi_hid_exk_send_report(void);
|
||||
#endif //EXK
|
||||
|
||||
//********************************************************************************************
|
||||
// CON Console
|
||||
//********************************************************************************************
|
||||
#ifdef CON
|
||||
extern UDC_DESC_STORAGE udi_api_t udi_api_hid_con;
|
||||
extern bool udi_hid_con_b_report_valid;
|
||||
extern uint8_t udi_hid_con_report_set[UDI_HID_CON_REPORT_SIZE];
|
||||
extern volatile bool udi_hid_con_b_report_trans_ongoing;
|
||||
bool udi_hid_con_send_report(void);
|
||||
#endif //CON
|
||||
|
||||
//********************************************************************************************
|
||||
// MOU Mouse
|
||||
//********************************************************************************************
|
||||
|
||||
@@ -134,6 +134,9 @@ UDC_DESC_STORAGE udc_desc_t udc_desc = {
|
||||
#ifdef EXK
|
||||
.hid_exk = UDI_HID_EXK_DESC,
|
||||
#endif
|
||||
#ifdef CON
|
||||
.hid_con = UDI_HID_CON_DESC,
|
||||
#endif
|
||||
#ifdef NKRO
|
||||
.hid_nkro = UDI_HID_NKRO_DESC,
|
||||
#endif
|
||||
@@ -155,6 +158,9 @@ UDC_DESC_STORAGE udi_api_t *udi_apis[USB_DEVICE_NB_INTERFACE] = {
|
||||
#ifdef EXK
|
||||
&udi_api_hid_exk,
|
||||
#endif
|
||||
#ifdef CON
|
||||
&udi_api_hid_con,
|
||||
#endif
|
||||
#ifdef NKRO
|
||||
&udi_api_hid_nkro,
|
||||
#endif
|
||||
|
||||
@@ -82,6 +82,12 @@ bool main_exk_enable(void);
|
||||
void main_exk_disable(void);
|
||||
#endif //EXK
|
||||
|
||||
#ifdef CON
|
||||
extern volatile bool main_b_con_enable;
|
||||
bool main_con_enable(void);
|
||||
void main_con_disable(void);
|
||||
#endif //CON
|
||||
|
||||
#ifdef MOU
|
||||
extern volatile bool main_b_mou_enable;
|
||||
bool main_mou_enable(void);
|
||||
|
||||
@@ -142,10 +142,15 @@ int main(void) {
|
||||
|
||||
/* Wait until the USB or serial link is active */
|
||||
while (true) {
|
||||
#if defined(WAIT_FOR_USB) || defined(SERIAL_LINK_ENABLE)
|
||||
if(USB_DRIVER.state == USB_ACTIVE) {
|
||||
driver = &chibios_driver;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
driver = &chibios_driver;
|
||||
break;
|
||||
#endif
|
||||
#ifdef SERIAL_LINK_ENABLE
|
||||
if(is_serial_link_connected()) {
|
||||
driver = get_serial_link_driver();
|
||||
@@ -178,6 +183,7 @@ int main(void) {
|
||||
/* Main loop */
|
||||
while(true) {
|
||||
|
||||
#if !defined(NO_USB_STARTUP_CHECK)
|
||||
if(USB_DRIVER.state == USB_SUSPENDED) {
|
||||
print("[s]");
|
||||
#ifdef VISUALIZER_ENABLE
|
||||
@@ -205,6 +211,7 @@ int main(void) {
|
||||
visualizer_resume();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
keyboard_task();
|
||||
#ifdef CONSOLE_ENABLE
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include "quantum.h"
|
||||
#include <util/atomic.h>
|
||||
#include "outputselect.h"
|
||||
#include "rgblight_reconfig.h"
|
||||
|
||||
#ifdef NKRO_ENABLE
|
||||
#include "keycode_config.h"
|
||||
|
||||
Reference in New Issue
Block a user