Fix:not saving card data when it is smaller than one page(256B)

This commit is contained in:
Willok
2019-12-06 10:18:22 +01:00
parent 5dcf851734
commit 1339e6350d
3 changed files with 6 additions and 4 deletions
+2 -1
View File
@@ -133,7 +133,8 @@ AVRDUDE_WRITE_EEPROM_LATEST = -U eeprom:w:Latest/Chameleon-RevG.eep
# Default target
all:
touch uartcmd.c
touch Terminal/Commands.c
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_core.mk
include $(LUFA_PATH)/Build/lufa_sources.mk
+3 -3
View File
@@ -204,7 +204,7 @@ INLINE void FlashWrite(const void *Buffer, uint32_t Address, uint16_t ByteCount)
/* We assume that FlashWrite is always called for write actions that are
* aligned to APP_SECTION_PAGE_SIZE and a multiple of APP_SECTION_PAGE_SIZE.
* Thus only full pages are written into the flash. */
uint16_t PageCount = ByteCount / APP_SECTION_PAGE_SIZE;
uint16_t PageCount = (ByteCount + APP_SECTION_PAGE_SIZE - 1) / APP_SECTION_PAGE_SIZE;
uint32_t PhysicalAddress = Address + FLASH_DATA_ADDR;
if ((PhysicalAddress >= FLASH_DATA_START) && (PhysicalAddress <= FLASH_DATA_END)) {
@@ -240,7 +240,7 @@ INLINE void FlashWrite(const void *Buffer, uint32_t Address, uint16_t ByteCount)
}
INLINE void FlashErase(uint32_t Address, uint16_t ByteCount) {
uint16_t PageCount = ByteCount / APP_SECTION_PAGE_SIZE;
uint16_t PageCount = (ByteCount + APP_SECTION_PAGE_SIZE - 1) / APP_SECTION_PAGE_SIZE;
uint32_t PhysicalAddress = Address + FLASH_DATA_ADDR;
if ((PhysicalAddress >= FLASH_DATA_START) && (PhysicalAddress <= FLASH_DATA_END)) {
@@ -308,7 +308,7 @@ INLINE void FRAMToFlash(uint32_t Address, uint16_t ByteCount) {
/* We assume that FlashWrite is always called for write actions that are
* aligned to APP_SECTION_PAGE_SIZE and a multiple of APP_SECTION_PAGE_SIZE.
* Thus only full pages are written into the flash. */
uint16_t PageCount = ByteCount / APP_SECTION_PAGE_SIZE;
uint16_t PageCount = (ByteCount + APP_SECTION_PAGE_SIZE - 1) / APP_SECTION_PAGE_SIZE;
uint32_t PhysicalAddress = Address + FLASH_DATA_ADDR;
if ((PhysicalAddress >= FLASH_DATA_START) && (PhysicalAddress <= FLASH_DATA_END)) {
@@ -670,6 +670,7 @@ CommandStatusIdType CommandSetLedMode(char *OutMessage, const char *InParam) {
break;
case 'R': // State reset
bKeepAlive = 1;
bUSBTerminal = 0;
break;
case 'T': // Test
SendTestCmd(InParam[1]);