00001
00016 #include <stddef.h>
00017 #include "nvm.h"
00018 #include "nvm_config.h"
00019
00021
00022
00023
00024
00025
00027 uint32_t colorTable[] = { 0x000000, 0xff0000, 0x00ff00, 0x0000ff, 0xffff00,
00028 0x00ffff, 0xff00ff, 0xc0c0c0, 0xffffff };
00029 uint8_t coefficientTable[] = { 11, 12, 13, 14, 15 };
00030 uint8_t primeNumberTable[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
00031 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,
00032 101, 103, 107, 109, 113, 127, 131, 137, 139, 149,
00033 151, 157, 163, 167, 173, 179, 181, 191, 193, 197,
00034 199, 211, 223, 227, 229, 233, 239, 241, 251 };
00035 uint8_t bonusTable[] = { 39, 38, 37, 36 };
00036 uint8_t privateKeyTable[] = { 49, 48, 47, 46 };
00037 uint8_t transformTable[] = { 59, 58, 57, 56 };
00038 int32_t safetyTable[] = { -71, 72, -73, 74, -75, -76, -77, -78, 79, -70 };
00039 uint8_t bigEmptyTable[450];
00040 uint32_t singleVariable = 68;
00041
00042
00043
00044
00045 typedef enum
00046 {
00047 COLOR_TABLE_ID,
00048 COEFFICIENT_TABLE_ID,
00049 PRIME_NUMBER_TABLE_ID,
00050 BONUS_TABLE_ID,
00051 PRIVATE_KEY_TABLE_ID,
00052 TRANSFORM_TABLE_ID,
00053 SINGLE_VARIABLE_ID,
00054 SAFETY_TABLE_ID,
00055 BIG_EMPTY_TABLE_ID
00056 } NVM_Object_Ids;
00057
00058
00059
00060 typedef enum
00061 {
00062 MY_PAGE_1,
00063 MY_PAGE_2,
00064 MY_PAGE_3,
00065 MY_PAGE_4
00066 } NVM_Page_Ids;
00067
00068
00069
00070 NVM_Page_t const myPage1 =
00071 {
00072
00073 { (uint8_t *) colorTable, sizeof(colorTable), COLOR_TABLE_ID },
00074 { (uint8_t *) bonusTable, sizeof(bonusTable), BONUS_TABLE_ID },
00075 { (uint8_t *) &singleVariable, sizeof(singleVariable), SINGLE_VARIABLE_ID },
00076 { (uint8_t *) bigEmptyTable, sizeof(bigEmptyTable), BIG_EMPTY_TABLE_ID },
00077 NVM_PAGE_TERMINATION
00078 };
00079
00080
00081
00082
00083
00084 NVM_Page_t const myPage2 =
00085 {
00086
00087 { (uint8_t *) safetyTable, sizeof(safetyTable), SAFETY_TABLE_ID },
00088 NVM_PAGE_TERMINATION
00089 };
00090
00091
00092
00093 NVM_Page_t const myPage3 =
00094 {
00095
00096 { (uint8_t *) coefficientTable, sizeof(coefficientTable), COEFFICIENT_TABLE_ID },
00097 { (uint8_t *) privateKeyTable, sizeof(privateKeyTable), PRIVATE_KEY_TABLE_ID },
00098 { (uint8_t *) &singleVariable, sizeof(singleVariable), SINGLE_VARIABLE_ID },
00099 NVM_PAGE_TERMINATION
00100 };
00101
00102
00103
00104 NVM_Page_t const myPage4 =
00105 {
00106
00107 { (uint8_t *) primeNumberTable, sizeof(primeNumberTable), PRIME_NUMBER_TABLE_ID },
00108 { (uint8_t *) transformTable, sizeof(transformTable), TRANSFORM_TABLE_ID },
00109 { (uint8_t *) &singleVariable, sizeof(singleVariable), SINGLE_VARIABLE_ID },
00110 NVM_PAGE_TERMINATION
00111 };
00112
00113
00114
00115 NVM_Page_Table_t const nvmPages =
00116 {
00117
00118 { MY_PAGE_1, &myPage1, nvmPageTypeNormal },
00119 { MY_PAGE_2, &myPage2, nvmPageTypeWear },
00120 { MY_PAGE_3, &myPage3, nvmPageTypeNormal },
00121 { MY_PAGE_4, &myPage4, nvmPageTypeNormal }
00122 };
00123
00124
00125
00126
00127
00148 #define NUMBER_OF_USER_PAGES (sizeof(nvmPages) / sizeof(NVM_Page_Descriptor_t))
00149 #define NUMBER_OF_PAGES (NVM_PAGES_SCRATCH + NUMBER_OF_USER_PAGES)
00150
00152
00153 #ifdef __ICCARM__
00154 #pragma data_alignment = NVM_PAGE_SIZE
00155 static const uint8_t nvmData[NVM_PAGE_SIZE * NUMBER_OF_PAGES] @ ".text";
00156 #else
00157 static const uint8_t nvmData[NVM_PAGE_SIZE * NUMBER_OF_PAGES] \
00158 __attribute__ ((__aligned__(NVM_PAGE_SIZE))) = { 0xFF };
00159 #endif
00160
00161
00162 static NVM_Config_t const nvmConfig =
00163 {
00164 &nvmPages,
00165 NUMBER_OF_PAGES,
00166 NUMBER_OF_USER_PAGES,
00167 nvmData
00168 };
00170
00177 NVM_Config_t const *NVM_ConfigGet(void)
00178 {
00179 return( &nvmConfig );
00180 }
00181