期末大作业-增加数码管
This commit is contained in:
		
							parent
							
								
									26b284daac
								
							
						
					
					
						commit
						cc80d09aeb
					
				
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										21
									
								
								FinalHomework/Core/Inc/SegLed.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								FinalHomework/Core/Inc/SegLed.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#ifndef __SEGLED_H
 | 
			
		||||
#define __SEGLED_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include "variable.h"
 | 
			
		||||
 | 
			
		||||
void Display(void);
 | 
			
		||||
void TimeToBuff(structTime *nstTime);
 | 
			
		||||
void DispToBuff(uint8_t val);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __SEGLED_H */
 | 
			
		||||
@ -59,6 +59,16 @@ void Error_Handler(void);
 | 
			
		||||
/* Private defines -----------------------------------------------------------*/
 | 
			
		||||
#define TickLed_Pin GPIO_PIN_13
 | 
			
		||||
#define TickLed_GPIO_Port GPIOC
 | 
			
		||||
#define AddrA_Pin GPIO_PIN_0
 | 
			
		||||
#define AddrA_GPIO_Port GPIOC
 | 
			
		||||
#define AddrB_Pin GPIO_PIN_1
 | 
			
		||||
#define AddrB_GPIO_Port GPIOC
 | 
			
		||||
#define AddrC_Pin GPIO_PIN_2
 | 
			
		||||
#define AddrC_GPIO_Port GPIOC
 | 
			
		||||
#define OE_Pin GPIO_PIN_3
 | 
			
		||||
#define OE_GPIO_Port GPIOC
 | 
			
		||||
#define SegLedData_Pin GPIO_PIN_0
 | 
			
		||||
#define SegLedData_GPIO_Port GPIOA
 | 
			
		||||
#define LCD_RST_Pin GPIO_PIN_11
 | 
			
		||||
#define LCD_RST_GPIO_Port GPIOB
 | 
			
		||||
#define LCD_CS_Pin GPIO_PIN_12
 | 
			
		||||
 | 
			
		||||
@ -62,7 +62,7 @@
 | 
			
		||||
/*#define HAL_SMBUS_MODULE_ENABLED   */
 | 
			
		||||
#define HAL_SPI_MODULE_ENABLED
 | 
			
		||||
/*#define HAL_SRAM_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_TIM_MODULE_ENABLED   */
 | 
			
		||||
#define HAL_TIM_MODULE_ENABLED
 | 
			
		||||
/*#define HAL_UART_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_USART_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_WWDG_MODULE_ENABLED   */
 | 
			
		||||
 | 
			
		||||
@ -55,6 +55,7 @@ void SVC_Handler(void);
 | 
			
		||||
void DebugMon_Handler(void);
 | 
			
		||||
void PendSV_Handler(void);
 | 
			
		||||
void SysTick_Handler(void);
 | 
			
		||||
void TIM3_IRQHandler(void);
 | 
			
		||||
/* USER CODE BEGIN EFP */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END EFP */
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										52
									
								
								FinalHomework/Core/Inc/tim.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								FinalHomework/Core/Inc/tim.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,52 @@
 | 
			
		||||
/* USER CODE BEGIN Header */
 | 
			
		||||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    tim.h
 | 
			
		||||
  * @brief   This file contains all the function prototypes for
 | 
			
		||||
  *          the tim.c file
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * Copyright (c) 2025 STMicroelectronics.
 | 
			
		||||
  * All rights reserved.
 | 
			
		||||
  *
 | 
			
		||||
  * This software is licensed under terms that can be found in the LICENSE file
 | 
			
		||||
  * in the root directory of this software component.
 | 
			
		||||
  * If no LICENSE file comes with this software, it is provided AS-IS.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
/* USER CODE END Header */
 | 
			
		||||
/* Define to prevent recursive inclusion -------------------------------------*/
 | 
			
		||||
#ifndef __TIM_H__
 | 
			
		||||
#define __TIM_H__
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "main.h"
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN Includes */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END Includes */
 | 
			
		||||
 | 
			
		||||
extern TIM_HandleTypeDef htim3;
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN Private defines */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END Private defines */
 | 
			
		||||
 | 
			
		||||
void MX_TIM3_Init(void);
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN Prototypes */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END Prototypes */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __TIM_H__ */
 | 
			
		||||
 | 
			
		||||
