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. --- stmhal/mpconfigport.h | 1 + stmhal/mphalport.h | 2 ++ 2 files changed, 3 insertions(+) (limited to 'stmhal') diff --git a/stmhal/mpconfigport.h b/stmhal/mpconfigport.h index 9d9487a66..0e3098095 100644 --- a/stmhal/mpconfigport.h +++ b/stmhal/mpconfigport.h @@ -106,6 +106,7 @@ #define MICROPY_PY_MACHINE_I2C_MAKE_NEW machine_hard_i2c_make_new #define MICROPY_PY_MACHINE_SPI (1) #define MICROPY_PY_MACHINE_SPI_MIN_DELAY (0) +#define MICROPY_PY_MACHINE_SPI_MAX_BAUDRATE (HAL_RCC_GetSysClockFreq() / 48) #define MICROPY_PY_FRAMEBUF (1) #ifndef MICROPY_PY_USOCKET diff --git a/stmhal/mphalport.h b/stmhal/mphalport.h index b55c9ccdc..f0c05555d 100644 --- a/stmhal/mphalport.h +++ b/stmhal/mphalport.h @@ -48,6 +48,7 @@ static inline mp_uint_t mp_hal_ticks_cpu(void) { #include "stmhal/pin.h" +#define MP_HAL_PIN_FMT "%q" #define MP_HAL_PIN_MODE_INPUT (0) #define MP_HAL_PIN_MODE_OUTPUT (1) #define MP_HAL_PIN_MODE_ALT (2) @@ -60,6 +61,7 @@ static inline mp_uint_t mp_hal_ticks_cpu(void) { #define mp_hal_pin_obj_t const pin_obj_t* #define mp_hal_get_pin_obj(o) pin_find(o) +#define mp_hal_pin_name(p) ((p)->name) #define mp_hal_pin_input(p) mp_hal_pin_config((p), MP_HAL_PIN_MODE_INPUT, MP_HAL_PIN_PULL_NONE, 0) #define mp_hal_pin_output(p) mp_hal_pin_config((p), MP_HAL_PIN_MODE_OUTPUT, MP_HAL_PIN_PULL_NONE, 0) #define mp_hal_pin_open_drain(p) mp_hal_pin_config((p), MP_HAL_PIN_MODE_OPEN_DRAIN, MP_HAL_PIN_PULL_NONE, 0) -- cgit v1.2.3