/** * @file main.c * @author Jake G * @date 15 June 2024 * @brief File contains the main function. * * This file contains the main logic loop and exists to setup the values * specific to the micro-controller. All other functions and configuration are * extracted into separate source files and headers for configuration. */ #include #define F_CPU 3333333UL // This can prevent issues with utils/delay.h library with the gcc toolchain #define __DELAY_BACKWARD_COMPATIBLE__ #include "RegEdit.h" #include "Relays.h" #include "SuperLoop.h" #include "config.h" #include "timer.h" #include /* Required header file */ #include #include #define RELAY0_ENPIN 1 // PORTA #define RELAY0_INPIN 3 // PORTA #define RELAY1_ENPIN 3 // PORTB #define RELAY1_INPIN 2 // PORTA #define RELAY2_ENPIN 2 // PORTB #define RELAY2_INPIN 0 // PORTB #define N_RELAYS 3 // Set the function pointer for the delay func void (*Delay_MicroSeconds)(double us) = _delay_us; 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; arr[0].disabled_fpc = false; // Set the directions for the input and output pins/ports PORTA.DIR |= (1 << RELAY0_ENPIN); PORTA.DIR &= ~(1 << RELAY0_INPIN); //for (int i = 0; i < N_RELAYS; i++) { //Relay_MeasureMakeTime(&arr[0]); //_delay_ms(5); //Relay_MeasureBreakTime(&arr[0]); //} } int main(int argc, char **argv) { // startup delay prevents fast toggles of relays on reset signals _delay_ms(500); Relay relay_array[N_RELAYS]; setup_relays(relay_array); Relay_MeasureMakeTime(&relay_array[0]); _delay_ms(500); Relay_MeasureBreakTime(&relay_array[0]); // Setup for Infinite Loop SuperLoop_SetIterations(0); SuperLoop_Run(); }