mirror of
https://github.com/dimoniche/solarium.vlad.git
synced 2026-01-30 04:53:30 +03:00
Продолжение. Пытаемся читать данные с карты.
This commit is contained in:
parent
bb3e477d29
commit
90e007dd31
@ -24,6 +24,8 @@
|
||||
#include <math.h>
|
||||
#include "ftp_app.h"
|
||||
|
||||
#include "rfid-spi.h"
|
||||
#include "mfrc522data.h"
|
||||
|
||||
extern CPU_INT32U ChannelsPayedTime[CHANNELS_NUM];
|
||||
|
||||
@ -622,18 +624,6 @@ void AppVladEventProcess(CPU_INT32U event)
|
||||
current_discount = CalcCurrentDiscount(SystemTime);
|
||||
}
|
||||
|
||||
// Look for new cards
|
||||
if (picc_is_new_card_present() ) {
|
||||
int y = 0;
|
||||
y++;
|
||||
y--;
|
||||
break;
|
||||
}
|
||||
// Select one of the cards
|
||||
//if (!picc_read_card_serial()) {
|
||||
// break;
|
||||
//}
|
||||
|
||||
#if APP_DEBUG
|
||||
if ((SystemTime % 30) == 0)
|
||||
{
|
||||
@ -738,6 +728,28 @@ void AppVladEventProcess(CPU_INT32U event)
|
||||
}
|
||||
}
|
||||
|
||||
// Look for new cards
|
||||
if (picc_is_new_card_present() ) {
|
||||
// Select one of the cards
|
||||
if (picc_read_card_serial()) {
|
||||
MIFARE_Key key;
|
||||
for (uint8_t i = 0; i < 6; i++) key.keyByte[i] = 0xFF;
|
||||
|
||||
uint8_t block = 4;
|
||||
uint8_t len = 18;
|
||||
uint8_t buffer1[18];
|
||||
|
||||
status_code status = pcd_authenticate(PICC_CMD_MF_AUTH_KEY_A, 4, &key, get_uid());
|
||||
if (status != STATUS_OK) {
|
||||
return;
|
||||
}
|
||||
status = mifare_read(block, buffer1, &len);
|
||||
if (status != STATUS_OK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// äàëüøå òîëüêî â ðàáî÷åì ðåæèìå
|
||||
if (GetMode() != MODE_WORK)
|
||||
{
|
||||
|
||||
@ -2,6 +2,11 @@
|
||||
|
||||
uid_struct uid; // Used by picc_read_card_serial().
|
||||
|
||||
uid_struct * get_uid()
|
||||
{
|
||||
return &uid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a number of bytes to the specified register in the MFRC522 chip.
|
||||
* The interface is described in the datasheet section 8.1.2.
|
||||
@ -157,11 +162,12 @@ pcd_calculate_crc(uint8_t *data, uint8_t length, uint8_t *result)
|
||||
write_mfrc522(FIFOLevelReg, 0x80); // FlushBuffer = 1, FIFO initialization
|
||||
write_bytes_mfrc522(FIFODataReg, length, data); // Write data to the FIFO
|
||||
write_mfrc522(CommandReg, PCD_CalcCRC); // Start the calculation
|
||||
|
||||
// Wait for the CRC calculation to complete. Each iteration of the while-loop takes 17.73μs.
|
||||
// TODO check/modify for other architectures than Arduino Uno 16bit
|
||||
// Wait for the CRC calculation to complete. Each iteration of the while-loop takes 17.73us.
|
||||
uint16_t i;
|
||||
for ( i = 5000; i > 0; i--)
|
||||
for ( i = 89; i > 0; i--)
|
||||
{
|
||||
// DivIrqReg[7..0] bits are: Set2 reserved reserved MfinActIRq reserved CRCIRq reserved reserved
|
||||
uint8_t n = read_mfrc522(DivIrqReg);
|
||||
@ -173,6 +179,8 @@ pcd_calculate_crc(uint8_t *data, uint8_t length, uint8_t *result)
|
||||
result[1] = read_mfrc522(CRCResultRegH);
|
||||
return STATUS_OK;
|
||||
}
|
||||
|
||||
OSTimeDly(1);
|
||||
}
|
||||
// 89ms passed and nothing happend. Communication with the MFRC522 might be down.
|
||||
//printf("89ms passed and nothing happend.\n");
|
||||
@ -231,7 +239,7 @@ pcd_communicate_tith_picc(uint8_t command, uint8_t wait_irq, uint8_t *send_data,
|
||||
// TODO check/modify for other architectures than Arduino Uno 16bit
|
||||
|
||||
uint16_t i;
|
||||
for (i = 2000; i > 0; i--)
|
||||
for (i = 36; i > 0; i--)
|
||||
{
|
||||
uint8_t n = read_mfrc522(ComIrqReg); // ComIrqReg[7..0] bits are: Set1 TxIRq RxIRq IdleIRq HiAlertIRq LoAlertIRq ErrIRq TimerIRq
|
||||
if (n & wait_irq)
|
||||
@ -242,6 +250,8 @@ pcd_communicate_tith_picc(uint8_t command, uint8_t wait_irq, uint8_t *send_data,
|
||||
{ // Timer interrupt - nothing received in 25ms
|
||||
return STATUS_TIMEOUT;
|
||||
}
|
||||
|
||||
OSTimeDly(1);
|
||||
}
|
||||
|
||||
// 35.7ms and nothing happend. Communication with the MFRC522 might be down.
|
||||
|
||||
@ -230,4 +230,7 @@ void get_status_code_name (status_code code);
|
||||
|
||||
void antenna_on();
|
||||
bool pcd_initialization();
|
||||
|
||||
uid_struct * get_uid();
|
||||
|
||||
#endif
|
||||
File diff suppressed because one or more lines are too long
@ -46,11 +46,11 @@
|
||||
<MultiCoreRunAll>1</MultiCoreRunAll>
|
||||
</Simulator>
|
||||
<PlDriver>
|
||||
<MemConfigValue>C:\Program Files\IAR Systems\Embedded Workbench 9.0\arm\CONFIG\debugger\NXP\LPC2368.ddf</MemConfigValue>
|
||||
<FirstRun>0</FirstRun>
|
||||
<MemConfigValue>C:\Program Files\IAR Systems\Embedded Workbench 9.0\arm\CONFIG\debugger\NXP\LPC2368.ddf</MemConfigValue>
|
||||
</PlDriver>
|
||||
<DebugChecksum>
|
||||
<Checksum>904050673</Checksum>
|
||||
<Checksum>4119436880</Checksum>
|
||||
</DebugChecksum>
|
||||
<Exceptions>
|
||||
<StopOnUncaught>_ 0</StopOnUncaught>
|
||||
@ -65,16 +65,29 @@
|
||||
</CallStack>
|
||||
<JLinkDriver>
|
||||
<WatchCond>_ 0</WatchCond>
|
||||
<Watch0>_ 0 "" 0 "" 0 "" 0 "" 0 0 0 0</Watch0>
|
||||
<Watch1>_ 0 "" 0 "" 0 "" 0 "" 0 0 0 0</Watch1>
|
||||
<jlinkResetStyle>12</jlinkResetStyle>
|
||||
<jlinkResetStrategy>0</jlinkResetStrategy>
|
||||
<Watch0>_ 0 "0x00000000" 4294967295 "0xFFFFFFFF" 0 "0x00000000" 4294967295 "0xFFFFFFFF" 3 0 0 0</Watch0>
|
||||
<Watch1>_ 0 "0x00000000" 4294967295 "0xFFFFFFFF" 0 "0x00000000" 4294967295 "0xFFFFFFFF" 3 0 0 0</Watch1>
|
||||
<LeaveTargetRunning>_ 0</LeaveTargetRunning>
|
||||
<CStepIntDis>_ 0</CStepIntDis>
|
||||
<jlinkResetStyle>12</jlinkResetStyle>
|
||||
<jlinkResetStrategy>0</jlinkResetStrategy>
|
||||
</JLinkDriver>
|
||||
<ArmDriver>
|
||||
<EnableCache>0</EnableCache>
|
||||
</ArmDriver>
|
||||
<Trace2>
|
||||
<Enabled>0</Enabled>
|
||||
<ShowSource>0</ShowSource>
|
||||
</Trace2>
|
||||
<TermIOLog>
|
||||
<LoggingEnabled>_ 0</LoggingEnabled>
|
||||
<LogFile>_ ""</LogFile>
|
||||
</TermIOLog>
|
||||
<LogFile>
|
||||
<LoggingEnabled>_ 0</LoggingEnabled>
|
||||
<LogFile>_ ""</LogFile>
|
||||
<Category>_ 0</Category>
|
||||
</LogFile>
|
||||
<DriverProfiling>
|
||||
<Enabled>0</Enabled>
|
||||
<Mode>1</Mode>
|
||||
@ -87,29 +100,21 @@
|
||||
<CallStackStripe>
|
||||
<ShowTiming>1</ShowTiming>
|
||||
</CallStackStripe>
|
||||
<Trace2>
|
||||
<Enabled>0</Enabled>
|
||||
<ShowSource>0</ShowSource>
|
||||
</Trace2>
|
||||
<LogFile>
|
||||
<LoggingEnabled>_ 0</LoggingEnabled>
|
||||
<LogFile>_ ""</LogFile>
|
||||
<Category>_ 0</Category>
|
||||
</LogFile>
|
||||
<DisassembleMode>
|
||||
<mode>0</mode>
|
||||
</DisassembleMode>
|
||||
<Breakpoints2>
|
||||
<Bp0>_ 1 "EMUL_CODE" "{$PROJ_DIR$\PROJECT\app\app_vlad.c}.628.19" 0 0 1 "" 0 "" 0</Bp0>
|
||||
<Bp1>_ 1 "EMUL_CODE" "{$PROJ_DIR$\PROJECT\app\app_vlad.c}.626.21" 0 0 1 "" 0 "" 0</Bp1>
|
||||
<Count>2</Count>
|
||||
<Bp0>_ 1 "EMUL_CODE" "{$PROJ_DIR$\PROJECT\app\app_vlad.c}.734.23" 0 0 1 "" 0 "" 0</Bp0>
|
||||
<Bp1>_ 1 "EMUL_CODE" "{$PROJ_DIR$\PROJECT\drivers\mfrc522\rfid-spi.c}.556.7" 0 0 1 "" 0 "" 0</Bp1>
|
||||
<Bp2>_ 1 "EMUL_CODE" "{$PROJ_DIR$\PROJECT\drivers\mfrc522\rfid-spi.c}.545.9" 0 0 1 "" 0 "" 0</Bp2>
|
||||
<Bp3>_ 1 "EMUL_CODE" "{$PROJ_DIR$\PROJECT\drivers\mfrc522\rfid-spi.c}.534.9" 0 0 1 "" 0 "" 0</Bp3>
|
||||
<Bp4>_ 1 "EMUL_CODE" "{$PROJ_DIR$\PROJECT\drivers\mfrc522\rfid-spi.c}.180.7" 0 0 1 "" 0 "" 0</Bp4>
|
||||
<Bp5>_ 1 "EMUL_CODE" "{$PROJ_DIR$\PROJECT\drivers\mfrc522\rfid-spi.c}.260.5" 0 0 1 "" 0 "" 0</Bp5>
|
||||
<Bp6>_ 1 "EMUL_CODE" "{$PROJ_DIR$\PROJECT\drivers\mfrc522\rfid-spi.c}.622.7" 0 0 1 "" 0 "" 0</Bp6>
|
||||
<Count>7</Count>
|
||||
</Breakpoints2>
|
||||
<Aliases>
|
||||
<Count>0</Count>
|
||||
<SuppressDialog>0</SuppressDialog>
|
||||
</Aliases>
|
||||
<TermIOLog>
|
||||
<LoggingEnabled>_ 0</LoggingEnabled>
|
||||
<LogFile>_ ""</LogFile>
|
||||
</TermIOLog>
|
||||
</settings>
|
||||
|
||||
File diff suppressed because one or more lines are too long
4322
sk-mlpc2368.dep
4322
sk-mlpc2368.dep
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user