完成第二次实验

This commit is contained in:
423A35C7 2024-10-29 21:20:17 +08:00
parent 2e01c0a278
commit f1bc6bd8e1
3 changed files with 12 additions and 4 deletions

View File

@ -9,6 +9,8 @@ extern "C" {
typedef struct { typedef struct {
uint8_t mMilSecCount; // 毫秒计数 uint8_t mMilSecCount; // 毫秒计数
uint8_t bTenMilSecOk; // 10毫秒标志位 uint8_t bTenMilSecOk; // 10毫秒标志位
uint8_t mTenMilSecCount; // 10毫秒计数
uint8_t bHundredMilSecOk; // 100毫秒标志位
uint8_t mTimeCount; // 秒计数 uint8_t mTimeCount; // 秒计数
uint8_t bTimeOk; // 秒标志位 uint8_t bTimeOk; // 秒标志位
} stSysTickTimer; } stSysTickTimer;

View File

@ -104,7 +104,9 @@ int main(void)
if (sSysTickTimer.bTimeOk) { if (sSysTickTimer.bTimeOk) {
sSysTickTimer.bTimeOk = 0; sSysTickTimer.bTimeOk = 0;
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
}
if (sSysTickTimer.bHundredMilSecOk) {
sSysTickTimer.bHundredMilSecOk = 0;
HAL_GPIO_WritePin(FlashLeds_GPIO_Port, nShift, GPIO_PIN_SET); HAL_GPIO_WritePin(FlashLeds_GPIO_Port, nShift, GPIO_PIN_SET);

View File

@ -192,11 +192,15 @@ void SysTick_Handler(void)
if (++sSysTickTimer.mMilSecCount >= 10) { if (++sSysTickTimer.mMilSecCount >= 10) {
sSysTickTimer.mMilSecCount = 0; sSysTickTimer.mMilSecCount = 0;
sSysTickTimer.bTenMilSecOk = 1; sSysTickTimer.bTenMilSecOk = 1;
if (++sSysTickTimer.mTimeCount >= 100) { if (++sSysTickTimer.mTenMilSecCount >= 10) {
sSysTickTimer.mTenMilSecCount = 0;
sSysTickTimer.bHundredMilSecOk = 1;
if (++sSysTickTimer.mTimeCount >= 10) {
sSysTickTimer.mTimeCount = 0; sSysTickTimer.mTimeCount = 0;
sSysTickTimer.bTimeOk = 1; sSysTickTimer.bTimeOk = 1;
} }
} }
}
/* USER CODE END SysTick_IRQn 1 */ /* USER CODE END SysTick_IRQn 1 */
} }