#include <avr/io.h>
#include <util/delay.h>

#include "twi.h"
#include "uart.h"
#include "si5351.h"
#include "wspr.h"
#include "ov7670.h"

int main(void) {

    twi_init();
    uart_init();

    ov7670_init();


    //while(1) {
        ov7670_wait_vsync();
        ov7670_toggle_wrst();
        ov7670_unset_we();

        ov7670_wait_vsync();
        ov7670_set_we();
        ov7670_toggle_rrst();


        for(uint16_t y = 0; y < 480; y++) {
            for(uint16_t x = 0; x < 640; x++) {
                ov7670_toggle_rck();
                uint8_t bits = ov7670_read_bits();
                uart_putc(bits);
            }
        }

        uart_puts("Done");

    //}

    while(1);
}
