?? hardware.h
字號:
/*********************************************************************
網上收集: 免費共享:慧凈電子
目 的: 建立xxxx操作庫
目標系統: 基于任何兼容AVR的微處理器
應用軟件: ICC
版 本: Version 2.0
收集時間: 2008-08-08
開發人員: 慧凈網上收集整理(感謝能放在網上共享的朋友們,功德無量,有你們,中國會更強大)
說 明: 版權:慧凈助學產品(包括程序源碼,硬件資源)沒有版權,歡迎復制共享,功德無量,為中國自動化與單片事業作一點功勞。部分源碼技術資料、軟件、來源網絡,如有傷害到你的利益請來郵:hjmcu@163.com 我們的助學會員會定期刪除,謝謝你的理解與支持。
助學小店:http://shop37031453.taobao.com/
慧凈空間:http://hi.baidu.com/hjmcu
助學QQ: 121350852
*********************************************************************/
/*01010101010101010101010101010101010101010101010101010101010101010101
----------------------------------------------------------------------
版本更新記錄:
----------------------------------------------------------------------
入口參數說明:
----------------------------------------------------------------------
待定參數說明:
----------------------------------------------------------------------
對外變量說明:
----------------------------------------------------------------------
對外函數說明:
----------------------------------------------------------------------
10101010101010101010101010101010101010101010101010101010101010101010*/
#ifndef Hardware_H
#define Hardware_H
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <macros.h>
#include <eeprom.h>
//#include <wdt.h>
/* TWI configs */
//如使用ATMEGA162(沒有TWI接口)之類的MCU,在加載Hardware.H前,務必加“#define NO_INCLUDE_I2C_H 1”語句
#if NO_INCLUDE_I2C_H
;
#else
#include "D:\ICC_H\I2C.H" //i2c即AVR的"twi"
#endif
/* 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
/*--------------------------------------------------------------------
函數全稱:50us 延時
函數功能:當然是 50us延時 啦
注意事項:基于7.3728M晶振,稍微有點誤差
提示說明:調用delay50us(20),得到1ms延時
輸 入:
返 回:無
--------------------------------------------------------------------*/
void delay50us(sint16 t)
{
uint8 j;
for(;t>0;t--)
for(j=0;j<70;j++)
;
}
/*--------------------------------------------------------------------
函數全稱:50ms 延時
函數功能:當然是 50ms延時 啦
注意事項:基于7.3728M晶振,稍微有點誤差
提示說明:調用delay50ms(20),得到1s延時
輸 入:
返 回:無
--------------------------------------------------------------------*/
void delay50ms(sint16 t)
{
uint16 i;
for(;t>0;t--)
for(i=0;i<52642;i++)
;
}
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -