Do not open the same ADC device again
This commit is contained in:
parent
bd6c7c5546
commit
1decd111d5
|
@ -68,10 +68,12 @@ void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, const
|
|||
mp_raise_ValueError(translate("Pin does not have ADC capabilities"));
|
||||
}
|
||||
|
||||
analogin_dev[self->number].fd = open(analogin_dev[pin->number].devpath, O_RDONLY);
|
||||
if (analogin_dev[self->number].fd < 0) {
|
||||
analogin_dev[self->number].fd = open(analogin_dev[self->number].devpath, O_RDONLY);
|
||||
if (analogin_dev[self->number].fd < 0) {
|
||||
mp_raise_ValueError(translate("Pin does not have ADC capabilities"));
|
||||
}
|
||||
}
|
||||
|
||||
// SCU FIFO overwrite
|
||||
ioctl(analogin_dev[self->number].fd, SCUIOC_SETFIFOMODE, 1);
|
||||
|
@ -99,7 +101,7 @@ void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
|
|||
}
|
||||
|
||||
bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self) {
|
||||
return self->pin == mp_const_none;
|
||||
return analogin_dev[self->number].fd < 0;
|
||||
}
|
||||
|
||||
uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
const mcu_pin_obj_t *pin;
|
||||
uint8_t number;
|
||||
int8_t number;
|
||||
} analogio_analogin_obj_t;
|
||||
|
||||
void analogin_reset(void);
|
||||
|
|
Loading…
Reference in New Issue