summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
authorDan Halbert <halbert@adafruit.com>2021-03-03 12:42:47 -0500
committerGitHub <noreply@github.com>2021-03-03 12:42:47 -0500
commitcd48c5ee8317fb94fed1fd6c430ab83d1b487ac9 (patch)
tree14c123c138b8a5ac748adc31c8eedea172fb5f2b /shared-module
parent514b73bcf8e2978bc7a4cd8985618208b103283d (diff)
parentfb7a0f7efcdd639ff4a14a2985f9381c426b2321 (diff)
Merge pull request #4315 from dhalbert/rp2040-i2c-short-writes
RP2040: Implement short I2C writes (2 bytes or less) using bitbangio
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/bitbangio/I2C.c1
-rw-r--r--shared-module/bitbangio/I2C.h43
-rw-r--r--shared-module/bitbangio/OneWire.c1
-rw-r--r--shared-module/bitbangio/OneWire.h39
-rw-r--r--shared-module/bitbangio/SPI.c4
-rw-r--r--shared-module/bitbangio/SPI.h (renamed from shared-module/bitbangio/types.h)20
-rw-r--r--shared-module/busio/I2C.h2
-rw-r--r--shared-module/busio/OneWire.h2
8 files changed, 89 insertions, 23 deletions
diff --git a/shared-module/bitbangio/I2C.c b/shared-module/bitbangio/I2C.c
index d44aec0e7..170630df6 100644
--- a/shared-module/bitbangio/I2C.c
+++ b/shared-module/bitbangio/I2C.c
@@ -32,7 +32,6 @@
#include "common-hal/microcontroller/Pin.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/digitalio/DigitalInOut.h"
-#include "shared-module/bitbangio/types.h"
#include "supervisor/shared/translate.h"
STATIC void delay(bitbangio_i2c_obj_t *self) {
diff --git a/shared-module/bitbangio/I2C.h b/shared-module/bitbangio/I2C.h
new file mode 100644
index 000000000..763c03adc
--- /dev/null
+++ b/shared-module/bitbangio/I2C.h
@@ -0,0 +1,43 @@
+/*
+ * 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_SHARED_MODULE_BITBANGIO_I2C_H
+#define MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_I2C_H
+
+#include "common-hal/digitalio/DigitalInOut.h"
+
+#include "py/obj.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ digitalio_digitalinout_obj_t scl;
+ digitalio_digitalinout_obj_t sda;
+ uint32_t us_delay;
+ uint32_t us_timeout;
+ volatile bool locked;
+} bitbangio_i2c_obj_t;
+
+#endif // MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_I2C_H
diff --git a/shared-module/bitbangio/OneWire.c b/shared-module/bitbangio/OneWire.c
index f5f479087..3e4ec8426 100644
--- a/shared-module/bitbangio/OneWire.c
+++ b/shared-module/bitbangio/OneWire.c
@@ -28,7 +28,6 @@
#include "shared-bindings/bitbangio/OneWire.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/digitalio/DigitalInOut.h"
-#include "shared-module/bitbangio/types.h"
// Durations are taken from here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126
diff --git a/shared-module/bitbangio/OneWire.h b/shared-module/bitbangio/OneWire.h
new file mode 100644
index 000000000..bc4cb2096
--- /dev/null
+++ b/shared-module/bitbangio/OneWire.h
@@ -0,0 +1,39 @@
+/*
+ * 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_SHARED_MODULE_BITBANGIO_ONEWIRE_H
+#define MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_ONEWIRE_H
+
+#include "common-hal/digitalio/DigitalInOut.h"
+
+#include "py/obj.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ digitalio_digitalinout_obj_t pin;
+} bitbangio_onewire_obj_t;
+
+#endif // MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_ONEWIRE_H
diff --git a/shared-module/bitbangio/SPI.c b/shared-module/bitbangio/SPI.c
index f3fe16029..9ed3d660a 100644
--- a/shared-module/bitbangio/SPI.c
+++ b/shared-module/bitbangio/SPI.c
@@ -29,9 +29,9 @@
#include "py/runtime.h"
#include "common-hal/microcontroller/Pin.h"
-#include "shared-bindings/microcontroller/__init__.h"
+#include "shared-bindings/bitbangio/SPI.h"
#include "shared-bindings/digitalio/DigitalInOut.h"
-#include "shared-module/bitbangio/types.h"
+#include "shared-bindings/microcontroller/__init__.h"
#include "supervisor/shared/translate.h"
#define MAX_BAUDRATE (common_hal_mcu_get_clock_frequency() / 48)
diff --git a/shared-module/bitbangio/types.h b/shared-module/bitbangio/SPI.h
index 6d1723474..f3e02c206 100644
--- a/shared-module/bitbangio/types.h
+++ b/shared-module/bitbangio/SPI.h
@@ -24,8 +24,8 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_TYPES_H
-#define MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_TYPES_H
+#ifndef MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_SPI_H
+#define MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_SPI_H
#include "common-hal/digitalio/DigitalInOut.h"
@@ -33,20 +33,6 @@
typedef struct {
mp_obj_base_t base;
- digitalio_digitalinout_obj_t scl;
- digitalio_digitalinout_obj_t sda;
- uint32_t us_delay;
- uint32_t us_timeout;
- volatile bool locked;
-} bitbangio_i2c_obj_t;
-
-typedef struct {
- mp_obj_base_t base;
- digitalio_digitalinout_obj_t pin;
-} bitbangio_onewire_obj_t;
-
-typedef struct {
- mp_obj_base_t base;
digitalio_digitalinout_obj_t clock;
digitalio_digitalinout_obj_t mosi;
digitalio_digitalinout_obj_t miso;
@@ -58,4 +44,4 @@ typedef struct {
volatile bool locked:1;
} bitbangio_spi_obj_t;
-#endif // MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_TYPES_H
+#endif // MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_SPI_H
diff --git a/shared-module/busio/I2C.h b/shared-module/busio/I2C.h
index 8e3525f19..e089ea367 100644
--- a/shared-module/busio/I2C.h
+++ b/shared-module/busio/I2C.h
@@ -27,7 +27,7 @@
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_I2C_H
#define MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_I2C_H
-#include "shared-module/bitbangio/types.h"
+#include "shared-module/bitbangio/I2C.h"
#include "py/obj.h"
diff --git a/shared-module/busio/OneWire.h b/shared-module/busio/OneWire.h
index 9ffb89d49..5d80bab17 100644
--- a/shared-module/busio/OneWire.h
+++ b/shared-module/busio/OneWire.h
@@ -27,7 +27,7 @@
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_ONEWIRE_H
#define MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_ONEWIRE_H
-#include "shared-module/bitbangio/types.h"
+#include "shared-module/bitbangio/OneWire.h"
#include "py/obj.h"