⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sle4442.c

📁 mifarea卡程序mifarea卡程序mifarea卡程序
💻 C
字号:
/****************************************
 * sle4442.c                            *
 * functions for sle4442 card           *
 * designed by liulixun                 *
 * last update: 05-18-2007              *
 ****************************************/

#include "..\inc\includes.h"

// read main memory
int Sle4442ReadMainMem(unsigned char address, unsigned char *buf)
{
    unsigned int i;
    
    // send command and address
    Sle4442Command(0x30, address, 0x00);
    // read data
    for(i=0; i<256-address; i++)
    {
        buf[i] = IccSyncGetChar();
    }
    // send another clock puls
    IccSyncClock();
    
    return i;
}

// update main memory
void Sle4442WriteMainMem(unsigned char address, unsigned char val)
{
    // send command
    Sle4442Command(0x38, address, val);
    // polling io
    IccSyncPollingIO(50);
}

// read 4 bytes protect memory
void Sle4442ReadProtectMem(unsigned char *buf)
{
    unsigned char ci;
    
    // send command
    Sle4442Command(0x34, 0x00, 0x00);
    // read data
    for(ci=0; ci<4; ci++)
    {
        buf[ci] = IccSyncGetChar();
    }
    // send another clock puls
    IccSyncClock();
}

// write protect memory
void Sle4442WriteProtectMem(unsigned char address, unsigned char val)
{
    // send command
    Sle4442Command(0x3c, address, val);
    // polling io
    IccSyncPollingIO(50);
}

// read 4 bytes
void Sle4442ReadSecurityMem(unsigned char *buf)
{
    unsigned char ci;
    
    // send command
    Sle4442Command(0x31, 0x00, 0x00);
    // read data
    for(ci=0; ci<4; ci++)
    {
        buf[ci] = IccSyncGetChar();
    }
    // send another clock puls
    IccSyncClock();
}

// update 
void Sle4442WriteSecurityMem(unsigned char address, unsigned char val)
{
    // send command
    Sle4442Command(0x39, address, val);
    // polling io
    IccSyncPollingIO(50);
}

// verify
void Sle4442Verify(unsigned char address, unsigned char val)
{
    // send command
    Sle4442Command(0x33, address, val);
    // polling io
    IccSyncPollingIO(50);
}

void Sle4442Command(unsigned char cmd, unsigned char addr, unsigned char da)
{
    IccSyncStart();
    IccSyncPutChar(cmd);
    IccSyncPutChar(addr);
    IccSyncPutChar(da);
    IccSyncStop();
}

⌨️ 快捷键说明

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