dey-examples/apix-adc-example
Francisco Gil 68f3f0f815 adc_example: Add an example about how to use the adc.
This example takes periodic samples using a thread and
calculate the rms value and the mean value of the samples
taken.

https://jira.digi.com/browse/DEL-4889

Signed-off-by: Francisco Gil <francisco.gilmartinez@digi.com>
2017-11-20 17:55:40 +01:00
..
Makefile adc_example: Add an example about how to use the adc. 2017-11-20 17:55:40 +01:00
README.md adc_example: Add an example about how to use the adc. 2017-11-20 17:55:40 +01:00
main.c adc_example: Add an example about how to use the adc. 2017-11-20 17:55:40 +01:00

README.md

Digi APIX ADC Sample Application

Sample application to access and manage ADC channels using the Digi APIX library.

The application enables one ADC channel on the board. After that, the application takes periodic samples and calculates the rms and mean value of the samples batch.

The ADC lines used in the sample are mapped as follows in the Digi Boards:

  • CCIMX6 SBC: PMIC_ADCIN1 (GPIO Connector Pin 1).
  • CCIMX6UL SBC Express: ADC1_IN4 (Expansion Connector Pin 7).
  • CCIMX6UL SBC Pro: ADC1_IN2 (GPIO Connector Pin 13).

The following device tree modifications are required for the sample to work:

  • CCIMX6 SBC: No device tree modifications are required.
  • CCIMX6UL SBC Express:
&adc1 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_adc1>;
	adc-ch-list = <4>;
	status = "okay";
};
 
&iomuxc {
	imx6ul-ccimx6ul {
		pinctrl_adc1: adc1grp {
			fsl,pins = <
				MX6UL_PAD_GPIO1_IO04__GPIO1_IO04        0xb0
			>;
		};
	};
};
  • CCIMX6UL SBC Pro:
&adc1 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_adc1>;
	adc-ch-list = <2>;
	status = "okay";
};
 
&iomuxc {
	imx6ul-ccimx6ul {
		pinctrl_adc1: adc1grp {
			fsl,pins = <
				MX6UL_PAD_GPIO1_IO02__GPIO1_IO02        0xb0
			>;
		};
	};
};

Running the application

Once the binary is in the target, launch the application:

#> apix-adc-example [adc_chip adc_channel interval number_of_samples]

Where:

  • 'adc_chip' the ADC chip number.
  • 'adc_channel' the ADC channel number.
  • 'interval' is the time interval between samples.
  • 'number_of_samples' is the number of samples to take.

Compiling the application

This demo can be compiled using a Digi Embedded Yocto based toolchain. Make sure to source the corresponding toolchain of the platform you are using, e.g:

$> . <DEY-toolchain-path>/environment-setup-cortexa7hf-vfp-neon-dey-linux-gnueabi
$> make

More information about Digi Embedded Yocto.

License

Copyright 2017, Digi International Inc.

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.