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

📄 main.c

📁 AVR单片机C语言程序设计实例精粹
💻 C
字号:
//***************************************************************
// File Name : LED.c
// Author    : Steaven
// Created   : 2008-07-26
// Modified  : 
// Revision  : V0.0
//***************************************************************

#include "includes.h"

//global variables definition
INT8U bI2C_Event = 0;

//***************************************************************
// Function    : sSet_I2C_Event
// Input       : event - i2c operation event 
// Output      : none
// Description : I2C Event Interface Function
//***************************************************************
void sSet_I2C_Event(INT8U event)
{
	bI2C_Event = event;
}

//***************************************************************
// Function    : sbGet_I2C_Event
// Input       :  none  
// Output      : i2c operation event
// Description : I2C Event Interface Function
//***************************************************************
INT8U sbGet_I2C_Event(void)
{
	INT8U event;
	event = bI2C_Event;
	bI2C_Event = 0;
	return(event);
}

void main(void) 
{ 
	Hardware_Init();
	Init_DS1337();
	
	while(1)
	{
		if(sbGet_I2C_Event() != 0)
		{
			Read_DS1337_Calendar();
		}
	}
} 

//***************************************************************
// Function    : wTimeCountr0_Interrupt                                
// Input       : none                                            
// Output      : none                                            
// Description : ATmega16 T/C0 ISR                               
//***************************************************************
#pragma interrupt_handler wTimeCountr0_Interrupt:20                    
void wTimeCountr0_Interrupt(void)                                      
{                                                                
	static INT8U int_count = 0;
	                                      
	//Clear wTimeCountr0 OCIF Flag                                     
	TIFR  |= 0x02;                                               
	TCNT0  = 0x00; 
	                                             
	//Interrupt count,send I2C event every second 
	if(int_count++ == 100)
	{
		int_count = 0;
		sSet_I2C_Event(1);
	}                                                
} 

//=========================END OF FILE=========================//
                    
                                    

⌨️ 快捷键说明

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