/*****************************************************
Chip type               : ATmega8
Program type            : Application
AVR Core Clock frequency: 9,600000 MHz
Memory model            : Small
External RAM size       : 0
Data Stack size         : 256
*****************************************************/

#include <mega8.h>
#include <sdcard.h>
#include <stdio.h>
#include <delay.h>
#include <ff.h>
#include <spi.h>
// Declare your global variables here

void main(void)
{
unsigned char status;

PORTB=0x00;
DDRB=0x2C;

// SPI initialization
// SPI Type: Master
// SPI Clock Rate: 2000,000 kHz
// SPI Clock Phase: Cycle Start
// SPI Clock Polarity: Low
// SPI Data Order: MSB First
SPCR=0x50;
SPSR=0x00;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 1000,000 kHz
TCCR0=0x02;
TCNT0=0xF5;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x01;

// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x33;

DDRD=0xff;
// Global enable interrupts
#asm("sei")




while (1)
      {
status=disk_initialize(0);
printf("%u\r",status);
     
      }
      
}


// Timer 0 overflow interrupt service routine
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
disk_timerproc();
TCNT0=0xF7; //f
}