main/task_adc.h

changeset 0
88d965579617
child 44
e52d11b8f252
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/task_adc.h	Tue Oct 08 12:00:31 2019 +0200
@@ -0,0 +1,62 @@
+/**
+ * @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