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

📄 main.c

📁 avr单片机的api编程
💻 C
字号:
#include <avr/io.h>
#include <compat/deprecated.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include "uart.c"

#define uint unsigned int
#define uchar unsigned char

#define __ASSERT_USE_STDERR   //定义此宏可使断言从STDERR输出错误信息,并进入一个无限循环
                              //若不定义,只能使程序进入一个无限循
#include <assert.h>

void DelayMs(uint16_t t)
{
  uint16_t i;
  for(i=0;i<t;i++)
    _delay_loop_2(250*4);
}

//io口访问测试
int main(void)
{	
//	uchar a;
	StdIoInit();  
	printf("hello!\nwelcome to here!\n>");    //发送测试字符 
	sei();									//使能全局中断
	
	/*//测试loop_until_bit_is_clear(),loop_until_bit_is_set();
	loop_until_bit_is_clear(PINB,0);
	printf("bit is clear\n");*/
	/*//cbi(DDRB,0);读端口测试bit_is_set(),bit_is_clesr();
	assert(bit_is_set(PINB,0));*/
	/*{
		DDRB = 0;
		a =  inp(PINB);
		printf("%d\n>",a);
	}*/
	
	while(1);
	/*测试端口输出cbi(),sbi();
	while(1)
	{
		cbi(PORTB,0);
		DelayMs(100);
		sbi(PORTB,0);
		DelayMs(100);
	}*/
}

⌨️ 快捷键说明

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