Added ledcontrol to lf functions

This commit is contained in:
Łukasz Jurczyk 2021-11-18 14:26:41 +01:00
commit 218a4ba2ec
No known key found for this signature in database
GPG key ID: 95B48A1500000000
26 changed files with 432 additions and 426 deletions

View file

@ -13,7 +13,7 @@
#define T0_PCF 8 //period for the pcf7931 in us
#define ALLOC 16
size_t DemodPCF7931(uint8_t **outBlocks) {
size_t DemodPCF7931(uint8_t **outBlocks, bool ledcontrol) {
// 2021 iceman, memor
uint8_t bits[256] = {0x00};
@ -37,7 +37,7 @@ size_t DemodPCF7931(uint8_t **outBlocks) {
BigBuf_Clear_keep_EM();
LFSetupFPGAForADC(LF_DIVISOR_125, true);
DoAcquisition_default(0, true);
DoAcquisition_default(0, true, ledcontrol);
/* Find first local max/min */
if (dest[1] > dest[0]) {
@ -188,7 +188,7 @@ bool IsBlock1PCF7931(uint8_t *block) {
return false;
}
void ReadPCF7931(void) {
void ReadPCF7931(bool ledcontrol) {
int found_blocks = 0; // successfully read blocks
int max_blocks = 8; // readable blocks
uint8_t memory_blocks[8][17]; // PCF content
@ -211,7 +211,7 @@ void ReadPCF7931(void) {
i = 0;
memset(tmp_blocks, 0, 4 * 16 * sizeof(uint8_t));
n = DemodPCF7931((uint8_t **)tmp_blocks);
n = DemodPCF7931((uint8_t **)tmp_blocks, ledcontrol);
if (!n)
++errors;
@ -353,7 +353,7 @@ end:
reply_mix(CMD_ACK, 0, 0, 0, 0, 0);
}
static void RealWritePCF7931(uint8_t *pass, uint16_t init_delay, int32_t l, int32_t p, uint8_t address, uint8_t byte, uint8_t data) {
static void RealWritePCF7931(uint8_t *pass, uint16_t init_delay, int32_t l, int32_t p, uint8_t address, uint8_t byte, uint8_t data, bool ledcontrol) {
uint32_t tab[1024] = {0}; // data times frame
uint32_t u = 0;
uint8_t parity = 0;
@ -427,7 +427,7 @@ static void RealWritePCF7931(uint8_t *pass, uint16_t init_delay, int32_t l, int3
}
}
SendCmdPCF7931(tab);
SendCmdPCF7931(tab, ledcontrol);
}
/* Write on a byte of a PCF7931 tag
@ -435,7 +435,7 @@ static void RealWritePCF7931(uint8_t *pass, uint16_t init_delay, int32_t l, int3
@param byte : address of the byte to write
@param data : data to write
*/
void WritePCF7931(uint8_t pass1, uint8_t pass2, uint8_t pass3, uint8_t pass4, uint8_t pass5, uint8_t pass6, uint8_t pass7, uint16_t init_delay, int32_t l, int32_t p, uint8_t address, uint8_t byte, uint8_t data) {
void WritePCF7931(uint8_t pass1, uint8_t pass2, uint8_t pass3, uint8_t pass4, uint8_t pass5, uint8_t pass6, uint8_t pass7, uint16_t init_delay, int32_t l, int32_t p, uint8_t address, uint8_t byte, uint8_t data, bool ledcontrol) {
if (g_dbglevel >= DBG_INFO) {
Dbprintf("Initialization delay : %d us", init_delay);
@ -449,7 +449,7 @@ void WritePCF7931(uint8_t pass1, uint8_t pass2, uint8_t pass3, uint8_t pass4, ui
uint8_t password[7] = {pass1, pass2, pass3, pass4, pass5, pass6, pass7};
RealWritePCF7931(password, init_delay, l, p, address, byte, data);
RealWritePCF7931(password, init_delay, l, p, address, byte, data, ledcontrol);
}
@ -457,7 +457,7 @@ void WritePCF7931(uint8_t pass1, uint8_t pass2, uint8_t pass3, uint8_t pass4, ui
* @param tab : array of the data frame
*/
void SendCmdPCF7931(uint32_t *tab) {
void SendCmdPCF7931(uint32_t *tab, bool ledcontrol) {
uint16_t u = 0, tempo = 0;
if (g_dbglevel >= DBG_INFO) {
@ -468,7 +468,7 @@ void SendCmdPCF7931(uint32_t *tab) {
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, LF_DIVISOR_125); //125kHz
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_PASSTHRU);
LED_A_ON();
if (ledcontrol) LED_A_ON();
// steal this pin from the SSP and use it to control the modulation
AT91C_BASE_PIOA->PIO_PER = GPIO_SSC_DOUT;
@ -505,7 +505,7 @@ void SendCmdPCF7931(uint32_t *tab) {
}
}
LED_A_OFF();
if (ledcontrol) LED_A_OFF();
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
SpinDelay(200);