diff --git a/Demos/Device/ClassDriver/AudioInput/AudioInput.c b/Demos/Device/ClassDriver/AudioInput/AudioInput.c index 859ff193aa6140e88f56b64807c7a242f598a995..7d3f49cd129773b1bb87be545d186c06d7aa0679 100644 --- a/Demos/Device/ClassDriver/AudioInput/AudioInput.c +++ b/Demos/Device/ClassDriver/AudioInput/AudioInput.c @@ -66,7 +66,10 @@ int main(void) { SetupHardware(); - LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); + PORTC.DIRSET = (1 << 5) | (1u << 6) | (1u << 7); + PORTC.OUTSET = (1 << 5) | (1u << 6) | (1u << 7); + + //LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); for (;;) @@ -86,17 +89,29 @@ void SetupHardware(void) /* Disable clock division */ clock_prescale_set(clock_div_1); + +#elif (ARCH == ARCH_XMEGA) + /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ + XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); + XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); + + /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ + XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); + XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); + + PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; + #endif /* Hardware Initialization */ - LEDs_Init(); - Buttons_Init(); - ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_32); - ADC_SetupChannel(MIC_IN_ADC_CHANNEL); + //LEDs_Init(); + //Buttons_Init(); + //ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_32); + //ADC_SetupChannel(MIC_IN_ADC_CHANNEL); USB_Init(); /* Start the ADC conversion in free running mode */ - ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | ADC_GET_CHANNEL_MASK(MIC_IN_ADC_CHANNEL)); + //ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | ADC_GET_CHANNEL_MASK(MIC_IN_ADC_CHANNEL)); } /** ISR to handle the reloading of the data endpoint with the next sample. */ @@ -118,7 +133,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK) CurrentWaveValue ^= 0x8000; /* Only generate audio if the board button is being pressed */ - AudioSample = (Buttons_GetStatus() & BUTTONS_BUTTON1) ? CurrentWaveValue : 0; + //AudioSample = (Buttons_GetStatus() & BUTTONS_BUTTON1) ? CurrentWaveValue : 0; #else /* Audio sample is ADC value scaled to fit the entire range */ AudioSample = ((SAMPLE_MAX_RANGE / ADC_MAX_RANGE) * ADC_GetResult()); @@ -138,7 +153,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK) /** Event handler for the library USB Connection event. */ void EVENT_USB_Device_Connect(void) { - LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); + //LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); /* Sample reload timer initialization */ TIMSK0 = (1 << OCIE0A); @@ -153,7 +168,7 @@ void EVENT_USB_Device_Disconnect(void) /* Stop the sample reload timer */ TCCR0B = 0; - LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); + //LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); } /** Event handler for the library USB Configuration Changed event. */ @@ -163,7 +178,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) ConfigSuccess &= Audio_Device_ConfigureEndpoints(&Microphone_Audio_Interface); - LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); + //LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); } /** Event handler for the library USB Control Request reception event. */ diff --git a/Demos/Device/ClassDriver/AudioInput/AudioInput.h b/Demos/Device/ClassDriver/AudioInput/AudioInput.h index b9f6ef43e2e3ed7e803629d3f91c0f5118ba3f7c..3b5ac1adc0075f9c13e747cff155659af310d509 100644 --- a/Demos/Device/ClassDriver/AudioInput/AudioInput.h +++ b/Demos/Device/ClassDriver/AudioInput/AudioInput.h @@ -42,9 +42,9 @@ #include <avr/power.h> #include <avr/interrupt.h> - #include <LUFA/Drivers/Board/LEDs.h> - #include <LUFA/Drivers/Board/Buttons.h> - #include <LUFA/Drivers/Peripheral/ADC.h> + //#include <LUFA/Drivers/Board/LEDs.h> + //#include <LUFA/Drivers/Board/Buttons.h> + //#include <LUFA/Drivers/Peripheral/ADC.h> #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Platform/Platform.h> @@ -56,19 +56,21 @@ #define SAMPLE_MAX_RANGE 0xFFFF /** Maximum ADC range for the microphone input. */ - #define ADC_MAX_RANGE 0x3FF + //#define ADC_MAX_RANGE 0x3FF /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ - #define LEDMASK_USB_NOTREADY LEDS_LED1 + //#define LEDMASK_USB_NOTREADY LEDS_LED1 /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ - #define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3) + //#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3) /** LED mask for the library LED driver, to indicate that the USB interface is ready. */ - #define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4) + //#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4) /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ - #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) + //#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) + + #define USE_TEST_TONEE 1 /* Function Prototypes: */ void SetupHardware(void); diff --git a/Demos/Device/ClassDriver/AudioInput/Config/LUFAConfig.h b/Demos/Device/ClassDriver/AudioInput/Config/LUFAConfig.h index c406eb8e1148103dd61758ca4c68d6f11fba4c95..208af711a19a737262923b0911d1349f73dcc1a4 100644 --- a/Demos/Device/ClassDriver/AudioInput/Config/LUFAConfig.h +++ b/Demos/Device/ClassDriver/AudioInput/Config/LUFAConfig.h @@ -85,6 +85,14 @@ // #define NO_AUTO_VBUS_MANAGEMENT // #define INVERTED_VBUS_ENABLE_LINE + #elif (ARCH == ARCH_XMEGA) + + #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL) + #define USE_FLASH_DESCRIPTORS + #define FIXED_CONTROL_ENDPOINT_SIZE 8 + #define FIXED_NUM_CONFIGURATIONS 1 + #define MAX_ENDPOINT_INDEX 2 + #else #error Unsupported architecture for this LUFA configuration file. diff --git a/Demos/Device/ClassDriver/AudioInput/makefile b/Demos/Device/ClassDriver/AudioInput/makefile index 73c4682e9073c99a79683bfd87b595c4ff8f5c6f..7ce2aa5c1b6d5ba2b4f1de1a11dfdac560ff27d7 100644 --- a/Demos/Device/ClassDriver/AudioInput/makefile +++ b/Demos/Device/ClassDriver/AudioInput/makefile @@ -11,10 +11,10 @@ # Run "make help" for target help. -MCU = at90usb1287 -ARCH = AVR8 -BOARD = USBKEY -F_CPU = 8000000 +MCU = atxmega128a4u +ARCH = XMEGA +BOARD = BOARD_USER +F_CPU = 48000000 F_USB = $(F_CPU) OPTIMIZATION = s TARGET = AudioInput