Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lufa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Erik Strand
lufa
Commits
48e50b6b
Commit
48e50b6b
authored
15 years ago
by
Dean Camera
Browse files
Options
Downloads
Patches
Plain Diff
Added memory erase handling to the PDI protocol in the AVRISP project.
parent
8a55d80e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Projects/AVRISP/Lib/NVMTarget.c
+27
-0
27 additions, 0 deletions
Projects/AVRISP/Lib/NVMTarget.c
Projects/AVRISP/Lib/NVMTarget.h
+1
-0
1 addition, 0 deletions
Projects/AVRISP/Lib/NVMTarget.h
Projects/AVRISP/Lib/PDIProtocol.c
+21
-1
21 additions, 1 deletion
Projects/AVRISP/Lib/PDIProtocol.c
with
49 additions
and
1 deletion
Projects/AVRISP/Lib/NVMTarget.c
+
27
−
0
View file @
48e50b6b
...
...
@@ -137,4 +137,31 @@ void NVMTarget_ReadMemory(uint32_t ReadAddress, uint8_t* ReadBuffer, uint16_t Re
}
}
void
NVMTarget_EraseMemory
(
uint8_t
EraseCommand
,
uint32_t
Address
)
{
NVMTarget_WaitWhileNVMControllerBusy
();
PDITarget_SendByte
(
PDI_CMD_STS
|
(
PDI_DATSIZE_4BYTES
<<
2
));
NVMTarget_SendNVMRegAddress
(
NVM_REG_CMD
);
PDITarget_SendByte
(
EraseCommand
);
if
(
EraseCommand
==
NVM_CMD_CHIPERASE
)
{
/* Set CMDEX bit in NVM CTRLA register to start the chip erase */
PDITarget_SendByte
(
PDI_CMD_STS
|
(
PDI_DATSIZE_4BYTES
<<
2
));
NVMTarget_SendNVMRegAddress
(
NVM_REG_CTRLA
);
PDITarget_SendByte
(
1
<<
0
);
}
else
{
/* Other erase modes just need us to address a byte within the target memory space */
PDITarget_SendByte
(
PDI_CMD_STS
|
(
PDI_DATSIZE_4BYTES
<<
2
));
NVMTarget_SendAddress
(
Address
);
PDITarget_SendByte
(
0x00
);
}
NVMTarget_WaitWhileNVMBusBusy
();
NVMTarget_WaitWhileNVMControllerBusy
();
}
#endif
This diff is collapsed.
Click to expand it.
Projects/AVRISP/Lib/NVMTarget.h
+
1
−
0
View file @
48e50b6b
...
...
@@ -117,5 +117,6 @@
void
NVMTarget_WaitWhileNVMControllerBusy
(
void
);
uint32_t
NVMTarget_GetMemoryCRC
(
uint8_t
MemoryCommand
);
void
NVMTarget_ReadMemory
(
uint32_t
ReadAddress
,
uint8_t
*
ReadBuffer
,
uint16_t
ReadSize
);
void
NVMTarget_EraseMemory
(
uint8_t
EraseCommand
,
uint32_t
Address
);
#endif
This diff is collapsed.
Click to expand it.
Projects/AVRISP/Lib/PDIProtocol.c
+
21
−
1
View file @
48e50b6b
...
...
@@ -154,11 +154,31 @@ static void PDIProtocol_Erase(void)
}
Erase_XPROG_Params
;
Endpoint_Read_Stream_LE
(
&
Erase_XPROG_Params
,
sizeof
(
Erase_XPROG_Params
));
Erase_XPROG_Params
.
Address
=
SwapEndian_32
(
Erase_XPROG_Params
.
Address
);
Endpoint_ClearOUT
();
Endpoint_SetEndpointDirection
(
ENDPOINT_DIR_IN
);
// TODO: Send erase command here via PDI protocol
uint8_t
EraseCommand
;
if
(
Erase_XPROG_Params
.
MemoryType
==
XPRG_ERASE_CHIP
)
EraseCommand
=
NVM_CMD_CHIPERASE
;
else
if
(
Erase_XPROG_Params
.
MemoryType
==
XPRG_ERASE_APP
)
EraseCommand
=
NVM_CMD_ERASEAPPSEC
;
else
if
(
Erase_XPROG_Params
.
MemoryType
==
XPRG_ERASE_BOOT
)
EraseCommand
=
NVM_CMD_ERASEBOOTSEC
;
else
if
(
Erase_XPROG_Params
.
MemoryType
==
XPRG_ERASE_EEPROM
)
EraseCommand
=
NVM_CMD_ERASEEEPROM
;
else
if
(
Erase_XPROG_Params
.
MemoryType
==
XPRG_ERASE_APP_PAGE
)
EraseCommand
=
NVM_CMD_ERASEAPPSECPAGE
;
else
if
(
Erase_XPROG_Params
.
MemoryType
==
XPRG_ERASE_BOOT_PAGE
)
EraseCommand
=
NVM_CMD_ERASEBOOTSECPAGE
;
else
if
(
Erase_XPROG_Params
.
MemoryType
==
XPRG_ERASE_EEPROM_PAGE
)
EraseCommand
=
NVM_CMD_ERASEEEPROMPAGE
;
else
if
(
Erase_XPROG_Params
.
MemoryType
==
XPRG_ERASE_USERSIG
)
EraseCommand
=
NVM_CMD_ERASEUSERSIG
;
NVMTarget_EraseMemory
(
EraseCommand
,
Erase_XPROG_Params
.
Address
);
Endpoint_Write_Byte
(
CMD_XPROG
);
Endpoint_Write_Byte
(
XPRG_CMD_ERASE
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment