aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Drivers
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-08-23 08:49:56 +0300
committerShlomo Hecht <shlomo@twine-s.com>2018-08-23 08:49:56 +0300
commitb92bebe3f84a5ef683e44decf1991359fb3a4e21 (patch)
tree57f1c054f36307ad92c8954670494a8c9b842ad0 /Software/Embedded_SW/Embedded/Drivers
parentbe4b16ebb5b6d6d77834c85b087aa748129cbdcd (diff)
parent0cd5871508a048d1b47b6f4286af106a3f9a8488 (diff)
downloadTango-b92bebe3f84a5ef683e44decf1991359fb3a4e21.tar.gz
Tango-b92bebe3f84a5ef683e44decf1991359fb3a4e21.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Drivers')
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Comm.h6
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c13
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/Flash_Memory/Flash_Memory.c101
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/Flash_Memory/Flash_Memory.h2
4 files changed, 112 insertions, 10 deletions
diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Comm.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Comm.h
index dd817765c..1ecedf00c 100644
--- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Comm.h
+++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Comm.h
@@ -119,6 +119,9 @@
#define F1_DRYER_LOADARM_ROTENC_M (*((volatile short *)(FPGA1_BASE | 0x152))) //10bits Value of the Msb of the QEI register, 1bit Direction of movement, 5bits Reserved
#define F1_DRYER_LOADARM_ROTENC_I (*((volatile short *)(FPGA1_BASE | 0x154))) //value of index counter
+//WATCHDOG
+#define F1_Watchdog_reg (*((volatile short *)(FPGA1_BASE | 0x160)))//Watchdog enable bit, watchdog value - F1_gpo_01 BIT2 DYEINGH_SSR10_CTRL HeadHeaterZ5
+
//SSI
#define F1_RSPARE_ROTENC_DATA_p_RX_lsb (*((volatile short *)(FPGA1_BASE | 0x180))) //The 16 Lsb bits of the shifted in data.
#define F1_RSPARE_ROTENC_DATA_p_RX_msb (*((volatile short *)(FPGA1_BASE | 0x182))) //16 bit MSB if nessesary
@@ -627,6 +630,9 @@
#define F3_RSPARE_ROTENC_msb (*((volatile short *)(FPGA3_BASE | 0x112))) //10bits Value of the Msb of the QEI register, 1bit Direction of movement, 5bits Reserved
#define F3_RSPARE_ROTENC_index (*((volatile short *)(FPGA3_BASE | 0x114))) //value of index counter
+//WATCHDOG
+#define F3_Watchdog_reg (*((volatile short *)(FPGA3_BASE | 0x140)))//Watchdog enable bit, watchdog value - F3_GPO_01_bus BIT4 DYEINGH_SSR11_CTRL HeadHeaterZ6
+
//SPI_MOTO_RLOADING_A1
#define F3_MOTO_SPARE1_1_A1_TX_00 (*((volatile short *)(FPGA3_BASE | 0x200))) //The second register to be shifted out of the spi. The msb bit of this register is shifted out first.
#define F3_MOTO_SPARE1_1_A1_TX_01 (*((volatile short *)(FPGA3_BASE | 0x202))) //The first register to be shifted out of the spi. The msb bit of this register is shifted out first.
diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c
index 4d10b6b7c..ef3933d30 100644
--- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c
+++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c
@@ -309,8 +309,8 @@ bool FPGA_Read_limit_Switches(FPGA_GPI_ENUM Limit_Switch)
LS_Dispenser_7_8.bits.F2_LS_DISPENSER_UP_8 = NO_LIMIT;
break;
default :
- //error
- break;
+ LM_Status = NO_LIMIT;
+ break;
}
return LM_Status;
}
@@ -376,13 +376,20 @@ uint32_t Control_WD(bool IsEnable, unsigned char SetTimer_Steps100mSec) // Contr
*/
{
#ifndef EVALUATION_BOARD
+
+ short WD_Enable = 0x4000 | SetTimer_Steps100mSec;
+
if (IsEnable == DISABLE)
{
+ F1_Watchdog_reg = 0;
F2_Watchdog_reg = 0;
+ F3_Watchdog_reg = 0;
}
else
{
- F2_Watchdog_reg = 0x4000 | SetTimer_Steps100mSec; // Enable the watchdog
+ F1_Watchdog_reg = WD_Enable; // Enable the watchdog F3_GPO_01_bus BIT4 DYEINGH_SSR11_CTRL HeadHeaterZ6
+ F2_Watchdog_reg = WD_Enable; // Enable the watchdog F2_CTRL + reset dispensers motor drivers
+ F3_Watchdog_reg = WD_Enable; // Enable the watchdog F1_gpo_01 BIT2 DYEINGH_SSR10_CTRL HeadHeaterZ5
}
#endif
return OK;
diff --git a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/Flash_Memory.c b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/Flash_Memory.c
index 944abb737..702ecafcc 100644
--- a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/Flash_Memory.c
+++ b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/Flash_Memory.c
@@ -3,6 +3,11 @@
//see also https://github.com/yuvadm/tiva-c/blob/master/boards/dk-tm4c129x/drivers/mx66l51235f.c
//On board Quad SPI 512Mb Flash
+
+//Macronixýþ þýMX66L51235FZ2I-10Gýþ
+//Sector Size 4KB
+
+
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
@@ -47,6 +52,12 @@
#define INS_PAGE_PROGRAM 0x02
#define INS_READ_DATA 0x03
+//-------------------- AVI: based on https://github.com/turingo/stm32ss/blob/master/src/stm32ss/bsp/sf.c
+#define INS_BLOCK_ERASE (0xd8)
+#define INS_CHIP_ERASE (0xc7)
+#define INS_WRITE_DISABLE (0x04)
+//-------------------------
+
#if defined(ewarm)
#pragma data_alignment=1024
tDMAControlTable g_sDMAControlTable[6];
@@ -610,13 +621,36 @@ int Read_Ext_Flash_Device_ID()
return 0;
}
-int Erase_Sector_before_writting_To_Ext_Flash(uint32_t ui32Address)
+int Erase_Sector_before_writting_To_Ext_Flash(uint32_t ui32Address)// 4Kb every 100h is sector (0-0xFFF, 0x1000-0x1fff,..)
{
SSILibSendEraseCommand(SSI3_BASE,ui32Address,INS_SECTOR_ERASE_4KB);
return 0;
}
+int Erase_Block(uint32_t ui32Address)// 32Kb or 64Kb ?
+{
+ //writeLine("Starting Erase Block Operations...");
+
+
+ SSILibSendEraseCommand(SSI3_BASE,ui32Address,INS_BLOCK_ERASE );
+
+ //writeLine("Erase Block Completed...");
+
+ return 0;
+}
+
+int Erase_Chip()// 32Kb or 64Kb ?
+{
+ //writeLine("Starting Erase Block Operations...");
+
+ SSILibSendEraseCommand(SSI3_BASE,0,INS_CHIP_ERASE );
+
+ //writeLine("Erase Block Completed...");
+
+ return 0;
+}
+
int Write_Words_To_Ext_Flash(uint32_t ui32Address, uint32_t NumOfWords, uint32_t* TxBuf)
{
@@ -714,7 +748,8 @@ int Ext_Flash_Operation(uint32_t ui32Address,uint32_t Operation, uint32_t NumOf
Display_RX_TX_Ext_Flash_Data(NumOfWords, pui32DataTx, NULL);
// Erase the Sector before Program Operation...
- Erase_Sector_before_writting_To_Ext_Flash(ui32Address);
+ Erase_Sector_before_writting_To_Ext_Flash(ui32Address);//Erase all the sector not only from this address
+ //Erase_Block(ui32Address);//Added by AVI for testing
// Write NUM_SSI_DATA words to the External Flash
Write_Words_To_Ext_Flash(ui32Address, NumOfWords, pui32DataTx);
@@ -750,7 +785,7 @@ Flash_Union Flash_RW;
uint32_t WriteBuf[MaxFlashBytes];
uint32_t ReadBuf[MaxFlashBytes];
-
+/*
uint32_t ExtFlashWriteBuf(uint32_t ui32Address,uint32_t NumOfWords, uint32_t* pui32DataTx)
{
static uint32_t AddressCounter = 0;
@@ -795,9 +830,63 @@ uint32_t ExtFlashWriteBuf(uint32_t ui32Address,uint32_t NumOfWords, uint32_t* p
Ext_Flash_Operation(0X00 + (0X100*AddressCounter), TX, No_Bytes , WriteBuf, NULL );////always use address 0 and handle the add by the AddressCounter
}
- return return_start_address;
+ return return_start_address;// for reading what we just wrote
}
+*/
+
+uint32_t ExtFlashWriteBuf(/*uint32_t ui32Address,*/uint32_t NumOfWords, uint32_t* pui32DataTx)//ui32Address not in use
+{
+ uint32_t AddressCounter = 0;
+ uint32_t i;
+ uint32_t No_Bytes;
+
+ static uint32_t Current_Start_address = 0x00;
+ uint32_t Save_Current_Start_address = 0x00;
+
+ assert(NumOfWords <= MaxFlashWords);
+
+ No_Bytes = NumOfWords *4;
+
+ uint32_t Current_End_address = Current_Start_address + No_Bytes;
+
+ memset(&Flash_RW,0,sizeof(Flash_RW));
+
+ for(i = 0; i < NumOfWords;i++)
+ {
+ Flash_RW.DWords[i] = pui32DataTx[i];
+ }
+
+ for(i = 0; i < No_Bytes;i++)
+ {
+ WriteBuf[i] = Flash_RW.Bytes[i];
+ }
+
+ if(No_Bytes >MaxBytesForAddress)
+ {
+ uint32_t number = No_Bytes / MaxBytesForAddress;
+ uint32_t Remainder = No_Bytes % MaxBytesForAddress;
+
+ for(i=0;i<number;i++,AddressCounter++)
+ {
+ Ext_Flash_Operation(Current_Start_address + (0X100*AddressCounter) , TX, MaxBytesForAddress , WriteBuf+ (MaxBytesForAddress*i), NULL ); //always use address 0 and handle the add by the AddressCounter
+ }
+ if(Remainder)
+ {
+ Ext_Flash_Operation(Current_Start_address + (0X100*AddressCounter) , TX, Remainder , WriteBuf+ (MaxBytesForAddress*i), NULL );////always use address 0 and handle the add by the AddressCounter
+ }
+ }
+ else
+ {
+ Ext_Flash_Operation(Current_Start_address, TX, No_Bytes , WriteBuf, NULL );////always use address 0 and handle the add by the AddressCounter
+ }
+
+ Save_Current_Start_address = Current_Start_address;
+
+ Current_Start_address = Current_End_address;// for the next time
+
+ return Save_Current_Start_address;// for reading the data that we just wrote
+}
uint32_t* ExtFlashReadBuf(uint32_t ui32Address,uint32_t NumOfWords )
@@ -805,7 +894,7 @@ uint32_t* ExtFlashReadBuf(uint32_t ui32Address,uint32_t NumOfWords )
uint32_t No_Bytes;
- static uint32_t AddressCounter = 0;
+ uint32_t AddressCounter = 0;
uint32_t i = 0;
assert(NumOfWords <= MaxFlashWords);
@@ -830,7 +919,7 @@ uint32_t* ExtFlashReadBuf(uint32_t ui32Address,uint32_t NumOfWords )
}
else
{
- Ext_Flash_Operation(ui32Address + (0X100*AddressCounter), RX, No_Bytes, NULL, ReadBuf );
+ Ext_Flash_Operation(ui32Address, RX, No_Bytes, NULL, ReadBuf );
}
for(i = 0; i < No_Bytes;i++)
diff --git a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/Flash_Memory.h b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/Flash_Memory.h
index e0f9eb9f7..cca2cd848 100644
--- a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/Flash_Memory.h
+++ b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/Flash_Memory.h
@@ -4,7 +4,7 @@
int Ext_Flash_Operation();
int FlashFS_Init();
-uint32_t ExtFlashWriteBuf(uint32_t ui32Address,uint32_t NumOfWords, uint32_t* pui32DataTx);
+uint32_t ExtFlashWriteBuf(/*uint32_t ui32Address,*/uint32_t NumOfWords, uint32_t* pui32DataTx);
uint32_t* ExtFlashReadBuf(uint32_t ui32Address,uint32_t NumOfWords );
extern Flash_Union Flash_RW;