This commit is contained in:
2026-05-28 17:53:50 +03:00
parent d65a758c31
commit c7aedab9cd
22 changed files with 359 additions and 583 deletions

View File

@@ -20,7 +20,6 @@
#include "main.h"
#include "adc.h"
#include "i2c.h"
#include "rtc.h"
#include "tim.h"
#include "usart.h"
#include "gpio.h"
@@ -133,9 +132,44 @@ int main(void)
MX_TIM2_Init();
MX_ADC1_Init();
MX_I2C1_Init();
// MX_RTC_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */
// #ifdef USART1_PA6_PA7
// HAL_UART_DeInit(&huart1);
// GPIO_InitTypeDef GPIO_InitStruct = {0};
//
// /* USER CODE BEGIN USART1_MspInit 0 */
// /* USER CODE END USART1_MspInit 0 */
// /* USART1 clock enable */
// __HAL_RCC_USART1_CLK_ENABLE();
// __HAL_RCC_GPIOB_CLK_ENABLE();
// /**USART1 GPIO Configuration
// PA9 ------> USART1_TX
// PA10 ------> USART1_RX
// */
// GPIO_InitStruct.Pin = GPIO_PIN_6;
// GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
// HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
// GPIO_InitStruct.Pin = GPIO_PIN_7;
// GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
// GPIO_InitStruct.Pull = GPIO_NOPULL;
// HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
// /* USART1 interrupt Init */
// HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
// HAL_NVIC_EnableIRQ(USART1_IRQn);
//
//
//
// if (HAL_UART_Init(&huart1) != HAL_OK)
// {
// Error_Handler();
// }
// #endif
LED_BlinkRx_Config_t led_rx =
{
.port = GPIOC,
@@ -221,7 +255,7 @@ int main(void)
static uint16_t dataLE[2];
uint32_t start_dwt = get_cycle_count();
uint32_t start = HAL_GetTick();
Dallas_StartConvertTAll(&hdallas, DALLAS_WAIT_NONE, 0);
Dallas_StartConvertTAll(&hdallas, DALLAS_WAIT_DELAY, 200);
uint32_t end_dwt = get_cycle_count();
uint32_t end = HAL_GetTick();
uint32_t time_DWT=end_dwt-start_dwt;
@@ -281,11 +315,10 @@ void SystemClock_Config(void)
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
@@ -307,8 +340,7 @@ void SystemClock_Config(void)
{
Error_Handler();
}
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_ADC;
PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;
PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{