You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
4.3 KiB
C

/**
******************************************************************************
* @file main.h
* @author MCU Application Team
* @brief Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2023 Puya Semiconductor Co.
* All rights reserved.</center></h2>
*
* This software component is licensed by Puya under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __StartTask_H
#define __StartTask_H
/* Includes ------------------------------------------------------------------*/
#include "py32f4xx_hal.h"
#include "py32f403xx_Start_Kit.h"
/* Private includes ----------------------------------------------------------*/
/* Private defines -----------------------------------------------------------*/
/* Exported variables prototypes ---------------------------------------------*/
/* Exported functions prototypes ---------------------------------------------*/
typedef enum
{
//LOGIC EVENT
eCmdEventIdel = 0x0000, //空
eCmd1ms,
eCmd10ms,
eCmd100ms,
eCmd1000ms,
eCmdPowerON, //power on
eCmdPowerOff, //power off
eCmdKeyONOFFShortPress, //key OnOff short press
eCmdKeyONOFFlongPress, //key OnOff long press
eCmdKeyModeShortPress, //key mode short press
eCmdKeyModelongPress, //key mode long press
eCmdMotorON,
eCmdMotorOFF,
eCmdMotorEnable,
eCmdMotorDisable,
eCmdPressureOverload,
eCmdMotorPause,
eCmdLCDBlack,
eCmdLCDRed,
eCmdLCDBlue,
ID_MAX
}TypedefID_T;
typedef enum{
stateIdel = 0, //初始状态
Brushing, //刷牙状态
Paused, //暂停状态
Success, //刷牙成功状态
stateSleep,
StateNum
}typedefStateID;
#define SysTimerReload 10*1000/2 //10Second
typedef enum{
StateMenu_1 =0,
StateMenu_2,
StateMenu_3,
StateMenu_4
}typedefStateMotor;
typedef struct{
typedefStateID State_system;
typedefStateMotor StateMenu;
uint32_t StateMenuGears;
uint32_t TickStart;
uint32_t TMotorPause10msLoop;
uint32_t motorRunTime; //当前电机运行时间
uint32_t motorStopTime; // 当前电机停止时间
uint32_t motorPauseTime; // 当前暂停时间
uint32_t cycleTime; // 当前模式的总循环时间(单位:毫秒)
uint32_t totalRunTime; // 当前总运行时间(单位:毫秒)
// 用于更新计时器的变量
uint32_t systemTick;
uint32_t modeStartTime; // 记录模式开始时间
// 用于跟踪已运行的时间
uint32_t motorRunDuration; // 累积电机运行时间(单位:毫秒)
//马达运行的周期及占空比
uint32_t Period;
uint32_t Duty;
//按键时间相关
uint32_t LastButtonPressTick; //上一次按键按键的时间
uint32_t CurrentButtonPressTime; //本次按键距离上次按键的时间间隔
}typedefStructStateSystem;
extern typedefStructStateSystem SysRegister;
typedef struct
{
TypedefID_T ECmd;
uint32_t DataValue;
}ECmdIDtypedef;
#define MotorStart StartMotor(SysRegister.Period,SysRegister.Duty)
#define MotorStop StopMotor()
extern QueueHandle_t at_CmdMsg;
void StartTask(void *pvParamters);
extern void SendCmd(TypedefID_T CmdData);
extern void SendCmdFromISR(TypedefID_T CmdData);
void SetMotorTimes(typedefStateMotor mode);
void MotorControl(void);
// ECmdIDtypedef
#endif /* __StartTask_H */
/************************ (C) COPYRIGHT Puya *****END OF FILE******************/