From da4743257980448c8e5de958d63c381ee7118359 Mon Sep 17 00:00:00 2001 From: yincheng.zhong <634916154@qq.com> Date: 星期三, 07 六月 2023 15:52:55 +0800 Subject: [PATCH] V1.64 重大更新 1.修改初始化代码,降低设备待机功耗到100ua(原来500ua)。 2.待机模式(无标签)5秒测距一次。 3.增加基站心跳包功能,携带基站版本号,功率,小组ID,电量,校准距离等参数,每分钟输出一次。 --- Src/OnChipDevices/Spi.c | 59 ++++++++++++++++++++++++++++------------------------------- 1 files changed, 28 insertions(+), 31 deletions(-) diff --git a/Src/OnChipDevices/Spi.c b/Src/OnChipDevices/Spi.c index 0e7d8fd..ba65d6a 100644 --- a/Src/OnChipDevices/Spi.c +++ b/Src/OnChipDevices/Spi.c @@ -46,26 +46,23 @@ SPIx_CS_GPIO->BRR = SPIx_CS; // delay_ms(1); - tt=HAL_SPI_Transmit(&hspi1,headerBuffer,headerLength,10); - tt=HAL_SPI_Transmit(&hspi1,bodyBuffer,bodylength,10); +// tt=HAL_SPI_Transmit(&hspi1,headerBuffer,headerLength,10); +// tt=HAL_SPI_Transmit(&hspi1,bodyBuffer,bodylength,10); // delay_ms(1); -// for(i = 0; i < headerLength; i++) -// { -// SPIx->DR = headerBuffer[i]; + for(i = 0; i < headerLength; i++) + { + SPIx->DR= headerBuffer[i]; + while ((SPIx->SR & SPI_FLAG_RXNE) == (uint16_t)RESET); + SPIx->DR; -// while ((SPIx->SR & SPI_FLAG_RXNE) == (uint16_t)RESET); + } -// SPIx->DR ; -// } - -// for(i = 0; i < bodylength; i++) -// { -// SPIx->DR = bodyBuffer[i]; - -// while((SPIx->SR & SPI_FLAG_RXNE) == (uint16_t)RESET); - -// SPIx->DR ; -// } + for(i = 0; i < bodylength; i++) + { + SPIx->DR = bodyBuffer[i]; + while ((SPIx->SR & SPI_FLAG_RXNE) == (uint16_t)RESET); + SPIx->DR ; + } SPIx_CS_GPIO->BSRR = SPIx_CS; @@ -102,25 +99,25 @@ //while (port_SPIx_busy_sending()); SPIx_CS_GPIO->BRR = SPIx_CS; - HAL_SPI_Transmit(&hspi1,headerBuffer,headerLength,10); - HAL_SPI_Receive(&hspi1,readBuffer,readlength,10); -// for(i = 0; i < headerLength; i++) -// { -// SPIx->DR = headerBuffer[i]; +// HAL_SPI_Transmit(&hspi1,headerBuffer,headerLength,10); +// HAL_SPI_Receive(&hspi1,readBuffer,readlength,10); + for(i = 0; i < headerLength; i++) + { + SPIx->DR = headerBuffer[i]; -// while((SPIx->SR & SPI_FLAG_RXNE) == (uint16_t)RESET); + while((SPIx->SR & SPI_FLAG_RXNE) == (uint16_t)RESET); -// readBuffer[0] = SPIx->DR ; // Dummy read as we write the header -// } + readBuffer[0] = SPIx->DR ; // Dummy read as we write the header + } -// for(i = 0; i < readlength; i++) -// { -// SPIx->DR = 0; // Dummy write as we read the message body + for(i = 0; i < readlength; i++) + { + SPIx->DR = 0; // Dummy write as we read the message body -// while((SPIx->SR & SPI_FLAG_RXNE) == (uint16_t)RESET); + while((SPIx->SR & SPI_FLAG_RXNE) == (uint16_t)RESET); -// readBuffer[i] = SPIx->DR ;//port_SPIx_receive_data(); //this clears RXNE bit -// } + readBuffer[i] = SPIx->DR ;//port_SPIx_receive_data(); //this clears RXNE bit + } SPIx_CS_GPIO->BSRR = SPIx_CS; -- Gitblit v1.9.3