Light sensor crashes I2C line


#1

Hi,
I open I2C hub (0x71) to IoT (no IoT is inserted) and I read light sensor every 1s. System crashes I2C line (all addresses disappear) and Light sensor after couple of min. mangOH red - processor WP8548

image

//Write to I2C
bool WriteByte(uint8_t Address, uint8_t Register)
{
	int FD = open("/dev/i2c-0", O_RDWR);
	if (FD > 0)
	{
		if(ioctl(FD, I2C_SLAVE_FORCE, Address) < 0)
		{
			return false;
		}
		else
		{
			if(write(FD, &Register ,1) == 1)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		close(FD);
	}
	return false;
}

void ADCLight(le_timer_Ref_t timerRef)
{
	char Val2[32];
	int32_t Ret=-1;
	if(le_adc_ReadValue ("EXT_ADC3", &Ret) == LE_OK)
	{
		sprintf(Val2 ,"Light sensor. Raw Data: %d" , Ret);
		LE_INFO((const char*)Val2);
	}
}

COMPONENT_INIT
{
	LE_INFO("Start...");
	sleep(1);

	//Open hub to IoT 
	WriteByte(0x71, 1);

	le_adc_TryConnectService();

	le_timer_Ref_t TimerRef = le_timer_Create("Switch");
	le_timer_SetMsInterval(TimerRef, 1000);
	le_timer_SetRepeat(TimerRef, 0);
	le_timer_SetHandler(TimerRef, ADCLight);
	le_timer_Start(TimerRef);
}