当前位置:首页 > 单片机 > 单片机
[导读]好吧,不得不承认,我使用飞思卡尔的XS128单片机已经非常之习惯了,结果一上手atmega8,最令我反感的就是atmega8不能对IO引脚进行操作,非要用些繁琐的位操作。我就不,我就要像飞思卡尔那样操作。。。于是。。。。。

好吧,不得不承认,我使用飞思卡尔的XS128单片机已经非常之习惯了,结果一上手atmega8,最令我反感的就是atmega8不能对IO引脚进行操作,非要用些繁琐的位操作。我就不,我就要像飞思卡尔那样操作。。。


于是。。。。。


把我写的下面这个头文件塞到winavr目录的include/avr中,并在io.h头文件的最后包含这个头文件。


嘿嘿,一切变得是那么的亲切与熟悉。。。。。。


/***********************************************************

* 函数库说明:ATMEGE8

* 版本: v1.0

*

************************************************************

*注意: 无

***********************************************************/


#ifndef _BIT_

#define _BIT_

//定义一个8字节的位段 bit0~7是每个位段名称 1代表一位 PBIT就是整个位段的名称

typedef struct

{

unsigned bit0 : 1 ;

unsigned bit1 : 1 ;

unsigned bit2 : 1 ;

unsigned bit3 : 1 ;

unsigned bit4 : 1 ;

unsigned bit5 : 1 ;

unsigned bit6 : 1 ;

unsigned bit7 : 1 ;

}PBIT;

//强制转换

#define PORTABIT (*(volatile PBIT *)0x3B)

#define DDRABIT (*(volatile PBIT *)0x3A)

#define PINABIT (*(volatile PBIT *)0x39)

#define PORTBBIT (*(volatile PBIT *)0x38)

#define DDRBBIT (*(volatile PBIT *)0x37)

#define PINBBIT (*(volatile PBIT *)0x36)

#define PORTCBIT (*(volatile PBIT *)0x35)

#define DDRCBIT (*(volatile PBIT *)0x34)

#define PINCBIT (*(volatile PBIT *)0x33)

#define PORTDBIT (*(volatile PBIT *)0x32)

#define DDRDBIT (*(volatile PBIT *)0x31)

#define PINDBIT (*(volatile PBIT *)0x30)

//继续封装

#define PORTA_PA0 PORTABIT.bit0

#define PORTA_PA1 PORTABIT.bit1

#define PORTA_PA2 PORTABIT.bit2

#define PORTA_PA3 PORTABIT.bit3

#define PORTA_PA4 PORTABIT.bit4

#define PORTA_PA5 PORTABIT.bit5

#define PORTA_PA6 PORTABIT.bit6

#define PORTA_PA7 PORTABIT.bit7

#define PORTB_PB0 PORTBBIT.bit0

#define PORTB_PB1 PORTBBIT.bit1

#define PORTB_PB2 PORTBBIT.bit2

#define PORTB_PB3 PORTBBIT.bit3

#define PORTB_PB4 PORTBBIT.bit4

#define PORTB_PB5 PORTBBIT.bit5

#define PORTB_PB6 PORTBBIT.bit6

#define PORTB_PB7 PORTBBIT.bit7

#define PORTC_PC0 PORTCBIT.bit0

#define PORTC_PC1 PORTCBIT.bit1

#define PORTC_PC2 PORTCBIT.bit2

#define PORTC_PC3 PORTCBIT.bit3

#define PORTC_PC4 PORTCBIT.bit4

#define PORTC_PC5 PORTCBIT.bit5

#define PORTC_PC6 PORTCBIT.bit6

#define PORTC_PC7 PORTCBIT.bit7

#define PORTD_PD0 PORTDBIT.bit0

#define PORTD_PD1 PORTDBIT.bit1

#define PORTD_PD2 PORTDBIT.bit2

#define PORTD_PD3 PORTDBIT.bit3

#define PORTD_PD4 PORTDBIT.bit4

#define PORTD_PD5 PORTDBIT.bit5

#define PORTD_PD6 PORTDBIT.bit6

#define PORTD_PD7 PORTDBIT.bit7

//**********************

#define DDRA_DDRA0 DDRABIT.bit0

#define DDRA_DDRA1 DDRABIT.bit1

#define DDRA_DDRA2 DDRABIT.bit2

#define DDRA_DDRA3 DDRABIT.bit3

#define DDRA_DDRA4 DDRABIT.bit4

#define DDRA_DDRA5 DDRABIT.bit5

#define DDRA_DDRA6 DDRABIT.bit6

#define DDRA_DDRA7 DDRABIT.bit7

#define DDRB_DDRB0 DDRBBIT.bit0

#define DDRB_DDRB1 DDRBBIT.bit1

#define DDRB_DDRB2 DDRBBIT.bit2

#define DDRB_DDRB3 DDRBBIT.bit3

#define DDRB_DDRB4 DDRBBIT.bit4

#define DDRB_DDRB5 DDRBBIT.bit5

#define DDRB_DDRB6 DDRBBIT.bit6

#define DDRB_DDRB7 DDRBBIT.bit7

#define DDRC_DDRC0 DDRCBIT.bit0

#define DDRC_DDRC1 DDRCBIT.bit1

#define DDRC_DDRC2 DDRCBIT.bit2

#define DDRC_DDRC3 DDRCBIT.bit3

#define DDRC_DDRC4 DDRCBIT.bit4

#define DDRC_DDRC5 DDRCBIT.bit5

#define DDRC_DDRC6 DDRCBIT.bit6

