mirror of https://github.com/ARMmbed/mbed-os.git
NRF52840 I2C driver: Initialise I2C pins before transmission
By default D0 - D3 pins are used for the bit-banged SPI com channel between mbed target and the FPGA-test-shield. For some reason, if pins were used as GPIOs and then reconfigured to I2C pins the I2C com does not work on NRF52840. This commit modifies i2c_configure_twi_instance() function and adds proper initialization of the I2C pins.pull/12436/head
parent
2b52c5861a
commit
e18a800e7c
|
@ -59,6 +59,13 @@
|
|||
#include "app_util_platform.h"
|
||||
#include "prs/nrfx_prs.h"
|
||||
|
||||
#define TWI_PIN_INIT(_pin) nrf_gpio_cfg((_pin), \
|
||||
NRF_GPIO_PIN_DIR_INPUT, \
|
||||
NRF_GPIO_PIN_INPUT_CONNECT, \
|
||||
NRF_GPIO_PIN_PULLUP, \
|
||||
NRF_GPIO_PIN_S0D1, \
|
||||
NRF_GPIO_PIN_NOSENSE)
|
||||
|
||||
#if 0
|
||||
#define DEBUG_PRINTF(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
|
@ -330,6 +337,13 @@ void i2c_configure_twi_instance(i2c_t *obj)
|
|||
nrf_twi_frequency_set(nordic_nrf5_twi_register[instance],
|
||||
config->frequency);
|
||||
|
||||
/* To secure correct signal levels on the pins used by the TWI
|
||||
master when the system is in OFF mode, and when the TWI master is
|
||||
disabled, these pins must be configured in the GPIO peripheral.
|
||||
*/
|
||||
TWI_PIN_INIT(config->scl);
|
||||
TWI_PIN_INIT(config->sda);
|
||||
|
||||
/* Enable TWI peripheral with new settings. */
|
||||
nrf_twi_enable(nordic_nrf5_twi_register[instance]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue