Move OneWire to onewireio
from busio
This will allow finer grained inclusion in 8.0.0 Fixes #5135
This commit is contained in:
parent
d294692c4e
commit
de796e2304
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Scott Shawcroft
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
|
||||
// Use bitbangio.
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
|
||||
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_ONEWIRE_H
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright 2019 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_CXD56_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_CXD56_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
|
||||
// Use bitbangio.
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
|
||||
#endif // MICROPY_INCLUDED_CXD56_COMMON_HAL_BUSIO_ONEWIRE_H
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Scott Shawcroft
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
|
||||
// Use bitbangio.
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
|
||||
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_BUSIO_ONEWIRE_H
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Scott Shawcroft
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
|
||||
// Use bitbangio.
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
|
||||
#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_ONEWIRE_H
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
|
||||
// Use bitbangio.
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
|
||||
#endif // MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_BUSIO_ONEWIRE_H
|
@ -155,7 +155,7 @@ ifeq ($(CIRCUITPY_BUSDEVICE),1)
|
||||
SRC_PATTERNS += adafruit_bus_device/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_BUSIO),1)
|
||||
SRC_PATTERNS += busio/% bitbangio/OneWire.%
|
||||
SRC_PATTERNS += busio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_CAMERA),1)
|
||||
SRC_PATTERNS += camera/%
|
||||
@ -218,6 +218,9 @@ endif
|
||||
ifeq ($(CIRCUITPY_NVM),1)
|
||||
SRC_PATTERNS += nvm/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_ONEWIREIO),1)
|
||||
SRC_PATTERNS += onewireio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_OS),1)
|
||||
SRC_PATTERNS += os/%
|
||||
endif
|
||||
@ -493,7 +496,6 @@ SRC_SHARED_MODULE_ALL = \
|
||||
audiomp3/__init__.c \
|
||||
audiopwmio/__init__.c \
|
||||
bitbangio/I2C.c \
|
||||
bitbangio/OneWire.c \
|
||||
bitbangio/SPI.c \
|
||||
bitbangio/__init__.c \
|
||||
bitmaptools/__init__.c \
|
||||
@ -502,7 +504,6 @@ SRC_SHARED_MODULE_ALL = \
|
||||
adafruit_bus_device/__init__.c \
|
||||
adafruit_bus_device/I2CDevice.c \
|
||||
adafruit_bus_device/SPIDevice.c \
|
||||
busio/OneWire.c \
|
||||
canio/Match.c \
|
||||
canio/Message.c \
|
||||
canio/RemoteTransmissionRequest.c \
|
||||
@ -522,6 +523,8 @@ SRC_SHARED_MODULE_ALL = \
|
||||
fontio/__init__.c \
|
||||
framebufferio/FramebufferDisplay.c \
|
||||
framebufferio/__init__.c \
|
||||
gamepadshift/GamePadShift.c \
|
||||
gamepadshift/__init__.c \
|
||||
getpass/__init__.c \
|
||||
ipaddress/IPv4Address.c \
|
||||
ipaddress/__init__.c \
|
||||
@ -531,15 +534,13 @@ SRC_SHARED_MODULE_ALL = \
|
||||
keypad/KeyMatrix.c \
|
||||
keypad/ShiftRegisterKeys.c \
|
||||
keypad/Keys.c \
|
||||
sdcardio/SDCard.c \
|
||||
sdcardio/__init__.c \
|
||||
gamepadshift/GamePadShift.c \
|
||||
gamepadshift/__init__.c \
|
||||
memorymonitor/__init__.c \
|
||||
memorymonitor/AllocationAlarm.c \
|
||||
memorymonitor/AllocationSize.c \
|
||||
network/__init__.c \
|
||||
msgpack/__init__.c \
|
||||
onewireio/__init__.c \
|
||||
onewireio/OneWire.c \
|
||||
os/__init__.c \
|
||||
qrio/__init__.c \
|
||||
qrio/QRDecoder.c \
|
||||
@ -548,6 +549,8 @@ SRC_SHARED_MODULE_ALL = \
|
||||
rgbmatrix/RGBMatrix.c \
|
||||
rgbmatrix/__init__.c \
|
||||
rotaryio/IncrementalEncoder.c \
|
||||
sdcardio/SDCard.c \
|
||||
sdcardio/__init__.c \
|
||||
sharpdisplay/SharpMemoryFramebuffer.c \
|
||||
sharpdisplay/__init__.c \
|
||||
socket/__init__.c \
|
||||
|
@ -583,6 +583,13 @@ extern const struct _mp_obj_module_t neopixel_write_module;
|
||||
extern const struct _mp_obj_module_t nvm_module;
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_OS
|
||||
extern const struct _mp_obj_module_t onewireio_module;
|
||||
#define ONEWIREIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_onewireio), (mp_obj_t)&onewireio_module },
|
||||
#else
|
||||
#define ONEWIREIO_MODULE
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_OS
|
||||
extern const struct _mp_obj_module_t os_module;
|
||||
#define OS_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module },
|
||||
@ -915,6 +922,7 @@ extern const struct _mp_obj_module_t msgpack_module;
|
||||
MICROCONTROLLER_MODULE \
|
||||
MSGPACK_MODULE \
|
||||
NEOPIXEL_WRITE_MODULE \
|
||||
ONEWIREIO_MODULE \
|
||||
PEW_MODULE \
|
||||
PIXELBUF_MODULE \
|
||||
PS2IO_MODULE \
|
||||
|
@ -199,6 +199,9 @@ CFLAGS += -DCIRCUITPY_GNSS=$(CIRCUITPY_GNSS)
|
||||
CIRCUITPY_I2CPERIPHERAL ?= $(CIRCUITPY_FULL_BUILD)
|
||||
CFLAGS += -DCIRCUITPY_I2CPERIPHERAL=$(CIRCUITPY_I2CPERIPHERAL)
|
||||
|
||||
CIRCUITPY_IMAGECAPTURE ?= 0
|
||||
CFLAGS += -DCIRCUITPY_IMAGECAPTURE=$(CIRCUITPY_IMAGECAPTURE)
|
||||
|
||||
CIRCUITPY_IPADDRESS ?= $(CIRCUITPY_WIFI)
|
||||
CFLAGS += -DCIRCUITPY_IPADDRESS=$(CIRCUITPY_IPADDRESS)
|
||||
|
||||
@ -226,12 +229,12 @@ CFLAGS += -DCIRCUITPY_NEOPIXEL_WRITE=$(CIRCUITPY_NEOPIXEL_WRITE)
|
||||
CIRCUITPY_NVM ?= 1
|
||||
CFLAGS += -DCIRCUITPY_NVM=$(CIRCUITPY_NVM)
|
||||
|
||||
CIRCUITPY_ONEWIREIO ?= $(CIRCUITPY_BUSIO)
|
||||
CFLAGS += -DCIRCUITPY_ONEWIREIO=$(CIRCUITPY_ONEWIREIO)
|
||||
|
||||
CIRCUITPY_OS ?= 1
|
||||
CFLAGS += -DCIRCUITPY_OS=$(CIRCUITPY_OS)
|
||||
|
||||
CIRCUITPY_IMAGECAPTURE ?= 0
|
||||
CFLAGS += -DCIRCUITPY_IMAGECAPTURE=$(CIRCUITPY_IMAGECAPTURE)
|
||||
|
||||
CIRCUITPY_PEW ?= 0
|
||||
CFLAGS += -DCIRCUITPY_PEW=$(CIRCUITPY_PEW)
|
||||
|
||||
|
@ -1,172 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "lib/utils/context_manager_helpers.h"
|
||||
#include "py/objproperty.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/runtime0.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/bitbangio/OneWire.h"
|
||||
#include "shared-bindings/util.h"
|
||||
|
||||
//| class OneWire:
|
||||
//| """Lowest-level of the Maxim OneWire protocol
|
||||
//|
|
||||
//| :class:`~bitbangio.OneWire` implements the timing-sensitive foundation of
|
||||
//| the Maxim (formerly Dallas Semi) OneWire protocol.
|
||||
//|
|
||||
//| Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126"""
|
||||
//|
|
||||
//| def __init__(self, pin: microcontroller.Pin) -> None:
|
||||
//|
|
||||
//| """Create a OneWire object associated with the given pin. The object
|
||||
//| implements the lowest level timing-sensitive bits of the protocol.
|
||||
//|
|
||||
//| :param ~microcontroller.Pin pin: Pin to read pulses from.
|
||||
//|
|
||||
//| Read a short series of pulses::
|
||||
//|
|
||||
//| import bitbangio
|
||||
//| import board
|
||||
//|
|
||||
//| onewire = bitbangio.OneWire(board.D7)
|
||||
//| onewire.reset()
|
||||
//| onewire.write_bit(True)
|
||||
//| onewire.write_bit(False)
|
||||
//| print(onewire.read_bit())"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t bitbangio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_pin };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
};
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj);
|
||||
|
||||
bitbangio_onewire_obj_t *self = m_new_obj(bitbangio_onewire_obj_t);
|
||||
self->base.type = &bitbangio_onewire_type;
|
||||
|
||||
shared_module_bitbangio_onewire_construct(self, pin);
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
//| def deinit(self) -> None:
|
||||
//| """Deinitialize the OneWire bus and release any hardware resources for reuse."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t bitbangio_onewire_deinit(mp_obj_t self_in) {
|
||||
bitbangio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
shared_module_bitbangio_onewire_deinit(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_onewire_deinit_obj, bitbangio_onewire_deinit);
|
||||
|
||||
STATIC void check_for_deinit(bitbangio_onewire_obj_t *self) {
|
||||
if (shared_module_bitbangio_onewire_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| def __enter__(self) -> OneWire:
|
||||
//| """No-op used by Context Managers."""
|
||||
//| ...
|
||||
//|
|
||||
// Provided by context manager helper.
|
||||
|
||||
//| def __exit__(self) -> None:
|
||||
//| """Automatically deinitializes the hardware when exiting a context. See
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t bitbangio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
shared_module_bitbangio_onewire_deinit(args[0]);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitbangio_onewire___exit___obj, 4, 4, bitbangio_onewire_obj___exit__);
|
||||
|
||||
//| def reset(self) -> bool:
|
||||
//| """Reset the OneWire bus"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t bitbangio_onewire_obj_reset(mp_obj_t self_in) {
|
||||
bitbangio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
|
||||
return mp_obj_new_bool(shared_module_bitbangio_onewire_reset(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_onewire_reset_obj, bitbangio_onewire_obj_reset);
|
||||
|
||||
//| def read_bit(self) -> bool:
|
||||
//| """Read in a bit
|
||||
//|
|
||||
//| :returns: bit state read
|
||||
//| :rtype: bool"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t bitbangio_onewire_obj_read_bit(mp_obj_t self_in) {
|
||||
bitbangio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
|
||||
return mp_obj_new_bool(shared_module_bitbangio_onewire_read_bit(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_onewire_read_bit_obj, bitbangio_onewire_obj_read_bit);
|
||||
|
||||
//| def write_bit(self, value: bool) -> None:
|
||||
//| """Write out a bit based on value."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t bitbangio_onewire_obj_write_bit(mp_obj_t self_in, mp_obj_t bool_obj) {
|
||||
bitbangio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
|
||||
shared_module_bitbangio_onewire_write_bit(self, mp_obj_is_true(bool_obj));
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(bitbangio_onewire_write_bit_obj, bitbangio_onewire_obj_write_bit);
|
||||
|
||||
STATIC const mp_rom_map_elem_t bitbangio_onewire_locals_dict_table[] = {
|
||||
// Methods
|
||||
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&bitbangio_onewire_deinit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&bitbangio_onewire___exit___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&bitbangio_onewire_reset_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_read_bit), MP_ROM_PTR(&bitbangio_onewire_read_bit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_write_bit), MP_ROM_PTR(&bitbangio_onewire_write_bit_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(bitbangio_onewire_locals_dict, bitbangio_onewire_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t bitbangio_onewire_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_OneWire,
|
||||
.make_new = bitbangio_onewire_make_new,
|
||||
.locals_dict = (mp_obj_dict_t *)&bitbangio_onewire_locals_dict,
|
||||
};
|
@ -34,7 +34,7 @@
|
||||
|
||||
#include "shared-bindings/bitbangio/__init__.h"
|
||||
#include "shared-bindings/bitbangio/I2C.h"
|
||||
#include "shared-bindings/bitbangio/OneWire.h"
|
||||
#include "shared-bindings/onewireio/OneWire.h"
|
||||
#include "shared-bindings/bitbangio/SPI.h"
|
||||
|
||||
#include "py/runtime.h"
|
||||
@ -72,7 +72,7 @@
|
||||
STATIC const mp_rom_map_elem_t bitbangio_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bitbangio) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&bitbangio_i2c_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_OneWire), MP_ROM_PTR(&bitbangio_onewire_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_OneWire), MP_ROM_PTR(&onewireio_onewire_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&bitbangio_spi_type) },
|
||||
};
|
||||
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_ONEWIRE_H
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "common-hal/busio/OneWire.h"
|
||||
|
||||
extern const mp_obj_type_t busio_onewire_type;
|
||||
|
||||
extern void common_hal_busio_onewire_construct(busio_onewire_obj_t *self,
|
||||
const mcu_pin_obj_t *pin);
|
||||
extern void common_hal_busio_onewire_deinit(busio_onewire_obj_t *self);
|
||||
extern bool common_hal_busio_onewire_deinited(busio_onewire_obj_t *self);
|
||||
extern bool common_hal_busio_onewire_reset(busio_onewire_obj_t *self);
|
||||
extern bool common_hal_busio_onewire_read_bit(busio_onewire_obj_t *self);
|
||||
extern void common_hal_busio_onewire_write_bit(busio_onewire_obj_t *self, bool bit);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_ONEWIRE_H
|
@ -32,9 +32,9 @@
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/busio/__init__.h"
|
||||
#include "shared-bindings/busio/I2C.h"
|
||||
#include "shared-bindings/busio/OneWire.h"
|
||||
#include "shared-bindings/busio/SPI.h"
|
||||
#include "shared-bindings/busio/UART.h"
|
||||
#include "shared-bindings/onewireio/OneWire.h"
|
||||
|
||||
#include "py/runtime.h"
|
||||
|
||||
@ -73,7 +73,7 @@ STATIC const mp_rom_map_elem_t busio_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_busio) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&busio_i2c_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&busio_spi_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_OneWire), MP_ROM_PTR(&busio_onewire_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_OneWire), MP_ROM_PTR(&onewireio_onewire_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&busio_uart_type) },
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "py/runtime.h"
|
||||
#include "py/runtime0.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/busio/OneWire.h"
|
||||
#include "shared-bindings/onewireio/OneWire.h"
|
||||
#include "shared-bindings/util.h"
|
||||
|
||||
//| class OneWire:
|
||||
@ -51,17 +51,17 @@
|
||||
//|
|
||||
//| Read a short series of pulses::
|
||||
//|
|
||||
//| import busio
|
||||
//| import onewireio
|
||||
//| import board
|
||||
//|
|
||||
//| onewire = busio.OneWire(board.D7)
|
||||
//| onewire = onewireio.OneWire(board.D7)
|
||||
//| onewire.reset()
|
||||
//| onewire.write_bit(True)
|
||||
//| onewire.write_bit(False)
|
||||
//| print(onewire.read_bit())"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t onewireio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_pin };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
@ -70,10 +70,10 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args,
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj);
|
||||
|
||||
busio_onewire_obj_t *self = m_new_obj(busio_onewire_obj_t);
|
||||
self->base.type = &busio_onewire_type;
|
||||
onewireio_onewire_obj_t *self = m_new_obj(onewireio_onewire_obj_t);
|
||||
self->base.type = &onewireio_onewire_type;
|
||||
|
||||
common_hal_busio_onewire_construct(self, pin);
|
||||
common_hal_onewireio_onewire_construct(self, pin);
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
@ -81,15 +81,15 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args,
|
||||
//| """Deinitialize the OneWire bus and release any hardware resources for reuse."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t busio_onewire_deinit(mp_obj_t self_in) {
|
||||
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
common_hal_busio_onewire_deinit(self);
|
||||
STATIC mp_obj_t onewireio_onewire_deinit(mp_obj_t self_in) {
|
||||
onewireio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
common_hal_onewireio_onewire_deinit(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_deinit_obj, busio_onewire_deinit);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(onewireio_onewire_deinit_obj, onewireio_onewire_deinit);
|
||||
|
||||
STATIC void check_for_deinit(busio_onewire_obj_t *self) {
|
||||
if (common_hal_busio_onewire_deinited(self)) {
|
||||
STATIC void check_for_deinit(onewireio_onewire_obj_t *self) {
|
||||
if (common_hal_onewireio_onewire_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
@ -105,12 +105,12 @@ STATIC void check_for_deinit(busio_onewire_obj_t *self) {
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t onewireio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
common_hal_busio_onewire_deinit(args[0]);
|
||||
common_hal_onewireio_onewire_deinit(args[0]);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_onewire___exit___obj, 4, 4, busio_onewire_obj___exit__);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(onewireio_onewire___exit___obj, 4, 4, onewireio_onewire_obj___exit__);
|
||||
|
||||
//| def reset(self) -> bool:
|
||||
//| """Reset the OneWire bus and read presence
|
||||
@ -119,13 +119,13 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_onewire___exit___obj, 4, 4, bus
|
||||
//| :rtype: bool"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) {
|
||||
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
STATIC mp_obj_t onewireio_onewire_obj_reset(mp_obj_t self_in) {
|
||||
onewireio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
|
||||
return mp_obj_new_bool(common_hal_busio_onewire_reset(self));
|
||||
return mp_obj_new_bool(common_hal_onewireio_onewire_reset(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_reset_obj, busio_onewire_obj_reset);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(onewireio_onewire_reset_obj, onewireio_onewire_obj_reset);
|
||||
|
||||
//| def read_bit(self) -> bool:
|
||||
//| """Read in a bit
|
||||
@ -134,41 +134,41 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_reset_obj, busio_onewire_obj_reset);
|
||||
//| :rtype: bool"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t busio_onewire_obj_read_bit(mp_obj_t self_in) {
|
||||
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
STATIC mp_obj_t onewireio_onewire_obj_read_bit(mp_obj_t self_in) {
|
||||
onewireio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
|
||||
return mp_obj_new_bool(common_hal_busio_onewire_read_bit(self));
|
||||
return mp_obj_new_bool(common_hal_onewireio_onewire_read_bit(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_read_bit_obj, busio_onewire_obj_read_bit);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(onewireio_onewire_read_bit_obj, onewireio_onewire_obj_read_bit);
|
||||
|
||||
//| def write_bit(self, value: bool) -> None:
|
||||
//| """Write out a bit based on value."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t busio_onewire_obj_write_bit(mp_obj_t self_in, mp_obj_t bool_obj) {
|
||||
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
STATIC mp_obj_t onewireio_onewire_obj_write_bit(mp_obj_t self_in, mp_obj_t bool_obj) {
|
||||
onewireio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
|
||||
common_hal_busio_onewire_write_bit(self, mp_obj_is_true(bool_obj));
|
||||
common_hal_onewireio_onewire_write_bit(self, mp_obj_is_true(bool_obj));
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(busio_onewire_write_bit_obj, busio_onewire_obj_write_bit);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(onewireio_onewire_write_bit_obj, onewireio_onewire_obj_write_bit);
|
||||
|
||||
STATIC const mp_rom_map_elem_t busio_onewire_locals_dict_table[] = {
|
||||
STATIC const mp_rom_map_elem_t onewireio_onewire_locals_dict_table[] = {
|
||||
// Methods
|
||||
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&busio_onewire_deinit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&onewireio_onewire_deinit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&busio_onewire___exit___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&busio_onewire_reset_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_read_bit), MP_ROM_PTR(&busio_onewire_read_bit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_write_bit), MP_ROM_PTR(&busio_onewire_write_bit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&onewireio_onewire___exit___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&onewireio_onewire_reset_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_read_bit), MP_ROM_PTR(&onewireio_onewire_read_bit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_write_bit), MP_ROM_PTR(&onewireio_onewire_write_bit_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(busio_onewire_locals_dict, busio_onewire_locals_dict_table);
|
||||
STATIC MP_DEFINE_CONST_DICT(onewireio_onewire_locals_dict, onewireio_onewire_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t busio_onewire_type = {
|
||||
const mp_obj_type_t onewireio_onewire_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_OneWire,
|
||||
.make_new = busio_onewire_make_new,
|
||||
.locals_dict = (mp_obj_dict_t *)&busio_onewire_locals_dict,
|
||||
.make_new = onewireio_onewire_make_new,
|
||||
.locals_dict = (mp_obj_dict_t *)&onewireio_onewire_locals_dict,
|
||||
};
|
@ -24,20 +24,20 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BITBANGIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_BITBANGIO_ONEWIRE_H
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ONEWIREIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_ONEWIREIO_ONEWIRE_H
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "shared-module/bitbangio/OneWire.h"
|
||||
#include "shared-module/onewireio/OneWire.h"
|
||||
|
||||
extern const mp_obj_type_t bitbangio_onewire_type;
|
||||
extern const mp_obj_type_t onewireio_onewire_type;
|
||||
|
||||
extern void shared_module_bitbangio_onewire_construct(bitbangio_onewire_obj_t *self,
|
||||
extern void common_hal_onewireio_onewire_construct(onewireio_onewire_obj_t *self,
|
||||
const mcu_pin_obj_t *pin);
|
||||
extern void shared_module_bitbangio_onewire_deinit(bitbangio_onewire_obj_t *self);
|
||||
extern bool shared_module_bitbangio_onewire_deinited(bitbangio_onewire_obj_t *self);
|
||||
extern bool shared_module_bitbangio_onewire_reset(bitbangio_onewire_obj_t *self);
|
||||
extern bool shared_module_bitbangio_onewire_read_bit(bitbangio_onewire_obj_t *self);
|
||||
extern void shared_module_bitbangio_onewire_write_bit(bitbangio_onewire_obj_t *self, bool bit);
|
||||
extern void common_hal_onewireio_onewire_deinit(onewireio_onewire_obj_t *self);
|
||||
extern bool common_hal_onewireio_onewire_deinited(onewireio_onewire_obj_t *self);
|
||||
extern bool common_hal_onewireio_onewire_reset(onewireio_onewire_obj_t *self);
|
||||
extern bool common_hal_onewireio_onewire_read_bit(onewireio_onewire_obj_t *self);
|
||||
extern void common_hal_onewireio_onewire_write_bit(onewireio_onewire_obj_t *self, bool bit);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BITBANGIO_ONEWIRE_H
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ONEWIREIO_ONEWIRE_H
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
|
||||
* Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -24,16 +24,28 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_ONEWIRE_H
|
||||
|
||||
#include "shared-module/bitbangio/OneWire.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
bitbangio_onewire_obj_t bitbang;
|
||||
} busio_onewire_obj_t;
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/onewireio/__init__.h"
|
||||
#include "shared-bindings/onewireio/OneWire.h"
|
||||
|
||||
#endif // MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_ONEWIRE_H
|
||||
#include "py/runtime.h"
|
||||
|
||||
//| """Low-level bit primitives for """
|
||||
//|
|
||||
|
||||
STATIC const mp_rom_map_elem_t onewireio_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_onewireio) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_OneWire), MP_ROM_PTR(&onewireio_onewire_type) },
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(onewireio_module_globals, onewireio_module_globals_table);
|
||||
|
||||
const mp_obj_module_t onewireio_module = {
|
||||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t *)&onewireio_module_globals,
|
||||
};
|
@ -24,10 +24,11 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ONEWIREIO___INIT___H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_ONEWIREIO___INIT___H
|
||||
|
||||
// Use bitbangio.
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
#include "py/obj.h"
|
||||
|
||||
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
// Nothing now.
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ONEWIREIO___INIT___H
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// Wraps the bitbangio implementation of OneWire for use in busio.
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "shared-bindings/bitbangio/OneWire.h"
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
|
||||
void common_hal_busio_onewire_construct(busio_onewire_obj_t *self,
|
||||
const mcu_pin_obj_t *pin) {
|
||||
shared_module_bitbangio_onewire_construct(&self->bitbang, pin);
|
||||
}
|
||||
|
||||
bool common_hal_busio_onewire_deinited(busio_onewire_obj_t *self) {
|
||||
return shared_module_bitbangio_onewire_deinited(&self->bitbang);
|
||||
}
|
||||
|
||||
void common_hal_busio_onewire_deinit(busio_onewire_obj_t *self) {
|
||||
if (common_hal_busio_onewire_deinited(self)) {
|
||||
return;
|
||||
}
|
||||
shared_module_bitbangio_onewire_deinit(&self->bitbang);
|
||||
}
|
||||
|
||||
bool common_hal_busio_onewire_reset(busio_onewire_obj_t *self) {
|
||||
return shared_module_bitbangio_onewire_reset(&self->bitbang);
|
||||
}
|
||||
|
||||
bool common_hal_busio_onewire_read_bit(busio_onewire_obj_t *self) {
|
||||
return shared_module_bitbangio_onewire_read_bit(&self->bitbang);
|
||||
}
|
||||
|
||||
void common_hal_busio_onewire_write_bit(busio_onewire_obj_t *self,
|
||||
bool bit) {
|
||||
shared_module_bitbangio_onewire_write_bit(&self->bitbang, bit);
|
||||
}
|
@ -25,24 +25,24 @@
|
||||
*/
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "shared-bindings/bitbangio/OneWire.h"
|
||||
#include "shared-bindings/onewireio/OneWire.h"
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/digitalio/DigitalInOut.h"
|
||||
|
||||
// Durations are taken from here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126
|
||||
|
||||
void shared_module_bitbangio_onewire_construct(bitbangio_onewire_obj_t *self,
|
||||
void common_hal_onewireio_onewire_construct(onewireio_onewire_obj_t *self,
|
||||
const mcu_pin_obj_t *pin) {
|
||||
self->pin.base.type = &digitalio_digitalinout_type;
|
||||
common_hal_digitalio_digitalinout_construct(&self->pin, pin);
|
||||
}
|
||||
|
||||
bool shared_module_bitbangio_onewire_deinited(bitbangio_onewire_obj_t *self) {
|
||||
bool common_hal_onewireio_onewire_deinited(onewireio_onewire_obj_t *self) {
|
||||
return common_hal_digitalio_digitalinout_deinited(&self->pin);
|
||||
}
|
||||
|
||||
void shared_module_bitbangio_onewire_deinit(bitbangio_onewire_obj_t *self) {
|
||||
if (shared_module_bitbangio_onewire_deinited(self)) {
|
||||
void common_hal_onewireio_onewire_deinit(onewireio_onewire_obj_t *self) {
|
||||
if (common_hal_onewireio_onewire_deinited(self)) {
|
||||
return;
|
||||
}
|
||||
common_hal_digitalio_digitalinout_deinit(&self->pin);
|
||||
@ -51,7 +51,7 @@ void shared_module_bitbangio_onewire_deinit(bitbangio_onewire_obj_t *self) {
|
||||
// We use common_hal_mcu_delay_us(). It should not be dependent on interrupts
|
||||
// to do accurate timekeeping, since we disable interrupts during the delays below.
|
||||
|
||||
bool shared_module_bitbangio_onewire_reset(bitbangio_onewire_obj_t *self) {
|
||||
bool common_hal_onewireio_onewire_reset(onewireio_onewire_obj_t *self) {
|
||||
common_hal_mcu_disable_interrupts();
|
||||
common_hal_digitalio_digitalinout_switch_to_output(&self->pin, false, DRIVE_MODE_OPEN_DRAIN);
|
||||
common_hal_mcu_delay_us(480);
|
||||
@ -63,7 +63,7 @@ bool shared_module_bitbangio_onewire_reset(bitbangio_onewire_obj_t *self) {
|
||||
return value;
|
||||
}
|
||||
|
||||
bool shared_module_bitbangio_onewire_read_bit(bitbangio_onewire_obj_t *self) {
|
||||
bool common_hal_onewireio_onewire_read_bit(onewireio_onewire_obj_t *self) {
|
||||
common_hal_mcu_disable_interrupts();
|
||||
common_hal_digitalio_digitalinout_switch_to_output(&self->pin, false, DRIVE_MODE_OPEN_DRAIN);
|
||||
common_hal_mcu_delay_us(6);
|
||||
@ -78,7 +78,7 @@ bool shared_module_bitbangio_onewire_read_bit(bitbangio_onewire_obj_t *self) {
|
||||
return value;
|
||||
}
|
||||
|
||||
void shared_module_bitbangio_onewire_write_bit(bitbangio_onewire_obj_t *self,
|
||||
void common_hal_onewireio_onewire_write_bit(onewireio_onewire_obj_t *self,
|
||||
bool bit) {
|
||||
common_hal_mcu_disable_interrupts();
|
||||
common_hal_digitalio_digitalinout_switch_to_output(&self->pin, false, DRIVE_MODE_OPEN_DRAIN);
|
@ -24,8 +24,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_ONEWIRE_H
|
||||
#ifndef MICROPY_INCLUDED_SHARED_MODULE_ONEWIREIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_SHARED_MODULE_ONEWIREIO_ONEWIRE_H
|
||||
|
||||
#include "common-hal/digitalio/DigitalInOut.h"
|
||||
|
||||
@ -34,6 +34,6 @@
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
digitalio_digitalinout_obj_t pin;
|
||||
} bitbangio_onewire_obj_t;
|
||||
} onewireio_onewire_obj_t;
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_ONEWIRE_H
|
||||
#endif // MICROPY_INCLUDED_SHARED_MODULE_ONEWIREIO_ONEWIRE_H
|
@ -24,10 +24,4 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_STM32_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_STM32_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
|
||||
// Use bitbangio.
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32F_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
// Nothing now.
|
Loading…
Reference in New Issue
Block a user