projects
/
pub
/
USBasp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move new Class Driver powered demos to a new ClassDriver subdirectory, re-add old...
[pub/USBasp.git]
/
Bootloaders
/
DFU
/
BootloaderDFU.c
diff --git
a/Bootloaders/DFU/BootloaderDFU.c
b/Bootloaders/DFU/BootloaderDFU.c
index
5375b9c
..
11177c5
100644
(file)
--- a/
Bootloaders/DFU/BootloaderDFU.c
+++ b/
Bootloaders/DFU/BootloaderDFU.c
@@
-139,7
+139,7
@@
int main (void)
/** Event handler for the USB_Disconnect event. This indicates that the bootloader should exit and the user
\r
* application started.
\r
*/
\r
/** Event handler for the USB_Disconnect event. This indicates that the bootloader should exit and the user
\r
* application started.
\r
*/
\r
-
EVENT_HANDLER(USB_Disconnect
)
\r
+
void EVENT_USB_Disconnect(void
)
\r
{
\r
/* Upon disconnection, run user application */
\r
RunBootloader = false;
\r
{
\r
/* Upon disconnection, run user application */
\r
RunBootloader = false;
\r
@@
-149,21
+149,15
@@
EVENT_HANDLER(USB_Disconnect)
* control requests that are not handled internally by the USB library (including the DFU commands, which are
\r
* all issued via the control endpoint), so that they can be handled appropriately for the application.
\r
*/
\r
* control requests that are not handled internally by the USB library (including the DFU commands, which are
\r
* all issued via the control endpoint), so that they can be handled appropriately for the application.
\r
*/
\r
-
EVENT_HANDLER(USB_UnhandledControlPacket
)
\r
+
void EVENT_USB_UnhandledControlPacket(void
)
\r
{
\r
{
\r
- /* Discard unused wIndex value */
\r
- Endpoint_Discard_Word();
\r
-
\r
- /* Discard unused wValue value */
\r
- Endpoint_Discard_Word();
\r
-
\r
/* Get the size of the command and data from the wLength value */
\r
/* Get the size of the command and data from the wLength value */
\r
- SentCommand.DataSize =
Endpoint_Read_Word_LE()
;
\r
+ SentCommand.DataSize =
USB_ControlRequest.wLength
;
\r
\r
\r
- switch (bRequest)
\r
+ switch (
USB_ControlRequest.
bRequest)
\r
{
\r
case DFU_DNLOAD:
\r
{
\r
case DFU_DNLOAD:
\r
- Endpoint_ClearS
etupReceived
();
\r
+ Endpoint_ClearS
ETUP
();
\r
\r
/* Check if bootloader is waiting to terminate */
\r
if (WaitForExit)
\r
\r
/* Check if bootloader is waiting to terminate */
\r
if (WaitForExit)
\r
@@
-178,7
+172,7
@@
EVENT_HANDLER(USB_UnhandledControlPacket)
/* If the request has a data stage, load it into the command struct */
\r
if (SentCommand.DataSize)
\r
{
\r
/* If the request has a data stage, load it into the command struct */
\r
if (SentCommand.DataSize)
\r
{
\r
- while (!(Endpoint_Is
Setup
OUTReceived()));
\r
+ while (!(Endpoint_IsOUTReceived()));
\r
\r
/* First byte of the data stage is the DNLOAD request's command */
\r
SentCommand.Command = Endpoint_Read_Byte();
\r
\r
/* First byte of the data stage is the DNLOAD request's command */
\r
SentCommand.Command = Endpoint_Read_Byte();
\r
@@
-225,7
+219,7
@@
EVENT_HANDLER(USB_UnhandledControlPacket)
{
\r
uint16_t Words[2];
\r
uint32_t Long;
\r
{
\r
uint16_t Words[2];
\r
uint32_t Long;
\r
- } CurrFlashAddress = {
Words:
{StartAddr, Flash64KBPage}};
\r
+ } CurrFlashAddress = {
.Words =
{StartAddr, Flash64KBPage}};
\r
\r
uint32_t CurrFlashPageStartAddress = CurrFlashAddress.Long;
\r
uint8_t WordsInFlashPage = 0;
\r
\r
uint32_t CurrFlashPageStartAddress = CurrFlashAddress.Long;
\r
uint8_t WordsInFlashPage = 0;
\r
@@
-235,8
+229,8
@@
EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */
\r
if (!(Endpoint_BytesInEndpoint()))
\r
{
\r
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */
\r
if (!(Endpoint_BytesInEndpoint()))
\r
{
\r
- Endpoint_Clear
Setup
OUT();
\r
- while (!(Endpoint_Is
Setup
OUTReceived()));
\r
+ Endpoint_ClearOUT();
\r
+ while (!(Endpoint_IsOUTReceived()));
\r
}
\r
\r
/* Write the next word into the current flash page */
\r
}
\r
\r
/* Write the next word into the current flash page */
\r
@@
-279,8
+273,8
@@
EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */
\r
if (!(Endpoint_BytesInEndpoint()))
\r
{
\r
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */
\r
if (!(Endpoint_BytesInEndpoint()))
\r
{
\r
- Endpoint_Clear
Setup
OUT();
\r
- while (!(Endpoint_Is
Setup
OUTReceived()));
\r
+ Endpoint_ClearOUT();
\r
+ while (!(Endpoint_IsOUTReceived()));
\r
}
\r
\r
/* Read the byte from the USB interface and write to to the EEPROM */
\r
}
\r
\r
/* Read the byte from the USB interface and write to to the EEPROM */
\r
@@
-296,17
+290,17
@@
EVENT_HANDLER(USB_UnhandledControlPacket)
}
\r
}
\r
\r
}
\r
}
\r
\r
- Endpoint_Clear
Setup
OUT();
\r
+ Endpoint_ClearOUT();
\r
\r
/* Acknowledge status stage */
\r
\r
/* Acknowledge status stage */
\r
- while (!(Endpoint_Is
Setup
INReady()));
\r
- Endpoint_Clear
Setup
IN();
\r
+ while (!(Endpoint_IsINReady()));
\r
+ Endpoint_ClearIN();
\r
\r
break;
\r
case DFU_UPLOAD:
\r
\r
break;
\r
case DFU_UPLOAD:
\r
- Endpoint_ClearS
etupReceived
();
\r
+ Endpoint_ClearS
ETUP
();
\r
\r
\r
- while (!(Endpoint_Is
Setup
INReady()));
\r
+ while (!(Endpoint_IsINReady()));
\r
\r
if (DFU_State != dfuUPLOAD_IDLE)
\r
{
\r
\r
if (DFU_State != dfuUPLOAD_IDLE)
\r
{
\r
@@
-336,15
+330,15
@@
EVENT_HANDLER(USB_UnhandledControlPacket)
{
\r
uint16_t Words[2];
\r
uint32_t Long;
\r
{
\r
uint16_t Words[2];
\r
uint32_t Long;
\r
- } CurrFlashAddress = {
Words:
{StartAddr, Flash64KBPage}};
\r
+ } CurrFlashAddress = {
.Words =
{StartAddr, Flash64KBPage}};
\r
\r
while (WordsRemaining--)
\r
{
\r
/* Check if endpoint is full - if so clear it and wait until ready for next packet */
\r
if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE)
\r
{
\r
\r
while (WordsRemaining--)
\r
{
\r
/* Check if endpoint is full - if so clear it and wait until ready for next packet */
\r
if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE)
\r
{
\r
- Endpoint_Clear
Setup
IN();
\r
- while (!(Endpoint_Is
Setup
INReady()));
\r
+ Endpoint_ClearIN();
\r
+ while (!(Endpoint_IsINReady()));
\r
}
\r
\r
/* Read the flash word and send it via USB to the host */
\r
}
\r
\r
/* Read the flash word and send it via USB to the host */
\r
@@
-368,8
+362,8
@@
EVENT_HANDLER(USB_UnhandledControlPacket)
/* Check if endpoint is full - if so clear it and wait until ready for next packet */
\r
if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE)
\r
{
\r
/* Check if endpoint is full - if so clear it and wait until ready for next packet */
\r
if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE)
\r
{
\r
- Endpoint_Clear
Setup
IN();
\r
- while (!(Endpoint_Is
Setup
INReady()));
\r
+ Endpoint_ClearIN();
\r
+ while (!(Endpoint_IsINReady()));
\r
}
\r
\r
/* Read the EEPROM byte and send it via USB to the host */
\r
}
\r
\r
/* Read the EEPROM byte and send it via USB to the host */
\r
@@
-384,15
+378,15
@@
EVENT_HANDLER(USB_UnhandledControlPacket)
DFU_State = dfuIDLE;
\r
}
\r
\r
DFU_State = dfuIDLE;
\r
}
\r
\r
- Endpoint_Clear
Setup
IN();
\r
+ Endpoint_ClearIN();
\r
\r
/* Acknowledge status stage */
\r
\r
/* Acknowledge status stage */
\r
- while (!(Endpoint_Is
Setup
OUTReceived()));
\r
- Endpoint_Clear
Setup
OUT();
\r
+ while (!(Endpoint_IsOUTReceived()));
\r
+ Endpoint_ClearOUT();
\r
\r
break;
\r
case DFU_GETSTATUS:
\r
\r
break;
\r
case DFU_GETSTATUS:
\r
- Endpoint_ClearS
etupReceived
();
\r
+ Endpoint_ClearS
ETUP
();
\r
\r
/* Write 8-bit status value */
\r
Endpoint_Write_Byte(DFU_Status);
\r
\r
/* Write 8-bit status value */
\r
Endpoint_Write_Byte(DFU_Status);
\r
@@
-407,46
+401,46
@@
EVENT_HANDLER(USB_UnhandledControlPacket)
/* Write 8-bit state string ID number */
\r
Endpoint_Write_Byte(0);
\r
\r
/* Write 8-bit state string ID number */
\r
Endpoint_Write_Byte(0);
\r
\r
- Endpoint_Clear
Setup
IN();
\r
+ Endpoint_ClearIN();
\r
\r
/* Acknowledge status stage */
\r
\r
/* Acknowledge status stage */
\r
- while (!(Endpoint_Is
Setup
OUTReceived()));
\r
- Endpoint_Clear
Setup
OUT();
\r
+ while (!(Endpoint_IsOUTReceived()));
\r
+ Endpoint_ClearOUT();
\r
\r
break;
\r
case DFU_CLRSTATUS:
\r
\r
break;
\r
case DFU_CLRSTATUS:
\r
- Endpoint_ClearS
etupReceived
();
\r
+ Endpoint_ClearS
ETUP
();
\r
\r
/* Reset the status value variable to the default OK status */
\r
DFU_Status = OK;
\r
\r
/* Acknowledge status stage */
\r
\r
/* Reset the status value variable to the default OK status */
\r
DFU_Status = OK;
\r
\r
/* Acknowledge status stage */
\r
- while (!(Endpoint_Is
Setup
INReady()));
\r
- Endpoint_Clear
Setup
IN();
\r
+ while (!(Endpoint_IsINReady()));
\r
+ Endpoint_ClearIN();
\r
\r
break;
\r
case DFU_GETSTATE:
\r
\r
break;
\r
case DFU_GETSTATE:
\r
- Endpoint_ClearS
etupReceived
();
\r
+ Endpoint_ClearS
ETUP
();
\r
\r
/* Write the current device state to the endpoint */
\r
Endpoint_Write_Byte(DFU_State);
\r
\r
\r
/* Write the current device state to the endpoint */
\r
Endpoint_Write_Byte(DFU_State);
\r
\r
- Endpoint_Clear
Setup
IN();
\r
+ Endpoint_ClearIN();
\r
\r
/* Acknowledge status stage */
\r
\r
/* Acknowledge status stage */
\r
- while (!(Endpoint_Is
Setup
OUTReceived()));
\r
- Endpoint_Clear
Setup
OUT();
\r
+ while (!(Endpoint_IsOUTReceived()));
\r
+ Endpoint_ClearOUT();
\r
\r
break;
\r
case DFU_ABORT:
\r
\r
break;
\r
case DFU_ABORT:
\r
- Endpoint_ClearS
etupReceived
();
\r
+ Endpoint_ClearS
ETUP
();
\r
\r
/* Reset the current state variable to the default idle state */
\r
DFU_State = dfuIDLE;
\r
\r
/* Acknowledge status stage */
\r
\r
/* Reset the current state variable to the default idle state */
\r
DFU_State = dfuIDLE;
\r
\r
/* Acknowledge status stage */
\r
- while (!(Endpoint_Is
Setup
INReady()));
\r
- Endpoint_Clear
Setup
IN();
\r
+ while (!(Endpoint_IsINReady()));
\r
+ Endpoint_ClearIN();
\r
\r
break;
\r
}
\r
\r
break;
\r
}
\r
@@
-463,10
+457,10
@@
static void DiscardFillerBytes(uint8_t NumberOfBytes)
{
\r
if (!(Endpoint_BytesInEndpoint()))
\r
{
\r
{
\r
if (!(Endpoint_BytesInEndpoint()))
\r
{
\r
- Endpoint_Clear
Setup
OUT();
\r
+ Endpoint_ClearOUT();
\r
\r
/* Wait until next data packet received */
\r
\r
/* Wait until next data packet received */
\r
- while (!(Endpoint_Is
Setup
OUTReceived()));
\r
+ while (!(Endpoint_IsOUTReceived()));
\r
}
\r
\r
Endpoint_Discard_Byte();
\r
}
\r
\r
Endpoint_Discard_Byte();
\r
@@
-531,8
+525,8
@@
static void LoadStartEndAddresses(void)
{
\r
uint8_t Bytes[2];
\r
uint16_t Word;
\r
{
\r
uint8_t Bytes[2];
\r
uint16_t Word;
\r
- } Address[2] = {{
Bytes:
{SentCommand.Data[2], SentCommand.Data[1]}},
\r
- {
Bytes:
{SentCommand.Data[4], SentCommand.Data[3]}}};
\r
+ } Address[2] = {{
.Bytes =
{SentCommand.Data[2], SentCommand.Data[1]}},
\r
+ {
.Bytes =
{SentCommand.Data[4], SentCommand.Data[3]}}};
\r
\r
/* Load in the start and ending read addresses from the sent data packet */
\r
StartAddr = Address[0].Word;
\r
\r
/* Load in the start and ending read addresses from the sent data packet */
\r
StartAddr = Address[0].Word;
\r
@@
-557,7
+551,7
@@
static void ProcessMemProgCommand(void)
{
\r
uint16_t Words[2];
\r
uint32_t Long;
\r
{
\r
uint16_t Words[2];
\r
uint32_t Long;
\r
- } CurrFlashAddress = {
Words:
{StartAddr, Flash64KBPage}};
\r
+ } CurrFlashAddress = {
.Words =
{StartAddr, Flash64KBPage}};
\r
\r
/* Erase the current page's temp buffer */
\r
boot_page_erase(CurrFlashAddress.Long);
\r
\r
/* Erase the current page's temp buffer */
\r
boot_page_erase(CurrFlashAddress.Long);
\r
@@
-639,7
+633,7
@@
static void ProcessWriteCommand(void)
{
\r
uint8_t Bytes[2];
\r
AppPtr_t FuncPtr;
\r
{
\r
uint8_t Bytes[2];
\r
AppPtr_t FuncPtr;
\r
- } Address = {
Bytes:
{SentCommand.Data[4], SentCommand.Data[3]}};
\r
+ } Address = {
.Bytes =
{SentCommand.Data[4], SentCommand.Data[3]}};
\r
\r
AppStartPtr = Address.FuncPtr;
\r
\r
\r
AppStartPtr = Address.FuncPtr;
\r
\r