summaryrefslogtreecommitdiff
path: root/shared-bindings/busio
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2020-05-06 11:04:53 -0500
committerJeff Epler <jepler@gmail.com>2020-06-26 11:50:23 -0500
commit57fde2e07bb2ee4dcff342deed08e4e7799da799 (patch)
treee0c9f2ecccc45637a48db61e823485ad3460e9cf /shared-bindings/busio
parent12df4ce221b212c866f83c0ccf0233458fb421bd (diff)
sdcardio: implement new library for SD card I/O
Testing performed: That a card is successfully mounted on Pygamer with the built in SD card slot This module is enabled for most FULL_BUILD boards, but is disabled for samd21 ("M0"), litex, and pca10100 for various reasons.
Diffstat (limited to 'shared-bindings/busio')
-rw-r--r--shared-bindings/busio/SPI.c7
-rw-r--r--shared-bindings/busio/SPI.h2
2 files changed, 9 insertions, 0 deletions
diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c
index 22f001d2d..793ab4f67 100644
--- a/shared-bindings/busio/SPI.c
+++ b/shared-bindings/busio/SPI.c
@@ -418,3 +418,10 @@ const mp_obj_type_t busio_spi_type = {
.make_new = busio_spi_make_new,
.locals_dict = (mp_obj_dict_t*)&busio_spi_locals_dict,
};
+
+busio_spi_obj_t *validate_obj_is_spi_bus(mp_obj_t obj) {
+ if (!MP_OBJ_IS_TYPE(obj, &busio_spi_type)) {
+ mp_raise_TypeError_varg(translate("Expected a %q"), busio_spi_type.name);
+ }
+ return MP_OBJ_TO_PTR(obj);
+}
diff --git a/shared-bindings/busio/SPI.h b/shared-bindings/busio/SPI.h
index b7b0715d1..aa7d715b9 100644
--- a/shared-bindings/busio/SPI.h
+++ b/shared-bindings/busio/SPI.h
@@ -70,4 +70,6 @@ uint8_t common_hal_busio_spi_get_polarity(busio_spi_obj_t* self);
// This is used by the supervisor to claim SPI devices indefinitely.
extern void common_hal_busio_spi_never_reset(busio_spi_obj_t *self);
+extern busio_spi_obj_t *validate_obj_is_spi_bus(mp_obj_t obj_in);
+
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_SPI_H