You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.6 KiB
C++
92 lines
2.6 KiB
C++
7 months ago
|
/*
|
||
|
* TriggerRegisterBase.cpp
|
||
|
*
|
||
|
* Author: Aleksey Gerasimenko
|
||
|
* gerasimenko.aleksey.n@gmail.com
|
||
|
*/
|
||
|
|
||
|
#include "SYSCTRL/TriggerRegister.h"
|
||
|
|
||
|
namespace SYSCTRL
|
||
|
{
|
||
|
|
||
|
TriggerRegister::TriggerRegister()
|
||
|
{}
|
||
|
#pragma CODE_SECTION("ramfuncs");
|
||
|
void TriggerRegister::clear(TriggerRegisterStructure& trigger)
|
||
|
{
|
||
|
trigger.all = 0x0028;
|
||
|
//
|
||
|
}//
|
||
|
//
|
||
|
#pragma CODE_SECTION("ramfuncs");
|
||
|
void TriggerRegister::set(TriggerRegisterStructure& trigger)
|
||
|
{
|
||
|
trigger.all = 0x0014;
|
||
|
//
|
||
|
}//
|
||
|
//
|
||
|
#pragma CODE_SECTION("ramfuncs");
|
||
|
void TriggerRegister::execute_set_priority(TriggerRegisterStructure& trigger)
|
||
|
{
|
||
|
// Q(i) = S | (nR & Q(i-1))
|
||
|
//
|
||
|
trigger.signal.quit_privious = trigger.signal.quit;
|
||
|
trigger.signal.quit = trigger.signal.set | ((!trigger.signal.reset) & trigger.signal.quit_privious);
|
||
|
SYSCTRL::TriggerRegister::_signal_constructor(trigger);
|
||
|
//
|
||
|
}//
|
||
|
//
|
||
|
#pragma CODE_SECTION("ramfuncs");
|
||
|
void TriggerRegister::execute_reset_priority(TriggerRegisterStructure& trigger)
|
||
|
{
|
||
|
// Q(i) = nR & (S | Q(i-1))
|
||
|
//
|
||
|
trigger.signal.quit_privious = trigger.signal.quit;
|
||
|
trigger.signal.quit = (!trigger.signal.reset) & (trigger.signal.set | trigger.signal.quit_privious);
|
||
|
SYSCTRL::TriggerRegister::_signal_constructor(trigger);
|
||
|
//
|
||
|
}//
|
||
|
//
|
||
|
#pragma CODE_SECTION("ramfuncs");
|
||
|
void TriggerRegister::execute_rs(TriggerRegisterStructure& trigger)
|
||
|
{
|
||
|
// Q(i) = (nR & (S | Q(i-1))) | (S & Q(i-1))
|
||
|
//
|
||
|
trigger.signal.quit_privious = trigger.signal.quit;
|
||
|
trigger.signal.quit = ((!trigger.signal.reset) & (trigger.signal.set | trigger.signal.quit_privious)) |
|
||
|
(trigger.signal.set & trigger.signal.quit_privious);
|
||
|
SYSCTRL::TriggerRegister::_signal_constructor(trigger);
|
||
|
//
|
||
|
}//
|
||
|
//
|
||
|
#pragma CODE_SECTION("ramfuncs");
|
||
|
void TriggerRegister::setSet(TriggerRegisterStructure& trigger, bool ref)
|
||
|
{
|
||
|
trigger.signal.set = ref;
|
||
|
trigger.signal.is_on = ref;
|
||
|
//
|
||
|
}//
|
||
|
//
|
||
|
#pragma CODE_SECTION("ramfuncs");
|
||
|
void TriggerRegister::setReset(TriggerRegisterStructure& trigger, bool ref)
|
||
|
{
|
||
|
trigger.signal.reset = ref;
|
||
|
trigger.signal.is_off = ref;
|
||
|
//
|
||
|
}//
|
||
|
//
|
||
|
#pragma CODE_SECTION("ramfuncs");
|
||
|
inline void TriggerRegister::_signal_constructor(TriggerRegisterStructure& trigger)
|
||
|
{
|
||
|
trigger.signal.is_on = trigger.signal.quit;
|
||
|
trigger.signal.negquit = !trigger.signal.quit;
|
||
|
trigger.signal.is_off = !trigger.signal.quit;
|
||
|
trigger.signal.is_switched_on = trigger.signal.quit & (!trigger.signal.quit_privious);
|
||
|
trigger.signal.is_switched_off = (!trigger.signal.quit) & trigger.signal.quit_privious;
|
||
|
//
|
||
|
}//
|
||
|
//
|
||
|
} /* namespace SYSCTRL */
|
||
|
|