lhaih
驱动小牛
驱动小牛
  • 注册日期2004-04-28
  • 最后登录2007-10-19
  • 粉丝0
  • 关注0
  • 积分50分
  • 威望5点
  • 贡献值0点
  • 好评度5点
  • 原创分0分
  • 专家分0分
阅读:1163回复:3

D12固件不明白之处,请求指点

楼主#
更多 发布于:2004-08-13 10:08
进入中断
1)  usb_isr() interrupt 0
   {
DISABLE;
fn_usb_isr();
ENABLE;
    }
   为什么加 DISABLE关闭中断,再ENABLE打开中断?
 
2)  D12ci.c中,以下两种定义有什么分别呢,
 
 void D12_SetAddressEnable(unsigned char bAddress, unsigned char bEnable)
{
if(bEPPflags.bits.in_isr == 0)
DISABLE;

outportb(D12_COMMAND, 0xD0);//输出指令
if(bEnable)
bAddress |= 0x80;
outportb(D12_DATA, bAddress);//设置地址

if(bEPPflags.bits.in_isr == 0)

ENABLE;
}


void D12_SetAddressEnable(unsigned char bAddress, unsigned char bEnable)
{
outportb(D12_COMMAND, 0xD0);//输出指令
if(bEnable)
bAddress |= 0x80;
outportb(D12_DATA, bAddress);//设置地址

}

书上写的是第二中,而 程序中都用的第一种?

先谢谢了!!
wly76
驱动小牛
驱动小牛
  • 注册日期2004-08-12
  • 最后登录2008-04-24
  • 粉丝0
  • 关注0
  • 积分30分
  • 威望3点
  • 贡献值0点
  • 好评度3点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2004-08-13 10:53
1,DISABLE AND ENABLE 被定义为 EA=0 AND EA=1在这里作为中断保护,防止重入。
2,书上的是简化的代码,功能是一样的,程序里加了中断保护。
lhaih
驱动小牛
驱动小牛
  • 注册日期2004-04-28
  • 最后登录2007-10-19
  • 粉丝0
  • 关注0
  • 积分50分
  • 威望5点
  • 贡献值0点
  • 好评度5点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2004-08-13 11:56
十分感谢!还有个问题
如果我想用汇编程序应该怎么
定义向下面的变量
typedef union _epp_flags
{
        struct _flags
        {
         unsigned char timer              :1;
         unsigned char bus_reset          :1;
         unsigned char suspend            :1;
         unsigned char setup_packet       :1;
         unsigned char remote_wakeup        :1;
         unsigned char in_isr        :1;
         unsigned char control_state        :2;
         unsigned char configuraton        :1;
         unsigned char command        :1;
         unsigned char ep1_rxdone        :1;
         unsigned char ep2_rxdone        :1;
         unsigned char ep1buf_full       :1;
         unsigned char ep2buf_full       :1;
         }bits;
         unsigned short value;
}EPPFLAGS;
和USB设备请求的结构体。
谢谢
wly76
驱动小牛
驱动小牛
  • 注册日期2004-08-12
  • 最后登录2008-04-24
  • 粉丝0
  • 关注0
  • 积分30分
  • 威望3点
  • 贡献值0点
  • 好评度3点
  • 原创分0分
  • 专家分0分
地板#
发布于:2004-08-13 15:10
如果用汇编的话,你应该非常谨慎的使用内部RAM,它可能会给你造成
很大的麻烦。因为C是动态管理RAM的,用汇编你可以分配固定存储区
给你的变量,如:
   unsigned char timer  :1;

      timer equ 20h   ;定义
    
      mov timer,a   ;访问
      mov a,timer
   
   
   见笑

游客

返回顶部