while(cnt-->0) _delay_ms(1);
}
+void set_busy ( uint8_t busy)
+{
+ if ( busy )
+ {
+ // Set busy signal
+ PORTB |= (1 << PB1);
+
+ // TODO: Disable SPI communication here...
+ }
+ else
+ {
+ // Clear Busy signal
+ PORTB &= ~(uint8_t)(1 << PB1);
+
+ // TODO: Enable SPI communication here...
+ }
+}
+
void active_lines ( void )
{
static uint8_t rept;
_delay_us(4);
+ // Set Busy signal. Line rendering is time-critical.
+ set_busy(1);
asm_render_line();
+ set_busy(0);
if( !rept )
{
void blank_lines ( void )
{
+ // Do nothing on the "lead-in" lines
if ( line < FIRST_LINE )
- {
- PORTB ^= 0x004;
return;
- }
+
+ // Clear Frame Ready signal
+ PORTD &= ~(uint8_t)(1 << PD5);
+
+ // Activate rendering
line_handler = active_lines;
}
buffer_position = 0;
line_handler = &blank_lines;
EIMSK &= ~(uint8_t)(1<<INT1);
+
+ // Set Frame Ready signal
+ PORTD |= (1 << PD5);
+
}
}
//Main Function
int main(void)
{
-
// Note: PB0 is used as CLKO outputting 20MHz clock to ATtiny
-
- // Using some pins on PORTB for debug-indicator-LEDs
- DDRB = (1 << PB1)|(1 << PB2);
- PORTB = 0x0;
-
+
+ // Set PB2 as Output for BUSY signal
+ DDRB = (1 << PB1);
+
+ // Set PD5 as Output for FR signal
+ // Set PD6 as Output for Status LED
// Using pin 7 on PD to clock out pixels \o/
- DDRD = (1<<PD7);
+ DDRD = (1<<PD5)|(1<<PD6)|(1<<PD7);
+
+ // Clear PORTB and PORTD
+ PORTB = 0x0;
PORTD = 0x0;
+ // Allocate the framebuffer :D
+ screen_buffer = (uint8_t*) malloc( hres_bytes * VRES * sizeof(uint8_t) );
+ // And make sure it's cleared
+ fill(c_BLACK);
+
/* LM1881 pins are connected to:
INT0 / PCINT18 / PD2 <- VSYNC
INT1 / PCINT19 / PD3 <- CSYNC
*/
EICRA |= (1<<ISC01)|(1<<ISC00); // Select Rising-edge interrupt for VSync
EICRA |= (1<<ISC11)|(1<<ISC10); // Select Rising-edge interrupt for HSync
- EIMSK |= (1<<INT0); // Enable VSync-interrupts
+ EIMSK |= (1<<INT0); // Enable VSync-interrupts
- // And enable interrupts globally.
+ // Enable interrupts globally.
sei();
- // Allocate the framebuffer :D
- screen_buffer = (uint8_t*) malloc( hres_bytes * VRES * sizeof(uint8_t) );
- // And make sure it's cleared
- fill(c_BLACK);
-
// Do some static drawing :P
set_pixel(28, 8, 1);
set_pixel(92, 82, 1);
set_pixel(92, 8, 1);
set_pixel(28, 82, 1);
-
draw_line(0, 0, 128, 92, 1);
draw_line(128, 0, 0, 92, 1);
fill_rect( 38, 25, 52, 42, 1);
fill_rect( 41, 28, 46, 36, 0);
- //fill_rect( 54, 41, 20, 10, 0);
-
for (;;)
{
- PORTB ^= 0x002;
+ // Toggle status LED
+ PORTD ^= (uint8_t)(1 << PD6);
+
for ( int j = 0; j < 92; j++ )
{
draw_line(0,0,128,j, 2);