Compare commits

...

2 Commits

Author SHA1 Message Date
Jack Humbert
ea948a1f2c trying out some different stuff 2018-01-18 16:32:26 -05:00
Jack Humbert
6b58b0c7dd xmega compiling (not flashing yet) 2018-01-16 02:15:21 -05:00
11 changed files with 152 additions and 2 deletions

View File

@ -0,0 +1 @@
#include "_xmega.h"

View File

@ -0,0 +1,3 @@
#include "quantum.h"
#define KEYMAP(k) { { k } }

48
keyboards/_xmega/config.h Normal file
View File

@ -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 { A0 }
#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

View File

@ -0,0 +1,5 @@
#include "_xmega.h"
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KEYMAP(KC_A)
};

56
keyboards/_xmega/rules.mk Normal file
View File

@ -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 = 48000000
# 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

View File

@ -6,7 +6,9 @@
#include <avr/wdt.h>
#include <util/delay.h>
#include "bootloader.h"
#include <avr/boot.h>
#ifndef __AVR_XMEGA__
#include <avr/boot.h>
#endif
#ifdef PROTOCOL_LUFA
#include <LUFA/Drivers/USB/USB.h>
@ -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<<FRZCLK); // disable USB
UCSR1B = 0;
@ -178,6 +180,11 @@ void bootloader_jump(void) {
#define MCUSR MCUCSR
#endif
#ifdef __AVR_XMEGA__
#define MCUSR RST_STATUS
#define WDRF RST_WDRF_bp
#endif
/* this runs before main() */
void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, section (".init3")));
void bootloader_jump_after_watchdog_reset(void)

View File

@ -20,6 +20,11 @@
#endif /* AUDIO_ENABLE */
#ifdef __AVR_XMEGA__
#define wdt_intr_enable(value) wdt_enable(value)
#else
#define wdt_intr_enable(value) \
__asm__ __volatile__ ( \
@ -37,6 +42,7 @@ __asm__ __volatile__ ( \
: "r0" \
)
#endif
void suspend_idle(uint8_t time)
{
@ -134,6 +140,7 @@ void suspend_wakeup_init(void)
led_set(host_keyboard_leds());
}
#ifndef __AVR_XMEGA__
#ifndef NO_SUSPEND_POWER_DOWN
/* watchdog timeout */
ISR(WDT_vect)
@ -148,3 +155,4 @@ ISR(WDT_vect)
}
}
#endif
#endif

View File

@ -7,6 +7,7 @@
#include <avr/wdt.h>
#include <avr/interrupt.h>
#ifndef __AVR_XMEGA__
#define wdt_intr_enable(value) \
__asm__ __volatile__ ( \
@ -25,3 +26,5 @@ __asm__ __volatile__ ( \
)
#endif
#endif

View File

@ -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++;

View File

@ -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)

View File

@ -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;