comparison Small_CPU/Src/spi.c @ 104:22a1094545f3 kittz

Tested and alive.
author Dmitry Romanov <kitt@bk.ru>
date Mon, 24 Dec 2018 16:15:02 +0300
parents 83857eb3b12b
children 6347a86caa18
comparison
equal deleted inserted replaced
103:f5d2f02dc73f 104:22a1094545f3
122 hspi1.Init.Direction = SPI_DIRECTION_2LINES; 122 hspi1.Init.Direction = SPI_DIRECTION_2LINES;
123 hspi1.Init.DataSize = SPI_DATASIZE_8BIT; 123 hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
124 hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; 124 hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
125 hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; 125 hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
126 hspi1.Init.NSS = SPI_NSS_HARD_INPUT; //SPI_NSS_SOFT; 126 hspi1.Init.NSS = SPI_NSS_HARD_INPUT; //SPI_NSS_SOFT;
127 hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64; 127 hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
128 hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; 128 hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
129 hspi1.Init.TIMode = SPI_TIMODE_DISABLED; 129 hspi1.Init.TIMode = SPI_TIMODE_DISABLED;
130 hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED; //_DISABLED; _ENABLED; 130 hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED; //_DISABLED; _ENABLED;
131 hspi1.Init.CRCPolynomial = 7; 131 hspi1.Init.CRCPolynomial = 7;
132 HAL_SPI_Init(&hspi1); 132 HAL_SPI_Init(&hspi1);
323 global.dataSendToSlaveIsNotValidCount = 0; 323 global.dataSendToSlaveIsNotValidCount = 0;
324 } else { 324 } else {
325 // GPIO_new_DEBUG_LOW(); //For debug. 325 // GPIO_new_DEBUG_LOW(); //For debug.
326 global.dataSendToSlaveIsValid = 0; 326 global.dataSendToSlaveIsValid = 0;
327 global.dataSendToSlaveIsNotValidCount++; 327 global.dataSendToSlaveIsNotValidCount++;
328 MX_SPI_DeInit();
329 HAL_Delay(30);
330 MX_DMA_Init();
331 MX_SPI1_Init();
328 } 332 }
329 global.dataSendToMaster.power_on_reset = 0; 333 global.dataSendToMaster.power_on_reset = 0;
330 global.deviceDataSendToMaster.power_on_reset = 0; 334 global.deviceDataSendToMaster.power_on_reset = 0;
331 335
332 336 //TODO:REMOVE
333 // if ( !global.dataSendToSlaveStopEval ) { 337 // if ( !global.dataSendToSlaveStopEval ) {
334 // scheduleSpecial_Evaluate_DataSendToSlave(); 338 // scheduleSpecial_Evaluate_DataSendToSlave();
335 // } 339 // }
336 scheduleSpecial_Evaluate_DataSendToSlave(); 340 scheduleSpecial_Evaluate_DataSendToSlave();
337 SPI_Start_single_TxRx_with_Master(); 341 SPI_Start_single_TxRx_with_Master(); //Send data always.
338 } 342 }
339 } 343 }
340 344
341 static uint8_t SPI_check_header_and_footer_ok(void) { 345 static uint8_t SPI_check_header_and_footer_ok(void) {
342 if (global.dataSendToSlave.header.checkCode[0] != 0xBB) 346 if (global.dataSendToSlave.header.checkCode[0] != 0xBB)