|
3 | 3 | *
|
4 | 4 | * The MIT License (MIT)
|
5 | 5 | *
|
6 |
| - * Copyright (c) 2017-2018 Glenn Ruben Bakke |
| 6 | + * Copyright (c) 2025 Ned Konz <ned@metamagix.tech> |
7 | 7 | *
|
8 | 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 | 9 | * of this software and associated documentation files (the "Software"), to deal
|
|
39 | 39 | * also needs to be specified in devicetree, in ADC controller child nodes. Also
|
40 | 40 | * the ADC resolution and oversampling setting (if used) need to be specified
|
41 | 41 | * 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 | + * |
42 | 68 | */
|
43 | 69 |
|
44 | 70 | // #include "extmod/modmachine.h" // included from extmod/machine_adc.c
|
45 | 71 |
|
46 |
| -#include "py/mphal.h" |
| 72 | +#include <inttypes.h> |
| 73 | +#include <stddef.h> |
| 74 | +#include <stdint.h> |
47 | 75 | #include <zephyr/device.h>
|
48 | 76 | #include <zephyr/devicetree.h>
|
49 | 77 | #include <zephyr/kernel.h>
|
50 | 78 | #include <zephyr/sys/printk.h>
|
51 | 79 | #include <zephyr/sys/util.h>
|
52 | 80 | #include <zephyr/drivers/adc.h>
|
| 81 | +#include "py/mphal.h" |
53 | 82 | #include "extmod/modmachine.h"
|
54 | 83 | #include "modmachine.h"
|
55 | 84 | #include "zephyr_device.h"
|
56 | 85 |
|
57 |
| -#include <inttypes.h> |
58 |
| -#include <stddef.h> |
59 |
| -#include <stdint.h> |
60 | 86 |
|
61 | 87 |
|
62 | 88 | #if !DT_NODE_EXISTS(DT_PATH(zephyr_user)) || \
|
|
0 commit comments