summaryrefslogtreecommitdiff
path: root/stmhal
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-12-08 13:47:01 +1100
committerDamien George <damien.p.george@gmail.com>2016-12-08 13:47:01 +1100
commit1eb3c66e9136b5934fc306408f00f11a07dea584 (patch)
tree045502e77bc1d1761be0df8ef82da2fe5c8c1e60 /stmhal
parentd9c839742f27b6b07abbebbe81bc76fcde11b306 (diff)
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.
Diffstat (limited to 'stmhal')
-rw-r--r--stmhal/mpconfigport.h1
-rw-r--r--stmhal/mphalport.h2
2 files changed, 3 insertions, 0 deletions
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)