/*
 * 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 _LimiterSwitchData {
    uint16_t gpioPin;
    GPIO_PinState pinState;
};

typedef struct _LimiterSwitchData LimiterSwitchData;

enum _EncoderDirection { encoderCW, encoderCCW };
typedef enum _EncoderDirection EncoderDirection;

enum _EncoderAxe { encoderAxeX, encoderAxeY };
typedef enum _EncoderAxe EncoderAxe;

struct _EncoderData {
    EncoderAxe axe;
    EncoderDirection direction;
};

typedef struct _EncoderData EncoderData;

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

extern osMutexId_t resMeasurementsMutex;
extern osMutexId_t sensorsInfoMutex;

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_ */
