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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SAFETY_ADC_HWCFG_H__
|
|
|
|
#define __SAFETY_ADC_HWCFG_H__
|
|
|
|
|
2020-12-01 21:00:23 +01:00
|
|
|
/**
|
|
|
|
* @file safety-adc-hwcfg.h
|
|
|
|
* @brief Safety ADC configuration settings
|
|
|
|
*/
|
|
|
|
|
2020-05-16 21:00:55 +02:00
|
|
|
#include <stm32/stm32f4xx.h>
|
|
|
|
|
2020-12-01 21:00:23 +01:00
|
|
|
/**
|
|
|
|
* @brief Peripheral to use as safety ADC.
|
|
|
|
* @note This must be ADC1, because it is the only ADC with access to the internal temperature sensor
|
|
|
|
*/
|
2020-05-16 21:00:55 +02:00
|
|
|
#define SAFETY_ADC_ADC_PERIPHERAL ADC1
|
2020-12-01 21:00:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Clock enable mask in RCC->APB2ENR to enable the #SAFETY_ADC_ADC_PERIPHERAL
|
|
|
|
*/
|
2020-05-16 21:00:55 +02:00
|
|
|
#define SAFETY_ADC_ADC_RCC_MASK RCC_APB2ENR_ADC1EN
|
2020-12-01 21:00:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ADC channel number of the internal temperature sensor
|
|
|
|
*/
|
2020-05-16 21:00:55 +02:00
|
|
|
#define TEMP_CHANNEL_NUM (16)
|
2020-12-01 21:00:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ADC channel number of the internal reference voltage
|
|
|
|
*/
|
2020-05-16 21:00:55 +02:00
|
|
|
#define INT_REF_CHANNEL_NUM (17)
|
|
|
|
|
2021-01-01 19:48:53 +01:00
|
|
|
#define SAFETY_ADC_SUPPLY_VOLTAGE_MONITOR_CHANNEL_NUM (15)
|
|
|
|
#define SAFETY_ADC_SUPPLY_VOLTAGE_MONITOR_PIN (5)
|
|
|
|
#define SAFETY_ADC_SUPPLY_VOLTAGE_MONITOR_PORT GPIOC
|
|
|
|
#define SAFETY_ADC_SUPPLY_VOLTAGE_MONITOR_PORT_RCC_MASK RCC_AHB1ENR_GPIOCEN
|
|
|
|
|
|
|
|
|
2020-12-01 21:00:23 +01:00
|
|
|
/**
|
|
|
|
* @brief Nominal value of the internal reference voltage.
|
|
|
|
*
|
|
|
|
* This is used to compare to the external reference voltage.
|
|
|
|
*/
|
2020-06-01 20:53:28 +02:00
|
|
|
#define SAFETY_ADC_INT_REF_MV 1210.0f
|
|
|
|
|
2020-12-01 21:00:23 +01:00
|
|
|
/**
|
|
|
|
* @brief Nominal temperature in degrees celsius of the internal temperature sensor at which it reads
|
|
|
|
* #SAFETY_ADC_TEMP_NOM_MV millivolts.
|
|
|
|
*
|
|
|
|
*/
|
2020-06-01 20:53:28 +02:00
|
|
|
#define SAFETY_ADC_TEMP_NOM 25.0f
|
2020-12-01 21:00:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Nominal internal temperature sensor voltage at temperature #SAFETY_ADC_TEMP_NOM
|
|
|
|
*/
|
2020-06-01 20:53:28 +02:00
|
|
|
#define SAFETY_ADC_TEMP_NOM_MV 760.0f
|
2020-12-01 21:00:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Sensitivity of the internal temperature sensor in millivolts per Kelvin
|
|
|
|
*/
|
2020-06-01 20:53:28 +02:00
|
|
|
#define SAFETY_ADC_TEMP_MV_SLOPE 2.5f
|
|
|
|
|
2020-12-01 21:00:23 +01:00
|
|
|
/**
|
|
|
|
* @brief Number of channels to handle for the SAFETY ADC.
|
|
|
|
* @note The maximum amount of channels is limited to 16
|
|
|
|
*/
|
2021-01-01 19:48:53 +01:00
|
|
|
#define SAFETY_ADC_NUM_OF_CHANNELS 12
|
2020-12-01 21:00:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Channel numbers to sample with the SAFETY ADC
|
|
|
|
*
|
|
|
|
* - The first 4 values are the internal temperature sensor
|
|
|
|
* - The next 4 values are the internal reference voltage
|
|
|
|
*
|
|
|
|
* The values are samples 4 times each to allow averaging them to get
|
|
|
|
* more precise readings. Check the maximum value of #SAFETY_ADC_NUM_OF_CHANNELS
|
|
|
|
* when adding more channels.
|
|
|
|
* @warning Safety controller expects the current measurment list. If you change it, check @ref safety_controller_handle_safety_adc
|
|
|
|
*/
|
2020-11-30 21:43:38 +01:00
|
|
|
#define SAFETY_ADC_CHANNELS TEMP_CHANNEL_NUM, TEMP_CHANNEL_NUM, TEMP_CHANNEL_NUM, TEMP_CHANNEL_NUM, \
|
2021-01-01 19:48:53 +01:00
|
|
|
INT_REF_CHANNEL_NUM, INT_REF_CHANNEL_NUM, INT_REF_CHANNEL_NUM, INT_REF_CHANNEL_NUM, \
|
|
|
|
SAFETY_ADC_SUPPLY_VOLTAGE_MONITOR_CHANNEL_NUM, SAFETY_ADC_SUPPLY_VOLTAGE_MONITOR_CHANNEL_NUM, \
|
|
|
|
SAFETY_ADC_SUPPLY_VOLTAGE_MONITOR_CHANNEL_NUM, SAFETY_ADC_SUPPLY_VOLTAGE_MONITOR_CHANNEL_NUM
|
2020-11-30 00:01:26 +01:00
|
|
|
|
2020-06-01 20:53:28 +02:00
|
|
|
|
2020-12-01 21:00:23 +01:00
|
|
|
/* Check the channel count of the safety ADC */
|
|
|
|
#if SAFETY_ADC_NUM_OF_CHANNELS > 16 || SAFETY_ADC_NUM_OF_CHANNELS < 0
|
|
|
|
#error "Invlaid count of channels for safety ADC"
|
|
|
|
#endif
|
|
|
|
|
2020-05-16 21:00:55 +02:00
|
|
|
#endif /* __SAFETY_ADC_HWCFG_H__ */
|