esp8266/machine_adc: Rename pyb_adc_* to machine_adc_*.
This commit is contained in:
parent
ebacdfabb6
commit
625609a737
|
@ -30,17 +30,17 @@
|
|||
#include "py/runtime.h"
|
||||
#include "user_interface.h"
|
||||
|
||||
const mp_obj_type_t pyb_adc_type;
|
||||
const mp_obj_type_t machine_adc_type;
|
||||
|
||||
typedef struct _pyb_adc_obj_t {
|
||||
typedef struct _machine_adc_obj_t {
|
||||
mp_obj_base_t base;
|
||||
bool isvdd;
|
||||
} pyb_adc_obj_t;
|
||||
} machine_adc_obj_t;
|
||||
|
||||
STATIC pyb_adc_obj_t pyb_adc_vdd3 = {{&pyb_adc_type}, true};
|
||||
STATIC pyb_adc_obj_t pyb_adc_adc = {{&pyb_adc_type}, false};
|
||||
STATIC machine_adc_obj_t machine_adc_vdd3 = {{&machine_adc_type}, true};
|
||||
STATIC machine_adc_obj_t machine_adc_adc = {{&machine_adc_type}, false};
|
||||
|
||||
STATIC mp_obj_t pyb_adc_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw,
|
||||
STATIC mp_obj_t machine_adc_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw,
|
||||
const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||
|
||||
|
@ -48,17 +48,17 @@ STATIC mp_obj_t pyb_adc_make_new(const mp_obj_type_t *type_in, size_t n_args, si
|
|||
|
||||
switch (chn) {
|
||||
case 0:
|
||||
return &pyb_adc_adc;
|
||||
return &machine_adc_adc;
|
||||
case 1:
|
||||
return &pyb_adc_vdd3;
|
||||
return &machine_adc_vdd3;
|
||||
default:
|
||||
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
|
||||
"not a valid ADC Channel: %d", chn));
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t pyb_adc_read(mp_obj_t self_in) {
|
||||
pyb_adc_obj_t *adc = self_in;
|
||||
STATIC mp_obj_t machine_adc_read(mp_obj_t self_in) {
|
||||
machine_adc_obj_t *adc = self_in;
|
||||
|
||||
if (adc->isvdd) {
|
||||
return mp_obj_new_int(system_get_vdd33());
|
||||
|
@ -66,16 +66,16 @@ STATIC mp_obj_t pyb_adc_read(mp_obj_t self_in) {
|
|||
return mp_obj_new_int(system_adc_read());
|
||||
}
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_adc_read_obj, pyb_adc_read);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_adc_read_obj, machine_adc_read);
|
||||
|
||||
STATIC const mp_rom_map_elem_t pyb_adc_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&pyb_adc_read_obj) }
|
||||
STATIC const mp_rom_map_elem_t machine_adc_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&machine_adc_read_obj) }
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(pyb_adc_locals_dict, pyb_adc_locals_dict_table);
|
||||
STATIC MP_DEFINE_CONST_DICT(machine_adc_locals_dict, machine_adc_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t pyb_adc_type = {
|
||||
const mp_obj_type_t machine_adc_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_ADC,
|
||||
.make_new = pyb_adc_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&pyb_adc_locals_dict,
|
||||
.make_new = machine_adc_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&machine_adc_locals_dict,
|
||||
};
|
||||
|
|
|
@ -410,7 +410,7 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
|
|||
{ MP_ROM_QSTR(MP_QSTR_Pin), MP_ROM_PTR(&pyb_pin_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_Signal), MP_ROM_PTR(&machine_signal_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWM), MP_ROM_PTR(&pyb_pwm_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ADC), MP_ROM_PTR(&pyb_adc_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ADC), MP_ROM_PTR(&machine_adc_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&pyb_uart_type) },
|
||||
#if MICROPY_PY_MACHINE_I2C
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&machine_i2c_type) },
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
extern const mp_obj_type_t pyb_pin_type;
|
||||
extern const mp_obj_type_t pyb_pwm_type;
|
||||
extern const mp_obj_type_t pyb_adc_type;
|
||||
extern const mp_obj_type_t machine_adc_type;
|
||||
extern const mp_obj_type_t pyb_rtc_type;
|
||||
extern const mp_obj_type_t pyb_uart_type;
|
||||
extern const mp_obj_type_t pyb_i2c_type;
|
||||
|
|
Loading…
Reference in New Issue