diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2020-12-20 12:17:26 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2020-12-20 12:17:26 +0200 |
| commit | 3f3d743a3f93c17571b681df94d4d9d1848614fa (patch) | |
| tree | 9cb0097a4f7f843b91d878c1ff3b50a2a61d7f58 /Software/Embedded_SW | |
| parent | 295cc6981e5fca0f958c7aef06ee9cf8f25a762c (diff) | |
| parent | 1e76d8115d4eae085c79cf9f1debfd8c672b2812 (diff) | |
| download | Tango-3f3d743a3f93c17571b681df94d4d9d1848614fa.tar.gz Tango-3f3d743a3f93c17571b681df94d4d9d1848614fa.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW')
| -rw-r--r-- | Software/Embedded_SW/Embedded/DataDef.h | 2 | ||||
| -rw-r--r-- | Software/Embedded_SW/Embedded/Drivers/Uart_Comm/BTSR/BTSR.c | 165 |
2 files changed, 165 insertions, 2 deletions
diff --git a/Software/Embedded_SW/Embedded/DataDef.h b/Software/Embedded_SW/Embedded/DataDef.h index 348ed37f6..001303c88 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -20,7 +20,7 @@ #define NO_INITIAL_HEATING #define MAX_STRING_LEN 255 //Embedded version + filter.c -//#define WATCHDOG +#define WATCHDOG //#define DISPESER_TEST //#define FPGA_WATCHDOG_DISABLE diff --git a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/BTSR/BTSR.c b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/BTSR/BTSR.c index 12699a1fd..92337080d 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/BTSR/BTSR.c +++ b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/BTSR/BTSR.c @@ -77,7 +77,7 @@ void U4RX() void uart4_intHandler() { - static uint8_t nop = 0; + //static uint8_t nop = 0; //Get interrupt flags unsigned long status = UARTIntStatus(UART4_BASE, 1); @@ -626,5 +626,168 @@ uint8_t BTSR_Read_Status(uint8_t BTSR_Id, uint8_t Application, uint8_t Yarn_Type return ERROR; } +//---------------------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------- +//BTSR_ALARM_AND_ENABLING_STATUS_READ +typedef struct +{ + bool D0 : 1;//0 + bool D1 : 1;//1 + bool D2 : 1;//2 + bool D3 : 1;//3 + bool D4 : 1;//4 + bool D5 : 1;//5 + bool D6 : 1;//6 + bool D7 : 1;//7 +}BITS; + + +typedef union +{ + BITS Bit[4]; + uint8_t Byte[4]; +}BTSR_ALARM_AND_ENABLING_STATUS_READ; + +BTSR_ALARM_AND_ENABLING_STATUS_READ BTSR_Status; + +void BTSR_Configuration_Set(uint8_t UFeeder_ID) +{ + memset(BTSR_TX_Buff, 0, Max_BTSR_TX_Bytes); + + BTSR_TX_Buff[0] = UFeeder_ID; + BTSR_TX_Buff[1] = 0x36; + BTSR_TX_Buff[2] = 0x80;//CCW + BTSR_TX_Buff[3] = 0x01;//YYT OFF, UNICO OFF + BTSR_TX_Buff[4] = 0x40;//FLIP DISPLAY + + BTSR_Calculate_CheckSum(BTSR_TX_Buff,18); + + BTSR_Send_Buf(Typology_Set.Buf, 20); + +} + +void BTSR_Alarm_and_Enabling_Status_Read(uint8_t UFeeder_ID) +{ + memset(BTSR_TX_Buff, 0, Max_BTSR_TX_Bytes); + + BTSR_TX_Buff[0] = UFeeder_ID; + BTSR_TX_Buff[1] = 0x1C; + + BTSR_Calculate_CheckSum(BTSR_TX_Buff,2); + + BTSR_Send_Buf(Typology_Set.Buf, 4); +} + +typedef enum +{ + //BTSR_READ + DEVICE_INFORMATION_READ_10 , + ADVANCED_PROGRAMMING_READ_18 , + ADVANCED_TENSION_READ_23 , + APPLICATION_AND_YARN_TYPOLOGY_READ_28 , + ALARM_AND_ENABLING_STATUS_READ_30 , + PC_LINK_READ_32 , + METERS_TOTAL_COUNTER_READ_LOW_37 , + METERS_TOTAL_COUNTER_READ_HIGH_39 , + METER_TOTAL_COUNTER_READ_HIGHEST_41 , + MAX_BTSR_READ , + + //BTSR_SET + //return 0xFA/0xFB/0xF9 + DEVICE_CALIBRATION_11 , + BAUDRATE_SET_13 , + DISPLAY_LANGUAGE_SET_14 , + CONFIGURATION_SET_15 , + ADVANCED_CONFIGURATION_SET_17 , + INPUT_CURRENT_CONTROL_SET_20 , + ADVANCED_TENSION_PROGRAMMING_21 , + ADVANCED_STYLE_LOAD_25 , + APPLICATION_AND_YARN_TYPOLOGY_SET_27 , + WORK_TENSION_AND_OPERATION_STATUS_SET_29 , + ALARM_STATUS_RESET_35 , + RESETS_ALL_THE_COUNTERS_36 , + //return device + Function code + METERS_TOTAL_COUNTER_RESET_LOW_38 , + METERS_TOTAL_COUNTER_RESET_HIGH_40 , + METERS_TOTAL_COUNTER_RESET_HIGHEST_42 , + MAX_BTSR_SET +}BTSR_CMD; + +#define Get_Set_resp 5 +#define Set_Command 6 + +#define Get_Read_resp 7 +#define Read_Command 8 + +BTSR_CMD BTSR_command_Stage[MAX_BTSR_SET]; + +uint8_t BTSR_State_Machine(uint8_t UFeeder_ID) +{ + uint8_t status = OK; + uint8_t i; + + for(i = DEVICE_CALIBRATION_11; i < MAX_BTSR_SET; i++) + { + if(BTSR_command_Stage[i] == Get_Set_resp) + { + if((i >= DEVICE_CALIBRATION_11) && (i <= RESETS_ALL_THE_COUNTERS_36) /*&& (BTSR_RX_Buff[0] != BTSR_RISP_OK)*/) + { + status = ERROR; + BTSR_command_Stage[i] = BTSR_RX_Buff[0]; + //print response + command ID + } + else if(((i == METERS_TOTAL_COUNTER_RESET_LOW_38) && (BTSR_RX_Buff[1] != 0x06)) || + ((i == METERS_TOTAL_COUNTER_RESET_HIGH_40) && (BTSR_RX_Buff[1] != 0x1E)) || + ((i == METERS_TOTAL_COUNTER_RESET_HIGHEST_42) && (BTSR_RX_Buff[1] != 0x48)) ) + { + status = ERROR; + BTSR_command_Stage[i] = BTSR_RX_Buff[1]; + //print response + command ID + } + //print response + command ID + BTSR_command_Stage[i] = OK; + } + + if(BTSR_command_Stage[i] == Set_Command) + { + if(i == CONFIGURATION_SET_15) + { + BTSR_Configuration_Set(UFeeder_ID); + } + + BTSR_command_Stage[i] = Get_Set_resp; + return status;//Only one command in cycle + } + } + + + for(i = DEVICE_INFORMATION_READ_10; i < MAX_BTSR_READ; i++) + { + if(BTSR_command_Stage[i] == Get_Read_resp) + { + // Add CRC check + if(i == ALARM_AND_ENABLING_STATUS_READ_30) + { + for(i = 0; i < 4; i++) + BTSR_Status.Byte[i] = BTSR_RX_Buff[i]; + } + BTSR_command_Stage[i] = 0; + } + + if(BTSR_command_Stage[i] == Read_Command) + { + + if(i == ALARM_AND_ENABLING_STATUS_READ_30) + { + BTSR_Alarm_and_Enabling_Status_Read(UFeeder_ID); + } + BTSR_command_Stage[i] = Get_Read_resp; + return status;//Only one command in cycle + } + } + + return status; +} |
