Merge branch 'dev' into feature/40-fir-filter

This commit is contained in:
Mario Hüttel 2021-08-19 21:47:11 +02:00
commit 836c7af163
6 changed files with 126 additions and 4 deletions

View File

@ -36,7 +36,7 @@
/**
* @brief Moving average filter coefficient for PT1000 measurement
*/
#define ADC_PT1000_FILTER_WEIGHT 0.005f
#define ADC_PT1000_FILTER_WEIGHT 0.01f
/**
* @brief Moving average filter weight used for fast regaulation. This is used when the measured resistance

View File

@ -0,0 +1,32 @@
/* 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 __MAIN_CYCLE_COUNTER_H__
#define __MAIN_CYCLE_COUNTER_H__
#include <stdint.h>
void main_cycle_counter_init(void);
void main_cycle_counter_inc(void);
uint64_t main_cycle_counter_get(void);
#endif /* __MAIN_CYCLE_COUNTER_H__ */

View File

@ -0,0 +1,39 @@
/* 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/>.
*/
#include <reflow-controller/main-cycle-counter.h>
#include <helper-macros/helper-macros.h>
static uint64_t IN_SECTION(.ccm.bss) main_cycle_counter;
void main_cycle_counter_init()
{
main_cycle_counter = 0ULL;
}
void main_cycle_counter_inc()
{
main_cycle_counter++;
}
uint64_t main_cycle_counter_get()
{
return main_cycle_counter;
}

View File

@ -48,6 +48,7 @@
#include <reflow-controller/updater/updater.h>
#include <reflow-controller/temp-profile/temp-profile-executer.h>
#include <reflow-controller/settings/spi-eeprom.h>
#include <reflow-controller/main-cycle-counter.h>
static void setup_nvic_priorities(void)
{
@ -248,6 +249,8 @@ int main(void)
shell_handle = shell_init(write_shell_callback);
shell_print_motd(shell_handle);
main_cycle_counter_init();
while (1) {
if (systick_ticks_have_passed(quarter_sec_timestamp, 250)) {
@ -285,7 +288,7 @@ int main(void)
__WFI();
else
__NOP();
main_loop_iter_count++;
main_cycle_counter_inc();
}
return 0;

View File

@ -1563,6 +1563,7 @@ int safety_controller_set_crc_monitor(enum crc_monitor mon, uint32_t password)
if (password != monitor->pw)
return -1002;
crc = 0;
(void)crc_monitor_calculate_crc(monitor->registers, &crc);
monitor->expected_crc = crc;
monitor->expected_crc_inv = ~crc;

View File

@ -27,6 +27,7 @@
#include <reflow-controller/digio.h>
#include <stdlib.h>
#include <malloc.h>
#include <inttypes.h>
#include <helper-macros/helper-macros.h>
#include <reflow-controller/systick.h>
#include <stm-periph/unique-id.h>
@ -43,6 +44,7 @@
#include <reflow-controller/hw-version-detect.h>
#include <reflow-controller/temp-profile/temp-profile-executer.h>
#include <reflow-controller/updater/updater.h>
#include <reflow-controller/main-cycle-counter.h>
#ifndef GIT_VER
#define GIT_VER "VERSION NOT SET"
@ -790,6 +792,43 @@ shellmatta_retCode_t shell_cmd_execute(const shellmatta_handle_t handle, const c
return SHELLMATTA_CONTINUE;
}
shellmatta_retCode_t shell_cmd_cycle_count (const shellmatta_handle_t handle, const char *args, uint32_t len)
{
uint64_t counter;
(void)args;
(void)len;
char option;
char *argument;
uint32_t arg_len;
int opt_stat;
bool clear = false;
const shellmatta_opt_long_t options[] = {
{"clear", 'c', SHELLMATTA_OPT_ARG_NONE},
{NULL, '\0', SHELLMATTA_OPT_ARG_NONE},
};
while (1) {
opt_stat = shellmatta_opt_long(handle, options, &option, &argument, &arg_len);
if (opt_stat != SHELLMATTA_OK)
break;
switch (option) {
case 'c':
clear = true;
break;
default:
break;
}
}
counter = main_cycle_counter_get();
shellmatta_printf(handle, "%"PRIu64"\r\n", counter);
if (clear)
main_cycle_counter_init();
return SHELLMATTA_OK;
}
//typedef struct shellmatta_cmd
//{
// char *cmd; /**< command name */
@ -799,7 +838,7 @@ shellmatta_retCode_t shell_cmd_execute(const shellmatta_handle_t handle, const c
// shellmatta_cmdFct_t cmdFct; /**< pointer to the cmd callack function */
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */
//} shellmatta_cmd_t;
static shellmatta_cmd_t cmd[21] = {
static shellmatta_cmd_t cmd[23] = {
{
.cmd = "version",
.cmdAlias = "ver",
@ -967,8 +1006,16 @@ static shellmatta_cmd_t cmd[21] = {
.helpText = "Execute Temp Profile",
.usageText = "execute /path/to/script.tpr",
.cmdFct = shell_cmd_execute,
.next = &cmd[21],
},
{
.cmd = "cyclecount",
.cmdAlias = "cc",
.helpText = "Print out the cycle counter of the main loop",
.usageText = "cyclecount [--clear]",
.cmdFct = shell_cmd_cycle_count,
.next = NULL,
}
},
};
shellmatta_handle_t shell_init(shellmatta_write_t write_func)