Renaming module from adcbuffer to analogbufio
This commit is contained in:
parent
478b40ecf9
commit
a1856ea3e9
@ -1 +0,0 @@
|
|||||||
// No adcbuffer module functions.
|
|
@ -32,8 +32,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "common-hal/adcbuffer/BufferedInput.h"
|
#include "common-hal/analogbufio/BufferedIn.h"
|
||||||
#include "shared-bindings/adcbuffer/BufferedInput.h"
|
#include "shared-bindings/analogbufio/BufferedIn.h"
|
||||||
#include "shared-bindings/microcontroller/Pin.h"
|
#include "shared-bindings/microcontroller/Pin.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "supervisor/shared/translate/translate.h"
|
#include "supervisor/shared/translate/translate.h"
|
||||||
@ -44,7 +44,7 @@
|
|||||||
#define ADC_FIRST_PIN_NUMBER 26
|
#define ADC_FIRST_PIN_NUMBER 26
|
||||||
#define ADC_PIN_COUNT 4
|
#define ADC_PIN_COUNT 4
|
||||||
|
|
||||||
void common_hal_adcbuffer_bufferedinput_construct(adcbuffer_bufferedinput_obj_t *self, const mcu_pin_obj_t *pin, uint8_t *buffer, uint32_t len, uint8_t bytes_per_sample, bool samples_signed, uint32_t sample_rate) {
|
void common_hal_analogbufio_bufferedin_construct(analogbufio_bufferedin_obj_t *self, const mcu_pin_obj_t *pin, uint8_t *buffer, uint32_t len, uint8_t bytes_per_sample, bool samples_signed, uint32_t sample_rate) {
|
||||||
|
|
||||||
// Make sure pin number is in range for ADC
|
// Make sure pin number is in range for ADC
|
||||||
if (pin->number < ADC_FIRST_PIN_NUMBER || pin->number >= (ADC_FIRST_PIN_NUMBER + ADC_PIN_COUNT)) {
|
if (pin->number < ADC_FIRST_PIN_NUMBER || pin->number >= (ADC_FIRST_PIN_NUMBER + ADC_PIN_COUNT)) {
|
||||||
@ -131,12 +131,12 @@ void common_hal_adcbuffer_bufferedinput_construct(adcbuffer_bufferedinput_obj_t
|
|||||||
adc_run(false);
|
adc_run(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_adcbuffer_bufferedinput_deinited(adcbuffer_bufferedinput_obj_t *self) {
|
bool common_hal_analogbufio_bufferedin_deinited(analogbufio_bufferedin_obj_t *self) {
|
||||||
return self->pin == NULL;
|
return self->pin == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_adcbuffer_bufferedinput_deinit(adcbuffer_bufferedinput_obj_t *self) {
|
void common_hal_analogbufio_bufferedin_deinit(analogbufio_bufferedin_obj_t *self) {
|
||||||
if (common_hal_adcbuffer_bufferedinput_deinited(self)) {
|
if (common_hal_analogbufio_bufferedin_deinited(self)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ void common_hal_adcbuffer_bufferedinput_deinit(adcbuffer_bufferedinput_obj_t *se
|
|||||||
dma_channel_unclaim(self->dma_chan);
|
dma_channel_unclaim(self->dma_chan);
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_adcbuffer_bufferedinput_read(adcbuffer_bufferedinput_obj_t *self) {
|
void common_hal_analogbufio_bufferedin_read(analogbufio_bufferedin_obj_t *self) {
|
||||||
|
|
||||||
uint32_t cdl = self->len / self->bytes_per_sample;
|
uint32_t cdl = self->len / self->bytes_per_sample;
|
||||||
|
|
@ -31,15 +31,15 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_ADCBUFFER_BUFFEREDINPUT_H
|
#ifndef MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_ANALOGBUFIO_BUFFEREDIN_H
|
||||||
#define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_ADCBUFFER_BUFFEREDINPUT_H
|
#define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_ANALOGBUFIO_BUFFEREDIN_H
|
||||||
|
|
||||||
#include "common-hal/microcontroller/Pin.h"
|
#include "common-hal/microcontroller/Pin.h"
|
||||||
#include "src/rp2_common/hardware_dma/include/hardware/dma.h"
|
#include "src/rp2_common/hardware_dma/include/hardware/dma.h"
|
||||||
|
|
||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
|
|
||||||
// This is the adcbuffer object
|
// This is the analogbufio object
|
||||||
typedef struct {
|
typedef struct {
|
||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
const mcu_pin_obj_t *pin;
|
const mcu_pin_obj_t *pin;
|
||||||
@ -51,8 +51,8 @@ typedef struct {
|
|||||||
uint8_t chan;
|
uint8_t chan;
|
||||||
uint dma_chan;
|
uint dma_chan;
|
||||||
dma_channel_config cfg;
|
dma_channel_config cfg;
|
||||||
} adcbuffer_bufferedinput_obj_t;
|
} analogbuf_bufferedin_obj_t;
|
||||||
|
|
||||||
void bufferedinput_init(void);
|
void bufferedin_init(void);
|
||||||
|
|
||||||
#endif // MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_ADCBUFFER_BUFFEREDINPUT_H
|
#endif // MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_ANALOGBUFIO_BUFFEREDIN_H
|
1
ports/raspberrypi/common-hal/analogbufio/__init__.c
Normal file
1
ports/raspberrypi/common-hal/analogbufio/__init__.c
Normal file
@ -0,0 +1 @@
|
|||||||
|
// No analogbufio module functions.
|
@ -26,8 +26,8 @@ CIRCUITPY_NVM = 1
|
|||||||
CIRCUITPY_PULSEIO ?= 1
|
CIRCUITPY_PULSEIO ?= 1
|
||||||
CIRCUITPY_WATCHDOG ?= 1
|
CIRCUITPY_WATCHDOG ?= 1
|
||||||
|
|
||||||
# Use of adcbuffer
|
# Use of analogbufio
|
||||||
CIRCUITPY_ADCBUFFER = 1
|
CIRCUITPY_ANALOGBUFIO = 1
|
||||||
|
|
||||||
# Audio via PWM
|
# Audio via PWM
|
||||||
CIRCUITPY_AUDIOIO = 0
|
CIRCUITPY_AUDIOIO = 0
|
||||||
|
@ -102,15 +102,15 @@ endif
|
|||||||
###
|
###
|
||||||
# Select which builtin modules to compile and include.
|
# Select which builtin modules to compile and include.
|
||||||
|
|
||||||
ifeq ($(CIRCUITPY_ADCBUFFER),1)
|
|
||||||
SRC_PATTERNS += adcbuffer/%
|
|
||||||
endif
|
|
||||||
ifeq ($(CIRCUITPY_AESIO),1)
|
ifeq ($(CIRCUITPY_AESIO),1)
|
||||||
SRC_PATTERNS += aesio/%
|
SRC_PATTERNS += aesio/%
|
||||||
endif
|
endif
|
||||||
ifeq ($(CIRCUITPY_ALARM),1)
|
ifeq ($(CIRCUITPY_ALARM),1)
|
||||||
SRC_PATTERNS += alarm/%
|
SRC_PATTERNS += alarm/%
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(CIRCUITPY_ANALOGBUFIO),1)
|
||||||
|
SRC_PATTERNS += analogbufio/%
|
||||||
|
endif
|
||||||
ifeq ($(CIRCUITPY_ANALOGIO),1)
|
ifeq ($(CIRCUITPY_ANALOGIO),1)
|
||||||
SRC_PATTERNS += analogio/%
|
SRC_PATTERNS += analogio/%
|
||||||
endif
|
endif
|
||||||
@ -387,13 +387,13 @@ SRC_COMMON_HAL_ALL = \
|
|||||||
_bleio/__init__.c \
|
_bleio/__init__.c \
|
||||||
_pew/PewPew.c \
|
_pew/PewPew.c \
|
||||||
_pew/__init__.c \
|
_pew/__init__.c \
|
||||||
adcbuffer/BufferedInput.c \
|
|
||||||
adcbuffer/__init__.c \
|
|
||||||
alarm/SleepMemory.c \
|
alarm/SleepMemory.c \
|
||||||
alarm/__init__.c \
|
alarm/__init__.c \
|
||||||
alarm/pin/PinAlarm.c \
|
alarm/pin/PinAlarm.c \
|
||||||
alarm/time/TimeAlarm.c \
|
alarm/time/TimeAlarm.c \
|
||||||
alarm/touch/TouchAlarm.c \
|
alarm/touch/TouchAlarm.c \
|
||||||
|
analogbufio/BufferedIn.c \
|
||||||
|
analogbufio/__init__.c \
|
||||||
analogio/AnalogIn.c \
|
analogio/AnalogIn.c \
|
||||||
analogio/AnalogOut.c \
|
analogio/AnalogOut.c \
|
||||||
analogio/__init__.c \
|
analogio/__init__.c \
|
||||||
|
@ -62,12 +62,12 @@ CFLAGS += -DCIRCUITPY_AESIO=$(CIRCUITPY_AESIO)
|
|||||||
CIRCUITPY_ALARM ?= 0
|
CIRCUITPY_ALARM ?= 0
|
||||||
CFLAGS += -DCIRCUITPY_ALARM=$(CIRCUITPY_ALARM)
|
CFLAGS += -DCIRCUITPY_ALARM=$(CIRCUITPY_ALARM)
|
||||||
|
|
||||||
|
CIRCUITPY_ANALOGBUFIO ?= 0
|
||||||
|
CFLAGS += -DCIRCUITPY_ANALOGBUFIO=$(CIRCUITPY_ANALOGBUFIO)
|
||||||
|
|
||||||
CIRCUITPY_ANALOGIO ?= 1
|
CIRCUITPY_ANALOGIO ?= 1
|
||||||
CFLAGS += -DCIRCUITPY_ANALOGIO=$(CIRCUITPY_ANALOGIO)
|
CFLAGS += -DCIRCUITPY_ANALOGIO=$(CIRCUITPY_ANALOGIO)
|
||||||
|
|
||||||
CIRCUITPY_ADCBUFFER ?= 0
|
|
||||||
CFLAGS += -DCIRCUITPY_ADCBUFFER=$(CIRCUITPY_ADCBUFFER)
|
|
||||||
|
|
||||||
CIRCUITPY_ATEXIT ?= $(CIRCUITPY_FULL_BUILD)
|
CIRCUITPY_ATEXIT ?= $(CIRCUITPY_FULL_BUILD)
|
||||||
CFLAGS += -DCIRCUITPY_ATEXIT=$(CIRCUITPY_ATEXIT)
|
CFLAGS += -DCIRCUITPY_ATEXIT=$(CIRCUITPY_ATEXIT)
|
||||||
|
|
||||||
|
@ -34,14 +34,14 @@
|
|||||||
#include "py/objproperty.h"
|
#include "py/objproperty.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "shared-bindings/microcontroller/Pin.h"
|
#include "shared-bindings/microcontroller/Pin.h"
|
||||||
#include "shared-bindings/adcbuffer/BufferedInput.h"
|
#include "shared-bindings/analogbufio/BufferedIn.h"
|
||||||
#include "shared-bindings/util.h"
|
#include "shared-bindings/util.h"
|
||||||
|
|
||||||
//| class BufferedInput:
|
//| class BufferedIn:
|
||||||
//| """Capture multiple analog voltage levels to the supplied buffer"""
|
//| """Capture multiple analog voltage levels to the supplied buffer"""
|
||||||
//|
|
//|
|
||||||
//| def __init__(self, pin: microcontroller.Pin, buffer: WriteableBuffer, *, sample_rate: int = 500000) -> None:
|
//| def __init__(self, pin: microcontroller.Pin, buffer: WriteableBuffer, *, sample_rate: int = 500000) -> None:
|
||||||
//| """Create a `BufferedInput` on the given pin. ADC values will be read
|
//| """Create a `BufferedIn` on the given pin. ADC values will be read
|
||||||
//| into the given buffer at the supplied sample_rate. Depending on the
|
//| into the given buffer at the supplied sample_rate. Depending on the
|
||||||
//| buffer typecode, 'b', 'B', 'h', 'H', samples are 8-bit byte-arrays or
|
//| buffer typecode, 'b', 'B', 'h', 'H', samples are 8-bit byte-arrays or
|
||||||
//| 16-bit half-words and are signed or unsigned.
|
//| 16-bit half-words and are signed or unsigned.
|
||||||
@ -55,13 +55,13 @@
|
|||||||
//| Usage::
|
//| Usage::
|
||||||
//|
|
//|
|
||||||
//| import board
|
//| import board
|
||||||
//| import adcbuffer
|
//| import analogbufio
|
||||||
//| import array
|
//| import array
|
||||||
//|
|
//|
|
||||||
//| length = 1000
|
//| length = 1000
|
||||||
//| mybuffer = array.array("H", [0] * length)
|
//| mybuffer = array.array("H", 0x0000 for i in range(length))
|
||||||
//| rate = 500000
|
//| rate = 500000
|
||||||
//| adcbuf = adcbuffer.BufferedInput(board.GP26, mybuffer, rate)
|
//| adcbuf = analogbufio.BufferedIn(board.GP26, mybuffer, rate)
|
||||||
//| adcbuf.read()
|
//| adcbuf.read()
|
||||||
//| adcbuf.deinit()
|
//| adcbuf.deinit()
|
||||||
//| for i in range(length):
|
//| for i in range(length):
|
||||||
@ -72,7 +72,7 @@
|
|||||||
//| (TODO) Provide mechanism to read CPU Temperature."""
|
//| (TODO) Provide mechanism to read CPU Temperature."""
|
||||||
//| ...
|
//| ...
|
||||||
//|
|
//|
|
||||||
STATIC mp_obj_t adcbuffer_bufferedinput_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
STATIC mp_obj_t analogbufio_bufferedin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||||
enum { ARG_pin, ARG_buffer, ARG_sample_rate };
|
enum { ARG_pin, ARG_buffer, ARG_sample_rate };
|
||||||
static const mp_arg_t allowed_args[] = {
|
static const mp_arg_t allowed_args[] = {
|
||||||
{ MP_QSTR_pin, MP_ARG_OBJ | MP_ARG_REQUIRED },
|
{ MP_QSTR_pin, MP_ARG_OBJ | MP_ARG_REQUIRED },
|
||||||
@ -104,11 +104,11 @@ STATIC mp_obj_t adcbuffer_bufferedinput_make_new(const mp_obj_type_t *type, size
|
|||||||
uint32_t sample_rate = (uint32_t)mp_arg_validate_int_range(args[ARG_sample_rate].u_int, 1, 500000, MP_QSTR_sample_rate);
|
uint32_t sample_rate = (uint32_t)mp_arg_validate_int_range(args[ARG_sample_rate].u_int, 1, 500000, MP_QSTR_sample_rate);
|
||||||
|
|
||||||
// Create local object
|
// Create local object
|
||||||
adcbuffer_bufferedinput_obj_t *self = m_new_obj(adcbuffer_bufferedinput_obj_t);
|
analogbufio_bufferedin_obj_t *self = m_new_obj(analogbufio_bufferedin_obj_t);
|
||||||
self->base.type = &adcbuffer_bufferedinput_type;
|
self->base.type = &analogbufio_bufferedin_type;
|
||||||
|
|
||||||
// Call local intereface in ports/common-hal/adcbuffer
|
// Call local intereface in ports/common-hal/analogbufio
|
||||||
common_hal_adcbuffer_bufferedinput_construct(self,
|
common_hal_analogbufio_bufferedin_construct(self,
|
||||||
pin,
|
pin,
|
||||||
((uint8_t *)bufinfo.buf),
|
((uint8_t *)bufinfo.buf),
|
||||||
bufinfo.len,
|
bufinfo.len,
|
||||||
@ -121,18 +121,18 @@ STATIC mp_obj_t adcbuffer_bufferedinput_make_new(const mp_obj_type_t *type, size
|
|||||||
}
|
}
|
||||||
|
|
||||||
//| def deinit(self) -> None:
|
//| def deinit(self) -> None:
|
||||||
//| """Shut down the `BufferedInput` and release the pin for other use."""
|
//| """Shut down the `BufferedIn` and release the pin for other use."""
|
||||||
//| ...
|
//| ...
|
||||||
//|
|
//|
|
||||||
STATIC mp_obj_t adcbuffer_bufferedinput_deinit(mp_obj_t self_in) {
|
STATIC mp_obj_t analogbufio_bufferedin_deinit(mp_obj_t self_in) {
|
||||||
adcbuffer_bufferedinput_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
analogbufio_bufferedin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||||
common_hal_adcbuffer_bufferedinput_deinit(self);
|
common_hal_analogbufio_bufferedin_deinit(self);
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
MP_DEFINE_CONST_FUN_OBJ_1(adcbuffer_bufferedinput_deinit_obj, adcbuffer_bufferedinput_deinit);
|
MP_DEFINE_CONST_FUN_OBJ_1(analogbufio_bufferedin_deinit_obj, analogbufio_bufferedin_deinit);
|
||||||
|
|
||||||
STATIC void check_for_deinit(adcbuffer_bufferedinput_obj_t *self) {
|
STATIC void check_for_deinit(analogbufio_bufferedin_obj_t *self) {
|
||||||
if (common_hal_adcbuffer_bufferedinput_deinited(self)) {
|
if (common_hal_analogbufio_bufferedin_deinited(self)) {
|
||||||
raise_deinited_error();
|
raise_deinited_error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,38 +144,38 @@ STATIC void check_for_deinit(adcbuffer_bufferedinput_obj_t *self) {
|
|||||||
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||||
//| ...
|
//| ...
|
||||||
//|
|
//|
|
||||||
STATIC mp_obj_t adcbuffer_bufferedinput___exit__(size_t n_args, const mp_obj_t *args) {
|
STATIC mp_obj_t analogbufio_bufferedin___exit__(size_t n_args, const mp_obj_t *args) {
|
||||||
(void)n_args;
|
(void)n_args;
|
||||||
common_hal_adcbuffer_bufferedinput_deinit(args[0]);
|
common_hal_analogbufio_bufferedin_deinit(args[0]);
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(adcbuffer_bufferedinput___exit___obj, 4, 4, adcbuffer_bufferedinput___exit__);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogbufio_bufferedin___exit___obj, 4, 4, analogbufio_bufferedin___exit__);
|
||||||
|
|
||||||
//|
|
//|
|
||||||
//| def read(self) -> None:
|
//| def read(self) -> None:
|
||||||
//| """Fills the provided buffer with ADC voltage values."""
|
//| """Fills the provided buffer with ADC voltage values."""
|
||||||
//|
|
//|
|
||||||
STATIC mp_obj_t adcbuffer_bufferedinput_obj_read(mp_obj_t self_in) {
|
STATIC mp_obj_t analogbufio_bufferedin_obj_read(mp_obj_t self_in) {
|
||||||
adcbuffer_bufferedinput_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
analogbufio_bufferedin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||||
check_for_deinit(self);
|
check_for_deinit(self);
|
||||||
common_hal_adcbuffer_bufferedinput_read(self);
|
common_hal_analogbufio_bufferedin_read(self);
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
MP_DEFINE_CONST_FUN_OBJ_1(adcbuffer_bufferedinput_read_obj, adcbuffer_bufferedinput_obj_read);
|
MP_DEFINE_CONST_FUN_OBJ_1(analogbufio_bufferedin_read_obj, analogbufio_bufferedin_obj_read);
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t adcbuffer_bufferedinput_locals_dict_table[] = {
|
STATIC const mp_rom_map_elem_t analogbufio_bufferedin_locals_dict_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&adcbuffer_bufferedinput_deinit_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&analogbufio_bufferedin_deinit_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
|
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&adcbuffer_bufferedinput___exit___obj) },
|
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&analogbufio_bufferedin___exit___obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&adcbuffer_bufferedinput_read_obj)},
|
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&analogbufio_bufferedin_read_obj)},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
STATIC MP_DEFINE_CONST_DICT(adcbuffer_bufferedinput_locals_dict, adcbuffer_bufferedinput_locals_dict_table);
|
STATIC MP_DEFINE_CONST_DICT(analogbufio_bufferedin_locals_dict, analogbufio_bufferedin_locals_dict_table);
|
||||||
|
|
||||||
const mp_obj_type_t adcbuffer_bufferedinput_type = {
|
const mp_obj_type_t analogbufio_bufferedin_type = {
|
||||||
{ &mp_type_type },
|
{ &mp_type_type },
|
||||||
.name = MP_QSTR_BufferedInput,
|
.name = MP_QSTR_BufferedIn,
|
||||||
.make_new = adcbuffer_bufferedinput_make_new,
|
.make_new = analogbufio_bufferedin_make_new,
|
||||||
.locals_dict = (mp_obj_t)&adcbuffer_bufferedinput_locals_dict,
|
.locals_dict = (mp_obj_t)&analogbufio_bufferedin_locals_dict,
|
||||||
};
|
};
|
@ -24,17 +24,17 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ADCBUFFER_BUFFEREDINPUT_H
|
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGBUFIO_BUFFEREDIN_H
|
||||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_ADCBUFFER_BUFFEREDINPUT_H
|
#define MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGBUFIO_BUFFEREDIN_H
|
||||||
|
|
||||||
#include "common-hal/microcontroller/Pin.h"
|
#include "common-hal/microcontroller/Pin.h"
|
||||||
#include "common-hal/adcbuffer/BufferedInput.h"
|
#include "common-hal/analogbufio/BufferedIn.h"
|
||||||
|
|
||||||
extern const mp_obj_type_t adcbuffer_bufferedinput_type;
|
extern const mp_obj_type_t analogbufio_bufferedin_type;
|
||||||
|
|
||||||
void common_hal_adcbuffer_bufferedinput_construct(adcbuffer_bufferedinput_obj_t *self, const mcu_pin_obj_t *pin, uint8_t *buffer, uint32_t len, uint8_t bytes_per_sample, bool samples_signed, uint32_t sample_rate);
|
void common_hal_analogbufio_bufferedin_construct(analogbufio_bufferedin_obj_t *self, const mcu_pin_obj_t *pin, uint8_t *buffer, uint32_t len, uint8_t bytes_per_sample, bool samples_signed, uint32_t sample_rate);
|
||||||
void common_hal_adcbuffer_bufferedinput_deinit(adcbuffer_bufferedinput_obj_t *self);
|
void common_hal_analogbufio_bufferedin_deinit(analogbufio_bufferedin_obj_t *self);
|
||||||
bool common_hal_adcbuffer_bufferedinput_deinited(adcbuffer_bufferedinput_obj_t *self);
|
bool common_hal_analogbufio_bufferedin_deinited(analogbufio_bufferedin_obj_t *self);
|
||||||
void common_hal_adcbuffer_bufferedinput_read(adcbuffer_bufferedinput_obj_t *self);
|
void common_hal_analogbufio_bufferedin_read(analogbufio_bufferedin_obj_t *self);
|
||||||
|
|
||||||
#endif // __MICROPY_INCLUDED_SHARED_BINDINGS_ADCBUFFER_BUFFEREDINPUT_H__
|
#endif // __MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGBUFIO_BUFFEREDIN_H__
|
@ -27,12 +27,12 @@
|
|||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "shared-bindings/microcontroller/Pin.h"
|
#include "shared-bindings/microcontroller/Pin.h"
|
||||||
#include "shared-bindings/adcbuffer/__init__.h"
|
#include "shared-bindings/analogbufio/__init__.h"
|
||||||
#include "shared-bindings/adcbuffer/BufferedInput.h"
|
#include "shared-bindings/analogbufio/BufferedIn.h"
|
||||||
|
|
||||||
//| """Analog buffered hardware support
|
//| """Analog Buffered IO Hardware Support
|
||||||
//|
|
//|
|
||||||
//| The `adcbuffer` module contains classes to provide access to analog-to-digital
|
//| The `analogbufio` module contains classes to provide access to analog-to-digital
|
||||||
//| conversion and digital-to-analog (DAC) for multiple value transfer.
|
//| conversion and digital-to-analog (DAC) for multiple value transfer.
|
||||||
//|
|
//|
|
||||||
//| All classes change hardware state and should be deinitialized when they
|
//| All classes change hardware state and should be deinitialized when they
|
||||||
@ -42,38 +42,38 @@
|
|||||||
//|
|
//|
|
||||||
//| For example::
|
//| For example::
|
||||||
//|
|
//|
|
||||||
//| import adcbuffer
|
//| import analogbufio
|
||||||
//| import array
|
//| import array
|
||||||
//| from board import *
|
//| from board import *
|
||||||
//|
|
//|
|
||||||
//| length = 5000000
|
//| length = 5000000
|
||||||
//| mybuffer = array.array("H", [0] * length)
|
//| mybuffer = array.array("H", 0x0000 for i in range(length))
|
||||||
//| adc_in = adcbuffer.BufferedInput(GP26, mybuffer, length)
|
//| adc_in = analogbufio.BufferedIn(GP26, mybuffer, length)
|
||||||
//| adcbuffer.read()
|
//| analogbufio.read()
|
||||||
//| print(*mybuffer)
|
//| print(*mybuffer)
|
||||||
//| adc_in.deinit()
|
//| adc_in.deinit()
|
||||||
//|
|
//|
|
||||||
//| This example will initialize the the device, read and fill
|
//| This example will initialize the the device, read and fill
|
||||||
//| :py:data:`~adcbuffer.BufferedInPut` to mybuffer
|
//| :py:data:`~analogbufio.BufferedIn` to mybuffer
|
||||||
//|
|
//|
|
||||||
//| TODO: For the essentials of `adcbuffer`, see the `CircuitPython Essentials
|
//| TODO: For the essentials of `analogbufio`, see the `CircuitPython Essentials
|
||||||
//| Learn guide <https://learn.adafruit.com/circuitpython-essentials/circuitpython-adcbuffer>`_
|
//| Learn guide <https://learn.adafruit.com/circuitpython-essentials/circuitpython-analogbufio>`_
|
||||||
//|
|
//|
|
||||||
//| TODO: For more information on using `adcbuffer`, see `this additional Learn guide
|
//| TODO: For more information on using `analogbufio`, see `this additional Learn guide
|
||||||
//| <https://learn.adafruit.com/circuitpython-advanced-analog-inputs-and-outputs>`_
|
//| <https://learn.adafruit.com/circuitpython-advanced-analog-inputs-and-outputs>`_
|
||||||
//| """
|
//| """
|
||||||
//|
|
//|
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t adcbuffer_module_globals_table[] = {
|
STATIC const mp_rom_map_elem_t analogbufio_module_globals_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_adcbuffer) },
|
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_analogbufio) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_BufferedInput), MP_ROM_PTR(&adcbuffer_bufferedinput_type) },
|
{ MP_ROM_QSTR(MP_QSTR_BufferedIn), MP_ROM_PTR(&analogbufio_bufferedin_type) },
|
||||||
};
|
};
|
||||||
|
|
||||||
STATIC MP_DEFINE_CONST_DICT(adcbuffer_module_globals, adcbuffer_module_globals_table);
|
STATIC MP_DEFINE_CONST_DICT(analogbufio_module_globals, analogbufio_module_globals_table);
|
||||||
|
|
||||||
const mp_obj_module_t adcbuffer_module = {
|
const mp_obj_module_t analogbufio_module = {
|
||||||
.base = { &mp_type_module },
|
.base = { &mp_type_module },
|
||||||
.globals = (mp_obj_dict_t *)&adcbuffer_module_globals,
|
.globals = (mp_obj_dict_t *)&analogbufio_module_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_adcbuffer, adcbuffer_module, CIRCUITPY_ADCBUFFER);
|
MP_REGISTER_MODULE(MP_QSTR_analogbufio, analogbufio_module, CIRCUITPY_ANALOGBUFIO);
|
@ -24,11 +24,11 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ADCBUFFER___INIT___H
|
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGBUFIO___INIT___H
|
||||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_ADCBUFFER___INIT___H
|
#define MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGBUFIO___INIT___H
|
||||||
|
|
||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
|
|
||||||
// Nothing now.
|
// Nothing now.
|
||||||
|
|
||||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ADCBUFFER___INIT___H
|
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGBUFIO___INIT___H
|
Loading…
Reference in New Issue
Block a user