X-Git-Url: https://git.defcon.no/?a=blobdiff_plain;f=syncgen%2Fmain.c;h=1dbfefb67913f324b1f547a93705c4c2b0f05923;hb=bcd052520233e777bc7724f960b23a5ac861b817;hp=efa18e7b2f1592725c64625606c30a03a1d7248e;hpb=060fbe0a05eab3ab6997ad0a2403b63c006ca522;p=avrfbosd diff --git a/syncgen/main.c b/syncgen/main.c index efa18e7..1dbfefb 100644 --- a/syncgen/main.c +++ b/syncgen/main.c @@ -1,110 +1,24 @@ #include #include #include -#define ZERO PORTB=0b000 -#define BLACK PORTB=0b001 - -// -----..----- ^ -// | | | -// -| RST VCC |-` -// | | -// .--| X1 PB2 |- -// [ ] | | 470R -// '--| X2 PB1 |--^v^v-. -// | | |----> VidOut -// .--| GND PB0 |--^v^v-' -// | | | 1kR -//----- ------------ -/* -uint8_t testimg_data[] = -{ - 0b11111100, 0b00000000, 0b00000011, 0b10000000, 0b00000000, 0b00000000, - 0b11111100, 0b00000000, 0b00000011, 0b10000000, 0b00000000, 0b00000000, - 0b11111100, 0b00000000, 0b00000011, 0b10000000, 0b00000000, 0b00000000, - 0b11111100, 0b00000000, 0b00000011, 0b10000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, - 0b11111100, 0b00000000, 0b00000011, 0b11000000, 0b00000000, 0b00000000, - 0b11111100, 0b00000000, 0b00000011, 0b11000000, 0b00000000, 0b00000000, - 0b11111100, 0b00000000, 0b00000011, 0b11000000, 0b00000000, 0b00000000, - 0b11111100, 0b00000000, 0b00000011, 0b11000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, - 0b00110000, 0b00000000, 0b00000011, 0b01100000, 0b00000000, 0b00000000, - 0b00110000, 0b00000000, 0b00000011, 0b01100000, 0b00000000, 0b00000000, - 0b00110000, 0b00000000, 0b00000011, 0b01100000, 0b00000000, 0b00000000, - 0b00110000, 0b00000000, 0b00000011, 0b01100000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, - 0b00110000, 0b00000000, 0b00000011, 0b01100000, 0b00000000, 0b00000000, - 0b00110000, 0b00000000, 0b00000011, 0b01100000, 0b00000000, 0b00000000, - 0b00110000, 0b00000000, 0b00000011, 0b01100000, 0b00000000, 0b00000000, - 0b00110000, 0b00000000, 0b00000011, 0b01100000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, - 0b00110010, 0b11001101, 0b10011011, 0b01101111, 0b00110000, 0b00000000, - 0b00110010, 0b11001101, 0b10011011, 0b01101111, 0b00110000, 0b00000000, - 0b00110010, 0b11001101, 0b10011011, 0b01101111, 0b00110000, 0b00000000, - 0b00110010, 0b11001101, 0b10011011, 0b01101111, 0b00110000, 0b00000000, - 0b00000000, 0b00000000, - 0b00110100, 0b11001101, 0b10011011, 0b01101111, 0b00110000, 0b00000000, - 0b00110100, 0b11001101, 0b10011011, 0b01101111, 0b00110000, 0b00000000, - 0b00110100, 0b11001101, 0b10011011, 0b01101111, 0b00110000, 0b00000000, - 0b00110100, 0b11001101, 0b10011011, 0b01101111, 0b00110000, 0b00000000, - 0b00000000, 0b00000000, - 0b00110000, 0b11101100, 0b11110011, 0b11011001, 0b10110000, 0b01101100, - 0b00110000, 0b11101100, 0b11110011, 0b11011001, 0b10110000, 0b01101100, - 0b00110000, 0b11101100, 0b11110011, 0b11011001, 0b10110000, 0b01101100, - 0b00110000, 0b11101100, 0b11110011, 0b11011001, 0b10110000, 0b01101100, - 0b01101100, 0b01101100, - 0b00110000, 0b11101100, 0b11110011, 0b11011001, 0b10110000, 0b10010010, - 0b00110000, 0b11101100, 0b11110011, 0b11011001, 0b10110000, 0b10010010, - 0b00110000, 0b11101100, 0b11110011, 0b11011001, 0b10110000, 0b10010010, - 0b00110000, 0b11101100, 0b11110011, 0b11011001, 0b10110000, 0b10010010, - 0b10010010, 0b10010010, - 0b00110110, 0b11111100, 0b01100011, 0b00011111, 0b10110000, 0b10000010, - 0b00110110, 0b11111100, 0b01100011, 0b00011111, 0b10110000, 0b10000010, - 0b00110110, 0b11111100, 0b01100011, 0b00011111, 0b10110000, 0b10000010, - 0b00110110, 0b11111100, 0b01100011, 0b00011111, 0b10110000, 0b10000010, - 0b10000010, 0b10000010, - 0b00110110, 0b11111100, 0b01100011, 0b00011111, 0b10110000, 0b01000100, - 0b00110110, 0b11111100, 0b01100011, 0b00011111, 0b10110000, 0b01000100, - 0b00110110, 0b11111100, 0b01100011, 0b00011111, 0b10110000, 0b01000100, - 0b00110110, 0b11111100, 0b01100011, 0b00011111, 0b10110000, 0b01000100, - 0b01000100, 0b01000100, - 0b00110110, 0b11011100, 0b01100011, 0b00011001, 0b10110000, 0b00101000, - 0b00110110, 0b11011100, 0b01100011, 0b00011001, 0b10110000, 0b00101000, - 0b00110110, 0b11011100, 0b01100011, 0b00011001, 0b10110000, 0b00101000, - 0b00110110, 0b11011100, 0b01100011, 0b00011001, 0b10110000, 0b00101000, - 0b00101000, 0b00101000, - 0b00110110, 0b11011100, 0b01100011, 0b00011001, 0b10110000, 0b00010000, - 0b00110110, 0b11011100, 0b01100011, 0b00011001, 0b10110000, 0b00010000, - 0b00110110, 0b11011100, 0b01100011, 0b00011001, 0b10110000, 0b00010000, - 0b00110110, 0b11011100, 0b01100011, 0b00011001, 0b10110000, 0b00010000, - 0b00010000, 0b00010000, - 0b00110110, 0b11001100, 0b01100011, 0b00011001, 0b10111111, 0b00000000, - 0b00110110, 0b11001100, 0b01100011, 0b00011001, 0b10111111, 0b00000000, - 0b00110110, 0b11001100, 0b01100011, 0b00011001, 0b10111111, 0b00000000, - 0b00110110, 0b11001100, 0b01100011, 0b00011001, 0b10111111, 0b00000000, - 0b00000000, 0b00000000, - 0b00110110, 0b11001100, 0b01100011, 0b00011001, 0b10111111, 0b00000000, - 0b00110110, 0b11001100, 0b01100011, 0b00011001, 0b10111111, 0b00000000, - 0b00110110, 0b11001100, 0b01100011, 0b00011001, 0b10111111, 0b00000000, - 0b00110110, 0b11001100, 0b01100011, 0b00011001, 0b10111111, 0b00000000, - 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, - 0b00000000, 0b00000000, -}; - -#define testimg_height 15 -#define testimg_width 208 - -#define START1 100 -#define END1 115 -#define START2 412 -#define END2 427 -*/ + +#define ZERO PORTB &= 0xFC +#define BLACK PORTB |= 0x01 + +// -----..----- ^ +// | ___ | | +// Com RST -| RST VCC |-` +// | | +// MegaClk -| CLKI ADC1 |---< VidDetect +// | | 470R +// VSwithc -| PB4 PB1 |--^v^v-. +// | | |----> VidOut +// .--| GND PB0 |--^v^v-' +// | | | 1kR +// --- ------------ #include "avrosdlogo.h" + volatile int rasterline; volatile uint16_t line; @@ -168,7 +82,7 @@ void asm_render_line( void ) { void hsync(void) { - line++; + line++; // Bumping the line-counter as part of hsync gives just the right front-porch ;D ZERO; _delay_us(4); // sync BLACK; _delay_us(8); // Back porch } @@ -180,38 +94,31 @@ void vsync(uint8_t odd_even) // Pre-equalization pulses b = odd_even ? 6 : 5; - for(a=0; a 312 ) ? line - 312 : line; + // Draw the logo-image centered vertically if ( t_line > 118 && t_line < 118 + (2*testimg_height) ) { - _delay_us(12); + _delay_us(12.3); asm_render_line(); + // Stretch the image vertically by repeating the same line twice if( !stretch ) { stretch = 1; renderLine += hres; + // Make sure we don't draw anything from RAM after the end of the image if ( renderLine > ((testimg_height*hres)-1) ) renderLine = 0; } else stretch--; } @@ -245,6 +156,18 @@ ISR (TIMER0_COMPA_vect) return; } +ISR (TIMER1_OVF_vect) +{ + // If this interrupt-vector is run, Timer1 has overflowed, and that means + // we have not seen any signal of significant level for quite a while. + // This means Sync-generation is needed... + + // Make sure sync-gen is running... + TIMSK |= (1< 64us. Trigger one early.. - sei(); + // Video detection is done using ADC1 on PB2... + ADMUX |= (1< 20) + { + // Make sure any signal generated by us does not leak back + PORTB &= 0xEF; // Switch OFF VOut-switch for ATtiny + // The next statement stops sync-generation, thus also image-generation.. + TIMSK &= ~(1<