Mercurial > public > ostc4
comparison Small_CPU/Src/i2c.c @ 100:b364c75005bb kittz
Stable.fix.
author | Dmitry Romanov <kitt@bk.ru> |
---|---|
date | Tue, 27 Nov 2018 12:59:56 +0300 |
parents | c6d284ea265b |
children | 22a1094545f3 |
comparison
equal
deleted
inserted
replaced
99:6a2308b9a3d4 | 100:b364c75005bb |
---|---|
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 = 100000;//400000; | 72 I2cHandle.Init.ClockSpeed = 400000;//400000; |
73 I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED; | 73 I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED; |
74 I2cHandle.Init.DutyCycle = I2C_DUTYCYCLE_2; | 74 I2cHandle.Init.DutyCycle = I2C_DUTYCYCLE_16_9; |
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; |
80 | 80 |
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 HAL_I2CEx_ConfigDigitalFilter(&I2cHandle,0x0F); | |
84 | |
83 | 85 |
84 | 86 |
85 global.dataSendToSlaveStopEval = 0; | 87 global.dataSendToSlaveStopEval = 0; |
86 // if(global.dataSendToSlavePending) | 88 if(global.dataSendToSlavePending) |
87 // { | 89 { |
88 // scheduleSpecial_Evaluate_DataSendToSlave(); | 90 scheduleSpecial_Evaluate_DataSendToSlave(); |
89 // } | 91 } |
90 return (HAL_StatusTypeDef)global.I2C_SystemStatus; | 92 return (HAL_StatusTypeDef)global.I2C_SystemStatus; |
91 } | 93 } |
92 | 94 |
93 | 95 |
94 void I2C_DeInit(void) | 96 void I2C_DeInit(void) |
116 if(global.I2C_SystemStatus != HAL_OK) | 118 if(global.I2C_SystemStatus != HAL_OK) |
117 { | 119 { |
118 I2C_Error_count(); | 120 I2C_Error_count(); |
119 } | 121 } |
120 global.dataSendToSlaveStopEval = 0; | 122 global.dataSendToSlaveStopEval = 0; |
121 if(global.dataSendToSlavePending) | 123 // if(global.dataSendToSlavePending) |
122 { | 124 // { |
123 scheduleSpecial_Evaluate_DataSendToSlave(); | 125 // scheduleSpecial_Evaluate_DataSendToSlave(); |
124 } | 126 // } |
125 return (HAL_StatusTypeDef)global.I2C_SystemStatus; | 127 return (HAL_StatusTypeDef)global.I2C_SystemStatus; |
126 } | 128 } |
127 | 129 |
128 | 130 |
129 HAL_StatusTypeDef I2C_Master_Transmit( uint16_t DevAddress, uint8_t *pData, uint16_t Size) | 131 HAL_StatusTypeDef I2C_Master_Transmit( uint16_t DevAddress, uint8_t *pData, uint16_t Size) |
139 { | 141 { |
140 I2C_Error_count(); | 142 I2C_Error_count(); |
141 } | 143 } |
142 | 144 |
143 global.dataSendToSlaveStopEval = 0; | 145 global.dataSendToSlaveStopEval = 0; |
144 if(global.dataSendToSlavePending) | 146 // if(global.dataSendToSlavePending) |
145 { | 147 // { |
146 scheduleSpecial_Evaluate_DataSendToSlave(); | 148 // scheduleSpecial_Evaluate_DataSendToSlave(); |
147 } | 149 // } |
148 | 150 |
149 return (HAL_StatusTypeDef)global.I2C_SystemStatus; | 151 return (HAL_StatusTypeDef)global.I2C_SystemStatus; |
150 } | 152 } |
151 | 153 |
152 | 154 |
166 } | 168 } |
167 | 169 |
168 global.dataSendToSlaveStopEval = 0; | 170 global.dataSendToSlaveStopEval = 0; |
169 // if(global.dataSendToSlavePending) | 171 // if(global.dataSendToSlavePending) |
170 // { | 172 // { |
171 // | 173 // scheduleSpecial_Evaluate_DataSendToSlave(); |
172 // } | 174 // } |
173 scheduleSpecial_Evaluate_DataSendToSlave(); | 175 |
174 return (HAL_StatusTypeDef)localHALstatusReturn; | 176 return (HAL_StatusTypeDef)localHALstatusReturn; |
175 } | 177 } |
176 | 178 |