第一范文网 - 专业文章范例文档资料分享平台

STM8 RC522 IC卡修改密码程序

来源:用户分享 时间:2020-06-26 本文由凌紫泪 分享 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/ #include \#include \#include \#include \#include \#include \#include \

void Delay(u32 nCount);

extern u8 RxBuffer[RxBufferSize]; extern u8 UART_RX_NUM;

unsigned char CT[2];//卡类型 unsigned char SN[4]; //卡号

unsigned char write[16]

{0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10}; unsigned char read[16]

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; unsigned char key[6] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};

/* Private macro -------------------------------------------------------------*/ #define countof(a) (sizeof(a) / sizeof(*(a))) #define BufferSize (countof(Tx_Buffer)-1)

/* Private variables ---------------------------------------------------------*/ u8 Tx_Buffer[] = %u8 Rx_Buffer[BufferSize]; u32 FLASH_ID ;

/* Private defines -----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/

#define ReadWriteAddr 11 //读写扇区

void main(void) {

unsigned char status; /* Infinite loop */

/*设置内部时钟16M为主时钟*/

CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);

= =

/*!

GPIO_Init( GPIOA, GPIO_PIN_3, GPIO_MODE_OUT_PP_HIGH_FAST); InitRc522();

UART1_SendString(Tx_Buffer,BufferSize); while(1) {

status = PcdRequest(PICC_REQALL,CT); /*扫描卡*/

status = PcdAnticoll(SN); /*防冲撞*/ if (status==MI_OK) {

GPIO_LOW(GPIOA, GPIO_PIN_3); //寻卡成功 UART1_SendString(\

status = PcdSelect(SN); //选择要操作的卡 if (status==MI_OK) {

if( MI_OK == PcdAuthState(0x60,ReadWriteAddr,key,SN) ) { status = PcdRead(ReadWriteAddr,read); if(MI_OK == status) {

read[0] = 0x01; read[1] = 0x02; read[2] = 0x03; read[3] = 0x04; read[4] = 0x05; read[5] = 0x06;

status = PcdWrite(ReadWriteAddr,read); UART1_SendString(\ } } } } else {

GPIO_HIGH(GPIOA, GPIO_PIN_3); }

Reset_RC522(); }

//验证A密码 }

void Delay(u32 nCount) {

/* Decrement nCount value */ while (nCount != 0) {

nCount--; } }

#ifdef USE_FULL_ASSERT /**

* @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name

* @param line: assert_param error line source number * @retval : None */

void assert_failed(u8* file, u32 line) {

/* User can add his own implementation to report the file name and line number, ex: printf(\

/* Infinite loop */ while (1) { } }

#endif

搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新资格考试认证STM8 RC522 IC卡修改密码程序 全文阅读和word下载服务。

STM8 RC522 IC卡修改密码程序 .doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/wenku/1102665.html(转载请注明文章来源)

相关推荐:

热门推荐
Copyright © 2018-2022 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top