main.c

来自「AVR单片机 C语言程序设计经典实用」· C语言 代码 · 共 78 行

C
78
字号
//***************************************************************
// 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 + =
减小字号Ctrl + -
显示快捷键?