2020-05-16 21:00:55 +02:00
/* Reflow Oven Controller
*
* Copyright ( C ) 2020 Mario Hüttel < mario . huettel @ gmx . net >
*
* This file is part of the Reflow Oven Controller Project .
*
* The reflow oven controller is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation .
*
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with the reflow oven controller project .
* If not , see < http : //www.gnu.org/licenses/>.
*/
2020-07-06 21:12:18 +02:00
/**
* @ addtogroup safety - adc
* @ {
*/
2020-05-16 21:00:55 +02:00
# ifndef __SAFETY_ADC_H__
# define __SAFETY_ADC_H__
# include <stdint.h>
# include <stdbool.h>
2020-12-01 21:00:23 +01:00
/**
* @ brief The safety ADC ' s measure channel
*/
enum safety_adc_meas_channel {
SAFETY_ADC_MEAS_VREF , /**< @brief Internal reference voltage @note This will not output the internal reference voltage but the recalculated external voltage! */
SAFETY_ADC_MEAS_TEMP , /**< @brief Internal temperature sensor */
2021-01-01 19:48:53 +01:00
SAFETY_ADC_MEAS_SUPPLY , /**< @brief Supply voltage */
2020-12-01 21:00:23 +01:00
} ;
2020-06-14 23:22:35 +02:00
2020-12-01 21:00:23 +01:00
/**
* @ brief Initialize safety ADC . Only call this function once !
*/
2020-11-30 00:01:26 +01:00
void safety_adc_init ( void ) ;
2020-05-16 21:00:55 +02:00
2020-12-01 21:00:23 +01:00
/**
* @ brief safety_adc_deinit Deactivate safety ADC
* @ warning For completeness . Do not call ! the safety ADC is a vital component . It ' s malfunction will trigger a critical safety flag .
*/
2020-11-30 00:01:26 +01:00
void safety_adc_deinit ( void ) ;
2020-05-16 21:00:55 +02:00
2020-12-01 21:00:23 +01:00
/**
* @ brief safety_adc_trigger_meas
*/
2020-11-30 00:01:26 +01:00
void safety_adc_trigger_meas ( void ) ;
2020-05-16 21:00:55 +02:00
/**
* @ brief Poll ADC result .
* @ return 1 if measurement successful , 0 if not ready , - 1 if ADC aborted or not started
*/
2020-11-30 00:01:26 +01:00
int safety_adc_poll_result ( void ) ;
2020-05-16 21:00:55 +02:00
2020-12-01 21:00:23 +01:00
/**
* @ brief Get the sampled signal values of the safety ADC .
*
* Use # safety_adc_poll_result to poll for a finished conversion of the safety ADC .
* After that , it is safe to use the output values until a new conversion is triggered using # safety_adc_trigger_meas
*
* @ warning This function return a constant buffer , that is directly written on by the DMA ! Check # safety_adc_poll_result to prevent race conditions .
2021-05-22 15:27:55 +02:00
* @ return Array of raw ADC readings with length of # SAFETY_ADC_NUM_OF_CHANNELS
2020-12-01 21:00:23 +01:00
*/
2020-11-30 00:01:26 +01:00
const uint16_t * safety_adc_get_values ( void ) ;
2020-05-16 21:00:55 +02:00
2020-12-01 21:00:23 +01:00
/**
* @ brief Convert a safety ADC raw value to an actual s ignal value
* @ param channel Measurment channel to convert voltage for
* @ param analog_value Raw value of the ADC to convert
* @ warning Double check @ ref safety_adc_meas_channel to make sure you understand the output of this function correctly .
* @ return
*/
2020-07-09 22:31:42 +02:00
float safety_adc_convert_channel ( enum safety_adc_meas_channel channel , uint16_t analog_value ) ;
2020-05-16 21:00:55 +02:00
# endif /* __SAFETY_ADC_H__ */
2020-07-06 21:12:18 +02:00
/** @} */