comparison Discovery/Src/data_exchange_main.c @ 87:e746bf846638 kittz

tmp
author Dmitry Romanov <kitt@bk.ru>
date Wed, 21 Nov 2018 13:57:58 +0300
parents a6f0881074a4
children 3db7389d49cc
comparison
equal deleted inserted replaced
86:cc41b5eaf1a7 87:e746bf846638
304 uint8_t DataEX_call(void) 304 uint8_t DataEX_call(void)
305 { 305 {
306 uint8_t SPI_DMA_answer = 0; 306 uint8_t SPI_DMA_answer = 0;
307 307
308 HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_SET); 308 HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_SET);
309 delayMicros(10); 309 delayMicros(50); //~exchange time(+20% reserve)
310 310 HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_RESET);
311 /* one cycle with NotChipSelect true to clear slave spi buffer */ 311 /* one cycle with NotChipSelect true to clear slave spi buffer */
312 312
313 if(data_old__lost_connection_to_slave_counter_temp >= 3) 313 if(data_old__lost_connection_to_slave_counter_temp >= 3)
314 { 314 {
315 data_old__lost_connection_to_slave_counter_temp = 0; 315 data_old__lost_connection_to_slave_counter_temp = 0;
316 data_old__lost_connection_to_slave_counter_retry++; 316 data_old__lost_connection_to_slave_counter_retry++;
317 } 317 }
318 else 318 // else
319 { 319 // {
320 HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_RESET); 320 // HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_RESET);
321 } 321 // }
322 322
323 DataEx_call_helper_requests(); 323 DataEx_call_helper_requests();
324 324
325 systick_last = HAL_GetTick(); 325 systick_last = HAL_GetTick();
326 326
327 //HAL_GPIO_WritePin(OSCILLOSCOPE2_GPIO_PORT,OSCILLOSCOPE2_PIN,GPIO_PIN_RESET); /* only for testing with Oscilloscope */ 327 //HAL_GPIO_WritePin(OSCILLOSCOPE2_GPIO_PORT,OSCILLOSCOPE2_PIN,GPIO_PIN_RESET); /* only for testing with Oscilloscope */
328 328
329 SPI_DMA_answer = HAL_SPI_TransmitReceive_DMA(&cpu2DmaSpi, (uint8_t *)&dataOut, (uint8_t *)&dataIn, EXCHANGE_BUFFERSIZE+1); 329 SPI_DMA_answer = HAL_SPI_TransmitReceive_DMA(&cpu2DmaSpi, (uint8_t *)&dataOut, (uint8_t *)&dataIn, EXCHANGE_BUFFERSIZE+1);
330 HAL_Delay(3); 330 // HAL_Delay(3);
331 if(SPI_DMA_answer != HAL_OK) 331 if(SPI_DMA_answer != HAL_OK)
332 DataEX_Error_Handler(SPI_DMA_answer); 332 DataEX_Error_Handler(SPI_DMA_answer);
333 //HAL_Delay(3); 333 //HAL_Delay(3);
334 //HAL_GPIO_WritePin(OSCILLOSCOPE2_GPIO_PORT,OSCILLOSCOPE2_PIN,GPIO_PIN_SET); /* only for testing with Oscilloscope */ 334 //HAL_GPIO_WritePin(OSCILLOSCOPE2_GPIO_PORT,OSCILLOSCOPE2_PIN,GPIO_PIN_SET); /* only for testing with Oscilloscope */
335 335