/*
 * task.h
 *
 *  Created on: 2024年6月24日
 *      Author: psx
 */

#ifndef APP_INC_TASK_H_
#define APP_INC_TASK_H_


#include "timeSliceOffset.h"
#include "uart_dev.h"
#include "math.h"

void stop_mpptWork(void);
void start_mpptWork(void);

#define runled_reloadVal 1000           /* 任务执行间隔  */
#define runled_offset 0                 /* 任务执行偏移量  */
extern STR_TimeSliceOffset m_runled;
extern void Task_RunLED(void);

#define startMpptControl_reloadVal 1000        /* 任务执行间隔  */
#define startMpptControl_offset 0            /* 任务执行偏移量  */
extern STR_TimeSliceOffset m_startMpptControl;;
extern void Task_startMpptControl(void);

#define softStart_reloadVal 30         /* 任务执行间隔  */
#define softStart_offset 0              /* 任务执行偏移量  */
extern STR_TimeSliceOffset m_softStart;
extern void Task_softStart(void);

#define usart_reloadVal 100             /* 任务执行间隔  */
#define usart_offset 0                  /* 任务执行偏移量  */
extern STR_TimeSliceOffset m_usart;
extern uint8_t RegistrationRequestFlag; /* 接收到广播帧标志位 */
void Task_usart(void);

#define wdi_reloadVal 1000              /* 任务执行间隔  */
#define wdi_offset 30                   /* 任务执行偏移量  */
#define wdi_RESET (60 * 60 * 24)        /* 一天复位一次  */
extern STR_TimeSliceOffset m_wdi;
extern void Task_wdi(void);

#define refreshRegister_reloadVal 1000  /* 任务执行间隔  */
#define refreshRegister_offset 0        /* 任务执行偏移量  */
extern STR_TimeSliceOffset m_refreshRegister;
extern uint8_t overTemperature;
extern void Task_refreshRegister(void);

#define recvbroadcast_reloadVal 3000    /* 任务执行间隔  */
#define recvbroadcast_offset 0          /* 任务执行偏移量  */
extern uint8_t recvbroadcast_flag;              /* 是否需要再次发送标志 */
extern device_handle  g_recvBroadcastDevice;    /* 串口句柄 */
extern uint8_t  g_recvBroadcastRegisterNumber;  /* 寄存器长度 */
extern STR_TimeSliceOffset m_recvbroadcast;
extern void Task_recvbroadcast(void);

#define impedanceCalculation_reloadVal 1000              /* 任务执行间隔  */
#define impedanceCalculation_offset 0                   /* 任务执行偏移量  */
extern float_t g_impedance;
extern float_t voltOut;
extern STR_TimeSliceOffset m_impedanceCalculation;
extern void Task_impedanceCalculation(void);

#define outputAgain_reloadVal 2              /* 任务执行间隔  */
#define outputAgain_offset 0                   /* 任务执行偏移量  */
extern uint8_t outputAgainFlag;
extern STR_TimeSliceOffset m_outputAgain;
extern void Task_outputAgain(void);

#define sensorEnableBroadcast_reloadVal 1000           /* 任务执行间隔  */
#define sensorEnableBroadcast_offset 0               /* 任务执行偏移量  */
extern STR_TimeSliceOffset m_sensorEnableBroadcast;
/* 是否接收广播帧标志位 */
extern uint8_t run_Broadcast;
extern void Task_sensorEnableBroadcast(void);

void task_Init(void);
void hardware_Init(void);

#endif /* APP_INC_TASK_H_ */
