mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-17 13:12:08 +00:00
Fix all device mode demos broken in the recent API changes.
Change USBtoSerial Tx to polling-driven rather than interrupt driven, to ensure more time for the Rx interrupt to be serviced.
This commit is contained in:
parent
b7ef7f49c9
commit
7eb4eb7cdd
@ -139,7 +139,7 @@ int main (void)
|
|||||||
/** Event handler for the USB_Disconnect event. This indicates that the bootloader should exit and the user
|
/** Event handler for the USB_Disconnect event. This indicates that the bootloader should exit and the user
|
||||||
* application started.
|
* application started.
|
||||||
*/
|
*/
|
||||||
void EventHandler_USB_Disconnect(void)
|
void EVENT_USB_Disconnect(void)
|
||||||
{
|
{
|
||||||
/* Upon disconnection, run user application */
|
/* Upon disconnection, run user application */
|
||||||
RunBootloader = false;
|
RunBootloader = false;
|
||||||
@ -149,7 +149,7 @@ void EventHandler_USB_Disconnect(void)
|
|||||||
* control requests that are not handled internally by the USB library (including the DFU commands, which are
|
* control requests that are not handled internally by the USB library (including the DFU commands, which are
|
||||||
* all issued via the control endpoint), so that they can be handled appropriately for the application.
|
* all issued via the control endpoint), so that they can be handled appropriately for the application.
|
||||||
*/
|
*/
|
||||||
void EventHandler_USB_UnhandledControlPacket(void)
|
void EVENT_USB_UnhandledControlPacket(void)
|
||||||
{
|
{
|
||||||
/* Get the size of the command and data from the wLength value */
|
/* Get the size of the command and data from the wLength value */
|
||||||
SentCommand.DataSize = USB_ControlRequest.wLength;
|
SentCommand.DataSize = USB_ControlRequest.wLength;
|
||||||
|
@ -75,7 +75,7 @@ int main(void)
|
|||||||
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs, and
|
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs, and
|
||||||
* configures the sample update and PWM timers.
|
* configures the sample update and PWM timers.
|
||||||
*/
|
*/
|
||||||
void EventHandler_USB_Connect(void)
|
void EVENT_USB_Connect(void)
|
||||||
{
|
{
|
||||||
/* Start USB management task */
|
/* Start USB management task */
|
||||||
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN);
|
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN);
|
||||||
@ -110,7 +110,7 @@ void EventHandler_USB_Connect(void)
|
|||||||
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
|
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
|
||||||
* the status LEDs, disables the sample update and PWM output timers and stops the USB and Audio management tasks.
|
* the status LEDs, disables the sample update and PWM output timers and stops the USB and Audio management tasks.
|
||||||
*/
|
*/
|
||||||
void EventHandler_USB_Disconnect(void)
|
void EVENT_USB_Disconnect(void)
|
||||||
{
|
{
|
||||||
/* Stop the timers */
|
/* Stop the timers */
|
||||||
TCCR0B = 0;
|
TCCR0B = 0;
|
||||||
@ -140,7 +140,7 @@ void EventHandler_USB_Disconnect(void)
|
|||||||
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration
|
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration
|
||||||
* of the USB device after enumeration - the device endpoints are configured.
|
* of the USB device after enumeration - the device endpoints are configured.
|
||||||
*/
|
*/
|
||||||
void EventHandler_USB_ConfigurationChanged(void)
|
void EVENT_USB_ConfigurationChanged(void)
|
||||||
{
|
{
|
||||||
/* Setup audio stream endpoint */
|
/* Setup audio stream endpoint */
|
||||||
Endpoint_ConfigureEndpoint(AUDIO_STREAM_EPNUM, EP_TYPE_ISOCHRONOUS,
|
Endpoint_ConfigureEndpoint(AUDIO_STREAM_EPNUM, EP_TYPE_ISOCHRONOUS,
|
||||||
@ -155,7 +155,7 @@ void EventHandler_USB_ConfigurationChanged(void)
|
|||||||
* control requests that are not handled internally by the USB library (including the Audio class-specific
|
* control requests that are not handled internally by the USB library (including the Audio class-specific
|
||||||
* requests) so that they can be handled appropriately for the application.
|
* requests) so that they can be handled appropriately for the application.
|
||||||
*/
|
*/
|
||||||
void EventHandler_USB_UnhandledControlPacket(void)
|
void EVENT_USB_UnhandledControlPacket(void)
|
||||||
{
|
{
|
||||||
/* Process General and Audio specific control requests */
|
/* Process General and Audio specific control requests */
|
||||||
switch (USB_ControlRequest.bRequest)
|
switch (USB_ControlRequest.bRequest)
|
||||||
|
@ -271,7 +271,7 @@ USB_Descriptor_String_t PROGMEM ProductString =
|
|||||||
* is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
|
* is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
|
||||||
* USB host.
|
* USB host.
|
||||||
*/
|
*/
|
||||||
uint16_t USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
|
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
|
||||||
{
|
{
|
||||||
const uint8_t DescriptorType = (wValue >> 8);
|
const uint8_t DescriptorType = (wValue >> 8);
|
||||||
const uint8_t DescriptorNumber = (wValue & 0xFF);
|
const uint8_t DescriptorNumber = (wValue & 0xFF);
|
||||||
|
@ -59,6 +59,9 @@ int main(void)
|
|||||||
/* Disable clock division */
|
/* Disable clock division */
|
||||||
clock_prescale_set(clock_div_1);
|
clock_prescale_set(clock_div_1);
|
||||||
|
|
||||||
|
/* Hardware Initialization */
|
||||||
|
LEDs_Init();
|
||||||
|
|
||||||
/* Indicate USB not ready */
|
/* Indicate USB not ready */
|
||||||
UpdateStatus(Status_USBNotReady);
|
UpdateStatus(Status_USBNotReady);
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */
|
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */
|
||||||
void EventHandler_USB_Connect(void)
|
void EVENT_USB_Connect(void)
|
||||||
{
|
{
|
||||||
/* Indicate USB enumerating */
|
/* Indicate USB enumerating */
|
||||||
UpdateStatus(Status_USBEnumerating);
|
UpdateStatus(Status_USBEnumerating);
|
||||||
@ -98,7 +98,7 @@ void EventHandler_USB_Connect(void)
|
|||||||
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
|
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
|
||||||
* the status LEDs and stops the Mass Storage management task.
|
* the status LEDs and stops the Mass Storage management task.
|
||||||
*/
|
*/
|
||||||
void EventHandler_USB_Disconnect(void)
|
void EVENT_USB_Disconnect(void)
|
||||||
{
|
{
|
||||||
/* Stop running mass storage task */
|
/* Stop running mass storage task */
|
||||||
Scheduler_SetTaskMode(USB_MassStorage, TASK_STOP);
|
Scheduler_SetTaskMode(USB_MassStorage, TASK_STOP);
|
||||||
@ -110,7 +110,7 @@ void EventHandler_USB_Disconnect(void)
|
|||||||
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration
|
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration
|
||||||
* of the USB device after enumeration - the device endpoints are configured and the Mass Storage management task started.
|
* of the USB device after enumeration - the device endpoints are configured and the Mass Storage management task started.
|
||||||
*/
|
*/
|
||||||
void EventHandler_USB_ConfigurationChanged(void)
|
void EVENT_USB_ConfigurationChanged(void)
|
||||||
{
|
{
|
||||||
/* Setup Mass Storage In and Out Endpoints */
|
/* Setup Mass Storage In and Out Endpoints */
|
||||||
Endpoint_ConfigureEndpoint(MASS_STORAGE_IN_EPNUM, EP_TYPE_BULK,
|
Endpoint_ConfigureEndpoint(MASS_STORAGE_IN_EPNUM, EP_TYPE_BULK,
|
||||||
@ -132,7 +132,7 @@ void EventHandler_USB_ConfigurationChanged(void)
|
|||||||
* control requests that are not handled internally by the USB library (including the Mass Storage class-specific
|
* control requests that are not handled internally by the USB library (including the Mass Storage class-specific
|
||||||
* requests) so that they can be handled appropriately for the application.
|
* requests) so that they can be handled appropriately for the application.
|
||||||
*/
|
*/
|
||||||
void EventHandler_USB_UnhandledControlPacket(void)
|
void EVENT_USB_UnhandledControlPacket(void)
|
||||||
{
|
{
|
||||||
/* Process UFI specific control requests */
|
/* Process UFI specific control requests */
|
||||||
switch (USB_ControlRequest.bRequest)
|
switch (USB_ControlRequest.bRequest)
|
||||||
|
@ -256,16 +256,9 @@ TASK(CDC_Task)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if Rx buffer contains data */
|
/* Check if Rx buffer contains data - if so, send it */
|
||||||
if (Rx_Buffer.Elements)
|
if (Rx_Buffer.Elements)
|
||||||
{
|
Serial_TxByte(Buffer_GetElement(&Rx_Buffer));
|
||||||
/* Initiate the transmission of the buffer contents if USART idle */
|
|
||||||
if (!(Transmitting))
|
|
||||||
{
|
|
||||||
Transmitting = true;
|
|
||||||
Serial_TxByte(Buffer_GetElement(&Rx_Buffer));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Select the Serial Tx Endpoint */
|
/* Select the Serial Tx Endpoint */
|
||||||
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
|
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
|
||||||
@ -303,19 +296,6 @@ TASK(CDC_Task)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ISR to handle the USART transmit complete interrupt, fired each time the USART has sent a character. This reloads the USART
|
|
||||||
* data register with the next byte from the Rx_Buffer circular buffer if a character is available, or stops the transmission if
|
|
||||||
* the buffer is currently empty.
|
|
||||||
*/
|
|
||||||
ISR(USART1_TX_vect, ISR_BLOCK)
|
|
||||||
{
|
|
||||||
/* Send next character if available */
|
|
||||||
if (Rx_Buffer.Elements)
|
|
||||||
UDR1 = Buffer_GetElement(&Rx_Buffer);
|
|
||||||
else
|
|
||||||
Transmitting = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** ISR to handle the USART receive complete interrupt, fired each time the USART has received a character. This stores the received
|
/** ISR to handle the USART receive complete interrupt, fired each time the USART has received a character. This stores the received
|
||||||
* character into the Tx_Buffer circular buffer for later transmission to the host.
|
* character into the Tx_Buffer circular buffer for later transmission to the host.
|
||||||
*/
|
*/
|
||||||
@ -383,7 +363,7 @@ void ReconfigureUSART(void)
|
|||||||
UCSR1A = (1 << U2X1);
|
UCSR1A = (1 << U2X1);
|
||||||
|
|
||||||
/* Enable transmit and receive modules and interrupts */
|
/* Enable transmit and receive modules and interrupts */
|
||||||
UCSR1B = ((1 << TXCIE1) | (1 << RXCIE1) | (1 << TXEN1) | (1 << RXEN1));
|
UCSR1B = ((1 << RXCIE1) | (1 << TXEN1) | (1 << RXEN1));
|
||||||
|
|
||||||
/* Set the USART mode to the mask generated by the Line Coding options */
|
/* Set the USART mode to the mask generated by the Line Coding options */
|
||||||
UCSR1C = ConfigMask;
|
UCSR1C = ConfigMask;
|
||||||
|
File diff suppressed because one or more lines are too long
@ -29,6 +29,7 @@
|
|||||||
* - Deleted StdDescriptors.c, renamed USB_GetDescriptor() to CALLBACK_USB_GetDescriptor, moved ConfigDescriptor.c/.h from the
|
* - Deleted StdDescriptors.c, renamed USB_GetDescriptor() to CALLBACK_USB_GetDescriptor, moved ConfigDescriptor.c/.h from the
|
||||||
* LUFA/Drivers/USB/Class/ directory to LUFA/Drivers/USB/HighLevel/ in preperation for the new USB class APIs
|
* LUFA/Drivers/USB/Class/ directory to LUFA/Drivers/USB/HighLevel/ in preperation for the new USB class APIs
|
||||||
* - Moved out each demos' functionality library files (e.g. Ring Buffer library) to /Lib directories for a better directory structure
|
* - Moved out each demos' functionality library files (e.g. Ring Buffer library) to /Lib directories for a better directory structure
|
||||||
|
* - Removed Tx interrupt from the USBtoSerial demo; now sends characters via polling to ensure more time for the Rx interrupt
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* \section Sec_ChangeLog090510 Version 090510
|
* \section Sec_ChangeLog090510 Version 090510
|
||||||
|
@ -117,8 +117,7 @@
|
|||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
/** Function to retrieve a given descriptor's size and memory location from the given descriptor type value,
|
/** Function to retrieve a given descriptor's size and memory location from the given descriptor type value,
|
||||||
* index and language ID. This function MUST be overridden in the user application (added with full, identical
|
* index and language ID. This function MUST be overridden in the user application (added with full, identical
|
||||||
* prototype and name except for the \ref ATTR_WEAK attribute) so that the library can call it to retrieve descriptor
|
* prototype and name so that the library can call it to retrieve descriptor data.
|
||||||
* data.
|
|
||||||
*
|
*
|
||||||
* \param wValue The type of the descriptor to retrieve in the upper byte, and the index in the
|
* \param wValue The type of the descriptor to retrieve in the upper byte, and the index in the
|
||||||
* lower byte (when more than one descriptor of the given type exists, such as the
|
* lower byte (when more than one descriptor of the given type exists, such as the
|
||||||
@ -139,7 +138,7 @@
|
|||||||
* \return Size in bytes of the descriptor if it exists, zero or \ref NO_DESCRIPTOR otherwise
|
* \return Size in bytes of the descriptor if it exists, zero or \ref NO_DESCRIPTOR otherwise
|
||||||
*/
|
*/
|
||||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
|
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_WEAK ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
/* Private Interface - For use in library only: */
|
/* Private Interface - For use in library only: */
|
||||||
#if !defined(__DOXYGEN__)
|
#if !defined(__DOXYGEN__)
|
||||||
|
Loading…
Reference in New Issue
Block a user