Change in simtrace2[master]: octsimtest: Adjust VCC voltage thresholds (resistive VCC divider)

laforge gerrit-no-reply at lists.osmocom.org
Thu Jun 3 07:03:55 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/simtrace2/+/24530 )


Change subject: octsimtest: Adjust VCC voltage thresholds (resistive VCC divider)
......................................................................

octsimtest: Adjust VCC voltage thresholds (resistive VCC divider)

octsimtest has a resistive voltage divider in front of the VCC ADC
in order to also detect 5V.  We must make the thresholds board-specific
and adjust them for octsimtest.

Change-Id: I9e4adb4f349d2d838ea4100eb49271f3a0e7a2a5
---
M firmware/libboard/octsimtest/include/board.h
M firmware/libboard/qmod/include/board.h
M firmware/libcommon/source/mode_cardemu.c
3 files changed, 11 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/30/24530/1

diff --git a/firmware/libboard/octsimtest/include/board.h b/firmware/libboard/octsimtest/include/board.h
index 361c180..2d8a896 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 5165434..0d35bef 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 604c66a..23f9f66 100644
--- a/firmware/libcommon/source/mode_cardemu.c
+++ b/firmware/libcommon/source/mode_cardemu.c
@@ -408,6 +408,9 @@
  ***********************************************************************/
 
 #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,8 +459,8 @@
 	return 0;
 }
 
-#define VCC_UV_THRESH_1V8	1500000
-#define VCC_UV_THRESH_3V	2500000
+#define VCC_UV_THRESH_1V8	(1500000/(47+30)*47)
+#define VCC_UV_THRESH_3V	(2500000/(47+30)*47)
 
 static void process_vcc_adc(struct cardem_inst *ci)
 {

-- 
To view, visit https://gerrit.osmocom.org/c/simtrace2/+/24530
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I9e4adb4f349d2d838ea4100eb49271f3a0e7a2a5
Gerrit-Change-Number: 24530
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210603/c693ad35/attachment.htm>


More information about the gerrit-log mailing list