From 2f95eea14689d30a3172a7e1e30980072bf23fac Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Thu, 20 Aug 2009 07:16:55 +0000 Subject: [PATCH] Add LOAD ADDRESS command parsing to the V2 Protocol hander in the AVRISP project. Fix up references to functions in the Endpoint/Pipe documentation. --- LUFA/Drivers/USB/HighLevel/Events.h | 2 +- LUFA/Drivers/USB/LowLevel/Endpoint.h | 22 ++++++++++----------- LUFA/Drivers/USB/LowLevel/Pipe.h | 20 +++++++++---------- Projects/Unfinished/AVRISP/Lib/V2Protocol.c | 20 +++++++++++++++++++ Projects/Unfinished/AVRISP/Lib/V2Protocol.h | 1 + 5 files changed, 43 insertions(+), 22 deletions(-) diff --git a/LUFA/Drivers/USB/HighLevel/Events.h b/LUFA/Drivers/USB/HighLevel/Events.h index 4ed6537b7b..9b60a957b1 100644 --- a/LUFA/Drivers/USB/HighLevel/Events.h +++ b/LUFA/Drivers/USB/HighLevel/Events.h @@ -97,7 +97,7 @@ /** Event for USB device attachment. This event fires when a the USB interface is in host mode, and * a USB device has been connected to the USB interface. This is interrupt driven, thus fires before - * the standard \ref EVENT_USB_Device_Connect event and so can be used to programmatically start the USB + * the standard \ref EVENT_USB_Device_Connect() event and so can be used to programmatically start the USB * management task to reduce CPU consumption. * * \note This event only exists on USB AVR models which supports host mode. diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h index e27ac50a62..977c63cfb1 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.h +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h @@ -789,7 +789,7 @@ */ uint8_t Endpoint_Write_Stream_LE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); - /** EEPROM buffer source version of \ref Endpoint_Write_Stream_LE. + /** EEPROM buffer source version of \ref Endpoint_Write_Stream_LE(). * * \ingroup Group_EndpointStreamRW * @@ -801,7 +801,7 @@ */ uint8_t Endpoint_Write_EStream_LE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); - /** FLASH buffer source version of \ref Endpoint_Write_Stream_LE. + /** FLASH buffer source version of \ref Endpoint_Write_Stream_LE(). * * \note The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. * @@ -838,7 +838,7 @@ */ uint8_t Endpoint_Write_Stream_BE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); - /** EEPROM buffer source version of \ref Endpoint_Write_Stream_BE. + /** EEPROM buffer source version of \ref Endpoint_Write_Stream_BE(). * * \ingroup Group_EndpointStreamRW * @@ -850,7 +850,7 @@ */ uint8_t Endpoint_Write_EStream_BE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); - /** FLASH buffer source version of \ref Endpoint_Write_Stream_BE. + /** FLASH buffer source version of \ref Endpoint_Write_Stream_BE(). * * \note The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. * @@ -887,7 +887,7 @@ */ uint8_t Endpoint_Read_Stream_LE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); - /** EEPROM buffer source version of \ref Endpoint_Read_Stream_LE. + /** EEPROM buffer source version of \ref Endpoint_Read_Stream_LE(). * * \ingroup Group_EndpointStreamRW * @@ -922,7 +922,7 @@ */ uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); - /** EEPROM buffer source version of \ref Endpoint_Read_Stream_BE. + /** EEPROM buffer source version of \ref Endpoint_Read_Stream_BE(). * * \ingroup Group_EndpointStreamRW * @@ -975,7 +975,7 @@ */ uint8_t Endpoint_Write_Control_EStream_LE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); - /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_LE. + /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_LE(). * * \note This function automatically clears the control transfer's status stage. Do not manually attempt * to clear the status stage when using this routine in a control transaction. @@ -1018,7 +1018,7 @@ */ uint8_t Endpoint_Write_Control_Stream_BE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); - /** EEPROM buffer source version of \ref Endpoint_Write_Control_Stream_BE. + /** EEPROM buffer source version of \ref Endpoint_Write_Control_Stream_BE(). * * \note This function automatically clears the control transfer's status stage. Do not manually attempt * to clear the status stage when using this routine in a control transaction. @@ -1037,7 +1037,7 @@ */ uint8_t Endpoint_Write_Control_EStream_BE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); - /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_BE. + /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_BE(). * * \note This function automatically clears the control transfer's status stage. Do not manually attempt * to clear the status stage when using this routine in a control transaction. @@ -1080,7 +1080,7 @@ */ uint8_t Endpoint_Read_Control_Stream_LE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); - /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_LE. + /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_LE(). * * \note This function automatically clears the control transfer's status stage. Do not manually attempt * to clear the status stage when using this routine in a control transaction. @@ -1121,7 +1121,7 @@ */ uint8_t Endpoint_Read_Control_Stream_BE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); - /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_BE. + /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_BE(). * * \note This function automatically clears the control transfer's status stage. Do not manually attempt * to clear the status stage when using this routine in a control transaction. diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.h b/LUFA/Drivers/USB/LowLevel/Pipe.h index b6fad51466..3931f85301 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.h +++ b/LUFA/Drivers/USB/LowLevel/Pipe.h @@ -836,7 +836,7 @@ */ uint8_t Pipe_Write_Stream_LE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); - /** EEPROM buffer source version of \ref Pipe_Write_Stream_LE. + /** EEPROM buffer source version of \ref Pipe_Write_Stream_LE(). * * \ingroup Group_PipeStreamRW * @@ -848,7 +848,7 @@ */ uint8_t Pipe_Write_EStream_LE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); - /** FLASH buffer source version of \ref Pipe_Write_Stream_LE. + /** FLASH buffer source version of \ref Pipe_Write_Stream_LE(). * * \note The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. * @@ -885,7 +885,7 @@ */ uint8_t Pipe_Write_Stream_BE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); - /** EEPROM buffer source version of \ref Pipe_Write_Stream_BE. + /** EEPROM buffer source version of \ref Pipe_Write_Stream_BE(). * * \ingroup Group_PipeStreamRW * @@ -897,7 +897,7 @@ */ uint8_t Pipe_Write_EStream_BE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); - /** FLASH buffer source version of \ref Pipe_Write_Stream_BE. + /** FLASH buffer source version of \ref Pipe_Write_Stream_BE(). * * \note The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. * @@ -926,7 +926,7 @@ * * \ingroup Group_PipeStreamRW * - * \param[out] Buffer Pointer to the source data buffer to write to. + * \param[out] Buffer Pointer to the source data buffer to write to. * \param[in] Length Number of bytes to read for the currently selected pipe to read from. * \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback * @@ -934,11 +934,11 @@ */ uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); - /** EEPROM buffer source version of \ref Pipe_Read_Stream_LE. + /** EEPROM buffer source version of \ref Pipe_Read_Stream_LE(). * * \ingroup Group_PipeStreamRW * - * \param[out] Buffer Pointer to the source data buffer to write to. + * \param[out] Buffer Pointer to the source data buffer to write to. * \param[in] Length Number of bytes to read for the currently selected pipe to read from. * \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback * @@ -961,7 +961,7 @@ * * \ingroup Group_PipeStreamRW * - * \param[out] Buffer Pointer to the source data buffer to write to. + * \param[out] Buffer Pointer to the source data buffer to write to. * \param[in] Length Number of bytes to read for the currently selected pipe to read from. * \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback * @@ -969,11 +969,11 @@ */ uint8_t Pipe_Read_Stream_BE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); - /** EEPROM buffer source version of \ref Pipe_Read_Stream_BE. + /** EEPROM buffer source version of \ref Pipe_Read_Stream_BE(). * * \ingroup Group_PipeStreamRW * - * \param[out] Buffer Pointer to the source data buffer to write to. + * \param[out] Buffer Pointer to the source data buffer to write to. * \param[in] Length Number of bytes to read for the currently selected pipe to read from. * \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback * diff --git a/Projects/Unfinished/AVRISP/Lib/V2Protocol.c b/Projects/Unfinished/AVRISP/Lib/V2Protocol.c index dfa27ad9e8..e55a7002ea 100644 --- a/Projects/Unfinished/AVRISP/Lib/V2Protocol.c +++ b/Projects/Unfinished/AVRISP/Lib/V2Protocol.c @@ -36,6 +36,9 @@ #define INCLUDE_FROM_V2PROTOCOL_C #include "V2Protocol.h" +uint32_t CurrentAddress; + + /* Table of masks for SPI_Init() from a given PARAM_SCK_DURATION value */ static const uint8_t SPIMaskFromSCKDuration[MAX_SPI_SETTINGS] = { @@ -88,6 +91,9 @@ void V2Protocol_ProcessCommand(void) case CMD_GET_PARAMETER: V2Protocol_Command_GetSetParam(V2Command); break; + case CMD_LOAD_ADDRESS: + V2Protocol_Command_LoadAddress(); + break; case CMD_SPI_MULTI: V2Protocol_Command_SPIMulti(); break; @@ -127,6 +133,7 @@ static void V2Protocol_Command_SignOn(void) Endpoint_WaitUntilReady(); V2Protocol_ReconfigureSPI(); + CurrentAddress = 0; Endpoint_Write_Byte(CMD_SIGN_ON); Endpoint_Write_Byte(STATUS_CMD_OK); @@ -166,6 +173,19 @@ static void V2Protocol_Command_GetSetParam(uint8_t V2Command) Endpoint_ClearIN(); } +static void V2Protocol_Command_LoadAddress(void) +{ + CurrentAddress = Endpoint_Read_DWord_LE(); + + Endpoint_ClearOUT(); + Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN); + Endpoint_WaitUntilReady(); + + Endpoint_Write_Byte(CMD_LOAD_ADDRESS); + Endpoint_Write_Byte(STATUS_CMD_OK); + Endpoint_ClearIN(); +} + static void V2Protocol_Command_SPIMulti(void) { uint8_t TxBytes = Endpoint_Read_Byte(); diff --git a/Projects/Unfinished/AVRISP/Lib/V2Protocol.h b/Projects/Unfinished/AVRISP/Lib/V2Protocol.h index 03ca835361..5283f1986f 100644 --- a/Projects/Unfinished/AVRISP/Lib/V2Protocol.h +++ b/Projects/Unfinished/AVRISP/Lib/V2Protocol.h @@ -62,6 +62,7 @@ static void V2Protocol_Command_Unknown(uint8_t V2Command); static void V2Protocol_Command_SignOn(void); static void V2Protocol_Command_GetSetParam(uint8_t V2Command); + static void V2Protocol_Command_LoadAddress(void); static void V2Protocol_Command_SPIMulti(void); #endif