00001 00002 // 00003 // This file is part of DueFlash 00004 // 00005 // Copyright (c) 2013 Pansenti, LLC 00006 // 00007 // Permission is hereby granted, free of charge, to any person obtaining a copy of 00008 // this software and associated documentation files (the "Software"), to deal in 00009 // the Software without restriction, including without limitation the rights to use, 00010 // copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the 00011 // Software, and to permit persons to whom the Software is furnished to do so, 00012 // subject to the following conditions: 00013 // 00014 // The above copyright notice and this permission notice shall be included in all 00015 // copies or substantial portions of the Software. 00016 // 00017 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 00018 // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 00019 // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 00020 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00021 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 00022 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00023 00024 00025 #ifndef DUEFLASH_H 00026 #define DUEFLASH_H 00027 00028 #include <Arduino.h> 00029 #include "flash_efc.h" 00030 00031 // DueFlash supports saving of non-volatile data for Arduino Due sketches. 00032 // 00033 // All writes are in flash block 1 and are always multiples of 32 bits. They 00034 // can start on any 32 bit boundary withing flash block 1. 00035 // 00036 // Note: uploading new software will erase all flash so data written to flash 00037 // using this library will not survive a new software upload. 00038 // 00039 00040 // FLASH_DEBUG can be enabled to get debugging information displayed. 00041 00042 #define FLASH_DEBUG 00043 00044 #ifdef FLASH_DEBUG 00045 #define _FLASH_DEBUG(x) Serial.print(x); 00046 #else 00047 #define _FLASH_DEBUG(x) 00048 #endif 00049 00050 // DueFlash is the main class for flash functions 00051 00052 class DueFlash 00053 { 00054 public: 00055 00056 // Constructor does basic initialization 00057 00058 DueFlash(); 00059 00060 // write() writes the specified amount of data into flash. 00061 // flashStart is the address in memory where the write should start 00062 // data is a pointer to the data to be written (multiple of 32 bits) 00063 // dataLength is length of data in units of 32 bits 00064 00065 boolean write(uint32_t *flashStart, uint32_t *data, uint32_t dataLength); 00066 }; 00067 00068 #endif // DUEFLASH_H