aboutsummaryrefslogtreecommitdiffstats
path: root/Software
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-03-11 19:46:54 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-03-11 19:46:54 +0200
commit53dd323db3ab3608743bb29ac40128a41b42e09f (patch)
tree17131d7c6721d901ac6679909fd968446351f5c0 /Software
parent057b7d9d9916144fed099ac8573a864c45cd0146 (diff)
parent96c8bd8c897b2620dd97b5d852e46ade86b6a4ee (diff)
downloadTango-53dd323db3ab3608743bb29ac40128a41b42e09f.tar.gz
Tango-53dd323db3ab3608743bb29ac40128a41b42e09f.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software')
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/EEPROM/Dispenser_EEPROM.c (renamed from Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispensers_EEPROM_MUX/Disp_EEPROM_MUX.c)28
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/EEPROM/Dispenser_EEPROM.h (renamed from Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispensers_EEPROM_MUX/Disp_EEPROM_MUX.h)4
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/I2C_Dispenser_Card_Mux.c37
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/I2C_Dispenser_Card_Mux.h16
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.c108
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.h76
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispensers_IO_Port/IO.c10
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispensers_IO_Port/IO.h21
-rw-r--r--Software/Embedded_SW/Embedded/Main.c2
9 files changed, 250 insertions, 52 deletions
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispensers_EEPROM_MUX/Disp_EEPROM_MUX.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/EEPROM/Dispenser_EEPROM.c
index 5954560ef..0e32f664f 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispensers_EEPROM_MUX/Disp_EEPROM_MUX.c
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/EEPROM/Dispenser_EEPROM.c
@@ -17,9 +17,10 @@
#include "drivers/I2C_Communication/I2C.h"
#include "StateMachines/Printing/PrintingSTM.h"
#include "driverlib/i2c.h"
+#include "drivers/I2C_Communication/Dispenser_Card/I2C_Dispenser_Card_Mux.h"
+
+
-#define I2C_ID_DISP_EEPROM_MUX 0x04
-#define TCA9548A_ADDRESS 0xE2 // switch address
#define I2C_Slave_EEprom_Add 0xA0 //eeprom address - 32kByte & 128kByte
#define I2C_Slave_EEprom_Add_2 0xA2 //eeprom address - only in the eeprom of 128kByte
@@ -40,18 +41,7 @@
uint8_t Write_Buf[Max_buf_size +2];
-uint32_t Select_EEprom_Mux_Channel(uint8_t Dispenser_ID)
-{
- uint32_t status= OK;
-
- assert(Dispenser_ID < MAX_DISPENSER_NUM);
- Write_Buf[0] = 0x01 << Dispenser_ID;
-
- status = I2C_Write(I2C_ID_DISP_EEPROM_MUX, TCA9548A_ADDRESS, Write_Buf, 1);
-
- return status;
-}
uint32_t I2C_EEprom_Write_Ch(uint8_t Dispenser_ID, uint8_t EEprom_Add)
{
@@ -60,7 +50,7 @@ uint32_t I2C_EEprom_Write_Ch(uint8_t Dispenser_ID, uint8_t EEprom_Add)
uint8_t i = 0;
- status |= Select_EEprom_Mux_Channel(Dispenser_ID);
+ status |= Select_Dispenser_Mux_Channel(Dispenser_ID);
Write_Buf[0] = 0x00;
Write_Buf[1] = 0x00;
@@ -70,7 +60,7 @@ uint32_t I2C_EEprom_Write_Ch(uint8_t Dispenser_ID, uint8_t EEprom_Add)
Write_Buf[i+2] = Dispenser_struct[Dispenser_ID].Write_Disp_EEPROM.Buf[i];
}
- status |= I2C_Write(I2C_ID_DISP_EEPROM_MUX, EEprom_Add, Write_Buf, Max_buf_size+2);
+ status |= I2C_Write(I2C_ID_DISP_MUX, EEprom_Add, Write_Buf, Max_buf_size+2);
return status;
}
@@ -79,12 +69,12 @@ uint32_t I2C_EEprom_Set_for_Read_Ch(uint8_t Dispenser_ID, uint8_t EEprom_Add)
{
uint32_t status= OK;
- status |= Select_EEprom_Mux_Channel(Dispenser_ID);
+ status |= Select_Dispenser_Mux_Channel(Dispenser_ID);
Write_Buf[0] = 0x00;
Write_Buf[1] = 0x00;
- status |= I2C_Write(I2C_ID_DISP_EEPROM_MUX, EEprom_Add, Write_Buf, 2);
+ status |= I2C_Write(I2C_ID_DISP_MUX, EEprom_Add, Write_Buf, 2);
return status;
}
@@ -93,9 +83,9 @@ uint32_t I2C_EEprom_Read_Ch(uint8_t Dispenser_ID, uint8_t EEprom_Add)
{
uint32_t status= OK;
- status |= Select_EEprom_Mux_Channel(Dispenser_ID);
+ status |= Select_Dispenser_Mux_Channel(Dispenser_ID);
- status |= I2C_Read(I2C_ID_DISP_EEPROM_MUX, EEprom_Add + 1, Dispenser_struct[Dispenser_ID].Read_Disp_EEPROM.Buf, Max_buf_size);
+ status |= I2C_Read(I2C_ID_DISP_MUX, EEprom_Add + 1, Dispenser_struct[Dispenser_ID].Read_Disp_EEPROM.Buf, Max_buf_size);
return status;
}
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispensers_EEPROM_MUX/Disp_EEPROM_MUX.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/EEPROM/Dispenser_EEPROM.h
index fff154cbd..76eee82af 100644
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispensers_EEPROM_MUX/Disp_EEPROM_MUX.h
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/EEPROM/Dispenser_EEPROM.h
@@ -8,7 +8,9 @@
#ifndef DRIVERS_I2C_COMMUNICATION_DISPENSERS_EEPROM_MUX_DISP_EEPROM_MUX_H_
#define DRIVERS_I2C_COMMUNICATION_DISPENSERS_EEPROM_MUX_DISP_EEPROM_MUX_H_
-uint32_t Select_EEprom_Mux_Channel(uint8_t Channel_ID);
+
+
+
uint32_t I2C_EEprom_Write_Ch(uint8_t Dispenser_ID);
uint32_t I2C_EEprom_Set_for_Read_Ch(uint8_t Dispenser_ID);;
uint32_t I2C_EEprom_Read_Ch(uint8_t Dispenser_ID);
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/I2C_Dispenser_Card_Mux.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/I2C_Dispenser_Card_Mux.c
new file mode 100644
index 000000000..0d1ea4615
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/I2C_Dispenser_Card_Mux.c
@@ -0,0 +1,37 @@
+/*
+ * I2C_Dispenser_Card_Mux.c
+ *
+ * Created on: Mar 11, 2019
+ * Author: avi
+ */
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <Container.h>
+#include <DataDef.h>
+#include <Drivers/I2C_Communication/Dispenser_Card/I2C_Dispenser_Card_Mux.h>
+#include "inc/hw_memmap.h"
+#include "inc/hw_types.h"
+#include "drivers/I2C_Communication/I2C.h"
+#include "StateMachines/Printing/PrintingSTM.h"
+#include "driverlib/i2c.h"
+
+
+uint32_t Select_Dispenser_Mux_Channel(uint8_t Dispenser_ID)
+{
+ uint32_t status= OK;
+
+ uint8_t Write_Buf[1];
+
+ assert(Dispenser_ID < MAX_DISPENSER_NUM);
+
+ Write_Buf[0] = 0x01 << Dispenser_ID;
+
+ status = I2C_Write(I2C_ID_DISP_MUX, TCA9548A_ADDRESS, Write_Buf, 1);
+
+ return status;
+}
+
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/I2C_Dispenser_Card_Mux.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/I2C_Dispenser_Card_Mux.h
new file mode 100644
index 000000000..c424ba6fa
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/I2C_Dispenser_Card_Mux.h
@@ -0,0 +1,16 @@
+/*
+ * I2C_Dispenser_Card.h
+ *
+ * Created on: Mar 11, 2019
+ * Author: avi
+ */
+
+#ifndef DRIVERS_I2C_COMMUNICATION_DISPENSER_CARD_I2C_DISPENSER_CARD_MUX_H_
+#define DRIVERS_I2C_COMMUNICATION_DISPENSER_CARD_I2C_DISPENSER_CARD_MUX_H_
+
+#define I2C_ID_DISP_MUX 0x04
+#define TCA9548A_ADDRESS 0xE2 // switch address
+
+uint32_t Select_Dispenser_Mux_Channel(uint8_t Channel_ID);
+
+#endif /* DRIVERS_I2C_COMMUNICATION_DISPENSER_CARD_I2C_DISPENSER_CARD_MUX_H_ */
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.c
new file mode 100644
index 000000000..e217aed67
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.c
@@ -0,0 +1,108 @@
+/*
+ * IO.c
+ *
+ * Created on: Mar 11, 2019
+ * Author: avi
+ */
+
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include "include.h"
+#include "drivers/I2C_Communication/I2C.h"
+#include "drivers/I2C_Communication/Dispenser_Card/I2C_Dispenser_Card_Mux.h"
+#include <Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.h>
+
+uint8_t TCA9534Init(uint8_t Dispenser_ID, TCA9534Regs* Regs)//2
+{
+ uint8_t status = PASSED;
+
+ uint8_t Write_Buf[2];
+
+ Regs->Config.Uchar = TCA9534_All_INPUT;
+
+ status |= Select_Dispenser_Mux_Channel(Dispenser_ID);
+
+ Write_Buf[0] = TCA9534_CONFIG_REG;
+ Write_Buf[1] = Regs->Config.Uchar;
+
+ status |= I2C_Write(I2C_ID_DISP_MUX, TCA9534_ADDRESS, Write_Buf, 2);
+
+ return status;
+
+}
+
+uint8_t TCA9534TestRelay(uint8_t Dispenser_ID, TCA9534Regs* Regs)//2
+{
+ uint8_t status = PASSED;
+
+ uint8_t Write_Buf[2];
+
+ Regs->Config.bit.RELAY_TEST = TCA9534_OUTPUT;
+
+ status |= Select_Dispenser_Mux_Channel(Dispenser_ID);
+
+ Write_Buf[0] = TCA9534_CONFIG_REG;
+ Write_Buf[1] = Regs->Config.Uchar;
+
+ status |= I2C_Write(I2C_ID_DISP_MUX, TCA9534_ADDRESS, Write_Buf, 2);
+
+ Regs->Config.bit.RELAY_TEST = TCA9534_INPUT;
+
+ return status;
+
+}
+
+uint8_t TCA9534ByPass(uint8_t Dispenser_ID, TCA9534Regs* Regs)//2
+{
+ uint8_t status = PASSED;
+
+ uint8_t Write_Buf[2];
+
+ Regs->Config.bit.BYPASS = TCA9534_OUTPUT;
+
+ status |= Select_Dispenser_Mux_Channel(Dispenser_ID);
+
+ Write_Buf[0] = TCA9534_CONFIG_REG;
+ Write_Buf[1] = Regs->Config.Uchar;
+
+ status |= I2C_Write(I2C_ID_DISP_MUX, TCA9534_ADDRESS, Write_Buf, 2);
+
+ Regs->Config.bit.BYPASS = TCA9534_INPUT;
+
+ return status;
+
+}
+
+// ****************************************************************************
+uint8_t TCA9534SetReadInputReg(uint8_t Dispenser_ID, TCA9534Regs* Regs)
+{
+ uint8_t status = PASSED;
+
+ uint8_t Write_Buf[1];
+
+ status |= Select_Dispenser_Mux_Channel(Dispenser_ID);
+
+ Write_Buf[0] = TCA9534_INPUT_REG;
+
+ status |= I2C_Write(I2C_ID_DISP_MUX, TCA9534_ADDRESS, Write_Buf, 1);
+
+
+ return status;
+}
+
+uint8_t TCA9534ReadInputReg(uint8_t Dispenser_ID, TCA9534Regs* Regs)
+{
+ uint8_t status = PASSED;
+
+ status |= Select_Dispenser_Mux_Channel(Dispenser_ID);
+
+ status |= I2C_Read(I2C_ID_DISP_MUX, TCA9534_ADDRESS + 1, Regs->Input.Uchar, 1);
+
+ return status;
+}
+
+
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.h
new file mode 100644
index 000000000..b40c25c2f
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.h
@@ -0,0 +1,76 @@
+/*
+ * IO.h
+ *
+ * Created on: Mar 11, 2019
+ * Author: avi
+ * Remote 8-Bit I2C Low-Power I/O Expander With Interrupt Output and Configuration Registers
+ */
+
+
+
+
+#ifndef DRIVERS_I2C_COMMUNICATION_DISPENSERS_IO_PORT_IO_H_
+#define DRIVERS_I2C_COMMUNICATION_DISPENSERS_IO_PORT_IO_H_
+
+
+
+
+/************************** I2C Address ***************************************/
+#define TCA9534_ADDRESS 0x40 // I2C Address 0100 + ADDR + R/W - ADDR tied to GND (permanent)
+
+/************************** I2C Registers *************************************/
+#define TCA9534_INPUT_REG 0x00 // Input status register
+#define TCA9534_OUTPUT_REG 0x01 // Output register to change state of output BIT set to 1, output set HIGH
+#define TCA9534_POLARITY_REG 0x02 // Polarity inversion register. BIT '1' inverts input polarity of register 0x00
+#define TCA9534_CONFIG_REG 0x03 // Configuration register. BIT = '1' sets port to input BIT = '0' sets port to output
+
+#define TCA9534_INPUT 0x01
+#define TCA9534_OUTPUT 0x00
+#define TCA9534_All_INPUT 0xFF
+
+
+
+typedef struct
+{
+ uint8_t RELAY_ON :1;//bit 0
+ uint8_t RELAY_TEST :1;//bit 1
+ uint8_t BYPASS :1;//bit 2
+ uint8_t DISP_UP :1;//bit 3
+ uint8_t DISP_DOWN :1;//bit 4
+ uint8_t OVER_PRESS :1;//bit 5
+ uint8_t P6 :1;//bit 6
+ uint8_t P7 :1;//bit 7
+}TCA9534_Pins;
+
+typedef union
+{
+ TCA9534_Pins bit;
+ uint8_t Uchar;
+}TCA9534_uConfig;
+
+typedef union
+{
+ TCA9534_Pins bit;
+ uint8_t Uchar;
+}TCA9534_uInput;
+
+typedef union
+{
+ TCA9534_Pins bit;
+ uint8_t Uchar;
+}TCA9534_uOutput;
+
+typedef union
+{
+ TCA9534_Pins bit;
+ uint8_t Uchar;
+}TCA9534_uPolarityInversion;
+
+typedef struct {
+ TCA9534_uInput Input;
+ TCA9534_uOutput Output;
+ TCA9534_uPolarityInversion PolarityInversion;
+ TCA9534_uConfig Config;
+} TCA9534Regs;
+
+#endif /* DRIVERS_I2C_COMMUNICATION_DISPENSERS_IO_PORT_IO_H_ */
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispensers_IO_Port/IO.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispensers_IO_Port/IO.c
deleted file mode 100644
index 4eb388d39..000000000
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispensers_IO_Port/IO.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * IO.c
- *
- * Created on: Mar 11, 2019
- * Author: avi
- */
-
-
-
-
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispensers_IO_Port/IO.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispensers_IO_Port/IO.h
deleted file mode 100644
index 5f79c7bcd..000000000
--- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispensers_IO_Port/IO.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * IO.h
- *
- * Created on: Mar 11, 2019
- * Author: avi
- *
- */
-
-
-
-
-#ifndef DRIVERS_I2C_COMMUNICATION_DISPENSERS_IO_PORT_IO_H_
-#define DRIVERS_I2C_COMMUNICATION_DISPENSERS_IO_PORT_IO_H_
-
- /*===============================================================================================================*
- I2C ADDRESS
- *===============================================================================================================*/
-
-
-
-#endif /* DRIVERS_I2C_COMMUNICATION_DISPENSERS_IO_PORT_IO_H_ */
diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c
index f14ef8ff1..64f4380a8 100644
--- a/Software/Embedded_SW/Embedded/Main.c
+++ b/Software/Embedded_SW/Embedded/Main.c
@@ -58,7 +58,7 @@
#include "Drivers/I2C_Communication/I2C.h"
-#include "Drivers/I2C_Communication/Dispensers_EEPROM_MUX/Disp_EEPROM_MUX.h"
+//#include "Drivers/I2C_Communication/Dispensers_EEPROM_MUX/Disp_EEPROM_MUX.h"
#include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h"