// internal sending function. not a RAMFUNC. bool intMfSniffSend() { int pckSize = 0; int pckLen = BigBuf_get_traceLen(); int pckNum = 0; uint8_t *trace = BigBuf_get_addr(); FpgaDisableSscDma(); while (pckLen > 0) { pckSize = MIN(USB_CMD_DATA_SIZE, pckLen); LED_B_ON(); cmd_send(CMD_ACK, 1, BigBuf_get_traceLen(), pckSize, trace + BigBuf_get_traceLen() - pckLen, pckSize); LED_B_OFF(); pckLen -= pckSize; pckNum++; } LED_B_ON(); cmd_send(CMD_ACK,2,0,0,0,0); LED_B_OFF(); clear_trace(); return TRUE; }
// internal sending function. not a RAMFUNC. bool intMfSniffSend() { int pckSize = 0; int pckLen = traceLen; int pckNum = 0; FpgaDisableSscDma(); while (pckLen > 0) { pckSize = MIN(USB_CMD_DATA_SIZE, pckLen); LED_B_ON(); cmd_send(CMD_ACK, 1, pckSize, pckNum, trace + traceLen - pckLen, pckSize); LED_B_OFF(); pckLen -= pckSize; pckNum++; } LED_B_ON(); cmd_send(CMD_ACK,2,0,0,0,0); LED_B_OFF(); iso14a_clear_trace(); return TRUE; }
bool MfSniffEnd(void){ LED_B_ON(); cmd_send(CMD_ACK,0,0,0,0,0); LED_B_OFF(); return FALSE; }
// LEDs: R(C) O(A) G(B) -- R(D) [1, 2, 4 and 8] void LED(int led, int ms) { if (led & LED_RED) LED_C_ON(); if (led & LED_ORANGE) LED_A_ON(); if (led & LED_GREEN) LED_B_ON(); if (led & LED_RED2) LED_D_ON(); if (!ms) return; SpinDelay(ms); if (led & LED_RED) LED_C_OFF(); if (led & LED_ORANGE) LED_A_OFF(); if (led & LED_GREEN) LED_B_OFF(); if (led & LED_RED2) LED_D_OFF(); }
void TIM2_IRQHandler (void) { TIM2->SR &= ~(0x01); bufferE[i%4096]= read_ADC(); switch(etat) { case 0 : DAC->DHR12R1= bufferE[i%4096]; LED_B_ON(1); LED_B_OFF(2); LED_B_OFF(10); LED_B_OFF(11); break; case 1 : DAC->DHR12R1= bufferE[i%4096] + bufferE[(i-1200)%4096] ; // Double LED_B_ON(2); LED_B_OFF(1); LED_B_OFF(10); LED_B_OFF(11); break; case 2 : DAC->DHR12R1= bufferE[i%4096]+0.7*bufferS[(i-2400)%4096]; // Echo bufferS[i%4096]=DAC->DOR1; LED_B_ON(10); LED_B_OFF(2); LED_B_OFF(1); LED_B_OFF(11); break; case 3 : float tmp=0; for(int j=0;j<5;j++) { tmp+= (float)bufferE[(i)%4096]*coeffsFIR[(j)%4096]; // FIR 10khz } DAC->DHR12R1=tmp; LED_B_ON(11); LED_B_OFF(2); LED_B_OFF(10); LED_B_OFF(1); TIM2->SR &= ~(0x01); break; } i++; }
void MifareDesfireGetInformation(){ int len = 0; uint8_t resp[USB_CMD_DATA_SIZE] = {0x00}; uint8_t dataout[USB_CMD_DATA_SIZE] = {0x00}; byte_t cardbuf[USB_CMD_DATA_SIZE] = {0x00}; /* 1 = PCB 1 2 = cid 2 3 = desfire command 3 4-5 = crc 4 key 5-6 crc PCB == 0x0A because sending CID byte. CID == 0x00 first card? */ clear_trace(); set_tracing(TRUE); iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN); // card select - information iso14a_card_select_t *card = (iso14a_card_select_t*)cardbuf; byte_t isOK = iso14443a_select_card(NULL, card, NULL, true, 0); if ( isOK == 0) { if (MF_DBGLEVEL >= MF_DBG_ERROR) { Dbprintf("Can't select card"); } OnError(1); return; } memcpy(dataout,card->uid,7); LED_A_ON(); LED_B_OFF(); LED_C_OFF(); uint8_t cmd[] = {GET_VERSION}; size_t cmd_len = sizeof(cmd); len = DesfireAPDU(cmd, cmd_len, resp); if ( !len ) { print_result("ERROR <--: ", resp, len); OnError(2); return; } LED_A_OFF(); LED_B_ON(); memcpy(dataout+7,resp+3,7); // ADDITION_FRAME 1 cmd[0] = ADDITIONAL_FRAME; len = DesfireAPDU(cmd, cmd_len, resp); if ( !len ) { print_result("ERROR <--: ", resp, len); OnError(2); return; } LED_B_OFF(); LED_C_ON(); memcpy(dataout+7+7,resp+3,7); // ADDITION_FRAME 2 len = DesfireAPDU(cmd, cmd_len, resp); if ( !len ) { print_result("ERROR <--: ", resp, len); OnError(2); return; } memcpy(dataout+7+7+7,resp+3,14); cmd_send(CMD_ACK,1,0,0,dataout,sizeof(dataout)); // reset the pcb_blocknum, pcb_blocknum = 0; OnSuccess(); }
/*************************************************** * Function: void timer0_isr(void) * * OverView: If low interrupt actived, called this function. * Control LED * * Note: reference BootLoader.h ***************************************************/ void timer0_isr(void) { if(INTCONbits.TMR0IF) { INTCONbits.TMR0IF = 0; TMR0L = tmr0l_temp; if(!wg_ledCtrl) { if(wg_ledPwmDuty <= 0) { TMR0L = wg_ledPwmDuty; LED_WG_OFF(); } else if(TMR0L == wg_ledPwmDuty) { TMR0L = 255 - wg_ledPwmDuty; LED_WG_ON(); } else { TMR0L = wg_ledPwmDuty; LED_WG_OFF(); } } else if(!r_ledCtrl) { if(r_ledPwmDuty <= 0) { TMR0L = r_ledPwmDuty; LED_R_OFF(); } else if(TMR0L == r_ledPwmDuty) { TMR0L = 255 - r_ledPwmDuty; LED_R_ON(); } else { TMR0L = r_ledPwmDuty; LED_R_OFF(); } } else if(!g_ledCtrl) { if(g_ledPwmDuty <= 0) { TMR0L = g_ledPwmDuty; LED_G_OFF(); } else if(TMR0L == g_ledPwmDuty) { TMR0L = 255 - g_ledPwmDuty; LED_G_ON(); } else { TMR0L = g_ledPwmDuty; LED_G_OFF(); } } else if(!b_ledCtrl) { if(b_ledPwmDuty <= 0) { TMR0L = b_ledPwmDuty; LED_B_OFF(); } else if(TMR0L == b_ledPwmDuty) { TMR0L = 255 - b_ledPwmDuty; LED_B_ON(); } else { TMR0L = b_ledPwmDuty; LED_B_OFF(); } } else { TMR0L = tmr0l_temp; LED_WG_OFF(); LED_R_OFF(); LED_G_OFF(); LED_B_OFF(); } tmr0l_temp = TMR0L; } }