forked from mirror/qmk_firmware
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -36,7 +36,7 @@ LDFLAGS +=-Wl,--gc-sections
|
||||
LDFLAGS += -Wl,-Map="%OUT%%PROJ_NAME%.map"
|
||||
LDFLAGS += -Wl,--start-group
|
||||
LDFLAGS += -Wl,--end-group
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += --specs=rdimon.specs
|
||||
LDFLAGS += -T$(LIB_PATH)/arm_atsam/packs/atmel/SAMD51_DFP/1.0.70/gcc/gcc/samd51j18a_flash.ld
|
||||
|
||||
OPT_DEFS += -DPROTOCOL_ARM_ATSAM
|
||||
|
||||
@@ -169,7 +169,8 @@ dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
|
||||
fi
|
||||
$(DFU_PROGRAMMER) $(MCU) reset
|
||||
|
||||
avrdude: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
|
||||
define EXEC_AVRDUDE
|
||||
USB= ;\
|
||||
if $(GREP) -q -s Microsoft /proc/version; then \
|
||||
echo 'ERROR: AVR flashing cannot be automated within the Windows Subsystem for Linux (WSL) currently. Instead, take the .hex file generated and flash it using AVRDUDE, AVRDUDESS, or XLoader.'; \
|
||||
else \
|
||||
@@ -191,6 +192,15 @@ avrdude: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
|
||||
sleep 1; \
|
||||
avrdude -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex; \
|
||||
fi
|
||||
endef
|
||||
|
||||
avrdude: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
|
||||
$(call EXEC_AVRDUDE)
|
||||
|
||||
avrdude-loop: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
|
||||
while true; do \
|
||||
$(call EXEC_AVRDUDE) ; \
|
||||
done
|
||||
|
||||
# Convert hex to bin.
|
||||
bin: $(BUILD_DIR)/$(TARGET).hex
|
||||
|
||||
@@ -198,10 +198,13 @@ ifneq ("$(SERIAL)","")
|
||||
DFU_ARGS += -S $(SERIAL)
|
||||
endif
|
||||
|
||||
ST_LINK_ARGS ?=
|
||||
|
||||
# List any extra directories to look for libraries here.
|
||||
EXTRALIBDIRS = $(RULESPATH)/ld
|
||||
|
||||
DFU_UTIL ?= dfu-util
|
||||
ST_LINK_CLI ?= st-link_cli
|
||||
|
||||
# Generate a .qmk for the QMK-FF
|
||||
qmk: $(BUILD_DIR)/$(TARGET).bin
|
||||
@@ -230,5 +233,8 @@ qmk: $(BUILD_DIR)/$(TARGET).bin
|
||||
dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
|
||||
$(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
|
||||
|
||||
st-link-cli: $(BUILD_DIR)/$(TARGET).hex sizeafter
|
||||
$(ST_LINK_CLI) $(ST_LINK_ARGS) -q -c SWD -p $(BUILD_DIR)/$(TARGET).hex -Rst
|
||||
|
||||
bin: $(BUILD_DIR)/$(TARGET).bin sizeafter
|
||||
$(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin;
|
||||
|
||||
@@ -43,6 +43,7 @@ endif
|
||||
endif
|
||||
|
||||
ifeq ($(PLATFORM),ARM_ATSAM)
|
||||
TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/printf.c
|
||||
TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/eeprom.c
|
||||
endif
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ void process_hand_swap(keyevent_t *event) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
|
||||
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
|
||||
bool disable_action_cache = false;
|
||||
|
||||
void process_record_nocache(keyrecord_t *record)
|
||||
@@ -777,6 +777,7 @@ void register_code(uint8_t code)
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
else if IS_MOUSEKEY(code) {
|
||||
mousekey_on(code);
|
||||
mousekey_send();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -841,6 +842,7 @@ void unregister_code(uint8_t code)
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
else if IS_MOUSEKEY(code) {
|
||||
mousekey_off(code);
|
||||
mousekey_send();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
|
||||
bool process_record_quantum(keyrecord_t *record);
|
||||
|
||||
/* Utilities for actions. */
|
||||
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
|
||||
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
|
||||
extern bool disable_action_cache;
|
||||
#endif
|
||||
|
||||
@@ -88,6 +88,7 @@ void process_record(keyrecord_t *record);
|
||||
void process_action(keyrecord_t *record, action_t action);
|
||||
void register_code(uint8_t code);
|
||||
void unregister_code(uint8_t code);
|
||||
inline void tap_code(uint8_t code) { register_code(code); unregister_code(code); }
|
||||
void register_mods(uint8_t mods);
|
||||
void unregister_mods(uint8_t mods);
|
||||
//void set_mods(uint8_t mods);
|
||||
|
||||
@@ -15,13 +15,22 @@
|
||||
*/
|
||||
uint32_t default_layer_state = 0;
|
||||
|
||||
/** \brief Default Layer State Set At user Level
|
||||
*
|
||||
* FIXME: Needs docs
|
||||
*/
|
||||
__attribute__((weak))
|
||||
uint32_t default_layer_state_set_user(uint32_t state) {
|
||||
return state;
|
||||
}
|
||||
|
||||
/** \brief Default Layer State Set At Keyboard Level
|
||||
*
|
||||
* FIXME: Needs docs
|
||||
*/
|
||||
__attribute__((weak))
|
||||
uint32_t default_layer_state_set_kb(uint32_t state) {
|
||||
return state;
|
||||
return default_layer_state_set_user(state);
|
||||
}
|
||||
|
||||
/** \brief Default Layer State Set
|
||||
@@ -219,7 +228,7 @@ void layer_debug(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
|
||||
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
|
||||
uint8_t source_layers_cache[(MATRIX_ROWS * MATRIX_COLS + 7) / 8][MAX_LAYER_BITS] = {{0}};
|
||||
|
||||
void update_source_layers_cache(keypos_t key, uint8_t layer)
|
||||
@@ -263,7 +272,7 @@ uint8_t read_source_layers_cache(keypos_t key)
|
||||
*/
|
||||
action_t store_or_get_action(bool pressed, keypos_t key)
|
||||
{
|
||||
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
|
||||
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
|
||||
if (disable_action_cache) {
|
||||
return layer_switch_get_action(key);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ void default_layer_set(uint32_t state);
|
||||
|
||||
__attribute__((weak))
|
||||
uint32_t default_layer_state_set_kb(uint32_t state);
|
||||
__attribute__((weak))
|
||||
uint32_t default_layer_state_set_user(uint32_t state);
|
||||
|
||||
#ifndef NO_ACTION_LAYER
|
||||
/* bitwise operation */
|
||||
@@ -88,7 +90,7 @@ uint32_t layer_state_set_kb(uint32_t state);
|
||||
#endif
|
||||
|
||||
/* pressed actions cache */
|
||||
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
|
||||
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
|
||||
/* The number of bits needed to represent the layer number: log2(32). */
|
||||
#define MAX_LAYER_BITS 5
|
||||
void update_source_layers_cache(keypos_t key, uint8_t layer);
|
||||
|
||||
@@ -15,5 +15,37 @@
|
||||
*/
|
||||
|
||||
#include "bootloader.h"
|
||||
#include "samd51j18a.h"
|
||||
#include "md_bootloader.h"
|
||||
|
||||
void bootloader_jump(void) {}
|
||||
//Set watchdog timer to reset. Directs the bootloader to stay in programming mode.
|
||||
void bootloader_jump(void) {
|
||||
#ifdef KEYBOARD_massdrop_ctrl
|
||||
//CTRL keyboards released with bootloader version below must use RAM method. Otherwise use WDT method.
|
||||
uint8_t ver_ram_method[] = "v2.18Jun 22 2018 17:28:08"; //The version to match (NULL terminated by compiler)
|
||||
uint8_t *ver_check = ver_ram_method; //Pointer to version match string for traversal
|
||||
uint8_t *ver_rom = (uint8_t *)0x21A0; //Pointer to address in ROM where this specific bootloader version would exist
|
||||
|
||||
while (*ver_check && *ver_rom == *ver_check) { //While there are check version characters to match and bootloader's version matches check's version
|
||||
ver_check++; //Move check version pointer to next character
|
||||
ver_rom++; //Move ROM version pointer to next character
|
||||
}
|
||||
|
||||
if (!*ver_check) { //If check version pointer is NULL, all characters have matched
|
||||
*MAGIC_ADDR = BOOTLOADER_MAGIC; //Set magic number into RAM
|
||||
NVIC_SystemReset(); //Perform system reset
|
||||
while (1) {} //Won't get here
|
||||
}
|
||||
#endif
|
||||
|
||||
WDT->CTRLA.bit.ENABLE = 0;
|
||||
while (WDT->SYNCBUSY.bit.ENABLE) {}
|
||||
while (WDT->CTRLA.bit.ENABLE) {}
|
||||
WDT->CONFIG.bit.WINDOW = 0;
|
||||
WDT->CONFIG.bit.PER = 0;
|
||||
WDT->EWCTRL.bit.EWOFFSET = 0;
|
||||
WDT->CTRLA.bit.ENABLE = 1;
|
||||
while (WDT->SYNCBUSY.bit.ENABLE) {}
|
||||
while (!WDT->CTRLA.bit.ENABLE) {}
|
||||
while (1) {} //Wait on timeout
|
||||
}
|
||||
|
||||
66
tmk_core/common/arm_atsam/printf.c
Normal file
66
tmk_core/common/arm_atsam/printf.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
Copyright 2018 Massdrop Inc.
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef CONSOLE_PRINT
|
||||
|
||||
#include "samd51j18a.h"
|
||||
#include "arm_atsam_protocol.h"
|
||||
#include "printf.h"
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void console_printf(char *fmt, ...) {
|
||||
while (udi_hid_con_b_report_trans_ongoing) {} //Wait for any previous transfers to complete
|
||||
|
||||
static char console_printbuf[CONSOLE_PRINTBUF_SIZE]; //Print and send buffer
|
||||
va_list va;
|
||||
int result;
|
||||
|
||||
va_start(va, fmt);
|
||||
result = vsnprintf(console_printbuf, CONSOLE_PRINTBUF_SIZE, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
uint32_t irqflags;
|
||||
char *pconbuf = console_printbuf; //Pointer to start send from
|
||||
int send_out = CONSOLE_EPSIZE; //Bytes to send per transfer
|
||||
|
||||
while (result > 0) { //While not error and bytes remain
|
||||
while (udi_hid_con_b_report_trans_ongoing) {} //Wait for any previous transfers to complete
|
||||
|
||||
irqflags = __get_PRIMASK();
|
||||
__disable_irq();
|
||||
__DMB();
|
||||
|
||||
if (result < CONSOLE_EPSIZE) { //If remaining bytes are less than console epsize
|
||||
memset(udi_hid_con_report, 0, CONSOLE_EPSIZE); //Clear the buffer
|
||||
send_out = result; //Send remaining size
|
||||
}
|
||||
|
||||
memcpy(udi_hid_con_report, pconbuf, send_out); //Copy data into the send buffer
|
||||
|
||||
udi_hid_con_b_report_valid = 1; //Set report valid
|
||||
udi_hid_con_send_report(); //Send report
|
||||
|
||||
__DMB();
|
||||
__set_PRIMASK(irqflags);
|
||||
|
||||
result -= send_out; //Decrement result by bytes sent
|
||||
pconbuf += send_out; //Increment buffer point by bytes sent
|
||||
}
|
||||
}
|
||||
|
||||
#endif //CONSOLE_PRINT
|
||||
@@ -1,8 +1,11 @@
|
||||
#ifndef _PRINTF_H_
|
||||
#define _PRINTF_H_
|
||||
|
||||
#define __xprintf dpf
|
||||
int dpf(const char *_Format, ...);
|
||||
#define CONSOLE_PRINTBUF_SIZE 512
|
||||
|
||||
void console_printf(char *fmt, ...);
|
||||
|
||||
#define __xprintf console_printf
|
||||
|
||||
#endif //_PRINTF_H_
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "timer.h"
|
||||
#include "led.h"
|
||||
#include "host.h"
|
||||
#include "rgblight_reconfig.h"
|
||||
|
||||
#ifdef PROTOCOL_LUFA
|
||||
#include "lufa.h"
|
||||
@@ -55,6 +56,24 @@ void suspend_idle(uint8_t time)
|
||||
sleep_disable();
|
||||
}
|
||||
|
||||
|
||||
// TODO: This needs some cleanup
|
||||
|
||||
/** \brief Run keyboard level Power down
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
__attribute__ ((weak))
|
||||
void suspend_power_down_user (void) { }
|
||||
/** \brief Run keyboard level Power down
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
__attribute__ ((weak))
|
||||
void suspend_power_down_kb(void) {
|
||||
suspend_power_down_user();
|
||||
}
|
||||
|
||||
#ifndef NO_SUSPEND_POWER_DOWN
|
||||
/** \brief Power down MCU with watchdog timer
|
||||
*
|
||||
@@ -72,21 +91,6 @@ void suspend_idle(uint8_t time)
|
||||
*/
|
||||
static uint8_t wdt_timeout = 0;
|
||||
|
||||
/** \brief Run keyboard level Power down
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
__attribute__ ((weak))
|
||||
void suspend_power_down_user (void) { }
|
||||
/** \brief Run keyboard level Power down
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
__attribute__ ((weak))
|
||||
void suspend_power_down_kb(void) {
|
||||
suspend_power_down_user();
|
||||
}
|
||||
|
||||
/** \brief Power down
|
||||
*
|
||||
* FIXME: needs doc
|
||||
@@ -143,6 +147,8 @@ static void power_down(uint8_t wdto)
|
||||
*/
|
||||
void suspend_power_down(void)
|
||||
{
|
||||
suspend_power_down_kb();
|
||||
|
||||
#ifndef NO_SUSPEND_POWER_DOWN
|
||||
power_down(WDTO_15MS);
|
||||
#endif
|
||||
@@ -189,12 +195,15 @@ void suspend_wakeup_init(void)
|
||||
#endif
|
||||
led_set(host_keyboard_leds());
|
||||
#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
|
||||
#ifdef BOOTLOADER_TEENSY
|
||||
wait_ms(10);
|
||||
#endif
|
||||
rgblight_enable_noeeprom();
|
||||
#ifdef RGBLIGHT_ANIMATIONS
|
||||
rgblight_timer_enable();
|
||||
#endif
|
||||
#endif
|
||||
suspend_wakeup_init_kb();
|
||||
suspend_wakeup_init_kb();
|
||||
}
|
||||
|
||||
#ifndef NO_SUSPEND_POWER_DOWN
|
||||
|
||||
@@ -8,32 +8,54 @@
|
||||
#include "eeprom_stm32.h"
|
||||
#endif
|
||||
|
||||
extern uint32_t default_layer_state;
|
||||
/** \brief eeconfig enable
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
__attribute__ ((weak))
|
||||
void eeconfig_init_user(void) {
|
||||
// Reset user EEPROM value to blank, rather than to a set value
|
||||
eeconfig_update_user(0);
|
||||
}
|
||||
|
||||
__attribute__ ((weak))
|
||||
void eeconfig_init_kb(void) {
|
||||
// Reset Keyboard EEPROM value to blank, rather than to a set value
|
||||
eeconfig_update_kb(0);
|
||||
|
||||
eeconfig_init_user();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
void eeconfig_init_quantum(void) {
|
||||
#ifdef STM32F303xC
|
||||
EEPROM_format();
|
||||
#endif
|
||||
eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
|
||||
eeprom_update_byte(EECONFIG_DEBUG, 0);
|
||||
eeprom_update_byte(EECONFIG_DEFAULT_LAYER, 0);
|
||||
default_layer_state = 0;
|
||||
eeprom_update_byte(EECONFIG_KEYMAP, 0);
|
||||
eeprom_update_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
|
||||
eeprom_update_byte(EECONFIG_BACKLIGHT, 0);
|
||||
eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default
|
||||
eeprom_update_dword(EECONFIG_RGBLIGHT, 0);
|
||||
eeprom_update_byte(EECONFIG_STENOMODE, 0);
|
||||
|
||||
eeconfig_init_kb();
|
||||
}
|
||||
|
||||
/** \brief eeconfig initialization
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
void eeconfig_init(void)
|
||||
{
|
||||
#ifdef STM32F303xC
|
||||
EEPROM_format();
|
||||
#endif
|
||||
eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
|
||||
eeprom_update_byte(EECONFIG_DEBUG, 0);
|
||||
eeprom_update_byte(EECONFIG_DEFAULT_LAYER, 0);
|
||||
eeprom_update_byte(EECONFIG_KEYMAP, 0);
|
||||
eeprom_update_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
eeprom_update_byte(EECONFIG_BACKLIGHT, 0);
|
||||
#endif
|
||||
#ifdef AUDIO_ENABLE
|
||||
eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default
|
||||
#endif
|
||||
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
|
||||
eeprom_update_dword(EECONFIG_RGBLIGHT, 0);
|
||||
#endif
|
||||
#ifdef STENO_ENABLE
|
||||
eeprom_update_byte(EECONFIG_STENOMODE, 0);
|
||||
#endif
|
||||
void eeconfig_init(void) {
|
||||
|
||||
eeconfig_init_quantum();
|
||||
}
|
||||
|
||||
/** \brief eeconfig enable
|
||||
@@ -54,7 +76,7 @@ void eeconfig_disable(void)
|
||||
#ifdef STM32F303xC
|
||||
EEPROM_format();
|
||||
#endif
|
||||
eeprom_update_word(EECONFIG_MAGIC, 0xFFFF);
|
||||
eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER_OFF);
|
||||
}
|
||||
|
||||
/** \brief eeconfig is enabled
|
||||
@@ -66,6 +88,15 @@ bool eeconfig_is_enabled(void)
|
||||
return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER);
|
||||
}
|
||||
|
||||
/** \brief eeconfig is disabled
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
bool eeconfig_is_disabled(void)
|
||||
{
|
||||
return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER_OFF);
|
||||
}
|
||||
|
||||
/** \brief eeconfig read debug
|
||||
*
|
||||
* FIXME: needs doc
|
||||
@@ -99,7 +130,6 @@ uint8_t eeconfig_read_keymap(void) { return eeprom_read_byte(EECONFIG_KEYMA
|
||||
*/
|
||||
void eeconfig_update_keymap(uint8_t val) { eeprom_update_byte(EECONFIG_KEYMAP, val); }
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
/** \brief eeconfig read backlight
|
||||
*
|
||||
* FIXME: needs doc
|
||||
@@ -110,9 +140,8 @@ uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BA
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
void eeconfig_update_backlight(uint8_t val) { eeprom_update_byte(EECONFIG_BACKLIGHT, val); }
|
||||
#endif
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
|
||||
/** \brief eeconfig read audio
|
||||
*
|
||||
* FIXME: needs doc
|
||||
@@ -123,4 +152,28 @@ uint8_t eeconfig_read_audio(void) { return eeprom_read_byte(EECONFIG_AUDIO)
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
void eeconfig_update_audio(uint8_t val) { eeprom_update_byte(EECONFIG_AUDIO, val); }
|
||||
#endif
|
||||
|
||||
|
||||
/** \brief eeconfig read kb
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
uint32_t eeconfig_read_kb(void) { return eeprom_read_dword(EECONFIG_KEYBOARD); }
|
||||
/** \brief eeconfig update kb
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
|
||||
void eeconfig_update_kb(uint32_t val) { eeprom_update_dword(EECONFIG_KEYBOARD, val); }
|
||||
/** \brief eeconfig read user
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
uint32_t eeconfig_read_user(void) { return eeprom_read_dword(EECONFIG_USER); }
|
||||
/** \brief eeconfig update user
|
||||
*
|
||||
* FIXME: needs doc
|
||||
*/
|
||||
void eeconfig_update_user(uint32_t val) { eeprom_update_dword(EECONFIG_USER, val); }
|
||||
|
||||
|
||||
|
||||
@@ -23,36 +23,41 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEED
|
||||
#define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF
|
||||
|
||||
/* eeprom parameteter address */
|
||||
#if !defined(STM32F303xC)
|
||||
#define EECONFIG_MAGIC (uint16_t *)0
|
||||
#define EECONFIG_DEBUG (uint8_t *)2
|
||||
#define EECONFIG_DEFAULT_LAYER (uint8_t *)3
|
||||
#define EECONFIG_KEYMAP (uint8_t *)4
|
||||
#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5
|
||||
#define EECONFIG_BACKLIGHT (uint8_t *)6
|
||||
#define EECONFIG_AUDIO (uint8_t *)7
|
||||
#define EECONFIG_DEBUG (uint8_t *)2
|
||||
#define EECONFIG_DEFAULT_LAYER (uint8_t *)3
|
||||
#define EECONFIG_KEYMAP (uint8_t *)4
|
||||
#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5
|
||||
#define EECONFIG_BACKLIGHT (uint8_t *)6
|
||||
#define EECONFIG_AUDIO (uint8_t *)7
|
||||
#define EECONFIG_RGBLIGHT (uint32_t *)8
|
||||
#define EECONFIG_UNICODEMODE (uint8_t *)12
|
||||
#define EECONFIG_STENOMODE (uint8_t *)13
|
||||
// EEHANDS for two handed boards
|
||||
#define EECONFIG_HANDEDNESS (uint8_t *)14
|
||||
#define EECONFIG_HANDEDNESS (uint8_t *)14
|
||||
#define EECONFIG_KEYBOARD (uint32_t *)15
|
||||
#define EECONFIG_USER (uint32_t *)19
|
||||
|
||||
#else
|
||||
/* STM32F3 uses 16byte block. Reconfigure memory map */
|
||||
#define EECONFIG_MAGIC (uint16_t *)0
|
||||
#define EECONFIG_DEBUG (uint8_t *)1
|
||||
#define EECONFIG_DEFAULT_LAYER (uint8_t *)2
|
||||
#define EECONFIG_KEYMAP (uint8_t *)3
|
||||
#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)4
|
||||
#define EECONFIG_BACKLIGHT (uint8_t *)5
|
||||
#define EECONFIG_AUDIO (uint8_t *)6
|
||||
#define EECONFIG_DEBUG (uint8_t *)1
|
||||
#define EECONFIG_DEFAULT_LAYER (uint8_t *)2
|
||||
#define EECONFIG_KEYMAP (uint8_t *)3
|
||||
#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)4
|
||||
#define EECONFIG_BACKLIGHT (uint8_t *)5
|
||||
#define EECONFIG_AUDIO (uint8_t *)6
|
||||
#define EECONFIG_RGBLIGHT (uint32_t *)7
|
||||
#define EECONFIG_UNICODEMODE (uint8_t *)9
|
||||
#define EECONFIG_UNICODEMODE (uint8_t *)9
|
||||
#define EECONFIG_STENOMODE (uint8_t *)10
|
||||
// EEHANDS for two handed boards
|
||||
#define EECONFIG_HANDEDNESS (uint8_t *)11
|
||||
#define EECONFIG_HANDEDNESS (uint8_t *)11
|
||||
#define EECONFIG_KEYBOARD (uint32_t *)12
|
||||
#define EECONFIG_USER (uint32_t *)14
|
||||
#endif
|
||||
|
||||
/* debug bit */
|
||||
@@ -73,8 +78,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
bool eeconfig_is_enabled(void);
|
||||
bool eeconfig_is_disabled(void);
|
||||
|
||||
void eeconfig_init(void);
|
||||
void eeconfig_init_quantum(void);
|
||||
void eeconfig_init_kb(void);
|
||||
void eeconfig_init_user(void);
|
||||
|
||||
void eeconfig_enable(void);
|
||||
|
||||
@@ -99,4 +108,9 @@ uint8_t eeconfig_read_audio(void);
|
||||
void eeconfig_update_audio(uint8_t val);
|
||||
#endif
|
||||
|
||||
uint32_t eeconfig_read_kb(void);
|
||||
void eeconfig_update_kb(uint32_t val);
|
||||
uint32_t eeconfig_read_user(void);
|
||||
void eeconfig_update_user(uint32_t val);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <stdbool.h>
|
||||
#include "util.h"
|
||||
|
||||
#if defined(PROTOCOL_CHIBIOS)
|
||||
#if defined(PROTOCOL_CHIBIOS) || defined(PROTOCOL_ARM_ATSAM)
|
||||
#define PSTR(x) x
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -378,7 +378,7 @@ check-size:
|
||||
$(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE)))
|
||||
if [ $(MAX_SIZE) -gt 0 ] && [ $(CURRENT_SIZE) -gt 0 ]; then \
|
||||
$(SILENT) || printf "$(MSG_CHECK_FILESIZE)" | $(AWK_CMD); \
|
||||
if [ $(CURRENT_SIZE) -gt $(MAX_SIZE) ]; then $(PRINT_WARNING_PLAIN); $(SILENT) || printf " * $(MSG_FILE_TOO_BIG)" ; else $(PRINT_OK); $(SILENT) || printf " * $(MSG_FILE_JUST_RIGHT)"; fi \
|
||||
if [ $(CURRENT_SIZE) -gt $(MAX_SIZE) ]; then printf "\n * $(MSG_FILE_TOO_BIG)"; $(PRINT_ERROR_PLAIN); else $(PRINT_OK); $(SILENT) || printf " * $(MSG_FILE_JUST_RIGHT)"; fi \
|
||||
fi
|
||||
else
|
||||
check-size:
|
||||
|
||||
Reference in New Issue
Block a user