mirror of
https://github.com/dimoniche/solarium.vlad.git
synced 2026-01-30 13:03:30 +03:00
Продолжение. Пытаемся читать данные с карты.
This commit is contained in:
parent
bb3e477d29
commit
90e007dd31
@ -24,6 +24,8 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "ftp_app.h"
|
#include "ftp_app.h"
|
||||||
|
|
||||||
|
#include "rfid-spi.h"
|
||||||
|
#include "mfrc522data.h"
|
||||||
|
|
||||||
extern CPU_INT32U ChannelsPayedTime[CHANNELS_NUM];
|
extern CPU_INT32U ChannelsPayedTime[CHANNELS_NUM];
|
||||||
|
|
||||||
@ -621,18 +623,6 @@ void AppVladEventProcess(CPU_INT32U event)
|
|||||||
{
|
{
|
||||||
current_discount = CalcCurrentDiscount(SystemTime);
|
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 APP_DEBUG
|
||||||
if ((SystemTime % 30) == 0)
|
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)
|
if (GetMode() != MODE_WORK)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
uid_struct uid; // Used by picc_read_card_serial().
|
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.
|
* Writes a number of bytes to the specified register in the MFRC522 chip.
|
||||||
* The interface is described in the datasheet section 8.1.2.
|
* 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_mfrc522(FIFOLevelReg, 0x80); // FlushBuffer = 1, FIFO initialization
|
||||||
write_bytes_mfrc522(FIFODataReg, length, data); // Write data to the FIFO
|
write_bytes_mfrc522(FIFODataReg, length, data); // Write data to the FIFO
|
||||||
write_mfrc522(CommandReg, PCD_CalcCRC); // Start the calculation
|
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.
|
// 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
|
// 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.
|
// Wait for the CRC calculation to complete. Each iteration of the while-loop takes 17.73us.
|
||||||
uint16_t i;
|
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
|
// DivIrqReg[7..0] bits are: Set2 reserved reserved MfinActIRq reserved CRCIRq reserved reserved
|
||||||
uint8_t n = read_mfrc522(DivIrqReg);
|
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);
|
result[1] = read_mfrc522(CRCResultRegH);
|
||||||
return STATUS_OK;
|
return STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSTimeDly(1);
|
||||||
}
|
}
|
||||||
// 89ms passed and nothing happend. Communication with the MFRC522 might be down.
|
// 89ms passed and nothing happend. Communication with the MFRC522 might be down.
|
||||||
//printf("89ms passed and nothing happend.\n");
|
//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
|
// TODO check/modify for other architectures than Arduino Uno 16bit
|
||||||
|
|
||||||
uint16_t i;
|
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
|
uint8_t n = read_mfrc522(ComIrqReg); // ComIrqReg[7..0] bits are: Set1 TxIRq RxIRq IdleIRq HiAlertIRq LoAlertIRq ErrIRq TimerIRq
|
||||||
if (n & wait_irq)
|
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
|
{ // Timer interrupt - nothing received in 25ms
|
||||||
return STATUS_TIMEOUT;
|
return STATUS_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSTimeDly(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 35.7ms and nothing happend. Communication with the MFRC522 might be down.
|
// 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();
|
void antenna_on();
|
||||||
bool pcd_initialization();
|
bool pcd_initialization();
|
||||||
|
|
||||||
|
uid_struct * get_uid();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
File diff suppressed because one or more lines are too long
@ -46,11 +46,11 @@
|
|||||||
<MultiCoreRunAll>1</MultiCoreRunAll>
|
<MultiCoreRunAll>1</MultiCoreRunAll>
|
||||||
</Simulator>
|
</Simulator>
|
||||||
<PlDriver>
|
<PlDriver>
|
||||||
<MemConfigValue>C:\Program Files\IAR Systems\Embedded Workbench 9.0\arm\CONFIG\debugger\NXP\LPC2368.ddf</MemConfigValue>
|
|
||||||
<FirstRun>0</FirstRun>
|
<FirstRun>0</FirstRun>
|
||||||
|
<MemConfigValue>C:\Program Files\IAR Systems\Embedded Workbench 9.0\arm\CONFIG\debugger\NXP\LPC2368.ddf</MemConfigValue>
|
||||||
</PlDriver>
|
</PlDriver>
|
||||||
<DebugChecksum>
|
<DebugChecksum>
|
||||||
<Checksum>904050673</Checksum>
|
<Checksum>4119436880</Checksum>
|
||||||
</DebugChecksum>
|
</DebugChecksum>
|
||||||
<Exceptions>
|
<Exceptions>
|
||||||
<StopOnUncaught>_ 0</StopOnUncaught>
|
<StopOnUncaught>_ 0</StopOnUncaught>
|
||||||
@ -65,16 +65,29 @@
|
|||||||
</CallStack>
|
</CallStack>
|
||||||
<JLinkDriver>
|
<JLinkDriver>
|
||||||
<WatchCond>_ 0</WatchCond>
|
<WatchCond>_ 0</WatchCond>
|
||||||
<Watch0>_ 0 "" 0 "" 0 "" 0 "" 0 0 0 0</Watch0>
|
<Watch0>_ 0 "0x00000000" 4294967295 "0xFFFFFFFF" 0 "0x00000000" 4294967295 "0xFFFFFFFF" 3 0 0 0</Watch0>
|
||||||
<Watch1>_ 0 "" 0 "" 0 "" 0 "" 0 0 0 0</Watch1>
|
<Watch1>_ 0 "0x00000000" 4294967295 "0xFFFFFFFF" 0 "0x00000000" 4294967295 "0xFFFFFFFF" 3 0 0 0</Watch1>
|
||||||
<jlinkResetStyle>12</jlinkResetStyle>
|
|
||||||
<jlinkResetStrategy>0</jlinkResetStrategy>
|
|
||||||
<LeaveTargetRunning>_ 0</LeaveTargetRunning>
|
<LeaveTargetRunning>_ 0</LeaveTargetRunning>
|
||||||
<CStepIntDis>_ 0</CStepIntDis>
|
<CStepIntDis>_ 0</CStepIntDis>
|
||||||
|
<jlinkResetStyle>12</jlinkResetStyle>
|
||||||
|
<jlinkResetStrategy>0</jlinkResetStrategy>
|
||||||
</JLinkDriver>
|
</JLinkDriver>
|
||||||
<ArmDriver>
|
<ArmDriver>
|
||||||
<EnableCache>0</EnableCache>
|
<EnableCache>0</EnableCache>
|
||||||
</ArmDriver>
|
</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>
|
<DriverProfiling>
|
||||||
<Enabled>0</Enabled>
|
<Enabled>0</Enabled>
|
||||||
<Mode>1</Mode>
|
<Mode>1</Mode>
|
||||||
@ -87,29 +100,21 @@
|
|||||||
<CallStackStripe>
|
<CallStackStripe>
|
||||||
<ShowTiming>1</ShowTiming>
|
<ShowTiming>1</ShowTiming>
|
||||||
</CallStackStripe>
|
</CallStackStripe>
|
||||||
<Trace2>
|
|
||||||
<Enabled>0</Enabled>
|
|
||||||
<ShowSource>0</ShowSource>
|
|
||||||
</Trace2>
|
|
||||||
<LogFile>
|
|
||||||
<LoggingEnabled>_ 0</LoggingEnabled>
|
|
||||||
<LogFile>_ ""</LogFile>
|
|
||||||
<Category>_ 0</Category>
|
|
||||||
</LogFile>
|
|
||||||
<DisassembleMode>
|
<DisassembleMode>
|
||||||
<mode>0</mode>
|
<mode>0</mode>
|
||||||
</DisassembleMode>
|
</DisassembleMode>
|
||||||
<Breakpoints2>
|
<Breakpoints2>
|
||||||
<Bp0>_ 1 "EMUL_CODE" "{$PROJ_DIR$\PROJECT\app\app_vlad.c}.628.19" 0 0 1 "" 0 "" 0</Bp0>
|
<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\app\app_vlad.c}.626.21" 0 0 1 "" 0 "" 0</Bp1>
|
<Bp1>_ 1 "EMUL_CODE" "{$PROJ_DIR$\PROJECT\drivers\mfrc522\rfid-spi.c}.556.7" 0 0 1 "" 0 "" 0</Bp1>
|
||||||
<Count>2</Count>
|
<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>
|
</Breakpoints2>
|
||||||
<Aliases>
|
<Aliases>
|
||||||
<Count>0</Count>
|
<Count>0</Count>
|
||||||
<SuppressDialog>0</SuppressDialog>
|
<SuppressDialog>0</SuppressDialog>
|
||||||
</Aliases>
|
</Aliases>
|
||||||
<TermIOLog>
|
|
||||||
<LoggingEnabled>_ 0</LoggingEnabled>
|
|
||||||
<LogFile>_ ""</LogFile>
|
|
||||||
</TermIOLog>
|
|
||||||
</settings>
|
</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