diff --git a/src/main.c b/src/main.c index 6a9a0c2..110b282 100644 --- a/src/main.c +++ b/src/main.c @@ -26,9 +26,10 @@ #define SW1PIN (1 << 5) #define SW2PIN (1 << 4) #define RELAYPIN (1 << 7) -#define RELAYREADINGPIN (1 << 0) // It would be better to use PA7 so USART worked +#define RELAYREADINGPIN (1 << 6) // It would be better to use PA7 so USART worked -#define LED_BM_PORTA (1 << 6)|(1 << 1)|(1 << 2)|(1 << 3) +//#define LED_BM_PORTA (1 << 6)|(1 << 1)|(1 << 2)|(1 << 3) +#define LED_BM_PORTA (1 << 1)|(1 << 2)|(1 << 3) #define LED_BM_PORTB (1 << 3)|(1 << 2)|(1 << 0)|(1 << 1) // Set the function pointer for the delay func @@ -58,7 +59,7 @@ void Deactivate_Relay(void) void WaitForRelayConnect(void) { - while (!(PORTB.IN & RELAYREADINGPIN)) + while (!(PORTA.IN & RELAYREADINGPIN)) { ; } @@ -66,7 +67,7 @@ void WaitForRelayConnect(void) void WaitForRelayDisconnect(void) { - while (PORTB.IN & RELAYREADINGPIN) + while (PORTA.IN & RELAYREADINGPIN) { ; } @@ -107,13 +108,18 @@ void LedSetup(LedByte *led_byte) //pin 3, bit 7, PA6 led_byte->leds[7].port = &PORTA.OUT; - led_byte->leds[7].pin_num = 6; + //led_byte->leds[7].pin_num = 6; + led_byte->leds[7].pin_num = 3; } int main(int argc, char **argv) { + //We use pin 10 which is the UDPI/RESET pin. + //This means we have to change it's mode. + + PORTA.DIR |= RELAYPIN; - PORTB.DIR &= ~RELAYREADINGPIN; + PORTA.DIR &= ~RELAYREADINGPIN; PORTA.DIR &= ~SW1PIN; PORTA.DIR &= ~SW2PIN; @@ -124,7 +130,7 @@ int main(int argc, char **argv) LedByte led_byte = LedController_New(&PORTA.OUT); LedSetup(&led_byte); - //wait for a second then disable UPDI + LedController_ShowByte(&led_byte, 0xAA); while (true) {