#define DDRC_DDRC7 DDRCBIT.bit7

#define DDRD_DDRD0 DDRDBIT.bit0

#define DDRD_DDRD1 DDRDBIT.bit1

#define DDRD_DDRD2 DDRDBIT.bit2

#define DDRD_DDRD3 DDRDBIT.bit3

#define DDRD_DDRD4 DDRDBIT.bit4

#define DDRD_DDRD5 DDRDBIT.bit5

#define DDRD_DDRD6 DDRDBIT.bit6

#define DDRD_DDRD7 DDRDBIT.bit7

//*****************

#define PINA_PA0 PINABIT.bit0

#define PINA_PA1 PINABIT.bit1

#define PINA_PA2 PINABIT.bit2

#define PINA_PA3 PINABIT.bit3

#define PINA_PA4 PINABIT.bit4

#define PINA_PA5 PINABIT.bit5

#define PINA_PA6 PINABIT.bit6

#define PINA_PA7 PINABIT.bit7

#define PINB_PB0 PINBBIT.bit0

#define PINB_PB1 PINBBIT.bit1

#define PINB_PB2 PINBBIT.bit2

#define PINB_PB3 PINBBIT.bit3

#define PINB_PB4 PINBBIT.bit4

#define PINB_PB5 PINBBIT.bit5

#define PINB_PB6 PINBBIT.bit6

#define PINB_PB7 PINBBIT.bit7

#define PINC_PC0 PINCBIT.bit0

#define PINC_PC1 PINCBIT.bit1

#define PINC_PC2 PINCBIT.bit2

#define PINC_PC3 PINCBIT.bit3

#define PINC_PC4 PINCBIT.bit4

#define PINC_PC5 PINCBIT.bit5

#define PINC_PC6 PINCBIT.bit6

#define PINC_PC7 PINCBIT.bit7

#define PIND_PD0 PINDBIT.bit0

#define PIND_PD1 PINDBIT.bit1

#define PIND_PD2 PINDBIT.bit2

#define PIND_PD3 PINDBIT.bit3

#define PIND_PD4 PINDBIT.bit4

#define PIND_PD5 PINDBIT.bit5

#define PIND_PD6 PINDBIT.bit6

#define PIND_PD7 PINDBIT.bit7

#endif


本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除。
换一批
延伸阅读

现在,对于很多驾驶者或者交通管理者而言,安全是汽车行业最关键的问题,整个汽车行业的目标当然是零受伤和零死亡人数,这对世界上的任何一个汽车制造商而言都是一个令人难以置信的结果,但却是一个积极且非常

关键字: 飞思卡尔 娱乐系统

  当今电子产品如果不能具有移动接入网络的功能似乎已经成为古董,因为在信息化的时代,能够随时获取移动数据已经成为大部分人的生活必需。智能互联设备以及数据、视频内容的爆发式增长引发了移动数据传输需

关键字: 飞思卡尔 宏蜂窝 基站设备

  第一季度瑞萨电子的汽车半导体营业收入为7.27亿美元,遥遥领先于其它竞争对手,紧排在其后的厂商是英飞凌、意法半导体、飞思卡尔和恩智浦。虽然市场总体库存仍然处于高位,库存严重过剩,但供应商对于

关键字: 飞思卡尔 汽车电子 意法半导体 瑞萨电子

  摘 要: 提出了一种基于Atmega8 和Stm32F101 双处理器的投影机升降控制设计方案,介绍了其电路组成、功能以及软件流程。其中Atmega8 负责数据采集,Stm32F101 实现

关键字: atmega8 stm32f101 uln2803a

  为期近5个月的雷士照明控制权之争出人意料地以“和解”告终。《中国企业报》记者获悉,雷士照明创始人吴长江,与公司现任董事长、赛富亚洲基金创始合伙人阎焱以及公司战略投资者

关键字: MCU 飞思卡尔 血糖监测仪

  最新的市场数据显示,美国LED灯泡的零售价格已经降到8美元,而节能荧光灯的价格约为5美元,在这一价差下,消费者选择更为节能的LED灯的倾向性将进一步增强,预计到2015年,将真正迎来LED照

关键字: 微控制器 飞思卡尔 汽车工业 汽车芯片 传动系统

  家庭医疗中心正在获得市场关注   在中国,血压计、血糖仪、血氧仪等便携医疗设备的家庭普及率很低。中国的糖尿病患者人口比例很高(占总人口的1/10),但在这些糖尿病患者中,城市的血糖仪

关键字: 飞思卡尔 医疗设备 血压计 血糖仪 便携医疗

  化工行业变频器市场主要来自设备配套和改造项目,大概各占40%,其余来自零部件和更换。   在化工行业,变频器主要用于风机、泵类和机械调速设备中。化工行业分支多,生产过程差异大,所用的

关键字: 飞思卡尔 汽车安全系统 adas 雷达发射器

  整合了单一、双重及四重ARM Cortex-A9核心,以高达1.2 GHz的时脉运行,飞思卡尔的i.MX 6系列兼具高效能、最佳的功率损耗、以及延展性。该系列包括五种元件:单核心的i.MX

关键字: 飞思卡尔 应用处理器 i.mx 6 汽车资讯娱乐系统

  停车位太狭窄,抽身车外,遥控指挥爱车自动入库;夏天太热,在打开车门前提前开启空调;交通拥堵太闷,打开人车交互系统聊天解闷……记者走访车市发现,如IPHONE等智能

关键字: MCU 飞思卡尔 Zigbee 意法半导体 智能电表 载波通信
关闭
关闭