Compare commits

...

8 Commits

19 changed files with 164 additions and 40 deletions

View File

@ -8,3 +8,9 @@ reflow-controller.cxxflags
reflow-controller.files reflow-controller.files
reflow-controller.includes reflow-controller.includes
*.creator.user *.creator.user
*.cflags
*.creator
*.cxxflags
*.includes
*.config
*.files

View File

@ -47,8 +47,9 @@ CFILES += temp-converter.c
CFILES += rotary-encoder.c CFILES += rotary-encoder.c
CFILES += stack-check.c
DEFINES += -DDEBUGBUILD DEFINES += -DDEBUGBUILD
#TODO
################################################################################### ###################################################################################
CC=arm-none-eabi-gcc CC=arm-none-eabi-gcc

View File

@ -8,7 +8,7 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* GDSII-Converter is distributed in the hope that it will be useful, * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.

View File

@ -8,7 +8,7 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* GDSII-Converter is distributed in the hope that it will be useful, * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.

View File

@ -13,7 +13,7 @@ license_header = """/* Reflow Oven Controller
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* GDSII-Converter is distributed in the hope that it will be useful, * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.

View File

@ -14,7 +14,7 @@ license_header = """/* Reflow Oven Controller
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* GDSII-Converter is distributed in the hope that it will be useful, * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.

View File

@ -8,7 +8,7 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* GDSII-Converter is distributed in the hope that it will be useful, * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.

View File

@ -0,0 +1,41 @@
/* 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.
*
* GDSII-Converter 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 __STACK_CHECK_H__
#define __STACK_CHECK_H__
#include <stdint.h>
#define STACK_CHECK_MIN_HEAP_GAP 16UL
int32_t stack_check_get_usage();
int32_t stack_check_get_free();
static inline uint32_t read_stack_pointer()
{
uint32_t stack_pointer;
__asm__ __volatile__ ("mov %0, sp\n\t" : "=r"(stack_pointer) : : );
return stack_pointer;
}
#endif /* __STACK_CHECK_H__ */

View File

@ -8,7 +8,7 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* GDSII-Converter is distributed in the hope that it will be useful, * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
@ -75,7 +75,7 @@ int main()
shell_handle = shell_init(); shell_handle = shell_init();
while(1) { while (1) {
pt1000_value_status = adc_pt1000_get_current_resistance(&pt1000_value); pt1000_value_status = adc_pt1000_get_current_resistance(&pt1000_value);
rot = rotary_encoder_get_abs_val(); rot = rotary_encoder_get_abs_val();
uart_receive_status = uart_receive_data_with_dma(&uart_input, &uart_input_len); uart_receive_status = uart_receive_data_with_dma(&uart_input, &uart_input_len);
@ -84,5 +84,3 @@ int main()
} }
} }

View File

@ -8,7 +8,7 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* GDSII-Converter is distributed in the hope that it will be useful, * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.

View File

@ -8,7 +8,7 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* GDSII-Converter is distributed in the hope that it will be useful, * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
@ -29,6 +29,8 @@
#include <stm-periph/unique-id.h> #include <stm-periph/unique-id.h>
#include <reflow-controller/calibration.h> #include <reflow-controller/calibration.h>
#include <reflow-controller/temp-converter.h> #include <reflow-controller/temp-converter.h>
#include <reflow-controller/stack-check.h>
#include <reflow-controller/rotary-encoder.h> #include <reflow-controller/rotary-encoder.h>
#ifndef GIT_VER #ifndef GIT_VER
@ -46,8 +48,8 @@ static shellmatta_retCode_t write_shell_callback(const char *data, uint32_t len)
} }
static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle, static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
const char *arguments, const char *arguments,
uint32_t length) uint32_t length)
{ {
(void)arguments; (void)arguments;
(void)length; (void)length;
@ -58,22 +60,22 @@ static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
unique_id_get(&high_id, &mid_id, &low_id); unique_id_get(&high_id, &mid_id, &low_id);
shellmatta_printf(handle, "Reflow Oven Controller Firmware " xstr(GIT_VER) "\r\n" shellmatta_printf(handle, "Reflow Oven Controller Firmware " xstr(GIT_VER) "\r\n"
"Compiled: " __DATE__ " at " __TIME__ "\r\n" "Compiled: " __DATE__ " at " __TIME__ "\r\n"
"Serial: %08X-%08X-%08X", high_id, mid_id, low_id); "Serial: %08X-%08X-%08X", high_id, mid_id, low_id);
return SHELLMATTA_OK; return SHELLMATTA_OK;
} }
static shellmatta_retCode_t shell_cmd_digio_get(const shellmatta_handle_t handle, static shellmatta_retCode_t shell_cmd_digio_get(const shellmatta_handle_t handle,
const char *arguments, const char *arguments,
uint32_t length) uint32_t length)
{ {
(void)arguments; (void)arguments;
(void)length; (void)length;
shellmatta_printf(handle, shellmatta_printf(handle,
"DIGIO0 DIGIO1 DIGIO2 DIGIO3 LED0 LED1 LS\r\n" "DIGIO0 DIGIO1 DIGIO2 DIGIO3 LED0 LED1 LS\r\n"
"%d %d %d %d %d %d %d\r\n", "%d %d %d %d %d %d %d\r\n",
digio_get(0), digio_get(1), digio_get(2), digio_get(3), digio_get(0), digio_get(1), digio_get(2), digio_get(3),
led_get(0), led_get(1), loudspeaker_get()); led_get(0), led_get(1), loudspeaker_get());
@ -81,8 +83,8 @@ static shellmatta_retCode_t shell_cmd_digio_get(const shellmatta_handle_t hand
} }
static shellmatta_retCode_t shell_cmd_digio_set(const shellmatta_handle_t handle, static shellmatta_retCode_t shell_cmd_digio_set(const shellmatta_handle_t handle,
const char *arguments, const char *arguments,
uint32_t length) uint32_t length)
{ {
(void)length; (void)length;
(void)handle; (void)handle;
@ -193,8 +195,8 @@ static shellmatta_retCode_t shell_cmd_uptime(const shellmatta_handle_t handle,
} }
static shellmatta_retCode_t shell_cmd_cal(const shellmatta_handle_t handle, static shellmatta_retCode_t shell_cmd_cal(const shellmatta_handle_t handle,
const char *arguments, const char *arguments,
uint32_t length) uint32_t length)
{ {
(void)arguments; (void)arguments;
(void)length; (void)length;
@ -203,12 +205,30 @@ static shellmatta_retCode_t shell_cmd_cal(const shellmatta_handle_t handle,
return SHELLMATTA_OK; return SHELLMATTA_OK;
} }
static shellmatta_retCode_t shell_cmd_rot(const shellmatta_handle_t handle, static shellmatta_retCode_t shell_get_sp(const shellmatta_handle_t handle,
const char *arguments, const char *arguments,
uint32_t length) uint32_t length)
{ {
(void)arguments; (void)arguments;
(void)length; (void)length;
shellmatta_printf(handle,
"Stack pointer: %p\r\n"
"Stack usage: 0x%x bytes\r\n"
"Lim to heap: 0x%x bytes\r\n",
read_stack_pointer(),
stack_check_get_usage(),
stack_check_get_free());
return SHELLMATTA_OK;
}
static shellmatta_retCode_t shell_cmd_rot(const shellmatta_handle_t handle,
const char *arguments,
uint32_t length)
{
(void)arguments;
(void)length;
uint32_t rot_val; uint32_t rot_val;
int32_t delta; int32_t delta;
@ -218,6 +238,7 @@ static shellmatta_retCode_t shell_cmd_rot(const shellmatta_handle_t handle,
return SHELLMATTA_OK; return SHELLMATTA_OK;
} }
//typedef struct shellmatta_cmd //typedef struct shellmatta_cmd
//{ //{
// char *cmd; /**< command name */ // char *cmd; /**< command name */
@ -228,7 +249,7 @@ static shellmatta_retCode_t shell_cmd_rot(const shellmatta_handle_t handle,
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */ // struct shellmatta_cmd *next; /**< pointer to next command or NULL */
//} shellmatta_cmd_t; //} shellmatta_cmd_t;
static shellmatta_cmd_t cmd[8] = { static shellmatta_cmd_t cmd[9] = {
{ {
.cmd = "version", .cmd = "version",
.cmdAlias = "ver", .cmdAlias = "ver",
@ -285,6 +306,14 @@ static shellmatta_cmd_t cmd[8] = {
.cmdFct = shell_cmd_cal, .cmdFct = shell_cmd_cal,
.next = &cmd[7], .next = &cmd[7],
}, },
{
.cmd = "get-stack-pointer",
.cmdAlias = "sp",
.helpText = "Get the stack pointer",
.usageText = "",
.cmdFct = shell_get_sp,
.next = &cmd[8],
},
{ {
.cmd = "rotary-encoder", .cmd = "rotary-encoder",
.cmdAlias = "rot", .cmdAlias = "rot",
@ -301,7 +330,7 @@ shellmatta_handle_t shell_init(void)
shellmatta_retCode_t ret; shellmatta_retCode_t ret;
ret = shellmatta_doInit(&shell, &handle, shell_buffer, sizeof(shell_buffer), history_buffer, sizeof(history_buffer), ret = shellmatta_doInit(&shell, &handle, shell_buffer, sizeof(shell_buffer), history_buffer, sizeof(history_buffer),
"\e[1;32mEnter command:\e[m\r\n", cmd, write_shell_callback); "\e[1;32mEnter command:\e[m\r\n", cmd, write_shell_callback);
if (ret != SHELLMATTA_OK) if (ret != SHELLMATTA_OK)
handle = NULL; handle = NULL;
@ -311,10 +340,10 @@ shellmatta_handle_t shell_init(void)
void shell_handle_input(shellmatta_handle_t shell, const char *data, size_t len) void shell_handle_input(shellmatta_handle_t shell, const char *data, size_t len)
{ {
if (!shell) if (!shell)
return; return;
shellmatta_processData(shell, (char *)data, (uint32_t)len); shellmatta_processData(shell, (char *)data, (uint32_t)len);
} }
void shell_print_string(shellmatta_handle_t shell, const char *string) void shell_print_string(shellmatta_handle_t shell, const char *string)

View File

@ -0,0 +1,47 @@
/* 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/stack-check.h>
#include <stdint.h>
extern char _estack;
extern char heap_top;
int32_t stack_check_get_usage()
{
uint32_t stack_top;
uint32_t stack_ptr;
stack_ptr = read_stack_pointer();
stack_top = (uint32_t)&_estack;
return stack_top - stack_ptr;
}
int32_t stack_check_get_free()
{
uint32_t upper_heap_boundary;
uint32_t stack_ptr;
stack_ptr = read_stack_pointer();
upper_heap_boundary = (uint32_t)&heap_top;
return stack_ptr - upper_heap_boundary;
}

View File

@ -8,7 +8,7 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* GDSII-Converter is distributed in the hope that it will be useful, * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.

View File

@ -8,7 +8,7 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* GDSII-Converter is distributed in the hope that it will be useful, * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.

View File

@ -8,7 +8,7 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* GDSII-Converter is distributed in the hope that it will be useful, * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
@ -66,7 +66,9 @@ void uart_disable()
UART_PERIPH->CR3 = 0; UART_PERIPH->CR3 = 0;
dma_ring_buffer_periph_to_mem_stop(&ring_buff_rx); dma_ring_buffer_periph_to_mem_stop(&ring_buff_rx);
dma_ring_buffer_mem_to_periph_stop(&ring_buff_tx); dma_ring_buffer_mem_to_periph_stop(&ring_buff_tx);
rcc_manager_disable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(UART_PORT_RCC_MASK)); #ifdef DEBUGBUILD
rcc_manager_disable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(UART_PORT_RCC_MASK));
#endif
rcc_manager_disable_clock(&RCC->APB2ENR, BITMASK_TO_BITNO(UART_RCC_MASK)); rcc_manager_disable_clock(&RCC->APB2ENR, BITMASK_TO_BITNO(UART_RCC_MASK));
} }

View File

@ -8,7 +8,7 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* GDSII-Converter is distributed in the hope that it will be useful, * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.

View File

@ -8,7 +8,7 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* GDSII-Converter is distributed in the hope that it will be useful, * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.

View File

@ -8,7 +8,7 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* GDSII-Converter is distributed in the hope that it will be useful, * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.

View File

@ -8,7 +8,7 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
* *
* GDSII-Converter is distributed in the hope that it will be useful, * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.