?? hardware.h
字號(hào):
/*********************************************************************
目 的: 建立AVR的硬件提取庫(kù),增加各類補(bǔ)丁,方便移植
目標(biāo)系統(tǒng): 基于AVR單片機(jī)
應(yīng)用軟件: GCCAVR
版 本: Version 2.0
圓版時(shí)間: 2006-09-25
開(kāi)發(fā)人員: YESON
說(shuō) 明: 若用于商業(yè)用途,請(qǐng)保留此段文字或注明代碼來(lái)源
*********************************************************************/
/*01010101010101010101010101010101010101010101010101010101010101010101
----------------------------------------------------------------------
版本更新記錄:
----------------------------------------------------------------------
入口參數(shù)說(shuō)明:
----------------------------------------------------------------------
待定參數(shù)說(shuō)明:
----------------------------------------------------------------------
對(duì)外變量說(shuō)明:
----------------------------------------------------------------------
對(duì)外函數(shù)說(shuō)明:
----------------------------------------------------------------------
10101010101010101010101010101010101010101010101010101010101010101010*/
#ifndef Hardware_H
#define Hardware_H
#include <math.h>
#include <string.h>
#include <stdio.h>
//#include <macros.h>
#include "avr/eeprom.h"
//#include "avr/wdt.h"
#include "I2C.H" //i2c即AVR的"twi"
/* hard configs */
#ifndef flash
#define flash const
#endif
#ifndef code
#define code const
#endif
#ifndef NOP
#define NOP() asm("nop")
#endif
/* io configs */
#define sbi(io,bit) ( io |= (1<<bit) ) //example: sbi(PORTA,0);sbi(DDRA,0);
#define cbi(io,bit) ( io &= ~(1<<bit) ) //example: cbi(PORTA,0);cbi(DDRA,0);
#define gbi(pin ,bit) ( pin & (1<<bit) ) //example: gbi(PINA,0);
/* interrupt configs */
#define DIS_INT asm("sei")
#define EN_INT asm("cli")
/* wdt configs */
#define WDT() asm("wdr")
/* bit operation */
//#ifndef BIT
//#define BIT(x) ( 1<<(x) )
//#endif
/* USART configs for 4 Mhz crystal */
//#define BAUD9600 25
//#define BAUD19000 12
//#define UART_TRAN_ON() UCR |= 0x08
//#define UART_TRAN_OFF() UCR &= ~0x08
//#define UART_RCV_ON() UCR |= 0x10
//#define UART_RCV_OFF() UCR &= ~0x10
#define SEI() asm("sei") //come form morch.h(ICCAVR)
/*--------------------------------------------------------------------
函數(shù)全稱:50us 延時(shí)
函數(shù)功能:當(dāng)然是 50us延時(shí) 啦
注意事項(xiàng):基于7.3728M晶振,稍微有點(diǎn)誤差
提示說(shuō)明:調(diào)用Delay50us(20),得到1ms延時(shí)
輸 入:
返 回:無(wú)
--------------------------------------------------------------------*/
void delay50us(sint16 t)
{
uint8 j;
for(;t>0;t--)
for(j=0;j<70;j++)
;
}
/*--------------------------------------------------------------------
函數(shù)全稱:50ms 延時(shí)
函數(shù)功能:當(dāng)然是 50ms延時(shí) 啦
注意事項(xiàng):基于7.3728M晶振,稍微有點(diǎn)誤差
提示說(shuō)明:調(diào)用delay50ms(20),得到1s延時(shí)
輸 入:
返 回:無(wú)
--------------------------------------------------------------------*/
void delay50ms(sint16 t)
{
uint16 i;
for(;t>0;t--)
for(i=0;i<52642;i++)
;
}
#endif
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -