drivers: adc: add ADC emulator

ADC emulator is designed to be used in tests on native_posix board. It
supports 1-16 bit resolution range and all GAINs from enum adc_gain.
Reference voltages and number of emulated channels are set through dts.
Using special API from drivers/adc/adc_emul.h it is possible to set
constant voltage value returned by given ADC channel or set custom
function which allows to simulate complex output.
Also reference voltages can be changed in runtime using the API.

The CL also includes:
- Add adc definitions of ADC emulator in
  tests/drivers/adc/adc_api/src/test_adc.c for supporting test suites.
- Add test for ADC emulator API in tests/drivers/adc/adc_emul/

Signed-off-by: Tomasz Michalec <tm@semihalf.com>
diff --git a/drivers/adc/Kconfig.adc_emul b/drivers/adc/Kconfig.adc_emul
new file mode 100644
index 0000000..8f3bc5b
--- /dev/null
+++ b/drivers/adc/Kconfig.adc_emul
@@ -0,0 +1,27 @@
+# Copyright 2021 Google LLC
+# SPDX-License-Identifier: Apache-2.0
+
+config ADC_EMUL
+	bool "ADC emulator"
+	help
+	  Enable the ADC emulator driver. This is a fake driver in that it
+	  does not talk to real hardware. It prenteds to be actual ADC. It
+	  is used for testing higher-level API for ADC devices.
+
+if ADC_EMUL
+
+config ADC_EMUL_ACQUISITION_THREAD_STACK_SIZE
+	int "Stack size for the ADC data acquisition thread"
+	default 512
+	help
+	  Size of the stack used for the internal data acquisition
+	  thread. Increasing size may be required when value function for
+	  emulated ADC require a lot of memory.
+
+config ADC_EMUL_ACQUISITION_THREAD_PRIO
+	int "Priority for the ADC data acquisition thread"
+	default 0
+	help
+	  Priority level for the internal ADC data acquisition thread.
+
+endif # ADC_EMUL