-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from shinhub/workmem_funcbtn_brute_log_clean
Workmem, CARD_FUNCTION, BRUTE, LOG and cleanup
- Loading branch information
Showing
19 changed files
with
907 additions
and
382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,32 @@ | ||
#include "AntennaLevel.h" | ||
#include "Application/Application.h" | ||
|
||
#define FIELD_MIN_RSSI 500 | ||
void AntennaLevelInit(void) { | ||
ADCA.CTRLA = ADC_ENABLE_bm; | ||
ADCA.CTRLB = ADC_RESOLUTION_12BIT_gc; | ||
ADCA.REFCTRL = ADC_REFSEL_INT1V_gc | ADC_BANDGAP_bm; | ||
ADCA.PRESCALER = ADC_PRESCALER_DIV32_gc; | ||
ADCA.CH0.CTRL = ADC_CH_INPUTMODE_SINGLEENDED_gc; | ||
ADCA.CH0.MUXCTRL = ADC_CH_MUXPOS_PIN7_gc; | ||
} | ||
|
||
uint16_t AntennaLevelGet(void) { | ||
ADCA.CH0.CTRL |= ADC_CH_START_bm; | ||
while( !(ADCA.CH0.INTFLAGS & ADC_CH_CHIF_bm) ); | ||
|
||
ADCA.CH0.INTFLAGS = ADC_CH_CHIF_bm; | ||
|
||
int16_t Result = ADCA.CH0RES - ANTENNA_LEVEL_OFFSET; | ||
if (Result < 0) Result = 0; | ||
|
||
return (uint16_t) (((uint32_t) Result * ANTENNA_LEVEL_NUMERATOR) / ANTENNA_LEVEL_DENOMINATOR); | ||
} | ||
|
||
void AntennaLevelTick(void) | ||
{ | ||
void AntennaLevelTick(void) { | ||
uint16_t rssi = AntennaLevelGet(); | ||
|
||
if (rssi < FIELD_MIN_RSSI) | ||
{ | ||
//LEDHook(LED_FIELD_DETECTED, LED_OFF); | ||
if (ActiveConfiguration.UidSize != 0) // this implies that we are emulating right now | ||
ApplicationReset(); // reset the application just like a real card gets reset when there is no field | ||
} else { | ||
//LEDHook(LED_FIELD_DETECTED, LED_ON); | ||
// UidSize != 0 implies that we are emulating right now | ||
if( (rssi < ANTENNA_FIELD_MIN_RSSI) && (ActiveConfiguration.UidSize != 0) ) { | ||
ApplicationReset(); // reset the application just like a real card gets reset when there is no field | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.