2020-02-15 22:09:55 +01: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.
|
|
|
|
*
|
2020-02-21 21:22:01 +01:00
|
|
|
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
2020-02-15 22:09:55 +01:00
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2020-02-16 17:35:35 +01:00
|
|
|
/**
|
|
|
|
* @file main.c
|
|
|
|
* @brief Main file for firmware
|
|
|
|
*/
|
|
|
|
|
2020-01-26 21:07:54 +01:00
|
|
|
#include <stdlib.h>
|
2020-02-02 00:01:08 +01:00
|
|
|
#include <string.h>
|
2020-02-12 21:00:35 +01:00
|
|
|
/* #include <arm_math.h> */
|
|
|
|
#include <stm32/stm32f4xx.h>
|
|
|
|
#include <cmsis/core_cm4.h>
|
|
|
|
#include <setup/system_stm32f4xx.h>
|
|
|
|
#include <reflow-controller/systick.h>
|
|
|
|
#include <reflow-controller/adc-meas.h>
|
|
|
|
#include <reflow-controller/shell.h>
|
|
|
|
#include <reflow-controller/digio.h>
|
2020-02-16 16:38:31 +01:00
|
|
|
#include <reflow-controller/rotary-encoder.h>
|
2020-02-12 21:00:35 +01:00
|
|
|
#include <stm-periph/stm32-gpio-macros.h>
|
|
|
|
#include <stm-periph/clock-enable-manager.h>
|
2020-02-12 21:06:52 +01:00
|
|
|
#include <stm-periph/uart.h>
|
2020-01-26 21:07:54 +01:00
|
|
|
|
2020-02-02 20:24:44 +01:00
|
|
|
static void setup_nvic_priorities()
|
2020-01-26 21:07:54 +01:00
|
|
|
{
|
2020-02-02 20:24:44 +01:00
|
|
|
/* No sub priorities */
|
|
|
|
NVIC_SetPriorityGrouping(2);
|
2020-01-26 21:07:54 +01:00
|
|
|
|
2020-02-02 20:24:44 +01:00
|
|
|
/* Setup Priorities */
|
2020-02-05 23:09:23 +01:00
|
|
|
NVIC_SetPriority(ADC_IRQn, 2);
|
|
|
|
NVIC_SetPriority(DMA2_Stream0_IRQn, 1);
|
2020-02-12 21:00:35 +01:00
|
|
|
NVIC_SetPriority(DMA2_Stream7_IRQn, 3);
|
2020-02-02 00:01:08 +01:00
|
|
|
}
|
|
|
|
|
2020-02-02 20:24:44 +01:00
|
|
|
static float pt1000_value;
|
|
|
|
static volatile int pt1000_value_status;
|
2020-02-16 16:38:31 +01:00
|
|
|
static uint32_t rot;
|
|
|
|
|
2020-02-02 00:01:08 +01:00
|
|
|
|
2020-02-09 19:13:37 +01:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
const char *uart_input;
|
|
|
|
size_t uart_input_len;
|
|
|
|
shellmatta_handle_t shell_handle;
|
2020-02-15 17:53:15 +01:00
|
|
|
int uart_receive_status;
|
2020-02-09 19:13:37 +01:00
|
|
|
|
2020-02-02 20:24:44 +01:00
|
|
|
setup_nvic_priorities();
|
2020-02-02 00:01:08 +01:00
|
|
|
systick_setup();
|
|
|
|
|
2020-02-02 01:49:37 +01:00
|
|
|
adc_pt1000_setup_meas();
|
2020-01-26 21:07:54 +01:00
|
|
|
|
2020-02-10 22:38:24 +01:00
|
|
|
digio_setup_default_all();
|
|
|
|
led_setup();
|
|
|
|
loudspeaker_setup();
|
2020-02-16 16:38:31 +01:00
|
|
|
rotary_encoder_setup();
|
2020-02-10 22:38:24 +01:00
|
|
|
|
2020-02-09 19:13:37 +01:00
|
|
|
uart_init_with_dma();
|
|
|
|
|
|
|
|
shell_handle = shell_init();
|
|
|
|
|
2020-02-21 23:37:48 +01:00
|
|
|
while (1) {
|
2020-02-02 20:24:44 +01:00
|
|
|
pt1000_value_status = adc_pt1000_get_current_resistance(&pt1000_value);
|
2020-02-16 16:38:31 +01:00
|
|
|
rot = rotary_encoder_get_abs_val();
|
2020-02-15 17:53:15 +01:00
|
|
|
uart_receive_status = uart_receive_data_with_dma(&uart_input, &uart_input_len);
|
|
|
|
if (uart_receive_status >= 1)
|
2020-02-09 19:13:37 +01:00
|
|
|
shell_handle_input(shell_handle, uart_input, uart_input_len);
|
2020-01-26 21:07:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|