mirror of
https://github.com/micropython/micropython.git
synced 2026-01-08 05:00:26 +01:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user