@ -13,6 +13,16 @@ typedef struct {
 | 
			
		||||
    uint8_t bTimeOk;                // 秒标志位
 | 
			
		||||
} stSysTickTimer;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  uint8_t mSecond;
 | 
			
		||||
  uint8_t mMinute;
 | 
			
		||||
  uint8_t mHour;
 | 
			
		||||
  uint8_t mTimeCount;
 | 
			
		||||
  uint8_t bSecondIsOk;
 | 
			
		||||
  uint8_t mTenMilCount;
 | 
			
		||||
  uint8_t bTenMilIsOk;
 | 
			
		||||
} structTime;
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										64
									
								
								FinalHomework/Core/Src/SegLed.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								FinalHomework/Core/Src/SegLed.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,64 @@
 | 
			
		||||
#include "main.h"
 | 
			
		||||
#include "variable.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
uint16_t display_tab[] = {
 | 
			
		||||
  0x3f,
 | 
			
		||||
  0x06,
 | 
			
		||||
  0x5b,
 | 
			
		||||
  0x4f,
 | 
			
		||||
  0x66,
 | 
			
		||||
  0x6d,
 | 
			
		||||
  0x7d,
 | 
			
		||||
  0x07,
 | 
			
		||||
  0x7f,
 | 
			
		||||
  0x6f,
 | 
			
		||||
  0x77,
 | 
			
		||||
  0x7c,
 | 
			
		||||
  0x39,
 | 
			
		||||
  0x5e,
 | 
			
		||||
  0x79,
 | 
			
		||||
  0x71,
 | 
			
		||||
  0x40
 | 
			
		||||
};
 | 
			
		||||
uint8_t DispBuff[8];
 | 
			
		||||
uint16_t PosSel = 0;
 | 
			
		||||
 | 
			
		||||
