big refactoring and features added

This commit is contained in:
Ayzen
2026-04-24 16:51:15 +03:00
parent eafc328caa
commit ea1fbb071d
184 changed files with 35336 additions and 75480 deletions

View File

@ -1,69 +0,0 @@
/*
* File_Handling_RTOS.h
*
* Created on: 14-May-2020
* Author: Controllerstech
*/
#ifndef FILE_HANDLING_RTOS_H_
#define FILE_HANDLING_RTOS_H_
#include "fatfs.h"
#include <string.h>
#include "stdio.h"
#include "fatfs.h"
/* mounts the sd card*/
int Mount_SD (const TCHAR* path);
/* unmounts the sd card*/
int Unmount_SD (const TCHAR* path);
/* Start node to be scanned (***also used as work area***) */
FRESULT Scan_SD (char* pat);
/* Only supports removing files from home directory. Directory remover to be added soon */
FRESULT Format_SD (void);
/* write the data to the file
* @ name : is the path to the file*/
FRESULT Write_File (char *name, char *data);
/* write the data to the file
* @ name : is the path to the file tooooooooooooooooooooooooooooooooooooooooooooooooo*/
FRESULT Write_File_byte (char *name, uint8_t *data, unsigned int bytesize);
/* read data from the file
* @ name : is the path to the file*/
FRESULT Read_File (char *name);
FRESULT Seek_Read_File (char *name, uint8_t *data, unsigned int bytesize, unsigned long goto_label);
/* creates the file, if it does not exists
* @ name : is the path to the file*/
FRESULT Create_File (char *name);
/* Removes the file from the sd card
* @ name : is the path to the file*/
FRESULT Remove_File (char *name);
/* creates a directory
* @ name: is the path to the directory
*/
FRESULT Create_Dir (char *name);
/* checks the free space in the sd card*/
void Check_SD_Space (void);
/* updates the file. write pointer is set to the end of the file
* @ name : is the path to the file
*/
FRESULT Update_File (char *name, char *data);
FRESULT Update_File_float (char *name, float *data, unsigned int bytesize);
FRESULT Update_File_byte (char *name, uint8_t *data, unsigned int bytesize);
#endif /* FILE_HANDLING_RTOS_H_ */

View File

@ -60,10 +60,19 @@
/* USER CODE END 0 */
#else
/* USER CODE BEGIN BSP_H_CODE */
/* Exported functions --------------------------------------------------------*/
uint8_t BSP_SD_Init(void);
/* USER CODE BEGIN BSP_H_CODE */
typedef struct bsp_sd_debug_info_t
{
uint8_t last_init_status;
uint8_t last_detect_status;
uint8_t last_hal_init_status;
uint8_t last_wide_bus_status;
uint32_t last_hal_error;
} bsp_sd_debug_info_t;
/* Exported functions --------------------------------------------------------*/
uint8_t BSP_SD_Init(void);
uint8_t BSP_SD_ITConfig(void);
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout);
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout);
@ -76,10 +85,11 @@ uint8_t BSP_SD_IsDetected(void);
/* These functions can be modified in case the current settings (e.g. DMA stream)
need to be changed for specific application needs */
void BSP_SD_AbortCallback(void);
void BSP_SD_WriteCpltCallback(void);
void BSP_SD_ReadCpltCallback(void);
/* USER CODE END BSP_H_CODE */
void BSP_SD_AbortCallback(void);
void BSP_SD_WriteCpltCallback(void);
void BSP_SD_ReadCpltCallback(void);
void BSP_SD_GetDebugInfo(bsp_sd_debug_info_t *out_info);
/* USER CODE END BSP_H_CODE */
#endif
#ifdef __cplusplus

View File

@ -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
}

View File

@ -27,15 +27,18 @@
/* can be used to modify / undefine following code or add new definitions */
/* USER CODE END firstSection */
/* Includes ------------------------------------------------------------------*/
#include "bsp_driver_sd.h"
/* Includes ------------------------------------------------------------------*/
#include "ff_gen_drv.h"
#include "bsp_driver_sd.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
extern const Diskio_drvTypeDef SD_Driver;
/* USER CODE BEGIN lastSection */
/* can be used to modify / undefine previous code or add new definitions */
/* USER CODE END lastSection */
/* Exported functions ------------------------------------------------------- */
extern const Diskio_drvTypeDef SD_Driver;
/* USER CODE BEGIN lastSection */
/* can be used to modify / undefine previous code or add new definitions */
DSTATUS sd_diskio_debug_get_last_initialize_status(void);
DSTATUS sd_diskio_debug_get_last_status_result(void);
/* USER CODE END lastSection */
#endif /* __SD_DISKIO_H */

View File

@ -54,16 +54,13 @@ void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
void ADC_IRQHandler(void);
void TIM1_UP_TIM10_IRQHandler(void);
void TIM1_TRG_COM_TIM11_IRQHandler(void);
void TIM2_IRQHandler(void);
void USART1_IRQHandler(void);
void TIM8_UP_TIM13_IRQHandler(void);
void TIM5_IRQHandler(void);
void TIM6_DAC_IRQHandler(void);
void TIM7_IRQHandler(void);
void SysTick_Handler(void);
void ADC_IRQHandler(void);
void TIM2_IRQHandler(void);
void USART1_IRQHandler(void);
void TIM5_IRQHandler(void);
void TIM6_DAC_IRQHandler(void);
void TIM7_IRQHandler(void);
void DMA2_Stream7_IRQHandler(void);
/* USER CODE BEGIN EFP */