ucio.c

来自「mifarea卡程序mifarea卡程序mifarea卡程序」· C语言 代码 · 共 64 行

C
64
字号
#include <reg52.h>
#include <absacc.h>     // 包含绝对地址访问宏
#include <ucio.h>
#include <v51rx2.h>


#ifndef disable
#define disable()   EA = 0
#define enable()    EA = 1
#endif

/********************************
 * write io port at address     *
 ********************************/
void WriteRawIO(unsigned char Address, unsigned char value)
{
    #ifdef  V51RX2
        disable();
        AUXR |= 0x02;
    #endif

    PBYTE[Address]=value;

    #ifdef  V51RX2
        AUXR &= 0xfd;
        enable();
    #endif
}

/********************************
 * write io port from address   *
 * return the value read        *
 ********************************/
unsigned char ReadRawIO(unsigned char Address)
{
    unsigned char c;
    
    #ifdef  V51RX2
        disable();
        AUXR |= 0x02;
    #endif
    
    c = PBYTE[Address];                     
    
    #ifdef  V51RX2
        AUXR &= 0xfd;
        enable();
    #endif
    
    return c;
}

void WriteIO(unsigned char address, unsigned char value)
{
    WriteRawIO(0x00,GetRegPage(address));   // select appropriate page
    WriteRawIO(address, value);
}

unsigned char ReadIO(unsigned char address)
{
    WriteRawIO(0x00,GetRegPage(address));   // select appropriate page
    return ReadRawIO(address);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?