This repository was archived by the owner on Mar 29, 2021. It is now read-only.
File tree 2 files changed +15
-4
lines changed
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ HDMI Switcher code for ATmega88PA
22
22
#include "switch.h"
23
23
#include "eeprom.h"
24
24
25
- volatile uint8_t selectedInput ;
25
+ volatile uint8_t selectedInput = 0x0 ;
26
26
volatile uint8_t timer = 11 ;
27
27
28
28
void init (void );
@@ -38,6 +38,8 @@ int main(void) {
38
38
outputState = 0x0 ; // reading failed, revert to default parameters
39
39
eeprom_write (outputState ); // try to save defaults
40
40
}
41
+ selectedInput = outputState ;
42
+ outputState = 0x0 ;
41
43
42
44
init ();
43
45
@@ -85,7 +87,7 @@ void init(void) {
85
87
PORTC = 0x0 ;
86
88
DDRD = 0x0 ; // set PD to input
87
89
PORTD = 0x0 ; // disable pull-ups
88
- PRR = 0xEB ; // power reduction
90
+ PRR = 0xE7 ; // power reduction
89
91
90
92
PCMSK2 = 0x3F ; // prepare interrupts for every input pin
91
93
PCICR = 0x4 ; // enable PCINT for PORTD
@@ -97,6 +99,15 @@ void init(void) {
97
99
}
98
100
99
101
void mcu_sleep (void ) {
102
+ PORTB |= 0xC3 ; // blink all LEDs
103
+ _delay_ms (1000 );
104
+ PORTB &= ~0xC3 ;
105
+ _delay_ms (100 );
106
+ PORTB |= 0xC3 ;
107
+ _delay_ms (100 );
108
+ PORTB &= ~0xC3 ; // disable LEDs
109
+ _delay_ms (100 );
110
+
100
111
set_sleep_mode (SLEEP_MODE_PWR_DOWN );
101
112
cli ();
102
113
sleep_enable ();
Original file line number Diff line number Diff line change @@ -25,13 +25,13 @@ void switch_off(void) {
25
25
_delay_ms (10 );
26
26
PORTC &= ~SW3_OE ; // disable SW3_OE
27
27
_delay_ms (10 );
28
+ PORTC &= ~Dx_SEL_MASK ; // clear Dx_SEL on all switches
28
29
}
29
30
30
31
void switch_input (uint8_t portConfig , uint8_t coldStart ) {
31
32
ATOMIC_BLOCK (ATOMIC_RESTORESTATE ) {
32
33
if (coldStart == 0 ) switch_off ();
33
- if (portConfig == OFF ) PORTC &= ~Dx_SEL_MASK ; // clear Dx_SEL on all switches
34
- else {
34
+ if (portConfig != OFF ) {
35
35
PORTC |= (portConfig & Dx_SEL_MASK ); // set Dx_SEL on all switches
36
36
_delay_ms (500 );
37
37
PORTC |= (portConfig & SW1_SW2_OE ); // enable SWn_OE
You can’t perform that action at this time.
0 commit comments