|
STM32單片機(jī)寫(xiě)的ic卡程序可進(jìn)行扣費(fèi)操作,對(duì)金額進(jìn)行修改,添加
1610944139343.jpg (5.57 MB, 下載次數(shù): 37)
下載附件
2021-1-18 12:34 上傳
單片機(jī)源程序如下:
- #include "delay.h"
- #include "sys.h"
- #include "usart.h"
- #include "dht11.h"
- #include "gpio.h"
- #include "rc522_new.h"
- #include "oled.h"
- #include "stmflash.h"
- #include "timer.h"
- #include "esp8266.h"
- #define P5 GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_1)
- #define P6 GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_2)
- #define P7 GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_3)
- #define P8 GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_4)
- #define P1(A) if(A){GPIO_SetBits(GPIOB,GPIO_Pin_8);}\
- else{GPIO_ResetBits(GPIOB,GPIO_Pin_8);}
- #define P2(A) if(A){GPIO_SetBits(GPIOB,GPIO_Pin_9);}\
- else{GPIO_ResetBits(GPIOB,GPIO_Pin_9);}
- #define P3(A) if(A){GPIO_SetBits(GPIOC,GPIO_Pin_13);}\
- else{GPIO_ResetBits(GPIOC,GPIO_Pin_13);}
- #define P4(A) if(A){GPIO_SetBits(GPIOA,GPIO_Pin_0);}\
- else{GPIO_ResetBits(GPIOA,GPIO_Pin_0);}
- #define renti GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_5)
- #define yanwu GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_6)
- #define CharBuffer1 0x01
- #define CharBuffer2 0x02
- #define FLASH_SAVE_ADDR 0X08007000
- uchar CardRevBuf[16] = { 0 };
- volatile uchar key_num,bz,bz1,bz2,bz3;
- u8 people_flag=1,people_flag_suo=0;
- uint money;
- uint money_buf;
- uint money_tab[5];
- uchar mode;
- extern uchar tab[20]; //接受緩存
- extern uchar num; //接收數(shù)據(jù)個(gè)數(shù)
- uint time; //時(shí)間累加變量
- uint shop_num;
- u8 temperature;
- u8 humidity;
- void KEY_Scan(void)
- {
- P1(1);
- P2(1);
- P3(1);
- P4(1);
-
- if((P5==0)&&(P6==0)&&(P7==0)&&(P8==0))
- {
- bz=0;
- bz3=0;
- key_num=100;
- }
-
- if(((P5!=0)||(P6!=0)||(P7!=0)||(P8!=0))&&(bz==0))
- {
- bz=1;
- P1(1);
- P2(0);
- P3(0);
- P4(0);
-
- if(P8==1)
- {
- key_num=14;return;
- }
- else if(P7==1)
- {
- key_num=1;return;
- }
- else if(P6==1)
- {
- key_num=4;return;
- }
- else if(P5==1)
- {
- key_num=7;return;
- }
-
-
- P1(0);
- P2(1);
- P3(0);
- P4(0);
- if(P8==1)
- {
- key_num=0;return;
- }
- else if(P7==1)
- {
- key_num=2;return;
- }
- else if(P6==1)
- {
- key_num=5;return;
- }
- else if(P5==1)
- {
- key_num=8;return;
- }
-
- P1(0);
- P2(0);
- P3(1);
- P4(0);
- if(P8==1)
- {
- key_num=15;return;
- }
- else if(P7==1)
- {
- key_num=3;return;
- }
- else if(P6==1)
- {
- key_num=6;return;
- }
- else if(P5==1)
- {
- key_num=9;return;
- }
- P1(0);
- P2(0);
- P3(0);
- P4(1);
- if(P8==1)
- {
- key_num=16;return;
- }
- else if(P7==1)
- {
- key_num=13;return;
- }
- else if(P6==1)
- {
- key_num=12;return;
- }
- else if(P5==1)
- {
- key_num=11;return;
- }
- key_num=key_num;
-
- }
- }
- void ctrl( void )
- {
- if( PcdRequest( PICC_REQIDL, &CardRevBuf[0] ) != MI_OK )//??????????????,?????? 2??
- {
- if( PcdRequest( PICC_REQIDL, &CardRevBuf[0] ) != MI_OK )//??????????????,?????? 2??
- {
- CardRevBuf[2]=0;
- CardRevBuf[3]=0;
- bz1=0;
- return;
- }
- }
- if( PcdAnticoll( &CardRevBuf[2] ) != MI_OK ) //???,??????? 4??
- {
- CardRevBuf[2]=0;
- CardRevBuf[3]=0;
- bz1=0;
- return;
- }
- if( PcdSelect( &CardRevBuf[2] ) != MI_OK )//?? ?????,4??
- {
- CardRevBuf[2]=0;
- CardRevBuf[3]=0;
- bz1=0;
- return;
- }
- }
- void xianshi()
- {
- if(mode==0)
- {
- OLED_ShowString(0,2,"Crad:");
-
- OLED_ShowChar(40,2,CardRevBuf[2]/100%10+'0');
- OLED_ShowChar(40+8,2,CardRevBuf[2]/10%10+'0');
- OLED_ShowChar(40+8*2,2,CardRevBuf[2]/1%10+'0');
-
- OLED_ShowString(0,0,"temp:");
- OLED_ShowChar(40,0,temperature/10%10+'0');
- OLED_ShowChar(40+8,0,temperature/1%10+'0');
-
- OLED_ShowString(40+8*3,0,"humi:");
- OLED_ShowChar(40+8*8,0,humidity/10%10+'0');
- OLED_ShowChar(40+8*9,0,humidity/1%10+'0');
-
- OLED_ShowString(0,4,"money:");
- OLED_ShowChar(48,4,money/1000%10+'0');
- OLED_ShowChar(48+8,4,money/100%10+'0');
- OLED_ShowChar(48+8*2,4,money/10%10+'0');
- OLED_ShowChar(48+8*3,4,'.');
- OLED_ShowChar(48+8*4,4,money/1%10+'0');
- OLED_ShowString(48+8*5,4," ");
-
- OLED_ShowString(0,6,"shop:");
- OLED_ShowChar(48,6,shop_num/1000%10+'0');
- OLED_ShowChar(48+8,6,shop_num/100%10+'0');
- OLED_ShowChar(48+8*2,6,shop_num/10%10+'0');
- OLED_ShowChar(48+8*3,6,'.');
- OLED_ShowChar(48+8*4,6,shop_num/1%10+'0');
-
- #if 0
- OLED_ShowString(48,6,"shop:");
- OLED_ShowChar(48+40,6,shop_num/100%10+'0');
- OLED_ShowChar(48+40+8,6,shop_num/10%10+'0');
- OLED_ShowChar(48+40+8*2,6,'.');
- OLED_ShowChar(48+40+8*3,6,shop_num/1%10+'0');
-
- OLED_ShowString(0,6,"Peo:");
- if(renti==0){OLED_ShowChar(32,6,'N');}
- if((renti==1)&&(bz2==0)){bz2=1;OLED_ShowChar(32,6,'Y');mode=4;OLED_Clear();}
- #endif
-
- }
-
- if(mode==1)
- ……………………
- …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼
所有資料51hei提供下載:
源碼.7z
(230.07 KB, 下載次數(shù): 64)
2021-1-18 15:42 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
|