📄 main.c
字号:
//ICC-AVR application builder : 2007-1-8 15:26:42
// Target : M8
// Crystal: 8.0000Mhz
#include <iom8v.h>
#include <macros.h>
#include <stdio.h>
#include "uart.h"
#include "function.h"
#include "port.h"
#include "twi.h"
//
//Watchdog initialize
// prescale: 2048K
void watchdog_init(void)
{
WDR(); //this prevents a timout on enabling
WDTCR = 0x0f; //WATCHDOG ENABLED - dont forget to issue WDRs
//close watch dog
//set WDCE and WDE
WDTCR |= (1<<WDCE) | (1<<WDE);
//close WDT
WDTCR = 0x00;
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
watchdog_init();
twi_init();
uart0_init();
MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x00; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
//
void main(void)
{
//initial device
init_devices();
//insert your functional code here...
while(1)
{
strTWI.STATUS=TW_OK;
putchar(TWI_RW(0x30+TW_WRITE,&ORGDATA[0],8));
// while(strTWI.STATUS==TW_BUSY);//wait
if (strTWI.STATUS==TW_FAIL)
{
//operate faile
putchar(0xff);
}
delay_100ms(0x10);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -