diff --git a/keyboards/_xmega/_xmega.c b/keyboards/_xmega/_xmega.c new file mode 100644 index 000000000..84c71106e --- /dev/null +++ b/keyboards/_xmega/_xmega.c @@ -0,0 +1 @@ +#include "_xmega.h" \ No newline at end of file diff --git a/keyboards/_xmega/_xmega.h b/keyboards/_xmega/_xmega.h new file mode 100644 index 000000000..3af876e87 --- /dev/null +++ b/keyboards/_xmega/_xmega.h @@ -0,0 +1,3 @@ +#include "quantum.h" + +#define KEYMAP(k) { { k } } \ No newline at end of file diff --git a/keyboards/_xmega/config.h b/keyboards/_xmega/config.h new file mode 100644 index 000000000..3a18abecc --- /dev/null +++ b/keyboards/_xmega/config.h @@ -0,0 +1,48 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6060 +#define DEVICE_VER 0x0001 +#define MANUFACTURER _SPINDLE +#define PRODUCT XMEGA +#define DESCRIPTION test board + +/* key matrix size */ +#define MATRIX_ROWS 1 +#define MATRIX_COLS 1 + +/* key matrix pins */ +#define MATRIX_ROW_PINS { D0} +#define MATRIX_COL_PINS { F0 } +#define UNUSED_PINS + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION COL2ROW + +/* number of backlight levels */ +// #define BACKLIGHT_PIN B6 +// #define BACKLIGHT_LEVELS 5 + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCING_DELAY 5 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE + +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + +/* prevent stuck modifiers */ +#define PREVENT_STUCK_MODIFIERS +#undef USE_STATIC_OPTIONS +#define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_RC32MCLKSRC | USB_OPT_BUSEVENT_PRIHIGH) +#endif diff --git a/keyboards/_xmega/keymaps/default/keymap.c b/keyboards/_xmega/keymaps/default/keymap.c new file mode 100644 index 000000000..03a36b184 --- /dev/null +++ b/keyboards/_xmega/keymaps/default/keymap.c @@ -0,0 +1,5 @@ +#include "_xmega.h" + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + KEYMAP(KC_A) +}; \ No newline at end of file diff --git a/keyboards/_xmega/rules.mk b/keyboards/_xmega/rules.mk new file mode 100644 index 000000000..99655392c --- /dev/null +++ b/keyboards/_xmega/rules.mk @@ -0,0 +1,56 @@ +# MCU name +MCU = atxmega32a4u + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_USB below, as it is sourced by +# F_USB after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 32000000 + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = XMEGA + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = 12000000 + +# Interrupt driven control endpoint task(+60) +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + +# Boot Section Size in *bytes* +OPT_DEFS += -DBOOTLOADER_SIZE=4096 + + +# Build Options +# comment out to disable the options. +# +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = no # Console for debug(+400) +COMMAND_ENABLE = no # Commands for debug and configuration +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +AUDIO_ENABLE = no +RGBLIGHT_ENABLE = no \ No newline at end of file diff --git a/tmk_core/common/avr/bootloader.c b/tmk_core/common/avr/bootloader.c index ee150817c..3e4b906a6 100644 --- a/tmk_core/common/avr/bootloader.c +++ b/tmk_core/common/avr/bootloader.c @@ -6,7 +6,9 @@ #include #include #include "bootloader.h" -#include +#ifndef __AVR_XMEGA__ + #include +#endif #ifdef PROTOCOL_LUFA #include @@ -152,7 +154,7 @@ void bootloader_jump(void) { #else // Assume remaining boards are DFU, even if the flag isn't set - #ifndef __AVR_ATmega32A__ // no USB - maybe BOOTLOADER_BOOTLOADHID instead though? + #ifdef BOOTLOADER_BOOTLOADHID // no USB - maybe BOOTLOADER_BOOTLOADHID instead though? UDCON = 1; USBCON = (1< #include +#ifndef __AVR_XMEGA__ #define wdt_intr_enable(value) \ __asm__ __volatile__ ( \ @@ -25,3 +26,5 @@ __asm__ __volatile__ ( \ ) #endif + +#endif diff --git a/tmk_core/common/avr/timer.c b/tmk_core/common/avr/timer.c index 369015200..dcfac701e 100644 --- a/tmk_core/common/avr/timer.c +++ b/tmk_core/common/avr/timer.c @@ -43,6 +43,7 @@ void timer_init(void) # error "Timer prescaler value is NOT vaild." #endif +#ifndef __AVR_XMEGA__ #ifndef __AVR_ATmega32A__ // Timer0 CTC mode TCCR0A = 0x02; @@ -58,6 +59,13 @@ void timer_init(void) OCR0 = TIMER_RAW_TOP; TIMSK = (1 << OCIE0); #endif +#else + TCC0.CTRLE = 0x01; // set timer in 8bit mode (default is 16 bits) + TCC0.INTCTRLA = 0x02; // Interrupt Enable register A (enable INT for tc0 (medium level)) + TCC0.PER = 132; // set period to 228 khz + TCC0.PERBUF = 132; // buffer for writing to TCC0.PER. + TCC0.CTRLA = prescaler; // clk=30324000 H +#endif } inline @@ -117,11 +125,15 @@ uint32_t timer_elapsed32(uint32_t last) } // excecuted once per 1ms.(excess for just timer count?) +#ifndef __AVR_XMEGA__ #ifndef __AVR_ATmega32A__ #define TIMER_INTERRUPT_VECTOR TIMER0_COMPA_vect #else #define TIMER_INTERRUPT_VECTOR TIMER0_COMP_vect #endif +#else +#define TIMER_INTERRUPT_VECTOR TCE0_OVF_vect +#endif ISR(TIMER_INTERRUPT_VECTOR, ISR_NOBLOCK) { timer_count++; diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index e3f8724e8..9d269090b 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -1082,6 +1082,7 @@ void virtser_send(const uint8_t byte) ******************************************************************************/ static void setup_mcu(void) { + #ifndef __AVR_XMEGA__ /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); @@ -1091,6 +1092,7 @@ static void setup_mcu(void) CLKPR = (1 << CLKPCE); CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0); + #endif } static void setup_usb(void) diff --git a/tmk_core/protocol/lufa/lufa.h b/tmk_core/protocol/lufa/lufa.h index a51573786..35492ec41 100644 --- a/tmk_core/protocol/lufa/lufa.h +++ b/tmk_core/protocol/lufa/lufa.h @@ -61,6 +61,11 @@ extern host_driver_t lufa_driver; } #endif +#ifdef __AVR_XMEGA__ + #define MCUSR RST_STATUS + #define WDRF RST_WDRF_bp +#endif + /* extra report structure */ typedef struct { uint8_t report_id;