Remove incorrect check for the current device state in the Set Configuration request handler of DevChapter9, which broke Set Configuration requests to the device under most circumstances.

Move out the SPI prescaler list to a PROGMEM module-level variable in ISPTarget.c.
pull/1469/head
Dean Camera 15 years ago
parent 571159df1b
commit 34047efc7e

@ -145,9 +145,6 @@ static void USB_Device_SetAddress(void)
static void USB_Device_SetConfiguration(void) static void USB_Device_SetConfiguration(void)
{ {
if (USB_DeviceState != DEVICE_STATE_Addressed)
return;
#if defined(FIXED_NUM_CONFIGURATIONS) #if defined(FIXED_NUM_CONFIGURATIONS)
if ((uint8_t)USB_ControlRequest.wValue > FIXED_NUM_CONFIGURATIONS) if ((uint8_t)USB_ControlRequest.wValue > FIXED_NUM_CONFIGURATIONS)
return; return;

@ -20,6 +20,8 @@
* - Fixed AVRISP-MKII clone project not correctly issuing LOAD EXTENDED ADDRESS commands when the extended address * - Fixed AVRISP-MKII clone project not correctly issuing LOAD EXTENDED ADDRESS commands when the extended address
* boundary is crossed during programming or readback (thanks to Gerard Sexton) * boundary is crossed during programming or readback (thanks to Gerard Sexton)
* - Fixed warnings when building the AVRISP-MKII clone project with the ENABLE_XPROG_PROTOCOL compile time option disabled * - Fixed warnings when building the AVRISP-MKII clone project with the ENABLE_XPROG_PROTOCOL compile time option disabled
* - Remove incorrect check for the current device state in the Set Configuration request handler of DevChapter9, which broke
* Set Configuration requests to the device under most circumstances.
* *
* \section Sec_ChangeLog100512 Version 100512 * \section Sec_ChangeLog100512 Version 100512
* *

@ -37,14 +37,8 @@
#if defined(ENABLE_ISP_PROTOCOL) || defined(__DOXYGEN__) #if defined(ENABLE_ISP_PROTOCOL) || defined(__DOXYGEN__)
/** Converts the given AVR Studio SCK duration parameter (set by a SET PARAM command from the host) to the nearest /** List of SPI prescaler masks for possible AVRStudio ISP programming speeds. */
* possible SPI clock prescaler mask for passing to the SPI_Init() routine. static uint8_t SPIMaskFromSCKDuration[] PROGMEM =
*
* \return Nearest SPI prescaler mask for the given SCK frequency
*/
uint8_t ISPTarget_GetSPIPrescalerMask(void)
{
static const uint8_t SPIMaskFromSCKDuration[] =
{ {
#if (F_CPU == 8000000) #if (F_CPU == 8000000)
SPI_SPEED_FCPU_DIV_2, // AVRStudio = 8MHz SPI, Actual = 4MHz SPI SPI_SPEED_FCPU_DIV_2, // AVRStudio = 8MHz SPI, Actual = 4MHz SPI
@ -67,12 +61,19 @@ uint8_t ISPTarget_GetSPIPrescalerMask(void)
#endif #endif
}; };
/** Converts the given AVR Studio SCK duration parameter (set by a SET PARAM command from the host) to the nearest
* possible SPI clock prescaler mask for passing to the SPI_Init() routine.
*
* \return Nearest SPI prescaler mask for the given SCK frequency
*/
uint8_t ISPTarget_GetSPIPrescalerMask(void)
{
uint8_t SCKDuration = V2Params_GetParameterValue(PARAM_SCK_DURATION); uint8_t SCKDuration = V2Params_GetParameterValue(PARAM_SCK_DURATION);
if (SCKDuration >= sizeof(SPIMaskFromSCKDuration)) if (SCKDuration >= sizeof(SPIMaskFromSCKDuration))
SCKDuration = (sizeof(SPIMaskFromSCKDuration) - 1); SCKDuration = (sizeof(SPIMaskFromSCKDuration) - 1);
return SPIMaskFromSCKDuration[SCKDuration]; return pgm_read_byte(&SPIMaskFromSCKDuration[SCKDuration]);
} }
/** Asserts or deasserts the target's reset line, using the correct polarity as set by the host using a SET PARAM command. /** Asserts or deasserts the target's reset line, using the correct polarity as set by the host using a SET PARAM command.

@ -38,6 +38,7 @@
/* Includes: */ /* Includes: */
#include <avr/io.h> #include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h> #include <util/delay.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>

Loading…
Cancel
Save