当前位置: 代码迷 >> 单片机 >> 怎样把单片机中的I/O口定义为结构体,例如P1口希望高手解答,该怎么处理
  详细解决方案

怎样把单片机中的I/O口定义为结构体,例如P1口希望高手解答,该怎么处理

热度:108   发布时间:2016-04-28 16:08:34.0
怎样把单片机中的I/O口定义为结构体,例如P1口希望高手解答
怎样把单片机中的I/O口定义为结构体,例如P1口
#define uchar unsigned char  
typedef struct Key
{
  uchar P1;
  uchar scanf;
}KEY;
为什么我编译的时候出现错误了
 

------解决方案--------------------
C/C++ code
extern volatile near unsigned char       PORTA;extern volatile near union {  struct {    unsigned RA0:1;    unsigned RA1:1;    unsigned RA2:1;    unsigned RA3:1;    unsigned RA4:1;    unsigned RA5:1;    unsigned RA6:1;    unsigned RA7:1;  };  struct {    unsigned AN0:1;    unsigned AN1:1;    unsigned AN2:1;    unsigned AN3:1;    unsigned T0CKI:1;    unsigned AN4:1;    unsigned OSC2:1;    unsigned OSC1:1;  };  struct {    unsigned CVREF:1;    unsigned :1;    unsigned VREFM:1;    unsigned VREFP:1;    unsigned :1;    unsigned HLVDIN:1;    unsigned CLKO:1;    unsigned CLKI:1;  };  struct {    unsigned CVREFA:1;    unsigned :4;    unsigned LVDIN:1;  };  struct {    unsigned :5;    unsigned SS:1;  };  struct {    unsigned :5;    unsigned NOT_SS:1;  };} PORTAbits;
  相关解决方案