UveosOnNation_VEGA_DeviceTe.../Inc/DeviceTesting_Env.h

145 lines
4.4 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// Created by xemon on 18.11.22.
//
#ifndef UVEOS_ON_NATION_DEVICETESTING_ENV_H
#define UVEOS_ON_NATION_DEVICETESTING_ENV_H
#include "DeviceTestsTable.h"
#include "GpioPinInterface.h"
#include "AtCmdCommon.h"
#include "AudioCodec.h"
#include "LoggerInterface.h"
#include "AudioPlayerInterface.h"
#include "AudioRecorderInterface.h"
#include "UserButtonsInterface.h"
#include "UserIndication.h"
#include "EraGlonassMsd.h"
#include "EraGlonassUveos.h"
#include "Adc.h"
#include "SpiPortIO.h"
#include "AccelDataFlowInterface.h"
#include "Accel.h"
#include "SpiPortNation.h"
#include "CmsisRtosThreadUtils.h"
#include "GsmWithGnss.h"
#include "AntTest.h"
#include "UserInputButtonWatcher.h"
#define DEVICE_TESTS_LIMIT (16)
typedef struct {
tMSD_DiagnosticResult tmsdDiagRes;
tTestDescriptor testsTableAlloc[DEVICE_TESTS_LIMIT];
tDeviceTestsTable testsTable;
tEraGlonassUveos *ErGlUv;
tLoggerInterface *logger;
tAudioPlayerInterface *audioPlayer;
tAudioRecorderInterface *audioRecorder;
tUserButtonsInterface *input;
tUserIndication *indication;
tGpioPin *pinIgnition;
tGpioPin *ringPin;
tAccelDataFlowInterface *accelDFI;
tUserInputButtonWatcher *UserInputButtonWatcher;
uint8_t indicationStatusRes;
uint8_t ignitionAddStatusRes;
uint8_t buttonAddStatusRes;
uint8_t ecallAddStatusRes;
#ifdef USE_GSM_AND_GNSS_TELIT
tGsmWithGnss *gsmWithGnss;
#endif
struct {
tTestDescriptor *ignition;
tTestDescriptor *gnssAnt;
tTestDescriptor *speakConnect;
tTestDescriptor *batteryConn;
tTestDescriptor *batteryCharge;
tTestDescriptor *firmware;
tTestDescriptor *gsm;
tTestDescriptor *audioCodec;
tTestDescriptor *accel;
} namedTests;
tStaticThreadBlock(512) threadTest;
bool flagAutoTestSucsess;
uint8_t flagAcsessExitThread;
tAntTest antDiscript;
} tDeviceTesting;
bool DeviceTesting_Init(
tDeviceTesting *env,
tUserInputButtonWatcher *UserInputButtonWatcher,
tGpioPin *ignPin,
tAdcIO *gnssAntAdc,
tAdcIO *speakerAdc,
tAdcIO *batteryAdc,
tAccel *accel,
tGsmWithGnss *gsmWithGnss,
tAudioCodec *audioCodec,
tLoggerInterface *logger,
tAtCmd *gsm,
tAudioPlayerInterface *audioPlayer,
tAudioRecorderInterface *audioRecorder,
tUserButtonsInterface *input,
tUserIndication *indication,
tEraGlonassUveos *ErGlUv,
bool *antMode,
tGpioPin *ring
);
//ограничение воспроизведения одного семпла в 60с, можно увеличить до длительности большего семпла
#define DEVTST_PLAY_SAMPLE(SAMPLE) \
SystemDelayMs(40);\
AudioPlayer_PlayStatic(env->audioPlayer, SAMPLE, 4*1000);
//ограничение записи одного семпла в 60с, можно увеличить до длительности большего семпла
#define DEVTST_REC_SAMPLE(SAMPLE) \
SystemDelayMs(40);\
AudioRecord_RecStatic(env->audioRecorder, SAMPLE, 8*1000);
//#define DEVTST_GET_MAIN(NAME) DeviceTestsTable_GetModeTestStatic(&env->testsTable, DEVICE_TESTING_MODE_MAIN, NAME);
//Return IF Error (RIFE) - Выйти в случае ошибки
#define DEVICE_TESTING_RIFE(FUNC) {bool result = FUNC; if(!result){ return result;}}
//Битовые флаги режимов тестирования (константы с локальной видимостью)
static const uint16_t DEVICE_TESTING_MODE_IGNITION_WITHOUT_GSM = 0b1 << 0;
static const uint16_t DEVICE_TESTING_MODE_IGNITION_AFTER_GSM = 0b1 << 1;
static const uint16_t DEVICE_TESTING_MODE_ALWAYS = 0b1 << 2;
static const uint16_t DEVICE_TESTING_MODE_PERIODICAL = 0b1 << 3;
static const uint16_t DEVICE_TESTING_MODE_MAIN = 0b1 << 4;
static const uint16_t DEVICE_TESTING_MODE_ALL = 0xFFFF;
static const uint16_t DEVICE_TESTING_MODE_NOT_ALWAYS =
DEVICE_TESTING_MODE_ALL
& ~DEVICE_TESTING_MODE_ALWAYS
& ~DEVICE_TESTING_MODE_IGNITION_WITHOUT_GSM
& ~DEVICE_TESTING_MODE_IGNITION_AFTER_GSM;
bool DeviceTests_InitTestsTable(
tDeviceTesting *env,
tGpioPin *ignitionPin,
tAdcIO *speakerAdc,
tAdcIO *batteryAdc,
tAtCmd *gsm,
tAudioCodec *audioCodec,
tAccel *accel,
tAntTest *antCheck
);
#endif //UVEOS_ON_NATION_DEVICETESTING_ENV_H