static void DisplayOneLed(uint8_t dat, uint8_t pos, uint8_t dot) {
 | 
			
		||||
  uint16_t temp;
 | 
			
		||||
 | 
			
		||||
  temp = display_tab[dat];
 | 
			
		||||
  if (dot)
 | 
			
		||||
    temp |= 0x80;
 | 
			
		||||
  
 | 
			
		||||
  SegLedData_GPIO_Port->ODR &= 0xFF00;
 | 
			
		||||
  SegLedData_GPIO_Port->ODR |= temp; // 段码
 | 
			
		||||
  AddrA_GPIO_Port->ODR &= 0xFFF0;
 | 
			
		||||
  AddrA_GPIO_Port->ODR |= pos; // 位码
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Display(void) {
 | 
			
		||||
  static uint8_t mPos = 0;
 | 
			
		||||
  DisplayOneLed(DispBuff[mPos], mPos, 0);
 | 
			
		||||
  if (++mPos >= 8) mPos = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TimeToBuff(structTime *nstTime) {
 | 
			
		||||
  DispBuff[0] = nstTime->mHour / 10;
 | 
			
		||||
  DispBuff[1] = nstTime->mHour % 10;
 | 
			
		||||
  DispBuff[2] = 16;
 | 
			
		||||
  DispBuff[3] = nstTime->mMinute / 10;
 | 
			
		||||
  DispBuff[4] = nstTime->mMinute % 10;
 | 
			
		||||
  DispBuff[5] = 16;
 | 
			
		||||
  DispBuff[6] = nstTime->mSecond / 10;
 | 
			
		||||
  DispBuff[7] = nstTime->mSecond % 10;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DispToBuff(uint8_t val) {
 | 
			
		||||
  uint8_t i;
 | 
			
		||||
  for (int i = 0; i < 7; i++) {
 | 
			
		||||
    DispBuff[i] = DispBuff[i + 1];
 | 
			
		||||
  }
 | 
			
		||||
  DispBuff[7] = val;
 | 
			
		||||
}
 | 
			
		||||
@ -47,21 +47,37 @@ void MX_GPIO_Init(void)
 | 
			
		||||
  /* GPIO Ports Clock Enable */
 | 
			
		||||
  __HAL_RCC_GPIOC_CLK_ENABLE();
 | 
			
		||||
  __HAL_RCC_GPIOF_CLK_ENABLE();
 | 
			
		||||
  __HAL_RCC_GPIOB_CLK_ENABLE();
 | 
			
		||||
  __HAL_RCC_GPIOA_CLK_ENABLE();
 | 
			
		||||
  __HAL_RCC_GPIOB_CLK_ENABLE();
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin Output Level */
 | 
			
		||||
  HAL_GPIO_WritePin(TickLed_GPIO_Port, TickLed_Pin, GPIO_PIN_RESET);
 | 
			
		||||
  HAL_GPIO_WritePin(GPIOC, TickLed_Pin|AddrA_Pin|AddrB_Pin|AddrC_Pin
 | 
			
		||||
                          |OE_Pin, GPIO_PIN_RESET);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin Output Level */
 | 
			
		||||
  HAL_GPIO_WritePin(GPIOA, SegLedData_Pin|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
 | 
			
		||||
                          |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7, GPIO_PIN_SET);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin Output Level */
 | 
			
		||||
  HAL_GPIO_WritePin(GPIOB, LCD_RST_Pin|LCD_CS_Pin|LCD_RS_Pin, GPIO_PIN_RESET);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pin : PtPin */
 | 
			
		||||
  GPIO_InitStruct.Pin = TickLed_Pin;
 | 
			
		||||
  /*Configure GPIO pins : PCPin PCPin PCPin PCPin
 | 
			
		||||
                           PCPin */
 | 
			
		||||
  GPIO_InitStruct.Pin = TickLed_Pin|AddrA_Pin|AddrB_Pin|AddrC_Pin
 | 
			
		||||
                          |OE_Pin;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_PULLUP;
 | 
			
		||||
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
  HAL_GPIO_Init(TickLed_GPIO_Port, &GPIO_InitStruct);
 | 
			
		||||
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pins : PAPin PA1 PA2 PA3
 | 
			
		||||
                           PA4 PA5 PA6 PA7 */
 | 
			
		||||
  GPIO_InitStruct.Pin = SegLedData_Pin|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
 | 
			
		||||
                          |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
 | 
			
		||||
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 | 
			
		||||
  GPIO_InitStruct.Pull = GPIO_PULLUP;
 | 
			
		||||
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
  /*Configure GPIO pins : PBPin PBPin PBPin */
 | 
			
		||||
  GPIO_InitStruct.Pin = LCD_RST_Pin|LCD_CS_Pin|LCD_RS_Pin;
 | 
			
		||||
 | 
			
		||||
@ -19,6 +19,7 @@
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "main.h"
 | 
			
		||||
#include "spi.h"
 | 
			
		||||
#include "tim.h"
 | 
			
		||||
#include "gpio.h"
 | 
			
		||||
 | 
			
		||||
/* Private includes ----------------------------------------------------------*/
 | 
			
		||||
@ -26,6 +27,7 @@
 | 
			
		||||
#include "variable.h"
 | 
			
		||||
#include "lcd.h"
 | 
			
		||||
#include "test.h"
 | 
			
		||||
#include "SegLed.h"
 | 
			
		||||
/* USER CODE END Includes */
 | 
			
		||||
 | 
			
		||||
/* Private typedef -----------------------------------------------------------*/
 | 
			
		||||
@ -49,8 +51,16 @@
 | 
			
		||||
stSysTickTimer sSysTickTimer = {
 | 
			
		||||
  0, 0, 0, 0
 | 
			
		||||
};
 | 
			
		||||
uint16_t mSecCount = 0;
 | 
			
		||||
uint16_t bSecondIsOk = 0;
 | 
			
		||||
uint8_t tempValue;
 | 
			
		||||
structTime stTime = {
 | 
			
		||||
  .mSecond = 50,
 | 
			
		||||
  .mMinute = 45,
 | 
			
		||||
  .mHour = 8,
 | 
			
		||||
  .mTimeCount = 0,
 | 
			
		||||
  .bSecondIsOk = 0,
 | 
			
		||||
  .mTenMilCount = 0,
 | 
			
		||||
  .bTenMilIsOk = 0
 | 
			
		||||
};
 | 
			
		||||
/* USER CODE END PV */
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
@ -94,8 +104,11 @@ int main(void)
 | 
			
		||||
  /* Initialize all configured peripherals */
 | 
			
		||||
  MX_GPIO_Init();
 | 
			
		||||
  MX_SPI2_Init();
 | 
			
		||||
  MX_TIM3_Init();
 | 
			
		||||
  /* USER CODE BEGIN 2 */
 | 
			
		||||
  LCD_Init();
 | 
			
		||||
  HAL_TIM_Base_Start_IT(&htim3);
 | 
			
		||||
  TimeToBuff(&stTime);
 | 
			
		||||
  /* USER CODE END 2 */
 | 
			
		||||
 | 
			
		||||
  /* Infinite loop */
 | 
			
		||||
@ -105,15 +118,31 @@ int main(void)
 | 
			
		||||
    /* USER CODE END WHILE */
 | 
			
		||||
 | 
			
		||||
    /* USER CODE BEGIN 3 */
 | 
			
		||||
    main_test();
 | 
			
		||||
    Test_Color();
 | 
			
		||||
    Test_FillRec();
 | 
			
		||||
    Test_Circle();
 | 
			
		||||
    Test_Triangle();
 | 
			
		||||
    English_Font_test();
 | 
			
		||||
    Chinese_Font_test();
 | 
			
		||||
    if (stTime.bTenMilIsOk) {
 | 
			
		||||
      stTime.bTenMilIsOk = 0;
 | 
			
		||||
    }
 | 
			
		||||
    if (stTime.bSecondIsOk) {
 | 
			
		||||
      stTime.bSecondIsOk = 0;
 | 
			
		||||
      if (++stTime.mSecond >= 60) {
 | 
			
		||||
        stTime.mSecond = 0;
 | 
			
		||||
        if (++stTime.mMinute >= 60) {
 | 
			
		||||
          stTime.mMinute = 0;
 | 
			
		||||
          if (++stTime.mHour >= 24) {
 | 
			
		||||
            stTime.mHour = 0;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      TimeToBuff(&stTime);
 | 
			
		||||
    }
 | 
			
		||||
    // main_test();
 | 
			
		||||
    // Test_Color();
 | 
			
		||||
    // Test_FillRec();
 | 
			
		||||
    // Test_Circle();
 | 
			
		||||
    // Test_Triangle();
 | 
			
		||||
    // English_Font_test();
 | 
			
		||||
    // Chinese_Font_test();
 | 
			
		||||
    Pic_test();
 | 
			
		||||
    Rotate_Test();
 | 
			
		||||
    // Rotate_Test();
 | 
			
		||||
    if (sSysTickTimer.bTimeOk) {
 | 
			
		||||
      sSysTickTimer.bTimeOk = 0;
 | 
			
		||||
      HAL_GPIO_TogglePin(TickLed_GPIO_Port, TickLed_Pin);
 | 
			
		||||
 | 
			
		||||
@ -56,11 +56,11 @@
 | 
			
		||||
/* USER CODE END 0 */
 | 
			
		||||
 | 
			
		||||
/* External variables --------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
extern TIM_HandleTypeDef htim3;
 | 
			
		||||
/* USER CODE BEGIN EV */
 | 
			
		||||
extern stSysTickTimer sSysTickTimer;
 | 
			
		||||
extern uint16_t mSecCount;
 | 
			
		||||
extern uint16_t bSecondIsOk;
 | 
			
		||||
extern structTime stTime;
 | 
			
		||||
extern void Display(void);
 | 
			
		||||
/* USER CODE END EV */
 | 
			
		||||
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
@ -190,11 +190,6 @@ void SysTick_Handler(void)
 | 
			
		||||
  /* USER CODE END SysTick_IRQn 0 */
 | 
			
		||||
  HAL_IncTick();
 | 
			
		||||
  /* USER CODE BEGIN SysTick_IRQn 1 */
 | 
			
		||||
  if (++mSecCount >= 100) {
 | 
			
		||||
    mSecCount = 0;
 | 
			
		||||
    bSecondIsOk = 1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (++sSysTickTimer.mMilSecCount >= 10) {
 | 
			
		||||
    sSysTickTimer.mMilSecCount = 0;
 | 
			
		||||
    sSysTickTimer.bTenMilSecOk = 1;
 | 
			
		||||
@ -213,6 +208,28 @@ void SysTick_Handler(void)
 | 
			
		||||
/* please refer to the startup file (startup_stm32g4xx.s).                    */
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief This function handles TIM3 global interrupt.
 | 
			
		||||
  */
 | 
			
		||||
void TIM3_IRQHandler(void)
 | 
			
		||||
{
 | 
			
		||||
  /* USER CODE BEGIN TIM3_IRQn 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM3_IRQn 0 */
 | 
			
		||||
  HAL_TIM_IRQHandler(&htim3);
 | 
			
		||||
  /* USER CODE BEGIN TIM3_IRQn 1 */
 | 
			
		||||
  Display();
 | 
			
		||||
  if (++stTime.mTenMilCount >= 10) {
 | 
			
		||||
    stTime.mTenMilCount = 0;
 | 
			
		||||
    stTime.bTenMilIsOk = 1;
 | 
			
		||||
    if (++stTime.mTimeCount >= 100) {
 | 
			
		||||
      stTime.mTimeCount = 0;
 | 
			
		||||
      stTime.bSecondIsOk = 1;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE END TIM3_IRQn 1 */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN 1 */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END 1 */
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										111
									
								
								FinalHomework/Core/Src/tim.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										111
									
								
								FinalHomework/Core/Src/tim.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,111 @@
 | 
			
		||||
/* USER CODE BEGIN Header */
 | 
			
		||||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    tim.c
 | 
			
		||||
  * @brief   This file provides code for the configuration
 | 
			
		||||
  *          of the TIM instances.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * Copyright (c) 2025 STMicroelectronics.
 | 
			
		||||
  * All rights reserved.
 | 
			
		||||
  *
 | 
			
		||||
  * This software is licensed under terms that can be found in the LICENSE file
 | 
			
		||||
  * in the root directory of this software component.
 | 
			
		||||
  * If no LICENSE file comes with this software, it is provided AS-IS.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
/* USER CODE END Header */
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "tim.h"
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN 0 */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END 0 */
 | 
			
		||||
 | 
			
		||||
TIM_HandleTypeDef htim3;
 | 
			
		||||
 | 
			
		||||
/* TIM3 init function */
 | 
			
		||||
void MX_TIM3_Init(void)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN TIM3_Init 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM3_Init 0 */
 | 
			
		||||
 | 
			
		||||
  TIM_ClockConfigTypeDef sClockSourceConfig = {0};
 | 
			
		||||
  TIM_MasterConfigTypeDef sMasterConfig = {0};
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN TIM3_Init 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM3_Init 1 */
 | 
			
		||||
  htim3.Instance = TIM3;
 | 
			
		||||
  htim3.Init.Prescaler = 170-1;
 | 
			
		||||
  htim3.Init.CounterMode = TIM_COUNTERMODE_CENTERALIGNED1;
 | 
			
		||||
  htim3.Init.Period = 999;
 | 
			
		||||
  htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
 | 
			
		||||
  htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
 | 
			
		||||
  if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
 | 
			
		||||
  if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
 | 
			
		||||
  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
 | 
			
		||||
  if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
 | 
			
		||||
  {
 | 
			
		||||
    Error_Handler();
 | 
			
		||||
  }
 | 
			
		||||
  /* USER CODE BEGIN TIM3_Init 2 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM3_Init 2 */
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  if(tim_baseHandle->Instance==TIM3)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN TIM3_MspInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM3_MspInit 0 */
 | 
			
		||||
    /* TIM3 clock enable */
 | 
			
		||||
    __HAL_RCC_TIM3_CLK_ENABLE();
 | 
			
		||||
 | 
			
		||||
    /* TIM3 interrupt Init */
 | 
			
		||||
    HAL_NVIC_SetPriority(TIM3_IRQn, 0, 0);
 | 
			
		||||
    HAL_NVIC_EnableIRQ(TIM3_IRQn);
 | 
			
		||||
  /* USER CODE BEGIN TIM3_MspInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM3_MspInit 1 */
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  if(tim_baseHandle->Instance==TIM3)
 | 
			
		||||
  {
 | 
			
		||||
  /* USER CODE BEGIN TIM3_MspDeInit 0 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM3_MspDeInit 0 */
 | 
			
		||||
    /* Peripheral clock disable */
 | 
			
		||||
    __HAL_RCC_TIM3_CLK_DISABLE();
 | 
			
		||||
 | 
			
		||||
    /* TIM3 interrupt Deinit */
 | 
			
		||||
    HAL_NVIC_DisableIRQ(TIM3_IRQn);
 | 
			
		||||
  /* USER CODE BEGIN TIM3_MspDeInit 1 */
 | 
			
		||||
 | 
			
		||||
  /* USER CODE END TIM3_MspDeInit 1 */
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN 1 */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END 1 */
 | 
			
		||||
							
								
								
									
										6724
									
								
								FinalHomework/Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_tim.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6724
									
								
								FinalHomework/Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_tim.h
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -11,22 +11,36 @@ Mcu.IP0=NVIC
 | 
			
		||||
Mcu.IP1=RCC
 | 
			
		||||
Mcu.IP2=SPI2
 | 
			
		||||
Mcu.IP3=SYS
 | 
			
		||||
Mcu.IPNb=4
 | 
			
		||||
Mcu.IP4=TIM3
 | 
			
		||||
Mcu.IPNb=5
 | 
			
		||||
Mcu.Name=STM32G473R(B-C-E)Tx
 | 
			
		||||
Mcu.Package=LQFP64
 | 
			
		||||
Mcu.Pin0=PC13
 | 
			
		||||
Mcu.Pin1=PF0-OSC_IN
 | 
			
		||||
Mcu.Pin10=VP_SYS_VS_Systick
 | 
			
		||||
Mcu.Pin11=VP_SYS_VS_DBSignals
 | 
			
		||||
Mcu.Pin10=PA3
 | 
			
		||||
Mcu.Pin11=PA4
 | 
			
		||||
Mcu.Pin12=PA5
 | 
			
		||||
Mcu.Pin13=PA6
 | 
			
		||||
Mcu.Pin14=PA7
 | 
			
		||||
Mcu.Pin15=PB11
 | 
			
		||||
Mcu.Pin16=PB12
 | 
			
		||||
Mcu.Pin17=PB13
 | 
			
		||||
Mcu.Pin18=PB14
 | 
			
		||||
Mcu.Pin19=PB15
 | 
			
		||||
Mcu.Pin2=PF1-OSC_OUT
 | 
			
		||||
Mcu.Pin3=PB11
 | 
			
		||||
Mcu.Pin4=PB12
 | 
			
		||||
Mcu.Pin5=PB13
 | 
			
		||||
Mcu.Pin6=PB14
 | 
			
		||||
Mcu.Pin7=PB15
 | 
			
		||||
Mcu.Pin8=PA13
 | 
			
		||||
Mcu.Pin9=PA14
 | 
			
		||||
Mcu.PinsNb=12
 | 
			
		||||
Mcu.Pin20=PA13
 | 
			
		||||
Mcu.Pin21=PA14
 | 
			
		||||
Mcu.Pin22=VP_SYS_VS_Systick
 | 
			
		||||
Mcu.Pin23=VP_SYS_VS_DBSignals
 | 
			
		||||
Mcu.Pin24=VP_TIM3_VS_ClockSourceINT
 | 
			
		||||
Mcu.Pin3=PC0
 | 
			
		||||
Mcu.Pin4=PC1
 | 
			
		||||
Mcu.Pin5=PC2
 | 
			
		||||
Mcu.Pin6=PC3
 | 
			
		||||
Mcu.Pin7=PA0
 | 
			
		||||
Mcu.Pin8=PA1
 | 
			
		||||
Mcu.Pin9=PA2
 | 
			
		||||
Mcu.PinsNb=25
 | 
			
		||||
Mcu.ThirdPartyNb=0
 | 
			
		||||
Mcu.UserConstants=
 | 
			
		||||
Mcu.UserName=STM32G473RCTx
 | 
			
		||||
@ -42,11 +56,53 @@ NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
 | 
			
		||||
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
 | 
			
		||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
 | 
			
		||||
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
 | 
			
		||||
NVIC.TIM3_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
 | 
			
		||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
 | 
			
		||||
PA0.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label
 | 
			
		||||
PA0.GPIO_Label=SegLedData
 | 
			
		||||
PA0.GPIO_PuPd=GPIO_PULLUP
 | 
			
		||||
PA0.Locked=true
 | 
			
		||||
PA0.PinState=GPIO_PIN_SET
 | 
			
		||||
PA0.Signal=GPIO_Output
 | 
			
		||||
PA1.GPIOParameters=PinState,GPIO_PuPd
 | 
			
		||||
PA1.GPIO_PuPd=GPIO_PULLUP
 | 
			
		||||
PA1.Locked=true
 | 
			
		||||
PA1.PinState=GPIO_PIN_SET
 | 
			
		||||
PA1.Signal=GPIO_Output
 | 
			
		||||
PA13.Mode=Serial_Wire
 | 
			
		||||
PA13.Signal=SYS_JTMS-SWDIO
 | 
			
		||||
PA14.Mode=Serial_Wire
 | 
			
		||||
PA14.Signal=SYS_JTCK-SWCLK
 | 
			
		||||
PA2.GPIOParameters=PinState,GPIO_PuPd
 | 
			
		||||
PA2.GPIO_PuPd=GPIO_PULLUP
 | 
			
		||||
PA2.Locked=true
 | 
			
		||||
PA2.PinState=GPIO_PIN_SET
 | 
			
		||||
PA2.Signal=GPIO_Output
 | 
			
		||||
PA3.GPIOParameters=PinState,GPIO_PuPd
 | 
			
		||||
PA3.GPIO_PuPd=GPIO_PULLUP
 | 
			
		||||
PA3.Locked=true
 | 
			
		||||
PA3.PinState=GPIO_PIN_SET
 | 
			
		||||
PA3.Signal=GPIO_Output
 | 
			
		||||
PA4.GPIOParameters=PinState,GPIO_PuPd
 | 
			
		||||
PA4.GPIO_PuPd=GPIO_PULLUP
 | 
			
		||||
PA4.Locked=true
 | 
			
		||||
PA4.PinState=GPIO_PIN_SET
 | 
			
		||||
PA4.Signal=GPIO_Output
 | 
			
		||||
PA5.GPIOParameters=PinState,GPIO_PuPd
 | 
			
		||||
PA5.GPIO_PuPd=GPIO_PULLUP
 | 
			
		||||
PA5.Locked=true
 | 
			
		||||
PA5.PinState=GPIO_PIN_SET
 | 
			
		||||
PA5.Signal=GPIO_Output
 | 
			
		||||
PA6.GPIOParameters=PinState,GPIO_PuPd
 | 
			
		||||
PA6.GPIO_PuPd=GPIO_PULLUP
 | 
			
		||||
PA6.Locked=true
 | 
			
		||||
PA6.PinState=GPIO_PIN_SET
 | 
			
		||||
PA6.Signal=GPIO_Output
 | 
			
		||||
PA7.GPIOParameters=PinState,GPIO_PuPd
 | 
			
		||||
PA7.GPIO_PuPd=GPIO_PULLUP
 | 
			
		||||
PA7.Locked=true
 | 
			
		||||
PA7.PinState=GPIO_PIN_SET
 | 
			
		||||
PA7.Signal=GPIO_Output
 | 
			
		||||
PB11.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label
 | 
			
		||||
PB11.GPIO_Label=LCD_RST
 | 
			
		||||
PB11.GPIO_PuPd=GPIO_PULLUP
 | 
			
		||||
@ -69,11 +125,31 @@ PB14.Locked=true
 | 
			
		||||
PB14.Signal=GPIO_Output
 | 
			
		||||
PB15.Mode=TX_Only_Simplex_Unidirect_Master
 | 
			
		||||
PB15.Signal=SPI2_MOSI
 | 
			
		||||
PC0.GPIOParameters=GPIO_PuPd,GPIO_Label
 | 
			
		||||
PC0.GPIO_Label=AddrA
 | 
			
		||||
PC0.GPIO_PuPd=GPIO_PULLUP
 | 
			
		||||
PC0.Locked=true
 | 
			
		||||
PC0.Signal=GPIO_Output
 | 
			
		||||
PC1.GPIOParameters=GPIO_PuPd,GPIO_Label
 | 
			
		||||
PC1.GPIO_Label=AddrB
 | 
			
		||||
PC1.GPIO_PuPd=GPIO_PULLUP
 | 
			
		||||
PC1.Locked=true
 | 
			
		||||
PC1.Signal=GPIO_Output
 | 
			
		||||
PC13.GPIOParameters=GPIO_PuPd,GPIO_Label
 | 
			
		||||
PC13.GPIO_Label=TickLed
 | 
			
		||||
PC13.GPIO_PuPd=GPIO_PULLUP
 | 
			
		||||
PC13.Locked=true
 | 
			
		||||
PC13.Signal=GPIO_Output
 | 
			
		||||
PC2.GPIOParameters=GPIO_PuPd,GPIO_Label
 | 
			
		||||
PC2.GPIO_Label=AddrC
 | 
			
		||||
PC2.GPIO_PuPd=GPIO_PULLUP
 | 
			
		||||
PC2.Locked=true
 | 
			
		||||
PC2.Signal=GPIO_Output
 | 
			
		||||
PC3.GPIOParameters=GPIO_PuPd,GPIO_Label
 | 
			
		||||
PC3.GPIO_Label=OE
 | 
			
		||||
PC3.GPIO_PuPd=GPIO_PULLUP
 | 
			
		||||
PC3.Locked=true
 | 
			
		||||
PC3.Signal=GPIO_Output
 | 
			
		||||
PF0-OSC_IN.Mode=HSE-External-Oscillator
 | 
			
		||||
PF0-OSC_IN.Signal=RCC_OSC_IN
 | 
			
		||||
PF1-OSC_OUT.Mode=HSE-External-Oscillator
 | 
			
		||||
@ -167,8 +243,14 @@ SPI2.Direction=SPI_DIRECTION_2LINES
 | 
			
		||||
SPI2.IPParameters=VirtualType,Mode,Direction,BaudRatePrescaler,CalculateBaudRate,DataSize
 | 
			
		||||
SPI2.Mode=SPI_MODE_MASTER
 | 
			
		||||
SPI2.VirtualType=VM_MASTER
 | 
			
		||||
TIM3.CounterMode=TIM_COUNTERMODE_CENTERALIGNED1
 | 
			
		||||
TIM3.IPParameters=Prescaler,CounterMode,PeriodNoDither
 | 
			
		||||
TIM3.PeriodNoDither=1000-1
 | 
			
		||||
TIM3.Prescaler=170-1
 | 
			
		||||
VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals
 | 
			
		||||
VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals
 | 
			
		||||
VP_SYS_VS_Systick.Mode=SysTick
 | 
			
		||||
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
 | 
			
		||||
VP_TIM3_VS_ClockSourceINT.Mode=Internal
 | 
			
		||||
VP_TIM3_VS_ClockSourceINT.Signal=TIM3_VS_ClockSourceINT
 | 
			
		||||
board=custom
 | 
			
		||||
 | 
			
		||||
@ -453,6 +453,62 @@
 | 
			
		||||
              <FileType>1</FileType>
 | 
			
		||||
              <FilePath>../Core/Src/spi.c</FilePath>
 | 
			
		||||
            </File>
 | 
			
		||||
            <File>
 | 
			
		||||
              <FileName>tim.c</FileName>
 | 
			
		||||
              <FileType>1</FileType>
 | 
			
		||||
              <FilePath>../Core/Src/tim.c</FilePath>
 | 
			
		||||
              <FileOption>
 | 
			
		||||
                <CommonProperty>
 | 
			
		||||
                  <UseCPPCompiler>2</UseCPPCompiler>
 | 
			
		||||
                  <RVCTCodeConst>0</RVCTCodeConst>
 | 
			
		||||
                  <RVCTZI>0</RVCTZI>
 | 
			
		||||
                  <RVCTOtherData>0</RVCTOtherData>
 | 
			
		||||
                  <ModuleSelection>0</ModuleSelection>
 | 
			
		||||
                  <IncludeInBuild>1</IncludeInBuild>
 | 
			
		||||
                  <AlwaysBuild>2</AlwaysBuild>
 | 
			
		||||
                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
 | 
			
		||||
                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
 | 
			
		||||
                  <PublicsOnly>2</PublicsOnly>
 | 
			
		||||
                  <StopOnExitCode>11</StopOnExitCode>
 | 
			
		||||
                  <CustomArgument></CustomArgument>
 | 
			
		||||
                  <IncludeLibraryModules></IncludeLibraryModules>
 | 
			
		||||
                  <ComprImg>1</ComprImg>
 | 
			
		||||
                </CommonProperty>
 | 
			
		||||
                <FileArmAds>
 | 
			
		||||
                  <Cads>
 | 
			
		||||
                    <interw>2</interw>
 | 
			
		||||
                    <Optim>0</Optim>
 | 
			
		||||
                    <oTime>2</oTime>
 | 
			
		||||
                    <SplitLS>2</SplitLS>
 | 
			
		||||
                    <OneElfS>2</OneElfS>
 | 
			
		||||
                    <Strict>2</Strict>
 | 
			
		||||
                    <EnumInt>2</EnumInt>
 | 
			
		||||
                    <PlainCh>2</PlainCh>
 | 
			
		||||
                    <Ropi>2</Ropi>
 | 
			
		||||
                    <Rwpi>2</Rwpi>
 | 
			
		||||
                    <wLevel>0</wLevel>
 | 
			
		||||
                    <uThumb>2</uThumb>
 | 
			
		||||
                    <uSurpInc>2</uSurpInc>
 | 
			
		||||
                    <uC99>2</uC99>
 | 
			
		||||
                    <uGnu>2</uGnu>
 | 
			
		||||
                    <useXO>2</useXO>
 | 
			
		||||
                    <v6Lang>0</v6Lang>
 | 
			
		||||
                    <v6LangP>0</v6LangP>
 | 
			
		||||
                    <vShortEn>2</vShortEn>
 | 
			
		||||
                    <vShortWch>2</vShortWch>
 | 
			
		||||
                    <v6Lto>2</v6Lto>
 | 
			
		||||
                    <v6WtE>2</v6WtE>
 | 
			
		||||
                    <v6Rtti>2</v6Rtti>
 | 
			
		||||
                    <VariousControls>
 | 
			
		||||
                      <MiscControls></MiscControls>
 | 
			
		||||
                      <Define></Define>
 | 
			
		||||
                      <Undefine></Undefine>
 | 
			
		||||
                      <IncludePath></IncludePath>
 | 
			
		||||
                    </VariousControls>
 | 
			
		||||
                  </Cads>
 | 
			
		||||
                </FileArmAds>
 | 
			
		||||
              </FileOption>
 | 
			
		||||
            </File>
 | 
			
		||||
            <File>
 | 
			
		||||
              <FileName>stm32g4xx_it.c</FileName>
 | 
			
		||||
              <FileType>1</FileType>
 | 
			
		||||
@ -463,6 +519,16 @@
 | 
			
		||||
              <FileType>1</FileType>
 | 
			
		||||
              <FilePath>../Core/Src/stm32g4xx_hal_msp.c</FilePath>
 | 
			
		||||
            </File>
 | 
			
		||||
            <File>
 | 
			
		||||
              <FileName>SegLed.h</FileName>
 | 
			
		||||
              <FileType>5</FileType>
 | 
			
		||||
              <FilePath>..\Core\Inc\SegLed.h</FilePath>
 | 
			
		||||
            </File>
 | 
			
		||||
            <File>
 | 
			
		||||
              <FileName>SegLed.c</FileName>
 | 
			
		||||
              <FileType>1</FileType>
 | 
			
		||||
              <FilePath>..\Core\Src\SegLed.c</FilePath>
 | 
			
		||||
            </File>
 | 
			
		||||
          </Files>
 | 
			
		||||
        </Group>
 | 
			
		||||
        <Group>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user