Improve documentation and beatify pieces of code

This commit is contained in:
Mario Hüttel 2021-07-15 19:50:14 +02:00
parent 0bf587b8bb
commit 9c872f6746
8 changed files with 131 additions and 7 deletions

View File

@ -0,0 +1,31 @@
.. _hw_version_detect:
Automatic Hardware Version detection
====================================
Functional Description
----------------------
In order to automatically select the available hardware features, the firmware checks the PCB's version
using vertain pins on the microcontroller.
The hardware revision is represented by the enum type :c:enum:`hw_revision`. A call to :c:func:`get_pcb_hardware_version` retrieves the revision.
When the function is called for the first time, it activates pull-up resistors on pin numbers :c:macro:`HW_REV_DETECT_PIN_LOW` to :c:macro:`HW_REV_DETECT_PIN_HIGH`
on port :c:macro:`HW_REV_DETECT_GPIO` and reads in the binary number.
The revision is set by externally connecting the pins to ground. The bit pattern read from the port is inverted and then checked internally to derive the hardware version.
After the version is read for the first time, it is stored internally and subsequent calls to :c:func:`get_pcb_hardware_version` only retrieve the internally stored value to reduce the overhead of the function.
Hardware Version Dependent Features
-----------------------------------
- The settings module searches for an external EEPROM on the SPI interface to store some settings, like the calibration. This is enabled for all versions higher or equal to ``v1.3``.
- The safety controller enables the acknowledging of the external watchdog for all versions higher or equal to ``v1.3``.
- The oven driver has a separate safety enable for the solid state relay which it enables on all versions higher or equal to ``v1.3``.
API Documentation
-----------------
.. doxygengroup:: hw-version-detect
:project: Reflow Controller Firmware

View File

@ -14,4 +14,5 @@ mechanisms and the behavior. For a detailed code documentation see the doxygen o
pid-controller
safety/index
code/index
hw-version-detect

View File

@ -21,4 +21,5 @@ which are used to retain boot information across resets, for example to communic
flags
backup-ram
error-handling
startup-tests
stack-checking

View File

@ -0,0 +1,23 @@
.. _safety_startup_tests:
Startup Tests
=============
The following tests will be performed after each reset / power cycle of the controller.
Internal Memory Test
--------------------
Directly after startup and after setting up the system clocks, the controller performs memory checks on the internal SRAM and the core coupled memory.
RAM checking is performed by testing the following sequences:
- Alternating 0x55AA55AA / 0xAA55AA55 pattern
- Alternating 0xAA55AA55 / 0x55AA55AA pattern
- 0xFFFFFFFF constant value
- 0x00000000 constant value
The following functions implement the RAM checking:
.. doxygenfunction:: startup_test_perform_ccm_ram_check
.. doxygenfunction:: startup_test_perform_system_ram_check

View File

@ -1,12 +1,32 @@
/* Reflow Oven Controller
*
* Copyright (C) 2021 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/>.
*/
/**
* @addtogroup hw-version-detect
* @{
*/
#include <reflow-controller/hw-version-detect.h>
#include <stm-periph/rcc-manager.h>
#include <stm32/stm32f4xx.h>
#define HW_REV_DETECT_GPIO GPIOE
#define HW_REV_DETECT_RCC_FIELD RCC_AHB1ENR_GPIOEEN
#define HW_REV_DETECT_PIN_LOW (8U)
#define HW_REV_DETECT_PIN_HIGH (15U)
enum hw_revision get_pcb_hardware_version(void)
{
uint8_t current_pin;
@ -46,3 +66,5 @@ enum hw_revision get_pcb_hardware_version(void)
return revision;
}
/** @} */

View File

@ -1,8 +1,54 @@
/* Reflow Oven Controller
*
* Copyright (C) 2021 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/>.
*/
/**
* @addtogroup hw-version-detect
* @{
*/
#ifndef _HW_VERSION_DETECT_H_
#define _HW_VERSION_DETECT_H_
#include <stdint.h>
/**
* @brief GPIO Port used for hardware version detection
*/
#define HW_REV_DETECT_GPIO GPIOE
/**
* @brief RCC Clock register mask used to enable @ref HW_REV_DETECT_GPIO GPIO Port
*/
#define HW_REV_DETECT_RCC_FIELD RCC_AHB1ENR_GPIOEEN
/**
* @brief Lowest pin on @ref HW_REV_DETECT_GPIO GPIO Port that shall be used to read in the hardware version
*/
#define HW_REV_DETECT_PIN_LOW (8U)
/**
* @brief Highest pin on @ref HW_REV_DETECT_GPIO GPIO Port that shall be used to read in the hardware version
*/
#define HW_REV_DETECT_PIN_HIGH (15U)
/**
* @brief PCB/Hardware Revision Type
*/
@ -32,3 +78,5 @@ enum hw_revision {
enum hw_revision get_pcb_hardware_version(void);
#endif /* _HW_VERSION_DETECT_H_ */
/** @} */

View File

@ -18,7 +18,6 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __SETTINGS_SETTINGS_H__
#define __SETTINGS_SETTINGS_H__

View File

@ -27,7 +27,6 @@
void HardFault_Handler(void)
{
/* This is a non recoverable fault. Stop the oven */
oven_driver_set_power(0);
oven_driver_apply_power_level();