2024-07-25 00:21:29 +00:00
|
|
|
/*
|
|
|
|
* Author: username
|
|
|
|
* Date: todays_date
|
|
|
|
* filename: test_TriacOut.c
|
|
|
|
* description: module_purpose
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "CppUTest/CommandLineTestRunner.h"
|
|
|
|
#include "CppUTestExt/MockSupport.h"
|
|
|
|
|
|
|
|
//This define allows us to dircetly include the device header without error.
|
|
|
|
#define _AVR_IO_H_
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#include <iotn404.h>
|
|
|
|
#include "TriacOut.h"
|
|
|
|
#include "MockRegEdit.h"
|
|
|
|
}
|
|
|
|
|
2024-07-27 18:23:07 +00:00
|
|
|
|
|
|
|
void FakeDelay(double us)
|
|
|
|
{
|
|
|
|
//do Nothing.
|
|
|
|
}
|
|
|
|
|
2024-07-25 00:21:29 +00:00
|
|
|
TEST_GROUP(test_TriacOut)
|
|
|
|
{
|
|
|
|
void setup()
|
|
|
|
{
|
2024-07-27 18:23:07 +00:00
|
|
|
UT_PTR_SET(Delay_MicroSeconds, FakeDelay);
|
2024-07-25 00:21:29 +00:00
|
|
|
}
|
|
|
|
void teardown()
|
|
|
|
{
|
|
|
|
mock().checkExpectations();
|
|
|
|
mock().clear();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST(test_TriacOut, FirstTest)
|
|
|
|
{
|
|
|
|
//FAIL("Fail me!");
|
|
|
|
CHECK(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(test_TriacOut, TriacOut_SetupPins)
|
|
|
|
{
|
|
|
|
//Expect that pin PA1 is set to output
|
|
|
|
mock().expectOneCall("RegEdit_SetBit")
|
|
|
|
.withPointerParameter("reg", (void *) &PORTA.DIR)
|
2024-07-27 16:51:06 +00:00
|
|
|
.withUnsignedIntParameter("bit_num", G1);
|
2024-07-25 00:21:29 +00:00
|
|
|
|
|
|
|
//Expect that pin PB3 is set to output
|
|
|
|
mock().expectOneCall("RegEdit_SetBit")
|
|
|
|
.withPointerParameter("reg", (void *) &PORTB.DIR)
|
2024-07-27 16:51:06 +00:00
|
|
|
.withUnsignedIntParameter("bit_num", G2);
|
2024-07-25 00:21:29 +00:00
|
|
|
|
|
|
|
//Expect that pin PB2 is set to output
|
|
|
|
mock().expectOneCall("RegEdit_SetBit")
|
|
|
|
.withPointerParameter("reg", (void *) &PORTB.DIR)
|
2024-07-27 16:51:06 +00:00
|
|
|
.withUnsignedIntParameter("bit_num", G3);
|
2024-07-25 00:21:29 +00:00
|
|
|
|
|
|
|
TriacOut_SetupPins();
|
|
|
|
}
|
|
|
|
|
2024-07-27 16:52:29 +00:00
|
|
|
|
2024-07-25 00:21:29 +00:00
|
|
|
TEST(test_TriacOut, TriacOut_SetAllHigh)
|
|
|
|
{
|
|
|
|
//Expect that pin PA1 is set to output
|
|
|
|
mock().expectOneCall("RegEdit_SetBit")
|
|
|
|
.withPointerParameter("reg", (void *) &PORTA.OUT)
|
2024-07-27 16:52:29 +00:00
|
|
|
.withUnsignedIntParameter("bit_num", G1);
|
2024-07-25 00:21:29 +00:00
|
|
|
|
|
|
|
//Expect that pin PB3 is set to output
|
|
|
|
mock().expectOneCall("RegEdit_SetBit")
|
|
|
|
.withPointerParameter("reg", (void *) &PORTB.OUT)
|
2024-07-27 16:52:29 +00:00
|
|
|
.withUnsignedIntParameter("bit_num", G2);
|
2024-07-25 00:21:29 +00:00
|
|
|
|
|
|
|
//Expect that pin PB2 is set to output
|
|
|
|
mock().expectOneCall("RegEdit_SetBit")
|
|
|
|
.withPointerParameter("reg", (void *) &PORTB.OUT)
|
2024-07-27 16:52:29 +00:00
|
|
|
.withUnsignedIntParameter("bit_num", G3);
|
2024-07-25 00:21:29 +00:00
|
|
|
|
|
|
|
TriacOut_SetAllHigh();
|
|
|
|
}
|
2024-07-27 16:52:29 +00:00
|
|
|
|
2024-07-25 00:21:29 +00:00
|
|
|
TEST(test_TriacOut, TriacOut_PulsePins)
|
|
|
|
{
|
|
|
|
|
|
|
|
//Expect that pin PA1 is set to output
|
|
|
|
mock().expectOneCall("RegEdit_ClearBit")
|
|
|
|
.withPointerParameter("reg", (void *) &PORTA.OUT)
|
2024-07-27 16:56:03 +00:00
|
|
|
.withUnsignedIntParameter("bit_num", G1);
|
2024-07-25 00:21:29 +00:00
|
|
|
|
|
|
|
//Expect that pin PB3 is set to output
|
|
|
|
mock().expectOneCall("RegEdit_ClearBit")
|
|
|
|
.withPointerParameter("reg", (void *) &PORTB.OUT)
|
2024-07-27 16:56:03 +00:00
|
|
|
.withUnsignedIntParameter("bit_num", G2);
|
2024-07-25 00:21:29 +00:00
|
|
|
|
|
|
|
//Expect that pin PB2 is set to output
|
|
|
|
mock().expectOneCall("RegEdit_ClearBit")
|
|
|
|
.withPointerParameter("reg", (void *) &PORTB.OUT)
|
2024-07-27 16:56:03 +00:00
|
|
|
.withUnsignedIntParameter("bit_num", G3);
|
2024-07-25 00:21:29 +00:00
|
|
|
|
|
|
|
TriacOut_PulsePins(1000);
|
|
|
|
}
|