F203/Core/Inc/my.h

1248 lines
28 KiB
C
Raw Normal View History

2023-12-13 16:59:07 +03:00
/*
* my.h
*
* Created on: 26 <EFBFBD><EFBFBD><EFBFBD>. 2018 <EFBFBD>.
* Author: toporov
*/
#include "stm32f7xx_hal.h"
#include "stm32756g_eval_lcd.h"
#include "sram.h"
#include <stdbool.h>
#include <string.h>
#include "gpio.h"
#include "keys.h"
#include "arm_math.h"
#include "usart.h"
#include "IIRFilterCode.h"
#include "QuadRootsCode.h"
#define A142 (1)
//#define A148 (1)
#define CONFIG_CHANNELS (4u)
//****************************************************//
static const unsigned int MONTH_CODE[] = {0, 1, 4, 4, 0, 2, 5, 0, 3, 6, 1, 4, 6};
static const unsigned int MONTH[] = {6, 7, 1, 2, 3, 4, 5};
//****************************************************//
extern volatile uint32_t Fs;
#define OMEGAC(Fc) (float64_t) (((Fc) * 2.0) / ((float64_t) Fs))
//****************************************************//
#define HALF_UDAR_BUFF 16384UL
#define SIZE_UDAR_BUFF 32768UL
#define CF 4 //<2F><><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> 0
#define LEN_M_BUF 9 //<2F><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define DF 0.5f //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> [0 +-DF]
#define NUM_SAMPLES 16
#define CF_TACHO 4 //<2F><><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> 0
#define LEN_M_BUF_TACHO 5 //<2F><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define DF_TACHO 20.5f //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> [0 +-DF]
typedef enum
{
CHARGE_1 = 0,
KU_2,
KU_5,
KU_10,
KU_x10,
CHARGE_10,
CHARGE_0_1,
ICP_1,
ICP_10,
KU_200,
KU_500,
KU_1000
} IC_CORR;
#define DTCM __attribute__ ((section(".dtcmram")))
#define EXTRAM __attribute__ ((section (".memory_b1")))
#define RAM2 __attribute__ ((section (".sram2")))
#define ROLL_LEVEL (6.0f)
#define NUM_DEFECTS 12
typedef enum
{
BIENIE_VALA = 0,
PEREKOS_VNUTRENNEGO_KOLCA,
PEREKOS_NARUZHNOGO_KOLCA,
IZNOS_BEGOVOY_DOROZHKI_NARUZHNOGO_KOLCA,
ZADIRI_TRESCHINI_NA_NARUZHNOM_KOLCE,
IZNOS_BEGOVOY_DOROZHKI_VNUTRENNEGO_KOLCA,
ZADIRI_TRESCHINI_NA_VNUTRENNEM_KOLCE,
IZNOS_TEL_KACHENIYA_I_SEPARATORA,
RAKOVINI_SKOLI_NA_TELAH_KACHENIYA,
NEURAVNOVESHENNOST_ROTORA,
DEFECTI_UZLOV_KREPLENIYA,
NESOOSNOST
} DEFECTS_TYPE;
#define DRAW_LOGO
#ifdef DRAW_LOGO
//#define LOGO_GT
#endif
#define N_MED_MEAS 5
#define SIZE_ADC_BUFF 32768UL
#define ADC_POINTS 32
#define MAX_NAME 25
#define NUM_POINTS 1000
#define MAX_FILES 64
#define VIEW_FILES 12UL
#define MAX_CHECKED_FILES 512UL
#define GUI_CONST_STORAGE const
#define NUM_TO_ASCI(x) ((x) + 0x30)
#define ASCI_TO_NUM(x) ((x) - 0x30)
#define LO(x) ((uint8_t) ((x) & 0xFF))
#define HI(x) ((uint8_t) (((x) >> 8) & 0xFF))
#define VDD_REF (3.000f)
#define _b8 ((float32_t) ( VDD_REF / 128.0f))
#define _b12 ((float32_t) ( VDD_REF / 4096.0f))
#define _b16 ((float32_t) ( VDD_REF / 65536.0f))
#define _b16V ((float32_t) ((VDD_REF / 65536.0f) * 0.001f))
#define _b24V ((float32_t) ((VDD_REF / 16777215.0f) * 0.001f))
#define _2b12 ((float32_t) ((VDD_REF / 4096.0f) * 2.0f))
#define _b24 ((float32_t) (VDD_REF / 16777216.0f))
#define BIT0 0x0001
#define BIT1 0x0002
#define BIT2 0x0004
#define BIT3 0x0008
#define BIT4 0x0010
#define BIT5 0x0020
#define BIT6 0x0040
#define BIT7 0x0080
#define BIT8 0x0100
#define BIT9 0x0200
#define BIT10 0x0400
#define BIT11 0x0800
#define BIT12 0x1000
#define BIT13 0x2000
#define BIT14 0x4000
#define BIT15 0x8000
#define _1_2PI ((float32_t) 0.1591549431)
#define _2PI ((float32_t) 6.2831853071795865)
#define _4PI ((float32_t) 12.566370614359173)
#define _6PI ((float32_t) 18.849555921538759)
#define _8PI ((float32_t) 25.132741228718346)
//***************************** APPROX [ adcOut = ( adcIn * approx1) + approx0 ] !!! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> !!!
#define approx1 ((float32_t) 1.000009295e+0)
#define approx0 ((float32_t) -4.404903207e-5)
typedef enum
{
MSD_NOCARD = 0,
MSD_PRESENT = 1,
MSD_READY = 3
} SDSTATE;
typedef enum
{
FILE_OK = 0x00000000,
FILE_NOT_OPENED = 0x00000001,
FILE_NOT_WRITTED = 0x00000002,
FILE_NOT_READED = 0x00000004,
FILE_BAD_DATA = 0x00000008,
FILE_DATA_NOT_FOUND = 0x00000010,
FILE_WAV_ERROR = 0x00000020,
FILE_EXIST = 0x00000040,
FILE_FORMAT_ERROR = 0x00000080,
FILE_NO_CARD = 0x80000000
} FILE_RESULT;
typedef enum
{
AP_OK = 0x00000000,
AP_FAIL,
AP_INVALID_FILE,
AP_BAD_DATA,
AP_WRITE_UNABLE,
AP_INVALID_NAME,
AP_FILE_EXIST,
AP_SAVING_SUCCESS,
AP_SAVING_ERROR,
AP_WRITE_ERROR,
AP_READ_ERROR,
AP_DISK_ERROR,
AP_DELETE_OK,
AP_DELETE_ERROR,
AP_NO_FILES_FOR_DELETE,
AP_FORMAT_OK,
AP_FORMAT_ERROR,
AP_NO_CARD,
AP_ADC_FAIL
} APSTATUS;
typedef enum
{
RESULT_COMPLETE = 0,
RESULT_ERROR,
RESULT_PROCESSING,
}PROCEDURE_RESULT;
typedef enum { CHARGE = 0, ICP} typeIIN;
typedef enum { Ku0_1 = 0, Ku0_2, Ku0_5, Ku1, Ku2, Ku5, Ku10, Ku20, Ku50, Ku100, Ku200, Ku500, Ku1000 } typeIKU;
typedef enum { Hp0_2 = 0, Hp0_3, Hp1, Hp2, Hp10 } typeIFV;
typedef enum { Lp200 = 0, Lp500, Lp1000, Lp5000, Lp10000, Lp20000, Lp50000, Lp100000 } typeIFN;
typedef enum { RUS = 0, ENG } typeLANG;
typedef enum { SET_DOWN = 0, SET_UP} CR_StateTypeDef;
typedef enum { SET_ON = 0, SET_OFF} DispStateTypeDef;
typedef enum { IN1 = 0, IN10} InKpTypeDef;
typedef enum { VIB = 0, SPEC, OSC, FRAN, WAVE, SPEC_OGIB, SPEC_OKT, SPEC_THIRD, ROLL, UDAR, DIAGN } typeSYG;
typedef enum { ACC = 0, VEL, DIS } typeIPR;
typedef enum { PEAK = 0, RMS, PEAK_TO_PEAK, PEAK_FACTOR, EXCESS } typeIVS;
typedef enum { SPECTR = 0, WAVEFORM } typeUDAR;
typedef enum { _125Hz = 0, _250Hz, _500Hz, _1000Hz, _2000Hz, _4000Hz, _8000Hz, _16000Hz, _32000Hz, _64000Hz } typeFRQ;
//typedef enum { _100Hz = 0, _200Hz, _400Hz, _800Hz, _1600Hz, _3200Hz, _6400Hz, _12800Hz, _25600Hz, _51200Hz } typeFRQ;
typedef enum { N400 = 0, N800, N1600, N3200, N6400, N12800 } typeLNE;
//for Udar x1 x10 x100 x1000
typedef enum { AVG1 = 0, AVG2, AVG4, AVG8, AVG16, AVG32, AVG64, AVG128, AVG256, AVG512, AVG1024 } typeAVG;
typedef enum { LIN = 0, LOG} typeLINLOG;
typedef enum { CONTINUOUS = 0, SEC3, SEC10, SEC30, MIN1, MIN3, MIN10, MIN30, HOUR1, HOUR2, HOUR3 } typeTME;
typedef enum { DONE = 0, CHARGING } typeChargingState;
typedef enum { Measuring_Stopped = 0, Measuring_Repairing, Measuring_ReadyToCapture, Measuring_Capturing } typeMeasurementState;
typedef enum { Forward = 0, Rear } typeFFT;
typedef enum { ICPx1 = 0, ICPx2, ICPx4, ICPx8, ICPx16, ICPx32, ICPx64, Kx10, ZARx1, PGA1, PGA10, PGA100 } pIndexCorr;
static const float32_t Ucorr[] = { 1024.0f, 512.0f, 256.0f, 128.0f, 64.0f, 32.0f, 16.0f, 100.0f, 1024.0f, 1000.0f, 100.0f, 10.0f };
static const uint8_t Icorr[] = { ICPx1, ICPx2, ICPx4, ICPx8, ICPx16, ICPx32, ICPx64, ICPx1, ZARx1, ICPx1, ICPx1, ICPx1};
//static const float32_t Ucorr[] = { 500.0f, 250.0f, 100.0f, 50.0f, 50.0f, 5000.0f, 500.0f, 50.0f, 111.875f };
//static const uint8_t Icorr[] = { ZARx1, Kx2, Kx5, Kx10, ZARx10, ZARx01, ICPx1, ICPx10, Kx16 };
static const float32_t KM_UDAR[] = {1.0f, 10.0f, 100.0f, 1000.0f};
static const float32_t KM[] = {1.0f, 2.0f, 4.0f, 8.0f, 16.0f, 32.0f, 64.0f, /*128.0f*/ 80.0f, 160.0f, 320.0f, 640.0f};
static const float32_t MAXVOLTS[] = {1000.00000f, 500.00000f, 500.00000f};
static const float32_t KIN[] = {1000.0f, 4000.0f};
static const uint32_t TIMEREC[6][11] = {
{ 4294967295, 3840, 12800, 38400, 76800, 230400, 768000, 2304000, 4608000, 9216000, 13824000 },
{ 4294967295, 7680, 25600, 76800, 153600, 460800, 1536000, 4608000, 9216000, 18432000, 27648000 },
{ 4294967295, 15360, 51200, 153600, 307200, 921600, 3072000, 9216000, 18432000, 36864000, 55296000 },
{ 4294967295, 30720, 102400, 307200, 614400, 1843200, 6144000, 18432000, 36864000, 73728000, 110592000 },
{ 4294967295, 76800, 256000, 768000, 1536000, 4608000, 15360000, 46080000, 92160000, 184320000, 276480000 },
{ 4294967295, 196608, 638976, 1925120, 3842048, 11517952, 38404096, 115204096, 230400000, 460800000, 552960000 }
// 3 10 30 1m 3m 10m 30m 1h 2h
};
static const float32_t LPF[] = {500, 500, 500, 1000, 1000, 2000, 2000, 10000, 20000};
//static const uint32_t INDEX_SUB[] = {298, 596, 1192, 2384};
typedef enum
{
MAIN = 0,
CALIBR_00, // CHANGING CHANNEL
CALIBR_0, // [CHARGE x1] + KU_1
CALIBR_1, // CHARGE x1 + [KU_2]
CALIBR_2, // CHARGE x1 + [KU_5]
CALIBR_3, // CHARGE x1 + [KU_10]
CALIBR_4, // CHARGE x1 + [KU_x10]
CALIBR_5, // [CHARGE x10] + KU_1
CALIBR_6, // [CHARGE x0.1] + KU_1
CALIBR_7, // [ICP x1] + KU_1
CALIBR_8, // [ICP x10] + KU_1
CALIBR_9, // [CHARGE x10 + KU_2 + KU_x10]
CALIBR_10, // [CHARGE x10 + KU_5 + KU_x10]
CALIBR_11, // [CHARGE x10 + KU_2 + KU_x10]
CALIBR_12,
CALIBR_13,
CALIBR_14,
CALIBR_15,
CALIBR_16,
CALIBR_17,
CALIBR_18,
CALIBR_19,
CALIBR_20,
CALIBR_21,
CALIBR_22,
OPTIONS,
MEAS_MODE,
ROUTE, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ROUTE_MAP, // 1) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// 2) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// 3) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> (<28><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>???)
//
ROUTE_PARAM,
LOGO,
PARAM_VIB,
PARAM_SPEC,
PARAM_OSC,
PARAM_FRAN,
PARAM_WAVE,
PARAM_SPEC_OGIB,
PARAM_SPEC_OKT,
PARAM_ROLL,
PARAM_UDAR,
PARAM_DIAGN,
PARAM_DIAGN_1,
PARAM_DIAGN_2,
SETTINGS,
ACCELEROMETER,
ARCHIVE,
ARCHIVE_SPEC,
ARCHIVE_FRAN,
ARCHIVE_WAVE,
DATETIME,
CLEAN_FILES,
FORMAT_DISK,
MAIN_VIB,
MAIN_SPEC,
MAIN_OSC,
MAIN_WAVE,
MAIN_FRAN,
MAIN_SYGNAL,
MAIN_SPEC_OGIB,
MAIN_SPEC_OKT,
MAIN_SPEC_THIRD,
MAIN_ROLL,
MAIN_UDAR,
MAIN_DIAGN,
ROLL_RESULTS,
VIEW_PORTRET,
EXPLORER,
EXPLORER_DIAGN,
INPUT_NAME_PTM,
INPUT_NAME_DGN,
INPUT_NAME_FRN,
INPUT_NAME_ROLL,
INPUT_NAME_SPEC,
INPUT_NAME_GTR,
INPUT_COMMENT,
INPUT_COMMENT_DIAGN,
INPUT_NAME,
/*CALIBR_00,
CALIBR_0,
CALIBR_1,
CALIBR_2,
CALIBR_3,
CALIBR_4,
CALIBR_5,
CALIBR_6,
CALIBR_7,
CALIBR_8,
CALIBR_9,
CALIBR_10,
CALIBR_11,
CALIBR_OFFSET,*/
LINK_PC,
POWER_OFF,
POWER_OFF2,
TREND_A,
TREND_V,
TREND_S,
LOW_BAT
} typeMenu;
typedef enum { Back = 255 } pBackMenupos;
typedef enum { Set100 = 0, Set_100, Set10, Set_10, Set1, Set_1, Next } pCalibr0_11;
typedef enum { /*Input = 0,*/ Hp = 0 , Lp, /*Sens, Val,*/ Out, Kikdt, Kikt, Kiks, Kikd, Kike, Kpt } pMainMenupos;
typedef enum { Inputs = 0, Lang, PowerOff } pOptionsMenupos;
typedef enum
{
Sens_1 = 0, Val_1, Kikdt_1, Kikt_1, Kiks_1, Kikd_1, Kike_1, Kpt_1,
Sens_2, Val_2, Kikdt_2, Kikt_2, Kiks_2, Kikd_2, Kike_2, Kpt_2,
Sens_3, Val_3, Kikdt_3, Kikt_3, Kiks_3, Kikd_3, Kike_3, Kpt_3,
Sens_4, Val_4, Kikdt_4, Kikt_4, Kiks_4, Kikd_4, Kike_4, Kpt_4
} pSettingsMenupos;
typedef enum { Accel = 0, Velocity, Pascal, k_Pascal, M_Pascal, Nython, k_Nuthon, pQ, mV } typeVALUE;
typedef enum { Ch1 = 0, Ch2, Ch3, Ch4, Ch5, Ch6, Ch7, Ch8, Ch9, Ch10, Ch11, Ch12, Ch13, Ch14, Ch15, Ch16 } typeCHANNEL;
typedef enum
{
Out_0_0001 = 0,
Out_0_0002 = 1,
Out_0_0005 = 2,
Out_0_0010 = 3,
Out_0_0020 = 4,
Out_0_0050 = 5,
Out_0_0100 = 6,
Out_0_0200 = 7,
Out_0_0500 = 8,
Out_0_1000 = 9,
Out_0_2000 = 10,
Out_0_5000 = 11,
Out_1_0000 = 12,
Out_2_0000 = 13,
Out_5_0000 = 14,
Out_10_000 = 15,
Out_20_000 = 16,
Out_50_000 = 17,
Out_100_00 = 18,
Out_200_00 = 19,
Out_500_00 = 20,
Out_1000_0 = 21,
Out_2000_0 = 22,
Out_5000_0 = 23,
Out_10000 = 24
} typeOUTPUT;
//typedef enum { Type = 1, Sens/* = 1*/, Lang, DateTime, FormatDisk, Bluetooth, Temper, FormatDiskNo, FormatDiskYes, FormatDiskResult, FormatDiskProcessing, CleanFiles, Ies, Ied, Iee, Ikd, Iks, Ikt } pSettt;
typedef enum { DateAll = 1, TimeAll, DateD, DateM, DateY, TimeH, TimeM } pDATETIME;
typedef enum
{
DIAGN_NO = 0x0,
DIAGN_ACC = 0x1,
DIAGN_VEL = 0x2,
DIAGN_DIS = 0x4
} typeIPR_DIAGN;
typedef enum
{
DIAGN_PEAK = 0x1,
DIAGN_RMS = 0x2,
DIAGN_PEAK_TO_PEAK = 0x4,
DIAGN_PEAK_FACTOR = 0x8,
DIAGN_EXCESS = 0x10
} typeIVS_DIAGN;
typedef enum { O_SpecBand = 1, O_SpecLines, O_SpecWin, O_LinLog, O_SAverage } pParam_Spec_Ogib;
typedef enum { Okt_SpecIVS = 1, Okt_LinLog, Okt_SAverage } pParam_Spec_Okt;
typedef enum { maskFFT = 0x30 } maskFFT_1;
typedef enum { fft = 0x00, env = 0x10, okt = 0x20, third = 0x30 } typeFFT_1;
typedef enum { FileNum = 3, CleanUp, CleanAll, UpNo, UpYes, AllNo, AllYes, CleanUpResult, CleanAllResult } pCLEANFILES;
typedef enum { StartStop = 0, BackMenu, Record, MyPoint, MyMeasure, MyFreq, MyLinLog } pMAIN_VIB;
typedef enum { ImageLeft = 2, ZoomIn, ZoomOut, ImageRight, Cursor, Stop, Results, SaveSpec } pMAIN_SPECOSC;
typedef enum { GainSelecting = 2, ReadyRec, CalculatingFreq} pMAIN_REC;
typedef enum {
WaveBand = 1, WaveFreq, WaveTacho,
WaveName, WaveTime, WaveAutoKu, WaveMax_ALL, WaveThr, WaveThr_ALL,
WaveMax_IDT, WaveMax_IET, WaveMax_IES, WaveMax_IED, WaveMax_IEE, WaveMax_IKD,
WaveThr_IDT, WaveThr_IET, WaveThr_IES, WaveThr_IED, WaveThr_IEE, WaveThr_IKD,
Wave_IVS
} pParam_Wave;
typedef enum { NoFilesPTM = 1, FilesPTM } pEXPLORER;
typedef enum { NoFilesDGN = 1, FilesDGN } pEXPLORER_DIAGN;
typedef enum { NoFilesCSV = 1, FilesCSV } pEXPLORER_ROUTE;
typedef enum { /*ArchiveSpec = 1, */ArchiveFran = 1, ArchiveWave } pArchive;
typedef enum { NoFilesSPEC = 1, FilesSPEC } pEXPLORER1;
typedef enum { NoFilesFRAN = 1, FilesFRAN } pEXPLORER2;
typedef enum { NoFilesGTR = 1, FilesGTR } pEXPLORER3;
typedef enum { NoFilesWAV = 1, FilesWAV } pEXPLORER4;
typedef enum { IN16_Reg = 0, IN_Reg, ADC_Reg, MEAN_Reg, SCR_Reg, CMPLX_A, CMPLX_V, CMPLX_S, WAV_SECTOR, OUT_Reg } DMA_DataType;
typedef enum { RUS_CHARS = 0, ENG_CHARS } TextTypeDef;
typedef enum { cbUnchecked = 0, cbChecked } CheckState_TypeDef;
typedef enum { STOPPED = 0, PLAYING, PAUSED } PlayingState_TypeDef;
typedef enum {
PrevPoint = 0, GoMeas, NextPoint,
RouteTacho, RouteTime, RouteAutoKu, RouteMax_ALL,
RouteMax_IDT, RouteMax_IET, RouteMax_IES, RouteMax_IED, RouteMax_IEE, RouteMax_IKD,
RouteNullYes, RouteNullNo
} RouteMeas_TypeDef;
typedef enum
{
ePoint = 0, // 0
ePoint1, // 1
eMeas, // 2
eMeas1, // 3
eAval, // 4
eAval1, // 5
eAval2, // 6
eAval3, // 7
eVval, // 8
eVval1, // 9
eVval2, // 10
eVval3, // 11
eSval, // 12
eSval1, // 13
eSval2, // 14
eSval3, // 15
eDateTime, // 16
eDateTime1, // 17
eDateTime2, // 18
eDateTime3, // 19
eAivs, // 20
eVivs, // 21
eSivs, // 22
eFval, // 23
eFval1, // 24
eFval2, // 25
eFval3, // 26
e13, // 27
e10, // 28
} eMeasStruct;
typedef enum
{
d_Point = 0, // 0
d_Point1, // 1
d_Meas, // 2
d_Meas1, // 3
d_Op1_1, // 4
d_Op1_2, // 5
d_Op1_3, // 6
d_Op1_4, // 7
d_Op2_1, // 8
d_Op2_2, // 9
d_Op2_3, // 10
d_Op2_4, // 11
d_Op3_1, // 12
d_Op3_2, // 13
d_Op3_3, // 14
d_Op3_4, // 15
d_DateTime, // 16
d_DateTime1, // 17
d_DateTime2, // 18
d_DateTime3, // 19
d_Op1_ipr, // 20
d_Op2_ipr, // 21
d_Op3_ipr, // 22
d_Op1_ivs, // 23
d_Op2_ivs, // 24
d_Op3_ivs, // 25
d_Op1_col, // 26
d_Op2_col, // 27
d_Op3_col, // 28
d_W, // 29
d_A, // 30
d_13, // 31
d_10, // 32
} eDiagnStruct;
typedef union{
uint8_t ch[2];
uint16_t sh;
} usshort;
typedef union
{
uint8_t ch[2];
int16_t sh;
} sshort_t;
typedef union{
uint8_t ch[4];
float32_t fl;
} usfloat;
typedef union
{
uint8_t ch[4];
uint32_t lg;
} ulong_t;
typedef struct
{
uint32_t CurrentFrame;
uint32_t NumFrames;
uint32_t FrameSize;
uint64_t CountBytes;
uint32_t SampleRate;
float32_t TimeLength;
float32_t Sensitivity;
float32_t Gain;
float32_t Freq;
uint32_t State;
} PlayState_TypeDef;
typedef struct amplif
{
uint16_t IIN; // 0,1 5001
uint16_t IFV; // 2,3 5002
uint16_t IFN; // 4,5 5003
uint16_t IKU; // 6,7 5004
uint16_t IKE; // 8,9 5005
uint16_t IKD; // 10,11 5006
uint16_t IKS; // 12,13 5007
uint16_t IPZ; // 14,15 5008
uint16_t OPZ; // 16,17 5009
uint16_t VAL; // 18,19 5010
float32_t KCOND; // 20,21,22,23 7501
float32_t SENS; // 24,25,26,27 7502
float32_t ACCEL; // 28,29,30,31 7503
} AmplifData_TypeDef;
typedef struct
{
AmplifData_TypeDef amplif[16];
uint16_t OWN; // 4001
uint16_t BAUD; // 4002
uint16_t INFB; // 4003
uint16_t LANG; // 6001
} UserData_TypeDef; // ********LENGTH = 220 bytes***********
typedef struct
{
float32_t CORR_ACC[9]; // 0 ... 31
float32_t CORR_VEL[9]; // 32 ... 63
float32_t CORR_DIS[9]; // 64 ... 95
} CorrData_TypeDef;
typedef struct
{
uint32_t TotalSectors;
uint32_t FreeSectors;
uint32_t Total_MB;
uint32_t Free_MB;
} SD_SpaceTypeDef;
typedef enum
{
_1 = 0, _2, _3, _4, _5, _6, _7, _8, _9, _0,
_Q, _W, _E, _R, _T, _Y, _U, _I, _O, _P,
_A, _S, _D, _F, _G, _H, _J, _K, _L, _BCKSPC,
_Z, _X, _C, _V, _SPACE, _B, _N, _M,
_ENTER, _CANCEL
} pINPUT_NAME;
static const char CHARS_ENG[] =
{
'1','2','3','4','5','6','7','8','9','0',
'Q','W','E','R','T','Y','U','I','O','P',
'A','S','D','F','G','H','J','K','L','\0',
'Z','X','C','V', ' ', 'B','N','M',
'\0', '\0'
};
static const uint32_t dT[] = {4, 8, 16, 32};
static const uint32_t dF[] = {2, 4, 8, 16};
static const uint8_t avgOSC[7][5] =
{
{4, 8, 16, 32, 64}, //todo
{2, 4, 8, 16, 32},
{1, 2, 4, 8, 16},
{1, 1, 2, 4, 8},
{1, 1, 1, 2, 4},
{1, 1, 1, 1, 2},
{1, 1, 1, 1, 1}
};
/*static const uint8_t avgOSC_VS[7][5] =
{
{4, 8, 16, 26, 64}, //todo
{2, 4, 8, 16, 26},
{1, 2, 4, 8, 16},
{1, 1, 2, 4, 8},
{1, 1, 1, 2, 4},
{1, 1, 1, 1, 2},
{1, 1, 1, 1, 1}
};*/
static const uint8_t avgSPC[5][4] =
{
{2, 4, 8, 16},
{1, 2, 4, 8},
{1, 1, 2, 4},
{1, 1, 1, 2},
{1, 1, 1, 1}
};
static const uint16_t Avg[2][35] =
{
{4, 8, 16, 32, 64, 2, 4, 8, 16, 32, 1, 2, 4, 8, 16, 1, 1, 2, 4, 8, 1, 1, 1, 2, 4, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1}, //TODO
{2, 4, 8, 16, 16, 1, 2, 4, 8, 8, 1, 1, 2, 4, 4, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
};
/*static const uint16_t Avg_VS[2][35] =
{
{4, 8, 16, 26, 64, 2, 4, 8, 16, 26, 1, 2, 4, 8, 16, 1, 1, 2, 4, 8, 1, 1, 1, 2, 4, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1}, //TODO
{2, 4, 8, 16, 16, 1, 2, 4, 8, 8, 1, 1, 2, 4, 4, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
};*/
#define VALUE_MIN (2UL)
#define VALUE_MID (64UL)
#define VALUE_MAX (256UL)
#define HI_LEVEL_BATTERY 43400 /* 3.90 V */
#define LO_LEVEL_BATTERY 37500 /* 3.20 V */
#define LOWEST_LEVEL_BATTERY 35100 /* 3.00 V */
#define DIAPAZONE_BATTERY (HI_LEVEL_BATTERY - LOWEST_LEVEL_BATTERY)//(HI_LEVEL_BATTERY - LO_LEVEL_BATTERY)
#define FULLY_CHARGE_LEVEL 50400 /* 4.31 V */
typedef enum { ALLFILES = 0xffffffff } typeAllFiles;
typedef enum { DATA_FREE = 0 } typeREADY1;
typedef enum { DATA_CAPTURED = 7 } typeREADY2;
typedef enum { DATA_NOSYNTH = 7 } typeREADY3;
static const uint16_t AVG[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
static const uint32_t NS[] = {1024, 2048, 4096, 8192, 16384};
static const uint32_t LINE[] = { 400, 800, 1600, 3200, 6400};
static const uint32_t FS[] = {125, 250, 500, 1000, 2000, 4000, 8000, 16000, 32000, 64000};
static const float32_t Delta_OSC[] = { 8.0f, 4.0f, 2.0f, 1.0f, 0.5f, 0.25f, 0.125f, 0.0625f, 0.03125f, 0.015625f}; // (1/Fs <20> <20><><EFBFBD><EFBFBD>)
static const float32_t Delta_SPC[10][4] =
{
{ 0.1220703125f, 0.06103515625f, 0.030517578125f, 0.0152587890625f }, // Fs = 125
{ 0.244140625f, 0.1220703125f, 0.06103515625f, 0.030517578125f }, // Fs = 250
{ 0.48828125f, 0.244140625f, 0.1220703125f, 0.06103515625f }, // Fs = 500
{ 0.9765625f, 0.48828125f, 0.244140625f, 0.1220703125f }, // Fs =1000
{ 1.953125f, 0.9765625f, 0.48828125f, 0.244140625f }, // Fs = 2000
{ 3.90625f, 1.953125f, 0.9765625f, 0.48828125f }, // Fs = 4000
{ 7.8125f, 3.90625f, 1.953125f, 0.9765625f }, // Fs = 8000
{ 15.625f, 7.8125f, 3.90625f, 1.953125f }, // Fs = 16000
{ 31.25f, 15.625f, 7.8125f, 3.90625f }, // Fs = 32000
{ 62.5f, 31.25f, 15.625f, 7.8125f } // Fs = 64000
};
static const float32_t OCTAVES[] = {1.0f, 2.0f, 4.0f, 8.0f, 16.0f, 31.5f, 63.0f, 125.0f, 250.0f, 500.0f, 1000.0f, 2000.0f, 4000.0f, 8000.0f, 16000.0f};
static const float32_t THIRD[] =
{
0.8f, 1.0f, 1.25f,
1.6f, 2.0f, 2.5f,
3.15f, 4.0f, 5.0f,
6.3f, 8.0f, 10.0f,
12.5f, 16.0f, 20.0f,
25.0f, 31.5f, 40.0f,
50.0f, 63.0f, 80.0f,
100.0f, 125.0f, 160.0f,
200.0f, 250.0f, 315.0f,
400.0f, 500.0f, 630.0f,
800.0f, 1000.0f, 1250.0f,
1600.0f, 2000.0f, 2500.0f,
3150.0f, 4000.0f, 5000.0f
};
static const uint32_t MAGNITUDE_LEN[6][4] =
{
{ 64, 128, 256, 512 }, // Fs = 1280
{ 32, 64, 128, 256 }, // Fs = 2560
{ 16, 32, 64, 128 }, // Fs = 5120
{ 16, 32, 64, 128 }, // Fs = 10240
{ 4, 8, 16, 32 }, // Fs = 25600
{ 2, 4, 8, 16 } // Fs = 51200
};
typedef union
{
uint8_t ch[4];
uint16_t sh[2];
uint32_t lg;
float32_t fl;
} sfloat;
typedef union
{
uint8_t ch[8];
uint16_t sh[4];
uint32_t lg[2];
float32_t fl32[2];
float64_t fl64;
} sfloat64;
typedef union
{
uint8_t ch[4];
uint16_t sh[2];
int32_t lg;
} uslong_t;
typedef union
{
uint8_t ch[2];
uint16_t sh;
} ushort_t;
typedef struct
{
uint32_t TotalSize; /*!< Total size of memory */
uint32_t FreeSize; /*!< Free size of memory */
} TM_FATFS_Size_t;
/**
* @brief FATFS find structure
*/
typedef struct
{
uint32_t FoldersCount; /*!< Number of folders in last search operation */
uint32_t FilesCount; /*!< Number of files in last search operation */
} TM_FATFS_Search_t;
typedef struct
{
uint8_t Month;
uint8_t Date;
uint8_t Year;
uint8_t Hours;
uint8_t Minutes;
uint8_t Seconds;
} TimeDate_TypeDef;
typedef struct
{
sfloat Aval;
sfloat Vval;
sfloat Sval;
sfloat Fval;
RTC_TimeTypeDef Time;
RTC_DateTypeDef Date;
uint8_t Aivs;
uint8_t Vivs;
uint8_t Sivs;
} FileData_TypeDef;
typedef struct
{
sfloat Op_1;
sfloat Op_2;
sfloat Op_3;
RTC_TimeTypeDef d_Time;
RTC_DateTypeDef d_Date;
uint8_t d_Op1_ipr;
uint8_t d_Op2_ipr;
uint8_t d_Op3_ipr;
uint8_t d_Op1_ivs;
uint8_t d_Op2_ivs;
uint8_t d_Op3_ivs;
uint8_t d_Op1_Color;
uint8_t d_Op2_Color;
uint8_t d_Op3_Color;
uint8_t d_Warning;
uint8_t d_Alarm;
} DiagnData_TypeDef;
typedef struct
{
sfloat Aval;
sfloat Vval;
sfloat Sval;
uint32_t DateTime;
uint8_t Aivs;
uint8_t Vivs;
uint8_t Sivs;
} TrendData_TypeDef;
#define TrendRAM(x) *(TrendData_TypeDef *) (MEAN_ADDR_OFFSET + (((x) * sizeof(TrendData_TypeDef))))
#define pTrendRAM (( uint8_t *) (MEAN_ADDR_OFFSET))
#define TrendRAM_TEMP(x) *(TrendData_TypeDef *) (CMPLX_ADDR_OFFSET + (((x) * sizeof(TrendData_TypeDef))))
#define pTrendRAM_TEMP (( uint8_t *) (CMPLX_ADDR_OFFSET))
typedef struct
{
bool Enabled;
uint16_t CURSOR;
uint16_t Mpos;
uint16_t fineMpos;
float32_t val_X;
float32_t val_Y;
} DynamicCursor_TypeDef;
typedef enum {
GET_NUM_PTM_FILES = 0, GET_NUM_GTR_FILES, GET_NUM_WAV_FILES, GET_NUM_SPEC_FILES, GET_NUM_FRAN_FILES, GET_NUM_DGN_FILES, GET_NUM_CSV_FILES, GET_NUM_ROUTE_FILES,
GET_NAMES_12_PTM_FILES, GET_NAMES_12_GTR_FILES, GET_NAMES_12_WAV_FILES, GET_PATH_TO_FILE, GET_NAMES_12_SPEC_FILES, GET_NAMES_12_FRAN_FILES, GET_NAMES_12_DGN_FILES, GET_NAMES_12_CSV_FILES,
GET_COUNT_MEAS_FILES
} ScanFiles_TypeDef;
void initDevice(void);
void NeedCalibrate(void);
void FileSystem(void);
uint8_t TM_FATFS_CheckCardDetectPin(void);
bool CheckSD(void);
void SDEventExecute(bool State);
uint32_t kbhit(void);
float32_t MedMeas(uint8_t AVS, float32_t InVal);
void initFilters(void);
float64_t filter2INT(float64_t val);
float64_t filterACC(float64_t val);
float64_t filterDIS(float64_t val);
int8_t CalculateGain(uint32_t SygPoints);
void FastCopy16(DMA_DataType SrcType, DMA_DataType DstType, uint32_t NumHalfWords);
void ARM_ADD_F32(DMA_DataType A, DMA_DataType B, DMA_DataType Dst, uint32_t BlockSize);
void ARM_SCALE_F32(DMA_DataType Src, float32_t Scale, DMA_DataType Dst, uint32_t BlockSize);
void Processing(void);
void INTEGR(float32_t *pSrc, float32_t *pDst);
void INTEGR_NEW(void);
void GetData(void);
//void CopyData(uint16_t CurrentIndex);
void WindowFunc(uint8_t Window, uint16_t Samples);
void LinToLog(float32_t *pSrc, float32_t *pDst);
void LinToLog_mV(float32_t *pSrc, float32_t *pDst, uint8_t IPR);
void initMemCopy(void);
void RTC_TimeShow(void);
void RTC_DateShow(void);
void RTC_TimeStampShow(void);
void ChangeDate(int8_t chDay, int8_t chMonth, int8_t chYear);
void ChangeTime(int8_t chHours, int8_t chMinutes);
void GetDateTimeFromUnix(TimeDate_TypeDef* data, uint32_t unix);
uint32_t GetUnixFromDateTime(TimeDate_TypeDef* data);
void Off(void);
void Sleep(void);
void initFFT(float32_t *pSrc, float32_t *pDst, uint8_t flag);
void RemoveNoise(uint32_t Dimension, float32_t *Src, float32_t *NormFactor);
void RAMTest(void);
uint32_t MedVbat(uint32_t val);
void DMA_MemToMem_HALFWORD(uint32_t fromRAM, uint32_t toRAM, uint32_t blocksize);
void USBState(void);
void CursorValue(void);
void initKeys(void);
void initAmplif(void);
uint32_t readkey(void);
void rdPar(void);
void wrPar(void);
void rdCorr(void);
void wrCorr(void);
void rdFlash(void);
void CheckFilesForWrite(void);
void initSD(void);
void initADCTim(uint32_t freq);
void initPWMTim(uint8_t band);
void keyIns(void);
void meas(void);
//void AutoKu(uint32_t adcLen);
uint32_t FsIndex(void);
char * FloatToASCII(float32_t Val, int32_t RoundTo);
void SetKU(void);
void calcK(void);
float32_t Corr(uint8_t *Km);
float32_t CorrKm(uint8_t *Km);
void MyFFT(uint32_t len, int32_t inverse);
void SetupADC(void);
void StopTIM2(void);
void StartTIM2(void);
void SetupPWM(uint8_t band);
void StopTIM10(void);
void StartTIM10(void);
void StopMeas(void);
void StartMeas(void);
void StartRecording(void);
void LTDC_Reset(void);
void Display(void);
void RedrawNums(void);
void DrawSamples(void);
void DrawKeyboard(void);
void RefreshGraf(void);
void DrawGraph(void);
void DrawCursorData(void);
void DrawScaleValue(void);
void DrawButtons(void);
void DrawLegend(void);
void DrawFilters(void);
void DrawRMS(void);
void DrawAVS(void);
void DrawSizeSD(void);
void DisplayStatus(void);
void DrawSpinner(uint16_t x, uint16_t y);
void DrawMySpinner(uint16_t x, uint16_t y);
void VerifyFileNamePTM(char *fname, char *out_name);
void VerifyFileNameDGN(char *fname, char *out_name);
void VerifyFileNameGTR(char *fname, char *out_name);
void VerifyFileNameWAV(char *fname, char *out_name);
void VerifyFileNameFRAN(char *fname, char *out_name);
void VerifyFileNameSPEC(char *fname, char *out_name);
void VerifyFileNameCSV(char *fname, char *out_name);
void Logo(void);
void RedrawScreen(void);
void EXTI_Config(void);
void GetTemperature(void);
void DisableWakeUpPins(void);
void initFlash(void);
void CALC_OFFSET(void);
void SPI_WrRd(uint16_t *tx, uint16_t *rx, uint16_t cnt);
void SET_ADCOption1(FunctionalState NewState);
void SET_ADCOption2(uint32_t ADCxDC2, FunctionalState NewState);
#define PinOutSet(x) HAL_GPIO_WritePin(x, GPIO_PIN_SET)
#define PinOutClear(x) HAL_GPIO_WritePin(x, GPIO_PIN_RESET)
#define PinOutToggle(x) HAL_GPIO_TogglePin(x)
#define PinInGet(x) HAL_GPIO_ReadPin(x)
#define PinOutGet(x) HAL_GPIO_ReadPin(x)
void initINT1_INT2(float64_t Fc);
void initHP(float64_t Fc);
void initLP(float64_t Fc);
void CALC_MEAN(uint32_t smooth);
void CalcFreq(void);
void CalcFreqTacho(void);
float64_t Calc_dBi(float64_t d, float64_t rpm);
float32_t Calc_dBc(void);
void LinToLog_UDAR(float32_t *pSrc, float32_t *pDst);
int8_t ReadRouteParam(void);
void cp1251_to_utf8(char *out, const char *in);
void DrawMarkers(void);
void DrawChannel_4(uint8_t ch, uint32_t blk);
void DrawChannel_8(uint8_t ch, uint32_t blk);
int8_t ReadChannel(uint8_t ch);
int8_t WriteChannel(uint8_t ch);
int8_t ReadChannelSens(uint8_t ch);
int8_t WriteChannelSens(uint8_t ch);
void VerifyGain(float32_t sens);
void AskChannels(void);
void AskPeriodic(void);
void DoKeyUP(void);
void DoKeyDN(void);
int8_t WriteCorr(uint8_t ch, uint8_t fasecor, uint8_t up);
int8_t Calibr(uint8_t ch, uint8_t on);
void CalibrOFF(void);
void CalibrON(void);
int8_t ReadIP(void);