/*
 * meas_tasks.h
 *
 *  Created on: Sep 5, 2024
 *      Author: jakubski
 */

#ifndef INC_MEAS_TASKS_H_
#define INC_MEAS_TASKS_H_

#include "FreeRTOS.h"
#include "FreeRTOSConfig.h"
#include "cmsis_os.h"
#include "stm32h7xx_hal.h"
#include "task.h"

#define GAIN_AUTO_CORRECTION

struct _EncoderTaskArg
{
	uint16_t dbgLed;
	float* currentPosition;
	float* pvEncoder;
	uint32_t initPinStates;
	osMessageQueueId_t dataQueue;
};

typedef struct _EncoderTaskArg EncoderTaskArg;

extern osMessageQueueId_t adc1MeasDataQueue;
extern osMessageQueueId_t adc2MeasDataQueue;
extern osMessageQueueId_t adc3MeasDataQueue;
extern osMessageQueueId_t limiterSwitchDataQueue;

extern osMutexId_t resMeasurementsMutex;
extern osMutexId_t sensorsInfoMutex;

extern osThreadId_t encoderXTaskHandle;
extern osThreadId_t encoderYTaskHandle;

extern EncoderTaskArg encoderXTaskArg;
extern EncoderTaskArg encoderYTaskArg;

void MeasTasksInit (void);
void ADC1MeasTask (void* arg);
void ADC2MeasTask (void* arg);
void ADC3MeasTask (void* arg);
void LimiterSwitchTask (void* arg);
void EncoderTask (void* arg);

#endif /* INC_MEAS_TASKS_H_ */
