关机APP代码实现

#define IOP_BASE      0xB1600000 // 0x56000000
typedef struct  {
    unsigned int  rGPACON;  // 00
    unsigned int  rGPADAT;
    unsigned int  rPAD1[2];
   
    unsigned int  rGPBCON;  // 10
    unsigned int  rGPBDAT;
    unsigned int  rGPBUP;
    unsigned int  rPAD2;
   
    unsigned int  rGPCCON;  // 20
    unsigned int  rGPCDAT;
    unsigned int  rGPCUP;
    unsigned int  rPAD3;
   
    unsigned int  rGPDCON;  // 30
    unsigned int  rGPDDAT;
    unsigned int  rGPDUP;
    unsigned int  rPAD4;
   
    unsigned int  rGPECON;  // 40
    unsigned int  rGPEDAT;
    unsigned int  rGPEUP;
    unsigned int  rPAD5;
   
    unsigned int  rGPFCON;  // 50
    unsigned int  rGPFDAT;
    unsigned int  rGPFUP;
    unsigned int  rPAD6;
   
    unsigned int  rGPGCON;  // 60
    unsigned int  rGPGDAT;
    unsigned int  rGPGUP;
    unsigned int  rPAD7;
   
    unsigned int  rGPHCON;  // 70
    unsigned int  rGPHDAT;
    unsigned int  rGPHUP;
    unsigned int  rPAD8;
}IOPreg; 
volatile IOPreg *G_pIOPRegs=NULL;


extern "C" _declspec(dllimport) BOOL VirtualCopy(LPVOID lpvDest, LPVOID lpvSrc,
             DWORD cbSize,DWORD fdwProtect);
void CStartDlg::OnButton1()
{

   G_pIOPRegs = (volatile IOPreg*)VirtualAlloc(0, sizeof(IOPreg), MEM_RESERVE, PAGE_NOACCESS);
  if (G_pIOPRegs == NULL)
  {
   DEBUGMSG (1,(TEXT("G_pIOPRegs is not allocated/n/r")));
   // return false;
  }
  if (!VirtualCopy((PVOID)G_pIOPRegs, (PVOID)IOP_BASE, sizeof(IOPreg), PAGE_READWRITE|PAGE_NOCACHE))
  {
   DEBUGMSG (1,(TEXT("G_pIOPRegs is not mapped/n/r")));
   //  return false;
  }
  
  G_pIOPRegs->rGPCCON &= ~(0x3<<14)|(0x3<<12);
  G_pIOPRegs->rGPCCON |= (0x1<<14)|(0x1<<12);
  G_pIOPRegs->rGPCUP  |= (0x1<<7)|(0x1<<6);
  G_pIOPRegs->rGPCDAT |= (0x1<<7)|(0x1<<6);
  
                       G_pIOPRegs->rGPBCON&=~(0x3);
     G_pIOPRegs->rGPBCON|=0x1;
     G_pIOPRegs->rGPBDAT&=~(0x1);
     G_pIOPRegs->rGPBUP|=0x1;
    
                       G_pIOPRegs->rGPBCON &= ~(0x3<<8);                 
                       G_pIOPRegs->rGPBCON |=  (0x1<<8);     
                       G_pIOPRegs->rGPBUP  |=  (0x1<<4);                 
                       G_pIOPRegs->rGPBDAT&=  ~(0x1<<4); 

 
     G_pIOPRegs->rGPGDAT &= ~(1<<3);
     G_pIOPRegs->rGPGUP |= (0x1<<3);
     G_pIOPRegs->rGPGCON &= ~(0x3<<6);
     G_pIOPRegs->rGPGCON |= (0x1<<6);  
    
                      G_pIOPRegs->rGPADAT &= ~(1<<13); 
                      G_pIOPRegs->rGPACON &= ~(1<<13);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值