main/task_adc.h

Sat, 14 Mar 2020 13:07:02 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 14 Mar 2020 13:07:02 +0100
changeset 47
1ab1f4a8c328
parent 44
e52d11b8f252
permissions
-rw-r--r--

Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.

/**
 * @file task_adc.h
 * @brief The FreeRTOS task to query the pressure sensors connected to
 *        ADC inputs.
 *        The task will update the ADC_State structure.
 */

#ifndef	_TASK_ADC_H
#define	_TASK_ADC_H

/*
 * Error codes in this task
 */
#define	ADC_ERR_NONE			0	///< No errors
#define	ADC_ERR_READ			1	///< Generic read error



/**
 * @brief Pressure sensors
 */
typedef struct strPressure {
    bool		valid;			///< Valid measurement
    adc_channel_t	channel;		///< Channel
    adc_atten_t		atten;			///< Attenuation
    uint32_t		voltage;		///< Voltage measured
    int			error;			///< Error result
} pressure_t;


/**
 * @brief Structure containing the variables for the ADC task.
 */
typedef struct {
    pressure_t	Pressure[3];			///< Pressure sensors
    uint32_t	Batt_voltage;			///< Battery voltage
    int		Batt_error;			///< Battery error state
} ADC_State;



/**
 * @brief Request a new measurement
 */
void request_adc(void);


/**
 * @brief Check if results are ready
 * @return true of results are ready, else false.
 */
bool ready_adc(void);


/**
 * @brief The FreeRTOS task to update the pressure sensors on request.
 * @param pvParameters Parameters for the task.
 */
void task_adc(void *pvParameters);


#endif

mercurial