From 1eb3c66e9136b5934fc306408f00f11a07dea584 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 8 Dec 2016 13:47:01 +1100 Subject: extmod/machine_spi: Provide reusable software SPI class. So long as a port defines relevant mp_hal_pin_xxx functions (and delay) it can make use of this software SPI class without the need for additional code. --- extmod/machine_spi.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'extmod/machine_spi.h') diff --git a/extmod/machine_spi.h b/extmod/machine_spi.h index 62f42a885..88a3e19f4 100644 --- a/extmod/machine_spi.h +++ b/extmod/machine_spi.h @@ -32,6 +32,8 @@ // SPI protocol typedef struct _mp_machine_spi_p_t { + void (*init)(mp_obj_base_t *obj, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); + void (*deinit)(mp_obj_base_t *obj); // can be NULL void (*transfer)(mp_obj_base_t *obj, size_t len, const uint8_t *src, uint8_t *dest); } mp_machine_spi_p_t; @@ -45,8 +47,13 @@ typedef struct _mp_machine_soft_spi_obj_t { mp_hal_pin_obj_t miso; } mp_machine_soft_spi_obj_t; +extern const mp_obj_type_t mp_machine_soft_spi_type; +extern const mp_obj_dict_t mp_machine_spi_locals_dict; + void mp_machine_soft_spi_transfer(mp_obj_base_t *self, size_t len, const uint8_t *src, uint8_t *dest); +mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); + MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_machine_spi_read_obj); MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_machine_spi_readinto_obj); MP_DECLARE_CONST_FUN_OBJ_2(mp_machine_spi_write_obj); -- cgit v1.2.3