main/task_adc.h

Tue, 08 Oct 2019 12:00:31 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 08 Oct 2019 12:00:31 +0200
changeset 0
88d965579617
child 44
e52d11b8f252
permissions
-rw-r--r--

Initial import of the CO2 meter application.

/**
 * @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.
 */
void task_adc(void *);


#endif

mercurial