⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 MP3播放程序
💻 C
字号:

//********************************************************************************************
//
// Title		: MP3测试 - 主程序
// Author		: Ant (gz_ant@126.com)
// Created		: 2005/02/16
// Revised		: 2005/02/19
// Version		: 0.1
// Target MCU	: MEGA16
// Editor Tabs	: 4
//
// 注: 	本代码用于测试STA013硬件及其驱动程序, 并非一个完整的MP3播放器程序.
//		上电后,会循环不停播放一段约2秒的MP3音乐.
//		硬件没有连接RAM缓冲及储存MP3文件的设备, MP3数据是保存在AVR的FLASH中.
//		本代码经测试, 但可能存有Bugs, 若你发现有任何Bug或有任何建议,
//		请来信告知: gz_ant@126.com
////		本代码部分来自"Procyon AVRlib": http://hubbard.engr.scu.edu/embedded/avr/avrlib/release_notes.html
//		特此感谢它的创始人: Pascal Stang !
//
//		感谢在www.21icbbs.com帮助过winsu的朋友, 希望使用者能发扬网络的 "自由,开放" 精神.
//********************************************************************************************

#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <avr/delay.h>

#include "type.h"
#include "main.h"
#include "UART.h"

int main(void)
{
	UART_Debug();
}

//短延时
void Delayus(long us) 
{
    while ( us ) us--;
}
//延时程序,它以毫秒为单位执行延时任务
void Delayms(u16 t)
{
	u16 i;
	for(i=0;i<t;i++)
		_delay_loop_2(FEQ * 250 - 1);
}
//=====================================
//数值转换成10,2,16进制,由ZZ从"c runtime lib"中获得,直接使用未修改
void xtoa (unsigned long val, char *buf, unsigned radix, int is_neg )
{
        char *p;                /* pointer to traverse string */
        char *firstdig;         /* pointer to first digit */
        char temp;              /* temp char */
        unsigned digval;        /* value of digit */

        p = buf;

        if (is_neg)
		{
            /* negative, so output '-' and negate */
            *p++ = '-';
            val = (unsigned long)(-(long)val);
        }

        firstdig = p;           /* save pointer to first digit */

        do {
            digval = (unsigned) (val % radix);
            val /= radix;       /* get next digit */

            /* convert to ascii and store */
            if (digval > 9)
                *p++ = (char) (digval - 10 + 'a');  /* a letter */
            else
                *p++ = (char) (digval + '0');       /* a digit */
        } while (val > 0);

        /* We now have the digit of the number in the buffer, but in reverse
           order.  Thus we reverse them now. */

        *p-- = '\0';            /* terminate string; p points to last digit */

        do {
            temp = *p;
            *p = *firstdig;
            *firstdig = temp;   /* swap *p and *firstdig */
            --p;
            ++firstdig;         /* advance to next two digits */
        } while (firstdig < p); /* repeat until halfway */
}
/////////
char * _itoa ( int val, char *buf, int radix )
{
        if (radix == 10 && val < 0)
            xtoa((unsigned long)val, buf, radix, 1);
        else
            xtoa((unsigned long)(unsigned int)val, buf, radix, 0);
        return buf;
}
//


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -