Merge branch 'dev' into ui
This commit is contained in:
		@@ -24,6 +24,11 @@
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <stm32/stm32f4xx.h>
 | 
			
		||||
 | 
			
		||||
/*If this is changed, change DMA code to fit the channel assignment! */
 | 
			
		||||
#define ADC_PT1000_PERIPH ADC3
 | 
			
		||||
#define ADC_PT1000_DMA2_STREAM0_CHANNEL 2
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Moving average filter coefficient for PT1000 measurement
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,31 @@
 | 
			
		||||
/* 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/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef __SAFETY_ADC_HWCFG_H__
 | 
			
		||||
#define __SAFETY_ADC_HWCFG_H__
 | 
			
		||||
 | 
			
		||||
#include <stm32/stm32f4xx.h>
 | 
			
		||||
 | 
			
		||||
#define SAFETY_ADC_ADC_PERIPHERAL ADC1
 | 
			
		||||
#define SAFETY_ADC_ADC_RCC_MASK RCC_APB2ENR_ADC1EN
 | 
			
		||||
#define TEMP_CHANNEL_NUM (16)
 | 
			
		||||
#define INT_REF_CHANNEL_NUM (17)
 | 
			
		||||
 | 
			
		||||
#endif /* __SAFETY_ADC_HWCFG_H__ */
 | 
			
		||||
							
								
								
									
										64
									
								
								stm-firmware/include/reflow-controller/safety-adc.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								stm-firmware/include/reflow-controller/safety-adc.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,64 @@
 | 
			
		||||
/* 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/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef __SAFETY_ADC_H__
 | 
			
		||||
#define __SAFETY_ADC_H__
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
 | 
			
		||||
#define SAFETY_ADC_FRAC_BITS (8)
 | 
			
		||||
#define SAFETY_ADC_VREF_VOLT (2.5)
 | 
			
		||||
#define SAFETY_ADC_VREF_TOL (0.25)
 | 
			
		||||
#define SAFETY_ADC_VREF_INT ()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
enum safety_adc_meas_channel {SAFETY_ADC_MEAS_VREF, SAFETY_ADC_MEAS_TEMP};
 | 
			
		||||
enum safety_adc_check_result {
 | 
			
		||||
				SAFETY_ADC_CHECK_OK = 0UL,
 | 
			
		||||
				SAFETY_ADC_CHECK_VREF_LOW = (1U<<0),
 | 
			
		||||
				SAFETY_ADC_CHECK_VREF_HIGH = (1U<<1),
 | 
			
		||||
				SAFETY_ADC_CHECK_TEMP_LOW = (1U<<2),
 | 
			
		||||
				SAFETY_ADC_CHECK_TEMP_HIGH = (1U<<3),
 | 
			
		||||
				};
 | 
			
		||||
 | 
			
		||||
void safety_adc_init();
 | 
			
		||||
 | 
			
		||||
void safety_adc_deinit();
 | 
			
		||||
 | 
			
		||||
void safety_adc_trigger_meas(enum safety_adc_meas_channel measurement);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Poll ADC result.
 | 
			
		||||
 * @param results adc results
 | 
			
		||||
 * @return 1 if measurement successful, 0 if not ready, -1 if ADC aborted or not started
 | 
			
		||||
 */
 | 
			
		||||
int safety_adc_poll_result(uint16_t *adc_result);
 | 
			
		||||
 | 
			
		||||
enum safety_adc_check_result safety_adc_check_results(uint16_t vref_result, uint16_t temp_result,
 | 
			
		||||
						      float *vref_calculated, float *temp_calculated);
 | 
			
		||||
 | 
			
		||||
enum safety_adc_check_result handle_safety_adc();
 | 
			
		||||
 | 
			
		||||
float safety_adc_get_temp();
 | 
			
		||||
 | 
			
		||||
float safety_adc_get_vref();
 | 
			
		||||
 | 
			
		||||
#endif /* __SAFETY_ADC_H__ */
 | 
			
		||||
		Reference in New Issue
	
	Block a user