diff Small_CPU/Src/i2c.c @ 104:22a1094545f3 kittz

Tested and alive.
author Dmitry Romanov <kitt@bk.ru>
date Mon, 24 Dec 2018 16:15:02 +0300
parents b364c75005bb
children e9cce686fe41
line wrap: on
line diff
--- a/Small_CPU/Src/i2c.c	Wed Nov 28 09:36:33 2018 +0300
+++ b/Small_CPU/Src/i2c.c	Mon Dec 24 16:15:02 2018 +0300
@@ -69,9 +69,9 @@
 {
 	I2cHandle.Instance             = I2Cx;
   I2cHandle.Init.AddressingMode  = I2C_ADDRESSINGMODE_7BIT;
-  I2cHandle.Init.ClockSpeed      = 400000;//400000;
+  I2cHandle.Init.ClockSpeed      = 100000;//400000; REDUCED for compatibility with  HMC5583L + MMA8452Q
   I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
-  I2cHandle.Init.DutyCycle       = I2C_DUTYCYCLE_16_9;
+  I2cHandle.Init.DutyCycle       = I2C_DUTYCYCLE_2;
   I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
   I2cHandle.Init.NoStretchMode   = I2C_NOSTRETCH_DISABLED;
   I2cHandle.Init.OwnAddress1     = 0x01;
@@ -120,6 +120,7 @@
 		I2C_Error_count();
 	}
 	global.dataSendToSlaveStopEval = 0;
+	//TODO: REMOVE.
 //	if(global.dataSendToSlavePending)
 //	{
 //		scheduleSpecial_Evaluate_DataSendToSlave();
@@ -136,13 +137,14 @@
 	
 	global.dataSendToSlaveStopEval = 1;
 
-	global.I2C_SystemStatus = HAL_I2C_Master_Transmit(&I2cHandle, DevAddress,  pData, Size, 100 /*FIXME , 1*/);
+	global.I2C_SystemStatus = HAL_I2C_Master_Transmit(&I2cHandle, DevAddress,  pData, Size,100 /*FIXME , 1*/);
 	if(global.I2C_SystemStatus != HAL_OK)
 	{
 		I2C_Error_count();
 	}
 
 	global.dataSendToSlaveStopEval = 0;
+	//TODO: REMOVE.
 //	if(global.dataSendToSlavePending)
 //	{
 //		scheduleSpecial_Evaluate_DataSendToSlave();
@@ -161,13 +163,14 @@
 
 	global.dataSendToSlaveStopEval = 1;
 
-  localHALstatusReturn = HAL_I2C_Master_Receive(&I2cHandle, DevAddress,  pData, Size, 100);
+  localHALstatusReturn = HAL_I2C_Master_Receive(&I2cHandle, DevAddress,  pData, Size, 10);
 	if(localHALstatusReturn != HAL_OK)
 	{
 		I2C_Error_count();
 	}
 
 	global.dataSendToSlaveStopEval = 0;
+	//TODO: REMOVE.
 //	if(global.dataSendToSlavePending)
 //	{
 //		scheduleSpecial_Evaluate_DataSendToSlave();