Refactored out the bitshifts for the defines.
This commit is contained in:
parent
25e1e647e8
commit
e2a9101d94
39
src/main.c
39
src/main.c
|
@ -24,14 +24,14 @@
|
|||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
#define RELAY0_ENPIN (1 << 1) // PORTA
|
||||
#define RELAY0_INPIN (1 << 3) // PORTA
|
||||
#define RELAY0_ENPIN 1 // PORTA
|
||||
#define RELAY0_INPIN 3 // PORTA
|
||||
|
||||
#define RELAY1_ENPIN (1 << 3) // PORTB
|
||||
#define RELAY1_INPIN (1 << 2) // PORTA
|
||||
#define RELAY1_ENPIN 3 // PORTB
|
||||
#define RELAY1_INPIN 2 // PORTA
|
||||
|
||||
#define RELAY2_ENPIN (1 << 2) // PORTB
|
||||
#define RELAY2_INPIN (1 << 0) // PORTB
|
||||
#define RELAY2_ENPIN 2 // PORTB
|
||||
#define RELAY2_INPIN 0 // PORTB
|
||||
|
||||
#define N_RELAYS 3
|
||||
|
||||
|
@ -44,20 +44,31 @@ void setup_relays(Relay *arr) {
|
|||
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 |= RELAY0_ENPIN;
|
||||
PORTA.DIR &= ~RELAY0_INPIN;
|
||||
PORTA.DIR |= (1 << RELAY0_ENPIN);
|
||||
PORTA.DIR &= ~(1 << RELAY0_INPIN);
|
||||
|
||||
for (int i = 0; i < N_RELAYS; i++) {
|
||||
Relay_MeasureMakeTime(&arr[0]);
|
||||
Relay_MeasureBreakTime(&arr[0]);
|
||||
}
|
||||
|
||||
//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) {
|
||||
Relay relay_array[N_RELAYS];
|
||||
setup_relays(relay_array);
|
||||
// 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);
|
||||
|
|
Loading…
Reference in New Issue