129 lines
3.7 KiB
C
129 lines
3.7 KiB
C
/*!
|
|
Copyright 2017 ÀÎ "ÍÈÈÝÒ" è ÎÎÎ "ÍÏÔ ÂÅÊÒÎÐ"
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
|
|
\file SMProtect.h
|
|
\brief Ìîäóëü çàùèò. (ñì. TSM_Protect)
|
|
\author ÎÎÎ "ÍÏÔ Âåêòîð". http://motorcontrol.ru
|
|
\version v 2.0 25/03/2016
|
|
|
|
\defgroup SMProtect Ìîäóëü çàùèò. (ñì. TSM_Protect)
|
|
@{
|
|
*/
|
|
#ifndef SM_Protect_H
|
|
#define SM_Protect_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#include "build.h"
|
|
|
|
//! Ìîäóëü àùèò âûêëþ÷åí
|
|
#define PROT_OFF 0
|
|
//! Ìîäóëü çàùèò âêëþ÷åí
|
|
#define PROT_ON_OK 1
|
|
//! Ìîäóëü çàùèò â ñîñòîÿíèè àâàðèè (ñðàáîòàëà çàùèòà)
|
|
#define PROT_FAIL 2
|
|
|
|
//Ìàêðîñ ïðèåìà àïïàðàòíîé àâàðèè èíâåðòîðà: åñëè íîëü, òî àâàðèÿ
|
|
#define DRV_FAULT (GPIOA->DATA & (1 << 7))
|
|
|
|
|
|
/*! \class TSM_Protect
|
|
\brief Ìîäóëü çàùèò.
|
|
|
|
Êëàññ \a TSM_Protect, îñíîâàííûé íà ñòðóêòóðå SSMProtect,
|
|
îáðàáàòûâàåò âñå âîçìîæíûå àâàðèéíûå ñèòóàöèè è âîçâîäèò ñîîòâåòñòâóþùèé ýòîé
|
|
àâàðèè áèò â îäíîì èç ñëîâ bit_fault 1-2. äàëåå ïðîèñõîäèò îáðàáîòêà ýòèõ ñëîâ, è,
|
|
åñëè ýòà àâàðèÿ íå çàìàñêèðîâàíà, ïðîèñõîäèò îñòàíîâ ïðèâîäà.
|
|
*/
|
|
|
|
//! ñì. TSM_Protect
|
|
struct SSM_Protect
|
|
{
|
|
Uint16 state;//!< Ñîñòîÿíèå
|
|
Uint16 state_prev;//!< Ñîñòîÿíèå ïðåäûäóùåå
|
|
|
|
Uint16 readDrvSts; //!<Ôëàã çàïðîñà ÷òåíèÿ ñòàòóñà drv8301
|
|
Uint16 clearDrvFault; //!<Ôëàã çàïðîñà ñáðîñà àâàðèè drv8301
|
|
|
|
Uint16 bit_fault1;//!<Ñëîâî àâàðèé 1
|
|
Uint16 bit_fault2;//!<Ñëîâî àâàðèé 2
|
|
|
|
Uint16 masked_bit_fault1;//!<Ñëîâî àâàðèé ïîñëå ìàñêèðîâàíèÿ
|
|
Uint16 masked_bit_fault2;//!<Ñëîâî àâàðèé ïîñëå ìàñêèðîâàíèÿ
|
|
|
|
Uint16 mask_fault1;//!<Ìàñêà àâàðèé 1
|
|
Uint16 mask_fault2;//!<Ìàñêà àâàðèé 2
|
|
|
|
Uint16 bit_fault_written1;
|
|
Uint16 bit_fault_written2;
|
|
|
|
long Imax_protect; //!<Óñòàâêà ìàêñèìàëüíî-òîêîâîé çàùèòû
|
|
long Umax_protect; //!<Óñòàâêà çàùèòû max íàïðÿæåíèÿ íà ÇÏÒ
|
|
long Umin_protect;//!<Óñòàâêà çàùèòû min íàïðÿæåíèÿ íà ÇÏÒ
|
|
long speed_max;//!<Óñòàâêà ìàêñèìàëüíîé ñêîðîñòè
|
|
long T_max;
|
|
|
|
int E;//!<Ôëàã ïåðâîãî âõîæäåíèÿ
|
|
Uint16 Main_ErrorCode;//!< //ëèñòàþùèéñÿ êîä àâàðèè
|
|
Uint32 Main_Flags;//!< //Ôëàã àâàðèéíîé áëîêèðîâêè áëîêà
|
|
Uint16 powered_okCounter;//!< Ñ÷åò÷èê äëÿ îæèäàíèÿ âêëþ÷åíÿ ìîäóëÿ çàùèò ïîñëå èíåöèàëèçàöèè
|
|
void (*init)(struct SSM_Protect*); /* Pointer to the init funcion */
|
|
void (*slow_calc)(struct SSM_Protect*); /* Pointer to the calc funtion */
|
|
void (*fast_calc)(struct SSM_Protect*); /* Pointer to the calc funtion */
|
|
void (*ms_calc)(struct SSM_Protect*); /* Pointer to the calc funtion */
|
|
} ;
|
|
typedef struct SSM_Protect TSM_Protect;
|
|
|
|
//!Èíèöèàëèçàòîð ïî óìîë÷àíèþ
|
|
#define SM_PROTECT_DEFAULTS {0,0,\
|
|
0,0,\
|
|
0,0,\
|
|
0,0,\
|
|
0,0,\
|
|
0,0,\
|
|
0,0,0,0,0,\
|
|
0,0,0,0,\
|
|
SM_Protect_Init,\
|
|
SM_Protect_Slow_Calc,\
|
|
SM_Protect_Fast_Calc,\
|
|
SM_Protect_ms_Calc,\
|
|
}
|
|
|
|
//! \memberof TSM_Protect
|
|
void SM_Protect_Init(TSM_Protect*);
|
|
//! \memberof TSM_Protect
|
|
void SM_Protect_Slow_Calc(TSM_Protect*);
|
|
//! \memberof TSM_Protect
|
|
void SM_Protect_Fast_Calc(TSM_Protect*);
|
|
//! \memberof TSM_Protect
|
|
void SM_Protect_ms_Calc(TSM_Protect*);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
|
|
|
|
|