diff options
author | David Crocker <dcrocker@eschertech.com> | 2016-11-03 19:51:26 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2016-11-03 19:52:11 +0300 |
commit | fcbf543a18fc8f35a787ac99863257971e56f23d (patch) | |
tree | 958415b943d172150f3e81962f0f841e3c68b6a1 /src/Libraries | |
parent | f14c676916706cf6f43f660bafb787a9bcf8f2e5 (diff) |
Version 1.16rc1
Merged in chrishamm's changes to support tmie stamping of uploaded files
(thanks chrishamm)
Added fan mapping in M563 command
Diffstat (limited to 'src/Libraries')
-rw-r--r-- | src/Libraries/Fatfs/fattime_rtc.c | 18 | ||||
-rw-r--r-- | src/Libraries/Flash/DueFlashStorage.cpp | 73 | ||||
-rw-r--r-- | src/Libraries/Flash/DueFlashStorage.h | 54 |
3 files changed, 9 insertions, 136 deletions
diff --git a/src/Libraries/Fatfs/fattime_rtc.c b/src/Libraries/Fatfs/fattime_rtc.c index fc8d1df1..fc46396f 100644 --- a/src/Libraries/Fatfs/fattime_rtc.c +++ b/src/Libraries/Fatfs/fattime_rtc.c @@ -66,16 +66,18 @@ uint32_t get_fattime(void); */ uint32_t get_fattime(void) { - /**@TODO FIX THIS - real time clock required*/ - /* + if (rtc_get_valid_entry(RTC) != 0) + { + // Date and time have not been set, return default timestamp instead + return 0x210001; + } + + // Retrieve current date and time from RTC uint32_t ul_time; uint32_t ul_hour, ul_minute, ul_second; uint32_t ul_year, ul_month, ul_day, ul_week; - - - // Retrieve date and time - //rtc_get_time(RTC, &ul_hour, &ul_minute, &ul_second); - //rtc_get_date(RTC, &ul_year, &ul_month, &ul_day, &ul_week); + rtc_get_time(RTC, &ul_hour, &ul_minute, &ul_second); + rtc_get_date(RTC, &ul_year, &ul_month, &ul_day, &ul_week); ul_time = ((ul_year - 1980) << 25) | (ul_month << 21) @@ -85,7 +87,5 @@ uint32_t get_fattime(void) | (ul_second << 0); return ul_time; - */ - return 0x210001; //set datetime } diff --git a/src/Libraries/Flash/DueFlashStorage.cpp b/src/Libraries/Flash/DueFlashStorage.cpp deleted file mode 100644 index 48003ddc..00000000 --- a/src/Libraries/Flash/DueFlashStorage.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "DueFlashStorage.h" -#include <cstring> - -void DueFlashStorage::read(uint32_t address, void *data, uint32_t dataLength) -{ - memcpy(data, FLASH_START + address, dataLength); -} - -bool DueFlashStorage::write(uint32_t address, const void *data, uint32_t dataLength) -{ - if ((uint32_t)FLASH_START + address < -#ifdef DUET_NG - IFLASH_ADDR -#else - IFLASH1_ADDR -#endif - ) - { - FLASH_DEBUG("Flash write address too low"); - return false; - } - - if ((uint32_t)FLASH_START + address + dataLength > -#ifdef DUET_NG - IFLASH_ADDR + IFLASH_SIZE -#else - IFLASH1_ADDR + IFLASH1_SIZE -#endif - ) - { - FLASH_DEBUG("Flash write address too high"); - return false; - } - - if ((((uint32_t)FLASH_START + address) & 3) != 0) - { - FLASH_DEBUG("Flash start address must be on 4-byte boundary\n"); - return false; - } - - // The flash management code in the ASF is fragile and has a tendency to fail to return. Help it by disabling interrupts. - irqflags_t flags = cpu_irq_save(); - - // Unlock page - uint32_t retCode = flash_unlock((uint32_t)FLASH_START + address, (uint32_t)FLASH_START + address + dataLength - 1, NULL, NULL); - if (retCode != FLASH_RC_OK) - { - FLASH_DEBUG("Failed to unlock flash for write"); - } - else - { - // Write data - retCode = flash_write((uint32_t)FLASH_START + address, data, dataLength, 1); - if (retCode != FLASH_RC_OK) - { - FLASH_DEBUG("Flash write failed"); - } - else - { - // Lock page - retCode = flash_lock((uint32_t)FLASH_START + address, (uint32_t)FLASH_START + address + dataLength - 1, NULL, NULL); - if (retCode != FLASH_RC_OK) - { - FLASH_DEBUG("Failed to lock flash page"); - } - } - } - - cpu_irq_restore(flags); - return retCode == FLASH_RC_OK; -} - -// End diff --git a/src/Libraries/Flash/DueFlashStorage.h b/src/Libraries/Flash/DueFlashStorage.h deleted file mode 100644 index cfec9c19..00000000 --- a/src/Libraries/Flash/DueFlashStorage.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -DueFlashStorage saves non-volatile data for Arduino Due. -The library is made to be similar to EEPROM library -Uses flash block 1 per default. - -Note: uploading new software will erase all flash so data written to flash -using this library will not survive a new software upload. - -Inspiration from Pansenti at https://github.com/Pansenti/DueFlash -Rewritten and modified by Sebastian Nilsson -Further modified up by David Crocker -*/ - - -#ifndef DUEFLASHSTORAGE_H -#define DUEFLASHSTORAGE_H - -#include "Core.h" -#include "flash_efc.h" - -#ifdef DUET_NG - -// 1Kb of data -#define FLASH_DATA_LENGTH ((IFLASH_PAGE_SIZE/sizeof(byte))*4) - -// Choose a start address close to the top of the Flash 1 memory space -#define FLASH_START ((uint8_t *)(IFLASH_ADDR + IFLASH_SIZE - FLASH_DATA_LENGTH)) - -#else - -// 1Kb of data -#define FLASH_DATA_LENGTH ((IFLASH1_PAGE_SIZE/sizeof(byte))*4) - -// Choose a start address close to the top of the Flash 1 memory space -#define FLASH_START ((uint8_t *)(IFLASH1_ADDR + IFLASH1_SIZE - FLASH_DATA_LENGTH)) - -#endif - -//#define FLASH_DEBUG(x) Serial.print(x); -#define FLASH_DEBUG(x) - -// DueFlash is the main namespace for flash functions -namespace DueFlashStorage -{ - // write() writes the specified amount of data into flash. - // flashStart is the address in memory where the write should start - // data is a pointer to the data to be written - // dataLength is length of data in bytes - - void read(uint32_t address, void *data, uint32_t dataLength); - bool write(uint32_t address, const void *data, uint32_t dataLength); -}; - -#endif |