📄 m64_sd_vs1003.c
字号:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <includes.h>
#include <stdio.h>
#include <VS1003B.c>
unsigned char Sector_Buffer[513]={0};
extern void show_lcd();
//UART0 initialize
// desired baud rate: 115200
// actual: baud rate:115198 (0.0%)
// char size: 8 bit
// parity: Disabled
void uart0_init(void)
{
UCSR0B = 0x00; //disable while setting baud rate
UCSR0A = 0x00;
UCSR0C = 0x06;
UBRR0L = 0x05; //set baud rate lo
UBRR0H = 0x00; //set baud rate hi
UCSR0B = 0x18;
}
//UART1 initialize
// desired baud rate:115200
// actual baud rate:115198 (0.0%)
void uart1_init(void)
{
UCSR1B = 0x00; //disable while setting baud rate
UCSR1A = 0x00;
UCSR1C = 0x06;
UBRR1L = 0x05; //set baud rate lo
UBRR1H = 0x00; //set baud rate hi
UCSR1B = 0x18;
}
void Delay(unsigned int n)//延时
{
while(n--)asm("nop");
}
int main(void)
{
//unsigned long temp;
unsigned int temp1;
unsigned int i;
unsigned char retry=0;
PORTB=0xff;
DDRG=0x01;
PORTG=0xfe;
DDRD=0XFF;
SPI_PORT_INIT();
PORTD|=(1<<3);
//show_lcd();
//SD_SPI_Init();
SD_SPI_High();
PORTD&=~(1<<3);
uart0_init();
SD_Init();//初始化spi口
if(VS1003B_Init()){
UDR0=0XAA;
while((UCSR0A&(1<<TXC0))==0);
UCSR0A|=(1<<TXC1);}
/* while(1)
{
VS1003B_WriteCMD(0x0b,0xFFFF);
VS1003B_ReadCMD(0x0b);
VS1003B_ReadCMD(0x0b);
VS1003B_ReadCMD(0x0b);
UDR0=VS1003B_ReadCMD(0x0b);
while((UCSR0A&(1<<TXC0))==0);
UCSR0A|=(1<<TXC1);
Delay(32767);
Delay(32767);
Delay(32767);
Delay(32767);
Delay(32767);
Delay(32767);
VS1003B_WriteCMD(0x0b,0x0000);
VS1003B_ReadCMD(0x0b);
VS1003B_ReadCMD(0x0b);
UDR0=VS1003B_ReadCMD(0x0b);
while((UCSR0A&(1<<TXC0))==0);
UCSR0A|=(1<<TXC1);
Delay(32767);
Delay(32767);
Delay(32767);
Delay(32767);
Delay(32767);
Delay(32767);
}*/
while(SD_Reset())//初始化SD卡 //sd card initialize
{
retry++;
if(retry>20)
{
for(i=0;i<4;i++)
{
UDR0=0xaa;
while((UCSR0A&(1<<TXC0))==0);
UCSR0A|=(1<<TXC0);
}
break;
}
}
i=Get_FAT_Basic_Info();
temp1=Root_Dir();
while (1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -