diff options
author | Damien George <damien@micropython.org> | 2023-10-11 13:48:49 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-10-23 17:16:45 +1100 |
commit | 95d8b5fd555ba26ebd79b29fade45d2bf0abc6c4 (patch) | |
tree | cff4cb6867f00c45c9f1df4489ea036ea964e9ca /extmod/modmachine.h | |
parent | 48e0986666c9f2059c92253f3c0f9b4184d68816 (diff) |
extmod/machine_adc: Factor ports' ADC Python bindings to common code.
No functional change, just code factoring to have the Python bindings in
one location, and all the ports use those same bindings.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'extmod/modmachine.h')
-rw-r--r-- | extmod/modmachine.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/extmod/modmachine.h b/extmod/modmachine.h index b0235dcf6..e635eedaa 100644 --- a/extmod/modmachine.h +++ b/extmod/modmachine.h @@ -29,7 +29,44 @@ #include "py/obj.h" +// Whether to enable the ADC.init() method. +// Requires a port to implement mp_machine_adc_init_helper(). +#ifndef MICROPY_PY_MACHINE_ADC_INIT +#define MICROPY_PY_MACHINE_ADC_INIT (0) +#endif + +// Whether to enable the ADC.deinit() method. +// Requires a port to implement mp_machine_adc_deinit(). +#ifndef MICROPY_PY_MACHINE_ADC_DEINIT +#define MICROPY_PY_MACHINE_ADC_DEINIT (0) +#endif + +// Whether to enable the ADC.block() method. +// Requires a port to implement mp_machine_adc_block(). +#ifndef MICROPY_PY_MACHINE_ADC_BLOCK +#define MICROPY_PY_MACHINE_ADC_BLOCK (0) +#endif + +// Whether to enable the ADC.read_uv() method. +// Requires a port to implement mp_machine_adc_read_uv(). +#ifndef MICROPY_PY_MACHINE_ADC_READ_UV +#define MICROPY_PY_MACHINE_ADC_READ_UV (0) +#endif + +// Whether to enable the ADC.atten() and ADC.width() methods. +// Note: these are legacy and should not be used on new ports. +#ifndef MICROPY_PY_MACHINE_ADC_ATTEN_WIDTH +#define MICROPY_PY_MACHINE_ADC_ATTEN_WIDTH (0) +#endif + +// Whether to enable the ADC.read() method. +// Note: this is legacy and should not be used on new ports. +#ifndef MICROPY_PY_MACHINE_ADC_READ +#define MICROPY_PY_MACHINE_ADC_READ (0) +#endif + // A port must provide these types, but they are otherwise opaque. +typedef struct _machine_adc_obj_t machine_adc_obj_t; typedef struct _machine_i2s_obj_t machine_i2s_obj_t; typedef struct _machine_pwm_obj_t machine_pwm_obj_t; typedef struct _machine_wdt_obj_t machine_wdt_obj_t; @@ -37,6 +74,7 @@ typedef struct _machine_wdt_obj_t machine_wdt_obj_t; // These classes correspond to machine.Type entries in the machine module. // Their Python bindings are implemented in extmod, and their implementation // is provided by a port. +extern const mp_obj_type_t machine_adc_type; extern const mp_obj_type_t machine_i2c_type; extern const mp_obj_type_t machine_i2s_type; extern const mp_obj_type_t machine_pwm_type; |