big refactoring and features added
This commit is contained in:
+23
-149
@@ -65,12 +65,8 @@ extern "C" {
|
||||
|
||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
void Error_Handler(void);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
void Set_LTEC(uint8_t, uint16_t);
|
||||
/* USER CODE END EFP */
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
void Error_Handler(void);
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
#define INP_0_Pin GPIO_PIN_3
|
||||
@@ -166,149 +162,27 @@ void Set_LTEC(uint8_t, uint16_t);
|
||||
#define OUT_9_Pin GPIO_PIN_7
|
||||
#define OUT_9_GPIO_Port GPIOB
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
#define CL_16 15
|
||||
#define DL_16 15
|
||||
#define CL_8 30
|
||||
#define DL_8 30
|
||||
#define TSK_8 32
|
||||
#define TSK_16 16
|
||||
|
||||
|
||||
// #define SD_Length 100
|
||||
|
||||
#define HALT 0
|
||||
#define DECODE_ENABLE 1
|
||||
#define DEFAULT_ENABLE 2
|
||||
#define TRANS_S_ENABLE 3
|
||||
#define TRANS_ENABLE 4
|
||||
#define REMOVE_FILE 5
|
||||
#define STATE 6
|
||||
#define WORK_ENABLE 7
|
||||
#define DECODE_TASK 8
|
||||
#define RUN_TASK 9
|
||||
#define AD9102_CMD 10
|
||||
#define AD9833_CMD 11
|
||||
#define DS1809_CMD 12
|
||||
#define STM32_DAC_CMD 13
|
||||
#define AD9102_WAVE_CTRL_CMD 14
|
||||
#define AD9102_WAVE_DATA_CMD 15
|
||||
|
||||
#define SD_ERR 0x01
|
||||
#define UART_ERR 0x02
|
||||
#define UART_DECODE_ERR 0x04
|
||||
#define TEC1_ERR 0x08
|
||||
#define TEC2_ERR 0x10
|
||||
#define DEFAUL_ERR 0x20
|
||||
#define REMOVE_ERR 0x40
|
||||
#define AD9102_ERR 0x80
|
||||
|
||||
#define NO_MESS 0
|
||||
#define MESS_01 1
|
||||
#define MESS_02 2
|
||||
#define MESS_03 3
|
||||
|
||||
// AD9102 serial command (compatible header with PC tool)
|
||||
#define AD9102_CMD_HEADER 0x8888
|
||||
#define AD9102_CMD_8 10 // total bytes including header
|
||||
#define AD9102_CMD_WORDS 4 // data words (flags, freq LSW, freq MSW, checksum)
|
||||
#define AD9833_CMD_HEADER 0x9999
|
||||
#define AD9833_CMD_8 10 // total bytes including header
|
||||
#define AD9833_CMD_WORDS 4 // data words (flags, freq LSW, freq MSW, checksum)
|
||||
#define DS1809_CMD_HEADER 0xAAAA
|
||||
#define DS1809_CMD_8 10 // total bytes including header
|
||||
#define DS1809_CMD_WORDS 4 // data words (flags, count, pulse_ms, checksum)
|
||||
#define STM32_DAC_CMD_HEADER 0xBBBB
|
||||
#define STM32_DAC_CMD_8 10 // total bytes including header
|
||||
#define STM32_DAC_CMD_WORDS 4 // data words (flags, dac_code, reserved, checksum)
|
||||
#define AD9102_WAVE_CTRL_HEADER 0xCCCC
|
||||
#define AD9102_WAVE_CTRL_8 10 // total bytes including header
|
||||
#define AD9102_WAVE_CTRL_WORDS 4 // data words (opcode, param0, param1, checksum)
|
||||
#define AD9102_WAVE_DATA_HEADER 0xDDDD
|
||||
#define AD9102_WAVE_DATA_8 30 // total bytes including header
|
||||
#define AD9102_WAVE_DATA_WORDS 14 // data words (count, 12 samples, checksum)
|
||||
|
||||
#define AD9102_ON_SPI2 1
|
||||
|
||||
// AD9102 CS (chip select) uses AD9102_CS_* pin definitions above.
|
||||
|
||||
typedef struct{
|
||||
|
||||
uint8_t WORK_EN;
|
||||
uint8_t U5V1_EN;
|
||||
uint8_t U5V2_EN;
|
||||
uint8_t LD1_EN;
|
||||
uint8_t LD2_EN;
|
||||
uint8_t REF1_EN;
|
||||
uint8_t REF2_EN;
|
||||
uint8_t TEC1_EN;
|
||||
uint8_t TEC2_EN;
|
||||
uint8_t TS1_EN;
|
||||
uint8_t TS2_EN;
|
||||
uint8_t SD_EN;
|
||||
uint8_t PI1_RD;
|
||||
uint8_t PI2_RD;
|
||||
|
||||
uint16_t AVERAGES;
|
||||
uint16_t MES_ID;
|
||||
|
||||
}Work_SetupTypeDef;
|
||||
|
||||
typedef struct{
|
||||
|
||||
uint16_t LD_TEMP;
|
||||
float P_coef_temp;
|
||||
float I_coef_temp;
|
||||
uint16_t CURRENT;
|
||||
|
||||
}LDx_SetupTypeDef;
|
||||
|
||||
typedef struct{
|
||||
|
||||
uint16_t LD_CURR_TEMP;
|
||||
float e_integral;
|
||||
uint16_t POWER;
|
||||
|
||||
}LDx_ParamTypeDef;
|
||||
|
||||
typedef enum _task_type_t
|
||||
{
|
||||
TT_CHANGE_CURR_1 = 0x1,
|
||||
TT_CHANGE_CURR_2 = 0x2,
|
||||
TT_CHANGE_TEMP_1 = 0x3,
|
||||
TT_CHANGE_TEMP_2 = 0x4,
|
||||
} task_type_t;
|
||||
|
||||
typedef struct _task_t
|
||||
{
|
||||
task_type_t task_type;
|
||||
float min_param;
|
||||
float max_param;
|
||||
float delta_param; // change step between min_param and max_param
|
||||
float current_param; // current_param is iterating by summary with delta_param every interrupt
|
||||
uint8_t dt; // microseconds
|
||||
uint16_t tau; // milliseconds or microseconds?
|
||||
float sec_param;
|
||||
float curr;
|
||||
float temp;
|
||||
float i_coef_1;
|
||||
float p_coef_1;
|
||||
float i_coef_2;
|
||||
float p_coef_2;
|
||||
} task_t;
|
||||
|
||||
|
||||
typedef struct{
|
||||
task_type_t task_type;
|
||||
uint16_t signal_pin;
|
||||
GPIO_TypeDef * signal_port;
|
||||
uint16_t param;
|
||||
uint8_t state; //0 -- disabled (do nothing);
|
||||
//1 -- update LD current;
|
||||
//2 -- blinking, set LD ON now;
|
||||
//3 -- blinking, set LD OFF now
|
||||
} LD_Blinker_StateTypeDef;
|
||||
/* USER CODE END Private defines */
|
||||
/* USER CODE BEGIN Private defines */
|
||||
/* Board-level extensions only. Application-layer types live under App/. */
|
||||
#define UI_LCD_RS_Pin GPIO_PIN_9
|
||||
#define UI_LCD_RS_GPIO_Port GPIOG
|
||||
#define UI_LCD_V0_REF_Pin GPIO_PIN_7
|
||||
#define UI_LCD_V0_REF_GPIO_Port GPIOD
|
||||
#define UI_LCD_CONTRAST_PWM_Pin GPIO_PIN_8
|
||||
#define UI_LCD_CONTRAST_PWM_GPIO_Port GPIOB
|
||||
#define UI_LCD_E_Pin OUT_0_Pin
|
||||
#define UI_LCD_E_GPIO_Port OUT_0_GPIO_Port
|
||||
#define UI_BUTTON_Pin OUT_1_Pin
|
||||
#define UI_BUTTON_GPIO_Port OUT_1_GPIO_Port
|
||||
#define UI_LCD_D4_Pin OUT_2_Pin
|
||||
#define UI_LCD_D4_GPIO_Port OUT_2_GPIO_Port
|
||||
#define UI_LCD_D5_Pin OUT_3_Pin
|
||||
#define UI_LCD_D5_GPIO_Port OUT_3_GPIO_Port
|
||||
#define UI_LCD_D6_Pin OUT_4_Pin
|
||||
#define UI_LCD_D6_GPIO_Port OUT_4_GPIO_Port
|
||||
#define UI_LCD_D7_Pin OUT_5_Pin
|
||||
#define UI_LCD_D7_GPIO_Port OUT_5_GPIO_Port
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user