/*
 * position_task.h
 *
 *  Created on: Nov 6, 2024
 *      Author: jakubski
 */

#ifndef INC_POSITION_TASK_H_
#define INC_POSITION_TASK_H_

#include "cmsis_os.h"
#include "main.h"

enum _MovementPhases
{
	idlePhase,
	startPhase,
	speedUpPhase,
	movePhase,
	slowDownPhase,
	stopPhase
};

typedef enum _MovementPhases MovementPhases;

struct _PositionControlTaskInitArg
{
	TIM_HandleTypeDef* htim;
	TIM_OC_InitTypeDef* motorTimerConfigOC;
	uint8_t channel1;
	uint8_t channel2;
	osTimerId_t motorTimerHandle;
	osMessageQueueId_t positionSettingQueue;
	uint8_t* switchLimiterUpStat;
	uint8_t* switchLimiterDownStat;
	uint8_t* switchLimiterCenterStat;
	float* currentPosition;
	float* positionSetting;
	uint8_t* motorStatus;
	float* motorPeakCurrent;
	char axe;
};

typedef struct _PositionControlTaskInitArg PositionControlTaskInitArg;

struct _PositionControlTaskData
{
	float positionSettingValue;
};

typedef struct _PositionControlTaskData PositionControlTaskData;

extern PositionControlTaskInitArg positionXControlTaskInitArg;
extern PositionControlTaskInitArg positionYControlTaskInitArg;

void PositionControlTaskInit(void);
void PositionControlTask (void* argument);

#endif /* INC_POSITION_TASK_H_ */
