Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
a136638b68
@ -40,7 +40,12 @@
|
|||||||
// voltage monitor function and the wifi function. Special handling is required
|
// voltage monitor function and the wifi function. Special handling is required
|
||||||
// to read the analog voltage.
|
// to read the analog voltage.
|
||||||
#if CIRCUITPY_CYW43
|
#if CIRCUITPY_CYW43
|
||||||
|
#include "bindings/cyw43/__init__.h"
|
||||||
#define SPECIAL_PIN(pin) (pin->number == 29)
|
#define SPECIAL_PIN(pin) (pin->number == 29)
|
||||||
|
|
||||||
|
const mcu_pin_obj_t *common_hal_analogio_analogin_validate_pin(mp_obj_t obj) {
|
||||||
|
return validate_obj_is_free_pin_or_gpio29(obj);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
#define SPECIAL_PIN(pin) false
|
#define SPECIAL_PIN(pin) false
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,6 +41,10 @@
|
|||||||
#include "pico/cyw43_arch.h"
|
#include "pico/cyw43_arch.h"
|
||||||
#include "bindings/cyw43/__init__.h"
|
#include "bindings/cyw43/__init__.h"
|
||||||
#define IS_CYW(self) ((self)->pin->base.type == &cyw43_pin_type)
|
#define IS_CYW(self) ((self)->pin->base.type == &cyw43_pin_type)
|
||||||
|
|
||||||
|
const mcu_pin_obj_t *common_hal_digitalio_validate_pin(mp_obj_t obj) {
|
||||||
|
return validate_obj_is_free_pin_including_cyw43(obj);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
digitalinout_result_t common_hal_digitalio_digitalinout_construct(
|
digitalinout_result_t common_hal_digitalio_digitalinout_construct(
|
||||||
|
@ -36,9 +36,9 @@
|
|||||||
#include "shared-bindings/analogio/AnalogIn.h"
|
#include "shared-bindings/analogio/AnalogIn.h"
|
||||||
#include "shared-bindings/util.h"
|
#include "shared-bindings/util.h"
|
||||||
|
|
||||||
#if CIRCUITPY_CYW43
|
MP_WEAK const mcu_pin_obj_t *common_hal_analogio_analogin_validate_pin(mp_obj_t obj) {
|
||||||
#include "bindings/cyw43/__init__.h"
|
return validate_obj_is_free_pin(obj);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
//| class AnalogIn:
|
//| class AnalogIn:
|
||||||
//| """Read analog voltage levels
|
//| """Read analog voltage levels
|
||||||
@ -64,11 +64,7 @@ STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type,
|
|||||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||||
|
|
||||||
// 1st argument is the pin
|
// 1st argument is the pin
|
||||||
#if CIRCUITPY_CYW43
|
const mcu_pin_obj_t *pin = common_hal_analogio_analogin_validate_pin(args[0]);
|
||||||
const mcu_pin_obj_t *pin = validate_obj_is_free_pin_or_gpio29(args[0]);
|
|
||||||
#else
|
|
||||||
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[0]);
|
|
||||||
#endif
|
|
||||||
analogio_analogin_obj_t *self = m_new_obj(analogio_analogin_obj_t);
|
analogio_analogin_obj_t *self = m_new_obj(analogio_analogin_obj_t);
|
||||||
self->base.type = &analogio_analogin_type;
|
self->base.type = &analogio_analogin_type;
|
||||||
common_hal_analogio_analogin_construct(self, pin);
|
common_hal_analogio_analogin_construct(self, pin);
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
extern const mp_obj_type_t analogio_analogin_type;
|
extern const mp_obj_type_t analogio_analogin_type;
|
||||||
|
|
||||||
|
const mcu_pin_obj_t *common_hal_analogio_analogin_validate_pin(mp_obj_t obj);
|
||||||
void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, const mcu_pin_obj_t *pin);
|
void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, const mcu_pin_obj_t *pin);
|
||||||
void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self);
|
void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self);
|
||||||
bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self);
|
bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self);
|
||||||
|
@ -66,6 +66,10 @@ STATIC void check_result(digitalinout_result_t result) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MP_WEAK const mcu_pin_obj_t *common_hal_digitalio_validate_pin(mp_obj_t obj) {
|
||||||
|
return validate_obj_is_free_pin(obj);
|
||||||
|
}
|
||||||
|
|
||||||
//| class DigitalInOut:
|
//| class DigitalInOut:
|
||||||
//| """Digital input and output
|
//| """Digital input and output
|
||||||
//|
|
//|
|
||||||
@ -87,14 +91,7 @@ STATIC mp_obj_t digitalio_digitalinout_make_new(const mp_obj_type_t *type,
|
|||||||
digitalio_digitalinout_obj_t *self = m_new_obj(digitalio_digitalinout_obj_t);
|
digitalio_digitalinout_obj_t *self = m_new_obj(digitalio_digitalinout_obj_t);
|
||||||
self->base.type = &digitalio_digitalinout_type;
|
self->base.type = &digitalio_digitalinout_type;
|
||||||
|
|
||||||
#if CIRCUITPY_CYW43
|
const mcu_pin_obj_t *pin = common_hal_digitalio_validate_pin(args[0]);
|
||||||
// The GPIO pin attached to the CYW43 co-processor can only be used for
|
|
||||||
// DigitalInOut, not for other purposes like PWM. That's why this check
|
|
||||||
// is here, and it's not rolled into validate_obj_is_free_pin.
|
|
||||||
const mcu_pin_obj_t *pin = validate_obj_is_free_pin_including_cyw43(args[0]);
|
|
||||||
#else
|
|
||||||
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[0]);
|
|
||||||
#endif
|
|
||||||
common_hal_digitalio_digitalinout_construct(self, pin);
|
common_hal_digitalio_digitalinout_construct(self, pin);
|
||||||
|
|
||||||
return MP_OBJ_FROM_PTR(self);
|
return MP_OBJ_FROM_PTR(self);
|
||||||
|
@ -55,6 +55,7 @@ typedef enum {
|
|||||||
DIGITALINOUT_REG_TOGGLE,
|
DIGITALINOUT_REG_TOGGLE,
|
||||||
} digitalinout_reg_op_t;
|
} digitalinout_reg_op_t;
|
||||||
|
|
||||||
|
const mcu_pin_obj_t *common_hal_digitalio_validate_pin(mp_obj_t obj);
|
||||||
digitalinout_result_t common_hal_digitalio_digitalinout_construct(digitalio_digitalinout_obj_t *self, const mcu_pin_obj_t *pin);
|
digitalinout_result_t common_hal_digitalio_digitalinout_construct(digitalio_digitalinout_obj_t *self, const mcu_pin_obj_t *pin);
|
||||||
void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self);
|
void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self);
|
||||||
bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t *self);
|
bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t *self);
|
||||||
|
Loading…
Reference in New Issue
Block a user