X-Git-Url: https://git.defcon.no/?a=blobdiff_plain;f=syncgen%2Fmain.c;h=3186c914f40704ff88db7a650dc2a49e68a79752;hb=2ea18f7e751c7464c664362f7907529e9fc869f0;hp=8ad9cb339f0e8dd686fabcbc9bdf323bec843121;hpb=59abb8c1a25fa444e1884450517e88f3c016e765;p=avrfbosd diff --git a/syncgen/main.c b/syncgen/main.c index 8ad9cb3..3186c91 100644 --- a/syncgen/main.c +++ b/syncgen/main.c @@ -5,17 +5,19 @@ #define ZERO PORTB &= 0xFC #define BLACK PORTB |= 0x01 -// -----..----- ^ -// | | | -// -| RST VCC |-` -// | | -// .--| X1 PB2 |- -// [ ] | | 470R -// '--| X2 PB1 |--^v^v-. -// | | |----> VidOut -// .--| GND PB0 |--^v^v-' -// | | | 1kR -//----- ------------ +#define DRAW_LOGO + +// -----..----- ^ +// | ___ | | +// Com RST -| RST VCC |-` +// | | +// MegaClk -| CLKI ADC1 |---< VidDetect +// | | 470R +// VSwithc -| PB4 PB1 |--^v^v-. +// | | |----> VidOut +// .--| GND PB0 |--^v^v-' +// | | | 1kR +// --- ------------ #include "avrosdlogo.h" @@ -82,7 +84,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 } @@ -94,38 +96,31 @@ void vsync(uint8_t odd_even) // Pre-equalization pulses b = odd_even ? 6 : 5; - for(a=0; a 312 ) ? line - 312 : line; + int t_line = line; // Reducing line-count complexity by half ;) + t_line = ( line > 312 ) ? line - 312 : line; +#ifdef DRAW_LOGO + // 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--; } - } +#endif + } return; } -/* -ISR (INT0_vect) +ISR (TIMER1_OVF_vect) { - //PORTB ^= 0x10; + // 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< 10) + // 255/50*4=20, thus 0.4V + if (ADCH > 20) { - // Dummy code. - // This needs to be replaced with something that triggers a timer ... - /// Simply indicate on PB4 that we are seeing somethin. - PORTB |= 0x10; + // 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<