|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2010-4-22 09:42:43
|
显示全部楼层
以下是主函数
//ICC-AVR application builder : 2010-4-20 9:19:00
// Target : M32
// Crystal: 4.0000Mhz
#include <iom32v.h>
#include <macros.h>
#include <AVRdef.h>
#include "PUBLIC.H"
#include "MAIN.H"
extern void I2CPORTInit (void);
extern uint8 FM24C256Read1Byte (uint16 Address);
extern void FM24C256Read (uint16 Address , uint16 ByteNumber , uint8 * DataPoint);
extern void FM24C256Write (uint16 Address , uint16 ByteNumber , uint8 * DataPoint);
#define TestAddress 0x0010
uint8 TestTemp1=0;
uint8 TestTemp2=0;
uint8 TestArray1[10]={0,0,0,0,0,0,0,0,0,0};
void port_init(void)
{
PORTA = 0x00;
DDRA = 0x00;
PORTB = 0x00;
DDRB = 0x00;
PORTC = 0x00;
DDRC = 0x00;
PORTD = 0x00;
DDRD = 0x00;
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x00; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
//
void main(void)
{
init_devices();
//SETBIT(I2CPORTD,SDA);
//SETBIT(I2CPORT,SDA);
//CLEARBIT(I2CPORTD,SDA);
//if( CHECKBIT(I2CPORTIN,SDA) )
//TestTemp1=0;
I2CPORTInit();
TestTemp2=FM24C256Read1Byte(TestAddress);
TestTemp1=0;
TestTemp1=0x0f;
FM24C256Write(TestAddress,1,&TestTemp1);
TestTemp1=0;
TestTemp2=FM24C256Read1Byte(TestAddress);
TestTemp1=0;
TestTemp1=0;
} |
|