summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Ruben Bakke <glennbakke@gmail.com>2018-12-23 16:22:00 +0100
committerGlenn Ruben Bakke <glennbakke@gmail.com>2019-10-02 20:42:06 +0200
commitd2e730b727fe5522e8b70b3af48bc4504545eb3b (patch)
treedba2ee13165298eec4cc4a49d4d98ea6d3f3f47f
parent4102320e908dfa6e2fc320d73f118670ad5b1501 (diff)
nrf/i2c: Add support for TWIM (EasyDMA).
-rw-r--r--ports/nrf/modules/machine/i2c.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/ports/nrf/modules/machine/i2c.c b/ports/nrf/modules/machine/i2c.c
index 1d8971612..6ec902a83 100644
--- a/ports/nrf/modules/machine/i2c.c
+++ b/ports/nrf/modules/machine/i2c.c
@@ -31,11 +31,33 @@
#include "py/runtime.h"
#include "py/mperrno.h"
#include "py/mphal.h"
+
+#if MICROPY_PY_MACHINE_I2C
+
#include "extmod/machine_i2c.h"
#include "i2c.h"
+#if NRFX_TWI_ENABLED
#include "nrfx_twi.h"
+#else
+#include "nrfx_twim.h"
+#endif
-#if MICROPY_PY_MACHINE_I2C
+#if NRFX_TWIM_ENABLED
+
+#define nrfx_twi_t nrfx_twim_t
+#define nrfx_twi_config_t nrfx_twim_config_t
+
+#define nrfx_twi_init nrfx_twim_init
+#define nrfx_twi_enable nrfx_twim_enable
+#define nrfx_twi_rx nrfx_twim_rx
+#define nrfx_twi_tx nrfx_twim_tx
+#define nrfx_twi_disable nrfx_twim_disable
+
+#define NRFX_TWI_INSTANCE NRFX_TWIM_INSTANCE
+
+#define NRF_TWI_FREQ_400K NRF_TWIM_FREQ_400K
+
+#endif
STATIC const mp_obj_type_t machine_hard_i2c_type;