AVR 硬件操作库函数

来自丢石头百科
Admin讨论 | 贡献2019年11月19日 (二) 09:22的版本 (文本替换 - 替换“www.waveshare.net”为“{{SERVERNAME}}”)


=== ===

<tbody></tbody>

/*********************************************************************  微 雪 电 子   WaveShare   <a class="Blue_2_12px_" href="http://wiki.diustou.com/" style="color: rgb(7, 66, 184);">http://www.waveShare.net               目    的:   建立AVR的硬件提取库,增加各类补丁,方便系统程序移植 目标系统:   基于AVR单片机                                                  应用软件:   ICCAVR                                                       版    本:   Version 1.0                                                        圆版时间:   2005-06-25 开发人员:   SEE 说    明:   若用于商业用途,请保留此段文字或注明代码来源   深 圳 市 微 雪 电 子 有 限 公 司 保 留 所 有 的 版 权     

                                                                                                                                          • /

/*01010101010101010101010101010101010101010101010101010101010101010101


版本更新记录:


入口参数说明:


待定参数说明:


 

对外变量说明:


对外程序说明:


10101010101010101010101010101010101010101010101010101010101010101010*/

  1. ifndef Hardware_H
  2. define Hardware_H
  3. include <math.h>
  4. include <string.h>
  5. include <stdio.h>
  6. include <macros.h>
  7. include <eeprom.h>

//#include <wdt.h></wdt.h></eeprom.h></macros.h></stdio.h></string.h></math.h> /* TWI configs */ //如使用ATMEGA162(没有TWI接口)之类的MCU,在加载Hardware.H前,务必加“#define NO_INCLUDE_I2C_H 1”语句

  1. if NO_INCLUDE_I2C_H
  1. else
  2. include "D:\ICC_H\I2C.H" //i2c即AVR的"twi"
  3. endif

/* hard configs */

  1. ifndef flash
  2. define flash const
  3. endif
  4. ifndef code
  5. define code const
  6. endif
  7. ifndef NOP
  8. define NOP() asm("nop")
  9. endif

/* io configs */

  1. define sbi(io,bit) ( io |= (1<<bit example:="" sbi="">#define cbi(io,bit) ( io &= ~(1<<bit cbi="" example:="">#define gbi(pin ,bit) ( pin & (1<<bit example:="" gbi="" p=""></bit></bit></bit>

/* interrupt configs */

  1. define DIS_INT asm("sei")
  2. define EN_INT asm("cli")

/* wdt configs */

  1. 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++)

 

}

  1. endif