Added function for setting up relays and called it in the `main()`

This commit is contained in:
jakeg00dwin 2024-09-03 16:42:02 -07:00
parent d1091fd73d
commit e3cd70448b
1 changed files with 17 additions and 7 deletions

View File

@ -33,17 +33,27 @@
#define RELAY2_ENPIN (1 << 2) // PORTB
#define RELAY2_INPIN (1 << 0) // PORTB
#define N_RELAYS 3
// Set the function pointer for the delay func
void (*Delay_MicroSeconds)(double us) = _delay_us;
int main(int argc, char **argv) {
Relay relay_array[3];
void setup_relays(Relay *arr) {
// setup the first relay
arr[0].output_port = &PORTA.OUT;
arr[0].output_pin = RELAY0_ENPIN;
arr[0].input_port = &PORTA.IN;
arr[0].input_pin = RELAY0_INPIN;
// setup for the first relay
relay_array[0].output_port = PORTA.OUT;
relay_array[0].output_pin = RELAY0_ENPIN;
relay_array[0].input_port = PORTA.IN;
relay_array[0].input_pin = RELAY0_INPIN;
for (int i = 0; i < N_RELAYS; i++) {
Relay_MeasureMakeTime(&arr[0]);
Relay_MeasureBreakTime(&arr[0]);
}
}
int main(int argc, char **argv) {
Relay relay_array[N_RELAYS];
setup_relays(relay_array);
// Setup for Infinite Loop
SuperLoop_SetIterations(0);