芯片解密RFID读写器二次开发资料 源码
芯片解密STM32读卡号读写数据代码示例3.0(C语言)单片机源程序如下:
- 芯片解密#include "stm32f10x.h"
- 芯片解密#include "Uart.h"
- 芯片解密#define STATUS_OK 0x00
- 芯片解密#define STATUS_ERR 0x01
- unsigned char Uart1RxBuf[UART1_RX_BUF_LEN];
- unsigned char Uart1RxDataConut = 0;
- unsigned char Rx1Flag = 0;
- unsigned char Uart2RxBuf[UART2_RX_BUF_LEN];
- unsigned char Uart2RxDataConut = 0;
- unsigned char Rx2Flag = 0;
- unsigned char Cmd_Read_Id[8] = {0x01,0x08,0xa1,0x20,0x00,0x00,0x00,0x00};
- unsigned char Cmd_Read_Block[8] = {0x01,0x08,0xa3,0x20,0x00,0x00,0x00,0x00};
- unsigned char Cmd_Write_Block[23] = {0x01,0x17,0xa5,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
- unsigned char WBlockData[16] = {0x11,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
- //CircularBuffer *Uart2_Circular_Buffer;
-
- //配置矢量中断,矢量的意思就是有顺序,有先后的意思。
- void NVIC_Configuration(void)
- {
- NVIC_InitTypeDef NVIC_InitStructure1; //定义数据结构体
- NVIC_InitTypeDef NVIC_InitStructure2; //定义数据结构体
-
- NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);//将中断矢量放到Flash的0地址
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);//设置优先级配置的模式,详情请阅读原材料中的文章
- //使能串口1中断,并设置优先级
- NVIC_InitStructure1.NVIC_IRQChannel = USART1_IRQn;
- NVIC_InitStructure1.NVIC_IRQChannelPreemptionPriority = 1;
- NVIC_InitStructure1.NVIC_IRQChannelSubPriority = 0;
- NVIC_InitStructure1.NVIC_IRQChannelCmd = ENABLE;
- NVIC_Init(&NVIC_InitStructure1); //将结构体丢到配置函数,即写入到对应寄存器中
- //使能串口2中断,并设置优先级
- NVIC_InitStructure2.NVIC_IRQChannel = USART2_IRQn;
- NVIC_InitStructure2.NVIC_IRQChannelPreemptionPriority = 2;
- NVIC_InitStructure2.NVIC_IRQChannelSubPriority = 0;
- NVIC_InitStructure2.NVIC_IRQChannelCmd = ENABLE;
- NVIC_Init(&NVIC_InitStructure2); //将结构体丢到配置函数,即写入到对应寄存器中
- }
- //延时,10000000大约为1S
- void Delay(__IO unsigned int nCount)
- {
- for (; nCount != 0; nCount--);
- }
- //发送新封装的包
- void Uart1_Send_Data(unsigned char *buf,unsigned char num)
- {
- unsigned char i;
- for(i=0;i<num;i++)
- {
- USART_SendData(USART1, buf[i]);
- while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
- }
- }
- void Uart2_Send_Data(unsigned char *buf,unsigned char num)
- {
- unsigned char i;
- for(i=0;i<num;i++)
- {
- USART_SendData(USART2, buf[i]);
- while (USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
- }
- }

芯片解密