Added test to ensure the relay is activated/deactivated for timing testing.
This commit is contained in:
parent
aa61a0821e
commit
25e1e647e8
|
@ -15,6 +15,7 @@
|
|||
|
||||
void Relay_MeasureMakeTime(Relay *relay) {
|
||||
Timer_Start();
|
||||
Relay_Enable(relay);
|
||||
while (!Relay_ReadState(relay)) {
|
||||
}
|
||||
Timer_Stop();
|
||||
|
@ -23,6 +24,7 @@ void Relay_MeasureMakeTime(Relay *relay) {
|
|||
|
||||
void Relay_MeasureBreakTime(Relay *relay) {
|
||||
Timer_Start();
|
||||
Relay_Disable(relay);
|
||||
while (Relay_ReadState(relay)) {
|
||||
}
|
||||
Timer_Stop();
|
||||
|
@ -34,7 +36,7 @@ void Relay_Enable(Relay *relay) {
|
|||
return;
|
||||
}
|
||||
|
||||
(*(uint8_t *)relay->output_port) |= (1 << (relay->output_pin));
|
||||
(*(volatile uint8_t *)relay->output_port) |= (1 << (relay->output_pin));
|
||||
}
|
||||
|
||||
void Relay_Disable(Relay *relay) {
|
||||
|
@ -48,7 +50,7 @@ void Relay_Disable(Relay *relay) {
|
|||
void Relay_DisableForPowerCycle(Relay *relay) { relay->disabled_fpc = true; }
|
||||
|
||||
bool Relay_ReadState(Relay *relay) {
|
||||
if (*(uint8_t *)relay->input_port & (1 << relay->input_pin)) {
|
||||
if (*(volatile uint8_t *)relay->input_port & (1 << relay->input_pin)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -155,6 +155,7 @@ TEST(test_RelaysTimer, MakeTimeCallsCorrectly)
|
|||
|
||||
Relay_MeasureMakeTime(&relay);
|
||||
CHECK_EQUAL(fake_return, relay.make_time);
|
||||
CHECK_EQUAL(0x01, fake_ouput_port);
|
||||
|
||||
mock().checkExpectations();
|
||||
}
|
||||
|
@ -162,6 +163,8 @@ TEST(test_RelaysTimer, MakeTimeCallsCorrectly)
|
|||
|
||||
TEST(test_RelaysTimer, BreakTimeCallsCorrectly)
|
||||
{
|
||||
//We should start by setting the bit for it high in the output reg.
|
||||
fake_ouput_port |= (1<<relay.output_pin);
|
||||
uint16_t fake_return = 56;
|
||||
mock().expectOneCall("Timer_Start");
|
||||
mock().expectOneCall("Timer_Stop");
|
||||
|
@ -170,6 +173,7 @@ TEST(test_RelaysTimer, BreakTimeCallsCorrectly)
|
|||
|
||||
Relay_MeasureBreakTime(&relay);
|
||||
CHECK_EQUAL(fake_return, relay.break_time);
|
||||
CHECK_EQUAL(0x00, fake_ouput_port);
|
||||
|
||||
mock().checkExpectations();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue