This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Issue including hardware peripherals to a project with softdevice loaded. TWI master communication issue.

Hello,

I have program w/o using softdevice to drive an LED driver using I2C. I was able to get this to work very well with out a softdevice, however once I loaded a soft device, the program gets stuck in a while loop.

In order to get out of the while loop a handler is used when a xfer is complete to flip a flag. I have my code attached, any help or direction would be greatly appreciated. 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "TLC59116.h"
#include "I2C wrapper.h"
void drv_TLC59116_init(void){
/* Initialize i2c bus */
nrf_gpio_range_cfg_output(22, 23);
nrf_gpio_pin_write(22, 1);
nrf_gpio_pin_write(23, 1);
/* Initialize mode regiters */
twi_sendCommand(IC_RED_ARRAY, REG_MODE1, 0x00, 2);
twi_sendCommand(IC_RED_ARRAY, REG_MODE2, MODE2_BLNK, 2);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "I2C wrapper.h"
#include "SEGGER_RTT.h"
extern const nrf_drv_twi_t I2C_twi_master;
/* Indicates if operation on TWI has ended. */
extern volatile bool mTWI_xfer_done;
//extern volatile bool //mTWI_xfer_error;
bool I2Cbus_init(void) {
bool bus_clear = false;
// data line
if (nrf_gpio_pin_read(nRF_PERIPH_MASTER_I2C_SDA) == 1) {
bus_clear = true;
//SEGGER_RTT_printf(0, "I2C Bus clear\r\n");
}
// clock line
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**
* Copyright (c) 2014 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX