summaryrefslogtreecommitdiff
path: root/stmhal/spi.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-09-26 00:57:26 +0100
committerDamien George <damien.p.george@gmail.com>2014-09-26 00:57:26 +0100
commitb766e79510d87db1b18028a0fae3f195091fcaf1 (patch)
tree88d13ec2c977e365413ee9758574a26032f54a8b /stmhal/spi.c
parentf996d8854f0cdd88446a8a369e1b330c14ea3eb7 (diff)
stmhal: Initial implementation of cc3k module and driver.
Pulled in and modified work done by mux/iabdalkader on cc3k driver, from iabdalkader-cc3k-update branch. That branch was terribly messy and had too many conflicts to merge neatly.
Diffstat (limited to 'stmhal/spi.c')
-rw-r--r--stmhal/spi.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/stmhal/spi.c b/stmhal/spi.c
index e08c07b0e..0b825ce1d 100644
--- a/stmhal/spi.c
+++ b/stmhal/spi.c
@@ -190,6 +190,14 @@ STATIC const pyb_spi_obj_t pyb_spi_obj[] = {
};
#define PYB_NUM_SPI MP_ARRAY_SIZE(pyb_spi_obj)
+SPI_HandleTypeDef *spi_get_handle(mp_obj_t o) {
+ if (!MP_OBJ_IS_TYPE(o, &pyb_spi_type)) {
+ nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "expecting an SPI object"));
+ }
+ pyb_spi_obj_t *self = o;
+ return self->spi;
+}
+
STATIC void pyb_spi_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
pyb_spi_obj_t *self = self_in;