Skip to content

Commit 2d35d46

Browse files
committed
zephyr/machine_adc: Add documentation of DTS overlay.
1 parent bbd4d54 commit 2d35d46

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

ports/zephyr/machine_adc.c

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* The MIT License (MIT)
55
*
6-
* Copyright (c) 2017-2018 Glenn Ruben Bakke
6+
* Copyright (c) 2025 Ned Konz <ned@metamagix.tech>
77
*
88
* Permission is hereby granted, free of charge, to any person obtaining a copy
99
* of this software and associated documentation files (the "Software"), to deal
@@ -39,24 +39,50 @@
3939
* also needs to be specified in devicetree, in ADC controller child nodes. Also
4040
* the ADC resolution and oversampling setting (if used) need to be specified
4141
* there.
42+
*
43+
* Here is an excerpt from a devicetree overlay that configures an ADC
44+
* with one channel that would be referred to as ('adc', 0) in the constructor
45+
* of the ADC object:
46+
*
47+
* / {
48+
* zephyr,user {
49+
* io-channels = <&adc 0>, <&adc 1>, <&adc 4>, <&adc 5>, <&adc 7>;
50+
* };
51+
* };
52+
*
53+
* &adc {
54+
* #address-cells = <1>;
55+
* #size-cells = <0>;
56+
*
57+
* channel@0 {
58+
* reg = <0>;
59+
* zephyr,gain = "ADC_GAIN_1_6";
60+
* zephyr,reference = "ADC_REF_INTERNAL";
61+
* zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
62+
* zephyr,input-positive = <NRF_SAADC_AIN0>;
63+
* zephyr,resolution = <12>;
64+
* };
65+
* // other channels here (1, 4, 5, 7)
66+
* };
67+
*
4268
*/
4369

4470
// #include "extmod/modmachine.h" // included from extmod/machine_adc.c
4571

46-
#include "py/mphal.h"
72+
#include <inttypes.h>
73+
#include <stddef.h>
74+
#include <stdint.h>
4775
#include <zephyr/device.h>
4876
#include <zephyr/devicetree.h>
4977
#include <zephyr/kernel.h>
5078
#include <zephyr/sys/printk.h>
5179
#include <zephyr/sys/util.h>
5280
#include <zephyr/drivers/adc.h>
81+
#include "py/mphal.h"
5382
#include "extmod/modmachine.h"
5483
#include "modmachine.h"
5584
#include "zephyr_device.h"
5685

57-
#include <inttypes.h>
58-
#include <stddef.h>
59-
#include <stdint.h>
6086

6187

6288
#if !DT_NODE_EXISTS(DT_PATH(zephyr_user)) || \

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy