comparison Small_CPU/Src/i2c.c @ 88:3db7389d49cc kittz

revert
author Dmitry Romanov <kitt@bk.ru>
date Thu, 22 Nov 2018 12:02:55 +0300
parents e6abbef57475
children c6d284ea265b
comparison
equal deleted inserted replaced
87:e746bf846638 88:3db7389d49cc
74 I2cHandle.Init.DutyCycle = I2C_DUTYCYCLE_16_9; 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 80
80 global.I2C_SystemStatus = HAL_I2C_Init(&I2cHandle); 81 global.I2C_SystemStatus = HAL_I2C_Init(&I2cHandle);
81 HAL_I2CEx_AnalogFilter_Config(&I2cHandle, I2C_ANALOGFILTER_ENABLED); 82 HAL_I2CEx_AnalogFilter_Config(&I2cHandle, I2C_ANALOGFILTER_ENABLED);
82 83
83 84
84 // if(global.dataSendToSlavePending) 85 global.dataSendToSlaveStopEval = 0;
85 // { 86 if(global.dataSendToSlavePending)
86 // scheduleSpecial_Evaluate_DataSendToSlave(); 87 {
87 // } 88 scheduleSpecial_Evaluate_DataSendToSlave();
88 global.dataUpdateIsNeeded = 1; 89 }
89 return (HAL_StatusTypeDef)global.I2C_SystemStatus; 90 return (HAL_StatusTypeDef)global.I2C_SystemStatus;
90 } 91 }
91 92
92 93
93 void I2C_DeInit(void) 94 void I2C_DeInit(void)
107 HAL_StatusTypeDef I2C_Master_TransmitNoStop( uint16_t DevAddress, uint8_t *pData, uint16_t Size) 108 HAL_StatusTypeDef I2C_Master_TransmitNoStop( uint16_t DevAddress, uint8_t *pData, uint16_t Size)
108 { 109 {
109 if(global.I2C_SystemStatus != HAL_OK) 110 if(global.I2C_SystemStatus != HAL_OK)
110 return (HAL_StatusTypeDef)global.I2C_SystemStatus; 111 return (HAL_StatusTypeDef)global.I2C_SystemStatus;
111 112
113 global.dataSendToSlaveStopEval = 1;
112 114
113
114 global.I2C_SystemStatus = HAL_I2C_Master_Transmit(&I2cHandle, DevAddress, pData, Size, 100 /*FIXME , 0*/); 115 global.I2C_SystemStatus = HAL_I2C_Master_Transmit(&I2cHandle, DevAddress, pData, Size, 100 /*FIXME , 0*/);
115 if(global.I2C_SystemStatus != HAL_OK) 116 if(global.I2C_SystemStatus != HAL_OK)
116 { 117 {
117 I2C_Error_count(); 118 I2C_Error_count();
118 } 119 }
119 120 global.dataSendToSlaveStopEval = 0;
120 // if(global.dataSendToSlavePending) 121 if(global.dataSendToSlavePending)
121 // { 122 {
122 // scheduleSpecial_Evaluate_DataSendToSlave(); 123 scheduleSpecial_Evaluate_DataSendToSlave();
123 // } 124 }
124 global.dataUpdateIsNeeded = 1;
125 return (HAL_StatusTypeDef)global.I2C_SystemStatus; 125 return (HAL_StatusTypeDef)global.I2C_SystemStatus;
126 } 126 }
127 127
128 128
129 HAL_StatusTypeDef I2C_Master_Transmit( uint16_t DevAddress, uint8_t *pData, uint16_t Size) 129 HAL_StatusTypeDef I2C_Master_Transmit( uint16_t DevAddress, uint8_t *pData, uint16_t Size)
130 { 130 {
131 if(global.I2C_SystemStatus != HAL_OK) 131 if(global.I2C_SystemStatus != HAL_OK)
132 return (HAL_StatusTypeDef)(global.I2C_SystemStatus & 0x03); 132 return (HAL_StatusTypeDef)(global.I2C_SystemStatus & 0x03);
133 133
134 134
135 135 global.dataSendToSlaveStopEval = 1;
136 136
137 global.I2C_SystemStatus = HAL_I2C_Master_Transmit(&I2cHandle, DevAddress, pData, Size, 100 /*FIXME , 1*/); 137 global.I2C_SystemStatus = HAL_I2C_Master_Transmit(&I2cHandle, DevAddress, pData, Size, 100 /*FIXME , 1*/);
138 if(global.I2C_SystemStatus != HAL_OK) 138 if(global.I2C_SystemStatus != HAL_OK)
139 { 139 {
140 I2C_Error_count(); 140 I2C_Error_count();
141 } 141 }
142 142
143 // if(global.dataSendToSlavePending) 143 global.dataSendToSlaveStopEval = 0;
144 // { 144 if(global.dataSendToSlavePending)
145 // scheduleSpecial_Evaluate_DataSendToSlave(); 145 {
146 // } 146 scheduleSpecial_Evaluate_DataSendToSlave();
147 // 147 }
148 global.dataUpdateIsNeeded = 1; 148
149 return (HAL_StatusTypeDef)global.I2C_SystemStatus; 149 return (HAL_StatusTypeDef)global.I2C_SystemStatus;
150 } 150 }
151 151
152 152
153 HAL_StatusTypeDef I2C_Master_Receive( uint16_t DevAddress, uint8_t *pData, uint16_t Size) 153 HAL_StatusTypeDef I2C_Master_Receive( uint16_t DevAddress, uint8_t *pData, uint16_t Size)
155 if(global.I2C_SystemStatus != HAL_OK) 155 if(global.I2C_SystemStatus != HAL_OK)
156 return (HAL_StatusTypeDef)global.I2C_SystemStatus; 156 return (HAL_StatusTypeDef)global.I2C_SystemStatus;
157 157
158 uint8_t localHALstatusReturn = 0xFF; 158 uint8_t localHALstatusReturn = 0xFF;
159 159
160 global.dataSendToSlaveStopEval = 1;
160 161
161 localHALstatusReturn = HAL_I2C_Master_Receive(&I2cHandle, DevAddress, pData, Size, 100); 162 localHALstatusReturn = HAL_I2C_Master_Receive(&I2cHandle, DevAddress, pData, Size, 100);
162 if(localHALstatusReturn != HAL_OK) 163 if(localHALstatusReturn != HAL_OK)
163 { 164 {
164 I2C_Error_count(); 165 I2C_Error_count();
165 } 166 }
166 167
167 global.dataUpdateIsNeeded = 1; 168 global.dataSendToSlaveStopEval = 0;
168 // if(global.dataSendToSlavePending) 169 if(global.dataSendToSlavePending)
169 // { 170 {
170 // scheduleSpecial_Evaluate_DataSendToSlave(); 171 scheduleSpecial_Evaluate_DataSendToSlave();
171 // } 172 }
172 return (HAL_StatusTypeDef)localHALstatusReturn; 173 return (HAL_StatusTypeDef)localHALstatusReturn;
173 } 174 }
174 175