diff --git a/firmware/libboard/octsimtest/include/board.h b/firmware/libboard/octsimtest/include/board.h index 361c1802..2d8a8964 100644 --- a/firmware/libboard/octsimtest/include/board.h +++ b/firmware/libboard/octsimtest/include/board.h @@ -105,6 +105,9 @@ #define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_BUSPOWERED_NORWAKEUP #define DETECT_VCC_BY_ADC +/* we have a resistive voltage divider of 47 + 30 kOhms to also detect 5V supply power */ +#define VCC_UV_THRESH_1V8 (1500000*47)/(47+30) +#define VCC_UV_THRESH_3V (2500000*47)/(47+30) /** Supported modes */ /* SIMtrace board supports sniffer mode */ diff --git a/firmware/libboard/qmod/include/board.h b/firmware/libboard/qmod/include/board.h index 51654341..0d35bef1 100644 --- a/firmware/libboard/qmod/include/board.h +++ b/firmware/libboard/qmod/include/board.h @@ -109,6 +109,9 @@ #define BOARD_USB_RELEASE 0x010 #define CARDEMU_SECOND_UART + #define DETECT_VCC_BY_ADC +#define VCC_UV_THRESH_1V8 1500000 +#define VCC_UV_THRESH_3V 2500000 #define HAVE_CARDEM diff --git a/firmware/libcommon/source/mode_cardemu.c b/firmware/libcommon/source/mode_cardemu.c index 604c66ae..8a59e162 100644 --- a/firmware/libcommon/source/mode_cardemu.c +++ b/firmware/libcommon/source/mode_cardemu.c @@ -408,6 +408,9 @@ void card_emu_uart_interrupt(uint8_t uart_chan) ***********************************************************************/ #ifdef DETECT_VCC_BY_ADC +#if !defined(VCC_UV_THRESH_1V8) || !defined(VCC_UV_THRESH_3V) +#error "You must define VCC_UV_THRESH_{1V1,3V} if you use ADC VCC detection" +#endif static volatile int adc_triggered = 0; static int adc_sam3s_reva_errata = 0; @@ -456,9 +459,6 @@ static int card_vcc_adc_init(void) return 0; } -#define VCC_UV_THRESH_1V8 1500000 -#define VCC_UV_THRESH_3V 2500000 - static void process_vcc_adc(struct cardem_inst *ci) { if (ci->vcc_uv >= VCC_UV_THRESH_3V)