comparison Small_CPU/Src/i2c.c @ 94:c6d284ea265b kittz

reduce i2c speed and dutycycle for compass stability
author Dmitry Romanov <kitt@bk.ru>
date Mon, 26 Nov 2018 12:20:31 +0300
parents 3db7389d49cc
children b364c75005bb
comparison
equal deleted inserted replaced
93:3d6ccfb0190b 94:c6d284ea265b
67 67
68 HAL_StatusTypeDef MX_I2C1_Init(void) 68 HAL_StatusTypeDef MX_I2C1_Init(void)
69 { 69 {
70 I2cHandle.Instance = I2Cx; 70 I2cHandle.Instance = I2Cx;
71 I2cHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; 71 I2cHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
72 I2cHandle.Init.ClockSpeed = 400000;//400000; 72 I2cHandle.Init.ClockSpeed = 100000;//400000;
73 I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED; 73 I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
74 I2cHandle.Init.DutyCycle = I2C_DUTYCYCLE_16_9; 74 I2cHandle.Init.DutyCycle = I2C_DUTYCYCLE_2;
75 I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED; 75 I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
76 I2cHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED; 76 I2cHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED;
77 I2cHandle.Init.OwnAddress1 = 0x01; 77 I2cHandle.Init.OwnAddress1 = 0x01;
78 78
79 global.dataSendToSlaveStopEval = 1; 79 global.dataSendToSlaveStopEval = 1;
81 global.I2C_SystemStatus = HAL_I2C_Init(&I2cHandle); 81 global.I2C_SystemStatus = HAL_I2C_Init(&I2cHandle);
82 HAL_I2CEx_AnalogFilter_Config(&I2cHandle, I2C_ANALOGFILTER_ENABLED); 82 HAL_I2CEx_AnalogFilter_Config(&I2cHandle, I2C_ANALOGFILTER_ENABLED);
83 83
84 84
85 global.dataSendToSlaveStopEval = 0; 85 global.dataSendToSlaveStopEval = 0;
86 if(global.dataSendToSlavePending) 86 // if(global.dataSendToSlavePending)
87 { 87 // {
88 scheduleSpecial_Evaluate_DataSendToSlave(); 88 // scheduleSpecial_Evaluate_DataSendToSlave();
89 } 89 // }
90 return (HAL_StatusTypeDef)global.I2C_SystemStatus; 90 return (HAL_StatusTypeDef)global.I2C_SystemStatus;
91 } 91 }
92 92
93 93
94 void I2C_DeInit(void) 94 void I2C_DeInit(void)
164 { 164 {
165 I2C_Error_count(); 165 I2C_Error_count();
166 } 166 }
167 167
168 global.dataSendToSlaveStopEval = 0; 168 global.dataSendToSlaveStopEval = 0;
169 if(global.dataSendToSlavePending) 169 // if(global.dataSendToSlavePending)
170 { 170 // {
171 scheduleSpecial_Evaluate_DataSendToSlave(); 171 //
172 } 172 // }
173 scheduleSpecial_Evaluate_DataSendToSlave();
173 return (HAL_StatusTypeDef)localHALstatusReturn; 174 return (HAL_StatusTypeDef)localHALstatusReturn;
174 } 175 }
175 176