нарыл в кодевижне пример, disk_status=disk_initialize(0) - не выходит из этой функции
Example:
/* ATmega128 I/O register definitions */
#include ‹mega128.h›
/* MMC/SD/SD HC card support */
#include ‹sdcard.h›
/* delay functions */
#include ‹delay.h›
/* the LCD is connected to PORTC outputs */
#asm
.equ __lcd_port=0x15 ;PORTC
#endasm
/* include the LCD driver routines */
#include ‹lcd.h›
/* Timer1 overflow interrupt frequency [Hz] */
#define T1_OVF_FREQ 100
/* Timer1 clock prescaler value */
#define T1_PRESC 1024L
/* Timer1 initialization value after overflow */
#define T1_INIT (0x10000L-(_MCU_CLOCK_FREQUENCY_/(T1_PRESC*T1_OVF_FREQ)))
/* 100Hz timer interrupt generated by ATmega128 Timer1 overflow */
interrupt [TIM1_OVF] void timer_comp_isr(void)
{
/* re-initialize Timer1 */
TCNT1H=T1_INIT››8;
TCNT1L=T1_INIT&0xFF;
/* card access low level timing function */
disk_timerproc();
/* the rest of the interrupt service routine */
/* .... */
}
void main(void)
{
unsigned char disk_status;
/* initialize Timer1 overflow interrupts in Mode 0 (Normal) */
TCCR1A=0x00;
/* clkio/1024 */
TCCR1B=(1‹‹CS12)|(1‹‹CS10);
/* timer overflow interrupts will occur with 100Hz frequency */
TCNT1H=T1_INIT››8;
TCNT1L=T1_INIT&0xFF;
/* enable Timer1 overflow interrupt */
TIMSK=1‹‹TOIE1;
/* initialize the LCD, 16 characters/line */
lcd_init(16);
/* globally enable interrupts */
#asm("sei")
/* initialize SPI interface and card driver */
disk_status=disk_initialize(0);
/* clear the LCD */
lcd_clear();
/* display disk initialization result on the LCD */
if (disk_status & STA_NOINIT) lcd_puts("Disk init failed");
else
if (disk_status & STA_NODISK) lcd_puts("Card not present");
else
if (disk_status & STA_PROTECT) lcd_puts("Card write\nprotected");
/* all status flags are 0, disk initialization OK */
else lcd_puts("Init OK");
/* wait 2 seconds */
delay_ms(2000);
/* the rest of the program */
/* .... */
while(1)
{
/* .... */
}
}
[/CODE]