Mercurial > public > ostc4
comparison Small_CPU/Src/i2c.c @ 84:e6abbef57475 kittz
Remove unusable code!!! prepare data for SPI in ONLY 1 IRQ!!!!
author | Dmitry Romanov <kitt@bk.ru> |
---|---|
date | Wed, 21 Nov 2018 10:25:15 +0300 |
parents | a6f0881074a4 |
children | 3db7389d49cc |
comparison
equal
deleted
inserted
replaced
83:ef4f45df70c1 | 84:e6abbef57475 |
---|---|
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; | |
80 | 79 |
81 global.I2C_SystemStatus = HAL_I2C_Init(&I2cHandle); | 80 global.I2C_SystemStatus = HAL_I2C_Init(&I2cHandle); |
82 HAL_I2CEx_AnalogFilter_Config(&I2cHandle, I2C_ANALOGFILTER_ENABLED); | 81 HAL_I2CEx_AnalogFilter_Config(&I2cHandle, I2C_ANALOGFILTER_ENABLED); |
83 | 82 |
84 | 83 |
85 global.dataSendToSlaveStopEval = 0; | 84 // if(global.dataSendToSlavePending) |
86 if(global.dataSendToSlavePending) | 85 // { |
87 { | 86 // scheduleSpecial_Evaluate_DataSendToSlave(); |
88 scheduleSpecial_Evaluate_DataSendToSlave(); | 87 // } |
89 } | 88 global.dataUpdateIsNeeded = 1; |
90 return (HAL_StatusTypeDef)global.I2C_SystemStatus; | 89 return (HAL_StatusTypeDef)global.I2C_SystemStatus; |
91 } | 90 } |
92 | 91 |
93 | 92 |
94 void I2C_DeInit(void) | 93 void I2C_DeInit(void) |
108 HAL_StatusTypeDef I2C_Master_TransmitNoStop( uint16_t DevAddress, uint8_t *pData, uint16_t Size) | 107 HAL_StatusTypeDef I2C_Master_TransmitNoStop( uint16_t DevAddress, uint8_t *pData, uint16_t Size) |
109 { | 108 { |
110 if(global.I2C_SystemStatus != HAL_OK) | 109 if(global.I2C_SystemStatus != HAL_OK) |
111 return (HAL_StatusTypeDef)global.I2C_SystemStatus; | 110 return (HAL_StatusTypeDef)global.I2C_SystemStatus; |
112 | 111 |
113 global.dataSendToSlaveStopEval = 1; | |
114 | 112 |
113 | |
115 global.I2C_SystemStatus = HAL_I2C_Master_Transmit(&I2cHandle, DevAddress, pData, Size, 100 /*FIXME , 0*/); | 114 global.I2C_SystemStatus = HAL_I2C_Master_Transmit(&I2cHandle, DevAddress, pData, Size, 100 /*FIXME , 0*/); |
116 if(global.I2C_SystemStatus != HAL_OK) | 115 if(global.I2C_SystemStatus != HAL_OK) |
117 { | 116 { |
118 I2C_Error_count(); | 117 I2C_Error_count(); |
119 } | 118 } |
120 global.dataSendToSlaveStopEval = 0; | 119 |
121 if(global.dataSendToSlavePending) | 120 // if(global.dataSendToSlavePending) |
122 { | 121 // { |
123 scheduleSpecial_Evaluate_DataSendToSlave(); | 122 // scheduleSpecial_Evaluate_DataSendToSlave(); |
124 } | 123 // } |
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 global.dataSendToSlaveStopEval = 1; | 135 |
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 global.dataSendToSlaveStopEval = 0; | 143 // if(global.dataSendToSlavePending) |
144 if(global.dataSendToSlavePending) | 144 // { |
145 { | 145 // scheduleSpecial_Evaluate_DataSendToSlave(); |
146 scheduleSpecial_Evaluate_DataSendToSlave(); | 146 // } |
147 } | 147 // |
148 | 148 global.dataUpdateIsNeeded = 1; |
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; | |
161 | 160 |
162 localHALstatusReturn = HAL_I2C_Master_Receive(&I2cHandle, DevAddress, pData, Size, 100); | 161 localHALstatusReturn = HAL_I2C_Master_Receive(&I2cHandle, DevAddress, pData, Size, 100); |
163 if(localHALstatusReturn != HAL_OK) | 162 if(localHALstatusReturn != HAL_OK) |
164 { | 163 { |
165 I2C_Error_count(); | 164 I2C_Error_count(); |
166 } | 165 } |
167 | 166 |
168 global.dataSendToSlaveStopEval = 0; | 167 global.dataUpdateIsNeeded = 1; |
169 if(global.dataSendToSlavePending) | 168 // if(global.dataSendToSlavePending) |
170 { | 169 // { |
171 scheduleSpecial_Evaluate_DataSendToSlave(); | 170 // scheduleSpecial_Evaluate_DataSendToSlave(); |
172 } | 171 // } |
173 return (HAL_StatusTypeDef)localHALstatusReturn; | 172 return (HAL_StatusTypeDef)localHALstatusReturn; |
174 } | 173 } |
175 | 174 |