aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Drivers/flash_ram
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Embedded_SW/Embedded/Drivers/flash_ram')
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c34
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h28
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.c36
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h14
4 files changed, 88 insertions, 24 deletions
diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c
index 10f65db1d..c757c3a3b 100644
--- a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c
+++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c
@@ -132,18 +132,16 @@ uint32_t ReadAppAndProgram(uint32_t ui32FlashStart,uint32_t ui32FileSize,void* b
return(1);
}
int base_flashErased = false;
-uint32_t EraseFlashSection(uint32_t ui32FlashStart)
+uint32_t EraseFlashSection(void)
{
- volatile uint32_t ui32Idx = ui32FlashStart;
+ volatile uint32_t ui32Idx = FLASH_RAM_BASE;
uint32_t status;
- if (ui32FlashStart<GENHWCFG_SECTION_FLASH)
- {
- if (base_flashErased == true)
- return ERROR;
- else
- base_flashErased = true; //once in a run
- }
+ if (base_flashErased == true)
+ return WARNING;
+ else
+ base_flashErased = true; //once in a run
+
#ifdef FLASH_DEBUG
Address[RxIndex] = ui32FlashStart;
Size[RxIndex] = ui32FileSize;
@@ -152,9 +150,27 @@ uint32_t EraseFlashSection(uint32_t ui32FlashStart)
RxIndex = 0;
#endif
status = FlashErase(ui32Idx);
+ //FlashErase returns 0 or -1
return status;
}
+/*void FlashTest(void)
+{
+ int i;
+ uint32_t stack[0x200];
+ uint32_t offset = 0;
+
+ for (i = 0; i < 0x200; i++)
+ stack[i] = i;
+
+ while (offset < FLASH_SIZE)
+ {
+ ReadAppAndProgram(FLASH_RAM_BASE+offset,0x200,stack);
+ offset+=0x200;
+ }
+ EraseFlashSection();
+
+}*/
//Each word may not be subject to more than a specific number of programming cycles before an
//erase cycle is required. In other words, for any given word, FlashProgram can only be called
//twice before FlashErase is called.
diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h
index 7da9f92a7..ab2c87acc 100644
--- a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h
+++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h
@@ -8,23 +8,23 @@
#ifndef DRIVERS_FLASH_RAM_FLASHPROGRAM_H_
#define DRIVERS_FLASH_RAM_FLASHPROGRAM_H_
-#define FLASH_RAM_BASE 0x000F8000
+#define FLASH_RAM_BASE 0x000FC000
-#define EMBEDDED_PARAMETERS_SECTION_FLASH (FLASH_RAM_BASE + 0X0000 ) //512
-#define PROCESS_PARAMETERS_SECTION_FLASH (FLASH_RAM_BASE + 0X0000 )//512
-#define DANCERS_SECTION_FLASH (FLASH_RAM_BASE + 0X0000)
-#define DISPENSERS_SECTION_FLASH (FLASH_RAM_BASE + 0X0000)
-#define GENHWCFG_SECTION_FLASH (FLASH_RAM_BASE + 0X2000)
-#define ALARM_SECTION_FLASH (FLASH_RAM_BASE + 0X4000 )
+//#define EMBEDDED_PARAMETERS_SECTION_FLASH (FLASH_RAM_BASE + 0X0000 ) //512
+//#define PROCESS_PARAMETERS_SECTION_FLASH (FLASH_RAM_BASE + 0X0000 )//512
+//#define DANCERS_SECTION_FLASH (FLASH_RAM_BASE + 0X0000)
+//#define DISPENSERS_SECTION_FLASH (FLASH_RAM_BASE + 0X0000)
+//#define GENHWCFG_SECTION_FLASH (FLASH_RAM_BASE + 0X0000)
+//#define ALARM_SECTION_FLASH (FLASH_RAM_BASE + 0X0000 )
+//#define PROCESS_PARAMETERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0X0200 )
+//#define DANCERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0X0400)
+//#define DISPENSERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0X500)
+//#define GENHWCFG_MAP_IN_FLASH (FLASH_RAM_BASE + 0x0300)
#define EMBEDDED_PARAMETERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0X0000 )
-#define PROCESS_PARAMETERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0X0200 )
-#define DANCERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0X0400)
-#define DISPENSERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0X500)
-#define GENHWCFG_MAP_IN_FLASH (FLASH_RAM_BASE + 0X2000)
-#define ALARM_MAP_IN_FLASH (FLASH_RAM_BASE + 0X4000 )
+#define ALARM_MAP_IN_FLASH (FLASH_RAM_BASE + 0X0300)
-#define FLASH_SIZE 0X8000
+#define FLASH_SIZE 0X4000
extern int base_flashErased;
@@ -38,7 +38,7 @@ extern int base_flashErased;
//*****************************************************************************
uint32_t ReadAppAndProgram(uint32_t ui32FlashStart,uint32_t ui32FileSize,void* buffer);
void FlashInit(void);
-uint32_t EraseFlashSection(uint32_t ui32FlashStart);
+uint32_t EraseFlashSection(void);
diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.c b/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.c
index e9d5cfc07..71d26888d 100644
--- a/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.c
+++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.c
@@ -60,6 +60,42 @@ uint32_t MCU_E2PromRead(int Address,uint32_t *Data)
return OK;
}
+/**************************************************/
+uint32_t MCU_E2PromProgramChunk(int Address,uint16_t Length,uint32_t Data)
+{
+ uint32_t Buffer = Data;
+#ifdef EVALUATION_BOARD
+ return 0;
+#else
+ Report("MCU_E2PromProgramChunk",__FILE__,Length,Address,RpWarning,Data,0);
+ return (EEPROMProgram((uint32_t *)Buffer, Address, Length));
+#endif
+}
+uint32_t MCU_E2PromReadChunk(int Address,uint16_t Length,uint32_t *Data)
+{
+#ifndef EVALUATION_BOARD
+ EEPROMRead((uint32_t *)Data,Address, Length);
+#endif
+ Report("MCU_E2PromReadChunk",__FILE__,Length,Address,RpWarning,*Data,0);
+
+ return OK;
+
+}
+void MCU_E2PromUpdateResetReason(int i)
+{
+ uint32_t Head;
+ uint32_t RESC = SysCtlResetCauseGet();
+
+ EEPROMRead(&Head,EEPROM_RESET_REASON_HEAD_ADDRESS, 4);
+ if (Head>=EEPROM_RESET_REASON_MAX_DATA) Head=0;
+ Head++;
+ RESC+=(i*0x1000);
+ EEPROMProgram(&Head, EEPROM_RESET_REASON_HEAD_ADDRESS, 4);
+ EEPROMProgram(&RESC, (EEPROM_RESET_REASON_HEAD_ADDRESS+(Head*4)), 4);
+
+}
+
+/*************************************************/
void MCU_E2PromProgramMidTank(int midtankId,float a,float b)
{
float A,B;
diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h b/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h
index 12598ed07..aee812973 100644
--- a/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h
+++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h
@@ -38,7 +38,7 @@ typedef enum {
EEPROM_ALARM_SUPPORT,
EEPROM_ORIFICE1_ZERO_VALUE,
EEPROM_ORIFICE3_ZERO_VALUE,
- EEPROM_WASTE_TANK_ZERO_VALUE,
+ EEPROM_LOCAL_TIME,
EEPROM_PULLER_TENSION_POSITION,
EEPROM_WINDER_TENSION_POSITION,
EEPROM_INIT_FAILURE_COUNTER,
@@ -61,6 +61,18 @@ typedef enum {
ORIFICE3_ZERO_VALUE_ADDR,
}EEPROM_ADDRESSES;*/
+#define EEPROM_RESET_REASON_HEAD_ADDRESS 160
+#define EEPROM_RESET_REASON_MAX_DATA 80
+
+#define DISPENSERS_MAP_IN_EEPROM 0x200
+#define PROCESS_PARAMATERS_IN_EEPROM 0x400
+
+uint32_t MCU_E2PromProgramChunk(int Address,uint16_t Length,uint32_t Data);
+uint32_t MCU_E2PromReadChunk(int Address,uint16_t Length,uint32_t *Data);
+
+void MCU_E2PromUpdateResetReason(int i);
+
+
uint32_t MCU_E2PromProgram(int Address,uint32_t Data);
uint32_t MCU_E2PromRead(int Address,uint32_t *Data);
void MCU_E2PromProgramMidTank(int midtankId,float a,float b);