Compare commits
10 Commits
43b14bdb92
...
jenkins
Author | SHA1 | Date | |
---|---|---|---|
4efa5ae797 | |||
5e90cd39fa | |||
015028bde2 | |||
4e6e5db2c3 | |||
a2bcd37800 | |||
ed936cf9f9 | |||
e595e398d4 | |||
86446e1b22 | |||
b26233d5e3 | |||
0ab13edced |
20
Jenkinsfile
vendored
20
Jenkinsfile
vendored
@@ -2,9 +2,22 @@ pipeline {
|
|||||||
agent any
|
agent any
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Build') {
|
stage('Configure') {
|
||||||
|
steps {
|
||||||
|
echo 'Configuring Cmake...'
|
||||||
|
sh '''
|
||||||
|
mkdir "build" &&
|
||||||
|
cd "build" &&
|
||||||
|
cmake "../stm-firmware"
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Build') {
|
||||||
steps {
|
steps {
|
||||||
echo 'Building..'
|
sh '''
|
||||||
|
cd "build" &&
|
||||||
|
make
|
||||||
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Test') {
|
stage('Test') {
|
||||||
@@ -13,8 +26,9 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Deploy') {
|
stage('Deploy') {
|
||||||
|
when { tag "*" }
|
||||||
steps {
|
steps {
|
||||||
echo 'Deploying....'
|
echo 'Deploying tag...'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,4 +15,4 @@ mechanisms and the behavior. For a detailed code documentation see the doxygen o
|
|||||||
safety/index
|
safety/index
|
||||||
code/index
|
code/index
|
||||||
hw-version-detect
|
hw-version-detect
|
||||||
peripherals
|
|
||||||
|
@@ -1,44 +0,0 @@
|
|||||||
.. _peripherals:
|
|
||||||
|
|
||||||
Used Peripheral Modules
|
|
||||||
=======================
|
|
||||||
|
|
||||||
This section lists all the used peripheral modules of the ``STM32F407VxT6``.
|
|
||||||
|
|
||||||
Core Peripherals
|
|
||||||
----------------
|
|
||||||
|
|
||||||
- ``SysTick``: Generating a 100us tick for the LCD routine and 1ms base system tick.
|
|
||||||
- ``NVIC``: Interrupt controller
|
|
||||||
- ``FPU``: The Flaoting Point Unit is activated and used in this formware.
|
|
||||||
|
|
||||||
AHB Peripherals
|
|
||||||
---------------
|
|
||||||
|
|
||||||
- ``DMA2``
|
|
||||||
- ``Stream0``: DMA transfer of PT1000 measurement ADC to memory
|
|
||||||
- ``Stream4``: DMA transfer of Safety ADC measurement values
|
|
||||||
- ``Stream5``: Shell UART RX
|
|
||||||
- ``Stream7``: Shell UART TX
|
|
||||||
- ``RNG``: Random number generation for stack corruption / overflow checker.
|
|
||||||
- ``CRC``: CRC verfication of various data (Safety structures, EEPROM data, Safety RAM)
|
|
||||||
- ``Backup RAM``: Backup RAM storing errors and bootloader information beyond system resets. The memory is cleared by a power cycle!
|
|
||||||
|
|
||||||
ABP1 Peripherals
|
|
||||||
----------------
|
|
||||||
|
|
||||||
- ``IWDG``: Independent Watchdog
|
|
||||||
- ``TIM2``: PT1000 measurement ADC sample time generation timer. Genewrates the 1 KHz sample trigger to the ADC peripheral via the internal event routing system.
|
|
||||||
- ``TIM3``: PWM timer for oven relais output.
|
|
||||||
- ``TIM5``: Input capture for rotary encoder.
|
|
||||||
- ``TIM7``: Timer for loudspeaker tone generation.
|
|
||||||
|
|
||||||
|
|
||||||
APB2 Peripherals
|
|
||||||
----------------
|
|
||||||
|
|
||||||
- ``SPI1``: SPI for external SPI-EEPROM
|
|
||||||
- ``SDIO``: SD card interface
|
|
||||||
- ``USART1``: Shell UART
|
|
||||||
- ``ADC1``: Safety ADC for monitoring voltages
|
|
||||||
- ``ADC3``: PT1000 measurement ADC
|
|
@@ -324,6 +324,7 @@ void __attribute__((noreturn)) Reset_Handler(void) {
|
|||||||
/* Move the stack and the stack pointer to CCMRAM
|
/* Move the stack and the stack pointer to CCMRAM
|
||||||
* This allows us to perform a RAM test on the main RAM.
|
* This allows us to perform a RAM test on the main RAM.
|
||||||
*/
|
*/
|
||||||
|
/* R2 holds the amount of bytes / words on the stack. */
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"mov r2, sp\n" /* Move stack pointer to register 2 */
|
"mov r2, sp\n" /* Move stack pointer to register 2 */
|
||||||
"sub r2, %[stacktop], r2\n" /* Subtract stackpointer from top of ram => byte usage */
|
"sub r2, %[stacktop], r2\n" /* Subtract stackpointer from top of ram => byte usage */
|
||||||
|
@@ -31,12 +31,6 @@
|
|||||||
#define CONFIG_PARSER_MAGIC 0x464a6e2bUL
|
#define CONFIG_PARSER_MAGIC 0x464a6e2bUL
|
||||||
#define CONFIG_PARSER(p) ((struct config_parser *)(p))
|
#define CONFIG_PARSER(p) ((struct config_parser *)(p))
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check if the supplied pointer is a valid @ref config_parser_handle_t
|
|
||||||
*
|
|
||||||
* If the pointer is invalid, the function using this macro will return with
|
|
||||||
* CONFIG_PARSER_PARAM_ERR
|
|
||||||
*/
|
|
||||||
#define config_parser_check_handle(handle) do { if (!(handle) || \
|
#define config_parser_check_handle(handle) do { if (!(handle) || \
|
||||||
((struct config_parser *)(handle))->magic != CONFIG_PARSER_MAGIC) \
|
((struct config_parser *)(handle))->magic != CONFIG_PARSER_MAGIC) \
|
||||||
return CONFIG_PARSER_PARAM_ERR; \
|
return CONFIG_PARSER_PARAM_ERR; \
|
||||||
@@ -62,18 +56,9 @@ config_parser_handle_t config_parser_open_file(struct config_parser *config_pars
|
|||||||
return (config_parser_handle_t)config_parser;
|
return (config_parser_handle_t)config_parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Token delimiters for the config parser.
|
|
||||||
*/
|
|
||||||
static const char * const token_delim = " \t";
|
static const char * const token_delim = " \t";
|
||||||
|
|
||||||
/**
|
static int parse_value(struct config_parser_entry *entry, char *value_start_token)
|
||||||
* @brief Parse a value in the configuration
|
|
||||||
* @param entry Entry to parse the value in to
|
|
||||||
* @param value_start_token char pointer holding the value. Must be null-terminated
|
|
||||||
* @return 0 if successful
|
|
||||||
*/
|
|
||||||
static int parse_value(struct config_parser_entry *entry, char *value_start_token)
|
|
||||||
{
|
{
|
||||||
char *dot;
|
char *dot;
|
||||||
char *endptr;
|
char *endptr;
|
||||||
@@ -91,6 +76,7 @@ static int parse_value(struct config_parser_entry *entry, char *value_start_toke
|
|||||||
|
|
||||||
if (value_start_token[0] != '-') {
|
if (value_start_token[0] != '-') {
|
||||||
/* Try parsing as ul */
|
/* Try parsing as ul */
|
||||||
|
/* Try parsing as int */
|
||||||
entry->value.uint_val = strtoul(value_start_token, &endptr, 0);
|
entry->value.uint_val = strtoul(value_start_token, &endptr, 0);
|
||||||
if (endptr == value_start_token) {
|
if (endptr == value_start_token) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@@ -33,68 +33,44 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <fatfs/ff.h>
|
#include <fatfs/ff.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Confi parser instance struct
|
|
||||||
*/
|
|
||||||
struct config_parser {
|
struct config_parser {
|
||||||
uint32_t magic; /**< @brief Magic value. Checked by each function to verify if the passed pointer is valid */
|
uint32_t magic;
|
||||||
bool write; /**< @brief File opened in write / read mode */
|
bool write;
|
||||||
FIL file; /**< @brief FatFS file */
|
FIL file;
|
||||||
char *buffer; /**< @brief Working buffer */
|
char *buffer;
|
||||||
size_t buff_size; /** @brief Size of the working buffer config_parser::buffer */
|
size_t buff_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief handle type for the config parser. Never dereference this pointer directly!
|
|
||||||
*/
|
|
||||||
typedef void * config_parser_handle_t;
|
typedef void * config_parser_handle_t;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Differnet value types a config entry can hold
|
|
||||||
*/
|
|
||||||
enum config_parser_value_type {
|
enum config_parser_value_type {
|
||||||
CONFIG_PARSER_TYPE_UINT = 0,
|
CONFIG_PARSER_TYPE_UINT = 0,
|
||||||
CONFIG_PARSER_TYPE_INT,
|
CONFIG_PARSER_TYPE_INT,
|
||||||
CONFIG_PARSER_TYPE_FLOAT,
|
CONFIG_PARSER_TYPE_FLOAT,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Error return code of config parser functions
|
|
||||||
*/
|
|
||||||
enum config_parser_ret {
|
enum config_parser_ret {
|
||||||
CONFIG_PARSER_OK = 0, /**< @brief Operation succeeded */
|
CONFIG_PARSER_OK = 0,
|
||||||
CONFIG_PARSER_PARAM_ERR, /**< @brief Function parameter error */
|
CONFIG_PARSER_PARAM_ERR,
|
||||||
CONFIG_PARSER_GENERIC_ERR, /**< @brief Generic unspecified error */
|
CONFIG_PARSER_GENERIC_ERR,
|
||||||
CONFIG_PARSER_IOERR, /**< @brief I/O Error while file handling */
|
CONFIG_PARSER_IOERR,
|
||||||
CONFIG_PARSER_LINE_COMMENT, /**< @brief The parser encountered a line starting with a comment. */
|
CONFIG_PARSER_LINE_COMMENT,
|
||||||
CONFIG_PARSER_LINE_TOO_LONG, /**< @brief The read line is too long for the parser to process. */
|
CONFIG_PARSER_LINE_TOO_LONG,
|
||||||
CONFIG_PARSER_LINE_MALFORM, /**< @brief Malfoirmed line. Line is neither a commenbt nor a key=value string */
|
CONFIG_PARSER_LINE_MALFORM,
|
||||||
CONFIG_PARSER_END_REACHED, /**< @brief The config parser has reached the end of the file */
|
CONFIG_PARSER_END_REACHED,
|
||||||
CONFIG_PARSER_WRONG_MODE, /**< @brief Read or write requested on config parser instance that is opened in a different mode */
|
CONFIG_PARSER_WRONG_MODE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Represents a configuration key-value-pair used by the config parser
|
|
||||||
*/
|
|
||||||
struct config_parser_entry {
|
struct config_parser_entry {
|
||||||
const char *name; /**< @brief Pointer to the name of the config entry (key) */
|
const char *name;
|
||||||
enum config_parser_value_type type; /**< @brief Type of the value held by this struct */
|
enum config_parser_value_type type;
|
||||||
union {
|
union {
|
||||||
uint32_t uint_val;
|
uint32_t uint_val;
|
||||||
int32_t int_val;
|
int32_t int_val;
|
||||||
float float_val;
|
float float_val;
|
||||||
} value; /**< @brief Value of the config entry. For correct processing, config_parser_entry::type has to be taken into account */
|
} value;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Open a config file
|
|
||||||
* @param config_parser Struict holding the config parser isntance. Will be filled by this function
|
|
||||||
* @param write Open the config file for writing (true) or reading (false)
|
|
||||||
* @param file_name File name to open
|
|
||||||
* @param working_buffer A working buffer used by the config parser to process the file.
|
|
||||||
* @param buff_size Size of \p working_buffer. Must be large enough to hold a full line of the config file
|
|
||||||
* @return Config parser error
|
|
||||||
*/
|
|
||||||
config_parser_handle_t config_parser_open_file(struct config_parser *config_parser, bool write, const char *file_name,
|
config_parser_handle_t config_parser_open_file(struct config_parser *config_parser, bool write, const char *file_name,
|
||||||
char *working_buffer, size_t buff_size);
|
char *working_buffer, size_t buff_size);
|
||||||
|
|
||||||
@@ -107,37 +83,13 @@ config_parser_handle_t config_parser_open_file(struct config_parser *config_pars
|
|||||||
* @return Config parser error
|
* @return Config parser error
|
||||||
*/
|
*/
|
||||||
enum config_parser_ret config_parser_get_line(config_parser_handle_t handle, struct config_parser_entry *entry, bool force_float);
|
enum config_parser_ret config_parser_get_line(config_parser_handle_t handle, struct config_parser_entry *entry, bool force_float);
|
||||||
/**
|
|
||||||
* @brief Reset the config parser instance to the beginning of the config file
|
|
||||||
* @param handle Config parser
|
|
||||||
* @return Config parser error
|
|
||||||
*/
|
|
||||||
enum config_parser_ret config_parser_reset_to_start(config_parser_handle_t handle);
|
enum config_parser_ret config_parser_reset_to_start(config_parser_handle_t handle);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Write a config entry to a config file
|
|
||||||
* @param handle Handle to the config parser. This must be opened in write mode.
|
|
||||||
* @param entry
|
|
||||||
* @return Config parser error
|
|
||||||
* @warning This function is currently not implemented and will return with a success!
|
|
||||||
*/
|
|
||||||
enum config_parser_ret config_parser_write_entry(config_parser_handle_t handle, const struct config_parser_entry *entry);
|
enum config_parser_ret config_parser_write_entry(config_parser_handle_t handle, const struct config_parser_entry *entry);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Close a config parser handle
|
|
||||||
* @param handle Config parser
|
|
||||||
* @return Config parser error
|
|
||||||
*/
|
|
||||||
enum config_parser_ret config_parser_close_file(config_parser_handle_t handle);
|
enum config_parser_ret config_parser_close_file(config_parser_handle_t handle);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check if the \p return_val is a abort condition to stop parsing a file.
|
|
||||||
*
|
|
||||||
* This function will return true if a disk error occured or the end of file is reached.
|
|
||||||
*
|
|
||||||
* @param return_val
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
bool config_parser_ret_is_abort_condition(enum config_parser_ret return_val);
|
bool config_parser_ret_is_abort_condition(enum config_parser_ret return_val);
|
||||||
|
|
||||||
#endif /* _CONFIG_PARSER_H_ */
|
#endif /* _CONFIG_PARSER_H_ */
|
||||||
|
@@ -89,8 +89,7 @@ with open(filename, 'r+b') as f:
|
|||||||
print('Section for flash CRC missing!')
|
print('Section for flash CRC missing!')
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
if flashcrc_sec.data_size != 6*4:
|
if flashcrc_sec.data_size != 6*4:
|
||||||
print("Error: .flashcrc section has wrong size:",flashcrc_sec.data_size)
|
print("Warning!!! .flashcrc section has wrong size:",flashcrc_sec.data_size)
|
||||||
sys.exit(-1);
|
|
||||||
|
|
||||||
crc_sec_data = bytearray(flashcrc_sec.data())
|
crc_sec_data = bytearray(flashcrc_sec.data())
|
||||||
magic1 = struct.unpack('<I'*1, bytes(crc_sec_data[0:4]))[0]
|
magic1 = struct.unpack('<I'*1, bytes(crc_sec_data[0:4]))[0]
|
||||||
|
@@ -18,11 +18,6 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @addtogroup digio
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <reflow-controller/digio.h>
|
#include <reflow-controller/digio.h>
|
||||||
#include <stm32/stm32f4xx.h>
|
#include <stm32/stm32f4xx.h>
|
||||||
#include <stm-periph/rcc-manager.h>
|
#include <stm-periph/rcc-manager.h>
|
||||||
@@ -52,10 +47,17 @@ static void digio_setup_pin_int(uint8_t bit_no, uint8_t in_out, uint8_t alt_func
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void digio_init(void)
|
void digio_setup_default_all(void)
|
||||||
{
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(DIGIO_RCC_MASK));
|
rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(DIGIO_RCC_MASK));
|
||||||
digio_set_default_values();
|
|
||||||
|
for (i = 0; i < COUNT_OF(digio_pins); i++) {
|
||||||
|
digio_setup_pin_int(digio_pins[i], digio_default_io[i], digio_default_altfunc[i]);
|
||||||
|
if (digio_default_io[i] == 1)
|
||||||
|
digio_set(i, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void digio_setup_pin(uint8_t num, uint8_t in_out, uint8_t alt_func)
|
void digio_setup_pin(uint8_t num, uint8_t in_out, uint8_t alt_func)
|
||||||
@@ -67,22 +69,12 @@ void digio_setup_pin(uint8_t num, uint8_t in_out, uint8_t alt_func)
|
|||||||
|
|
||||||
void digio_set(uint8_t num, int val)
|
void digio_set(uint8_t num, int val)
|
||||||
{
|
{
|
||||||
uint8_t pin;
|
|
||||||
|
|
||||||
if (num >= COUNT_OF(digio_pins))
|
if (num >= COUNT_OF(digio_pins))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pin = digio_pins[num];
|
|
||||||
|
|
||||||
/* Check if port is an output. If not, do noting. */
|
|
||||||
if ((DIGIO_PORT->MODER & (0x3<<pin)) != OUTPUT(pin)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (val)
|
if (val)
|
||||||
DIGIO_PORT->ODR |= (1<<pin);
|
DIGIO_PORT->ODR |= (1<<digio_pins[num]);
|
||||||
else
|
else
|
||||||
DIGIO_PORT->ODR &= ~(1<<pin);
|
DIGIO_PORT->ODR &= ~(1<<digio_pins[num]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int digio_get(uint8_t num)
|
int digio_get(uint8_t num)
|
||||||
@@ -127,12 +119,7 @@ int led_get(uint8_t num)
|
|||||||
return ((LED_PORT->ODR & (1<<led_pins[num])) ? 1 : 0);
|
return ((LED_PORT->ODR & (1<<led_pins[num])) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialize the timer for the beeper to generate the output frequency
|
|
||||||
*
|
|
||||||
* TIM7 is used as the frequency generating timer. If @ref LOUDSPEAKER_MULTIFREQ
|
|
||||||
* is 0, the timer is unused and this function does nothing.
|
|
||||||
*/
|
|
||||||
static void loudspeaker_freq_timer_init(void)
|
static void loudspeaker_freq_timer_init(void)
|
||||||
{
|
{
|
||||||
#if LOUDSPEAKER_MULTIFREQ
|
#if LOUDSPEAKER_MULTIFREQ
|
||||||
@@ -156,13 +143,6 @@ void loudspeaker_setup(void)
|
|||||||
loudspeaker_set(0U);
|
loudspeaker_set(0U);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Start the beeper
|
|
||||||
* @param val frequency value of the speaker in 'Timer relaod values'
|
|
||||||
* @note If @ref LOUDSPEAKER_MULTIFREQ isn't set,
|
|
||||||
* the speaker output will be set to high and no frequency is generated.
|
|
||||||
* The value of @p val is ignored in this case
|
|
||||||
*/
|
|
||||||
static void loudspeaker_start_beep(uint16_t val)
|
static void loudspeaker_start_beep(uint16_t val)
|
||||||
{
|
{
|
||||||
#if LOUDSPEAKER_MULTIFREQ
|
#if LOUDSPEAKER_MULTIFREQ
|
||||||
@@ -175,9 +155,6 @@ static void loudspeaker_start_beep(uint16_t val)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Stop the beeping of the loudspeaker
|
|
||||||
*/
|
|
||||||
static void loudspeaker_stop_beep(void)
|
static void loudspeaker_stop_beep(void)
|
||||||
{
|
{
|
||||||
#if LOUDSPEAKER_MULTIFREQ
|
#if LOUDSPEAKER_MULTIFREQ
|
||||||
@@ -207,12 +184,6 @@ uint16_t loudspeaker_get(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if LOUDSPEAKER_MULTIFREQ
|
#if LOUDSPEAKER_MULTIFREQ
|
||||||
/**
|
|
||||||
* @brief Timer7 IRQ Handler
|
|
||||||
*
|
|
||||||
* This IRQ Handler is used by the loudspeaker to synthesize the output frequency.
|
|
||||||
* If @ref LOUDSPEAKER_MULTIFREQ is 0, TIM7 and this interrupt will not be used.
|
|
||||||
*/
|
|
||||||
void TIM7_IRQHandler(void)
|
void TIM7_IRQHandler(void)
|
||||||
{
|
{
|
||||||
TIM7->SR = 0UL;
|
TIM7->SR = 0UL;
|
||||||
@@ -220,16 +191,3 @@ void TIM7_IRQHandler(void)
|
|||||||
LOUDSPEAKER_PORT->ODR ^= (1<<LOUDSPEAKER_PIN);
|
LOUDSPEAKER_PORT->ODR ^= (1<<LOUDSPEAKER_PIN);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
void digio_set_default_values()
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for (i = 0; i < COUNT_OF(digio_pins); i++) {
|
|
||||||
digio_setup_pin_int(digio_pins[i], digio_default_io[i], digio_default_altfunc[i]);
|
|
||||||
if (digio_default_io[i] == 1)
|
|
||||||
digio_set(i, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -463,7 +463,7 @@ LOOKUP_CACHE_SIZE = 0
|
|||||||
# DOT_NUM_THREADS setting.
|
# DOT_NUM_THREADS setting.
|
||||||
# Minimum value: 0, maximum value: 32, default value: 1.
|
# Minimum value: 0, maximum value: 32, default value: 1.
|
||||||
|
|
||||||
NUM_PROC_THREADS = 0
|
NUM_PROC_THREADS = 1
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Build related configuration options
|
# Build related configuration options
|
||||||
@@ -968,8 +968,7 @@ EXCLUDE = ../include/stm32 \
|
|||||||
../linklist-lib/test \
|
../linklist-lib/test \
|
||||||
../base64-lib/test \
|
../base64-lib/test \
|
||||||
../shellmatta/doc/main.dox \
|
../shellmatta/doc/main.dox \
|
||||||
../updater/ram-code \
|
../updater/ram-code
|
||||||
./
|
|
||||||
|
|
||||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
# directories that are symbolic links (a Unix file system feature) are excluded
|
||||||
|
@@ -1,24 +0,0 @@
|
|||||||
FatFs License
|
|
||||||
|
|
||||||
FatFs has being developped as a personal project of the author, ChaN. It is free from the code anyone else wrote at current release. Following code block shows a copy of the FatFs license document that heading the source files.
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------/
|
|
||||||
/ FatFs - Generic FAT Filesystem Module Rx.xx /
|
|
||||||
/-----------------------------------------------------------------------------/
|
|
||||||
/
|
|
||||||
/ Copyright (C) 20xx, ChaN, all right reserved.
|
|
||||||
/
|
|
||||||
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
|
||||||
/ source and binary forms, with or without modification, are permitted provided
|
|
||||||
/ that the following condition is met:
|
|
||||||
/
|
|
||||||
/ 1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
/ this condition and the following disclaimer.
|
|
||||||
/
|
|
||||||
/ This software is provided by the copyright holder and contributors "AS IS"
|
|
||||||
/ and any warranties related to this software are DISCLAIMED.
|
|
||||||
/ The copyright owner or contributors be NOT LIABLE for any damages caused
|
|
||||||
/ by use of this software.
|
|
||||||
/----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
Therefore FatFs license is one of the BSD-style licenses, but there is a significant feature. FatFs is mainly intended for embedded systems. In order to extend the usability for commercial products, the redistributions of FatFs in binary form, such as embedded code, binary library and any forms without source code, do not need to include about FatFs in the documentations. This is equivalent to the 1-clause BSD license. Of course FatFs is compatible with the most of open source software licenses include GNU GPL. When you redistribute the FatFs source code with changes or create a fork, the license can also be changed to GNU GPL, BSD-style license or any open source software license that not conflict with FatFs license.
|
|
File diff suppressed because it is too large
Load Diff
@@ -33,9 +33,6 @@ enum hw_revision get_pcb_hardware_version(void)
|
|||||||
uint16_t port_bitmask = 0U;
|
uint16_t port_bitmask = 0U;
|
||||||
static enum hw_revision revision = HW_REV_NOT_DETECTED;
|
static enum hw_revision revision = HW_REV_NOT_DETECTED;
|
||||||
|
|
||||||
/* If the revision has been previously detected,
|
|
||||||
* just return it and don't do the whole detection stuff
|
|
||||||
*/
|
|
||||||
if (revision != HW_REV_NOT_DETECTED)
|
if (revision != HW_REV_NOT_DETECTED)
|
||||||
return revision;
|
return revision;
|
||||||
|
|
||||||
@@ -48,15 +45,12 @@ enum hw_revision get_pcb_hardware_version(void)
|
|||||||
HW_REV_DETECT_GPIO->PUPDR |= PULLUP(current_pin);
|
HW_REV_DETECT_GPIO->PUPDR |= PULLUP(current_pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loop again and read in the pin mask.
|
/* Loop again and read in the pin mask */
|
||||||
* Because we use GND-Shorts on the pins to detect the version, the pins are read inverted.
|
|
||||||
*/
|
|
||||||
for (current_pin = HW_REV_DETECT_PIN_LOW; current_pin <= HW_REV_DETECT_PIN_HIGH; current_pin++) {
|
for (current_pin = HW_REV_DETECT_PIN_LOW; current_pin <= HW_REV_DETECT_PIN_HIGH; current_pin++) {
|
||||||
port_bitmask >>= 1;
|
port_bitmask >>= 1;
|
||||||
port_bitmask |= (HW_REV_DETECT_GPIO->IDR & (1 << current_pin)) ? 0x0 : 0x80;
|
port_bitmask |= (HW_REV_DETECT_GPIO->IDR & (1 << current_pin)) ? 0x0 : 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Resolve the read in bitmask to a hardware version */
|
|
||||||
switch (port_bitmask) {
|
switch (port_bitmask) {
|
||||||
case 0U:
|
case 0U:
|
||||||
revision = HW_REV_V1_2;
|
revision = HW_REV_V1_2;
|
||||||
@@ -64,9 +58,6 @@ enum hw_revision get_pcb_hardware_version(void)
|
|||||||
case 1U:
|
case 1U:
|
||||||
revision = HW_REV_V1_3;
|
revision = HW_REV_V1_3;
|
||||||
break;
|
break;
|
||||||
case 2U:
|
|
||||||
revision = HW_REV_V1_3_1;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
revision = HW_REV_ERROR;
|
revision = HW_REV_ERROR;
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
/*----------------------------------------------------------------------------/
|
/*----------------------------------------------------------------------------/
|
||||||
/ FatFs - Generic FAT Filesystem module R0.14b /
|
/ FatFs - Generic FAT Filesystem module R0.14a /
|
||||||
/-----------------------------------------------------------------------------/
|
/-----------------------------------------------------------------------------/
|
||||||
/
|
/
|
||||||
/ Copyright (C) 2021, ChaN, all right reserved.
|
/ Copyright (C) 2020, ChaN, all right reserved.
|
||||||
/
|
/
|
||||||
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
||||||
/ source and binary forms, with or without modification, are permitted provided
|
/ source and binary forms, with or without modification, are permitted provided
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef FF_DEFINED
|
#ifndef FF_DEFINED
|
||||||
#define FF_DEFINED 86631 /* Revision ID */
|
#define FF_DEFINED 80196 /* Revision ID */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -35,14 +35,10 @@ extern "C" {
|
|||||||
|
|
||||||
/* Integer types used for FatFs API */
|
/* Integer types used for FatFs API */
|
||||||
|
|
||||||
#if defined(_WIN32) /* Windows VC++ (for development only) */
|
#if defined(_WIN32) /* Main development platform */
|
||||||
#define FF_INTDEF 2
|
#define FF_INTDEF 2
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
typedef unsigned __int64 QWORD;
|
typedef unsigned __int64 QWORD;
|
||||||
#include <float.h>
|
|
||||||
#define isnan(v) _isnan(v)
|
|
||||||
#define isinf(v) (!_finite(v))
|
|
||||||
|
|
||||||
#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) /* C99 or later */
|
#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) /* C99 or later */
|
||||||
#define FF_INTDEF 2
|
#define FF_INTDEF 2
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -52,7 +48,6 @@ typedef uint16_t WORD; /* 16-bit unsigned integer */
|
|||||||
typedef uint32_t DWORD; /* 32-bit unsigned integer */
|
typedef uint32_t DWORD; /* 32-bit unsigned integer */
|
||||||
typedef uint64_t QWORD; /* 64-bit unsigned integer */
|
typedef uint64_t QWORD; /* 64-bit unsigned integer */
|
||||||
typedef WORD WCHAR; /* UTF-16 character type */
|
typedef WORD WCHAR; /* UTF-16 character type */
|
||||||
|
|
||||||
#else /* Earlier than C99 */
|
#else /* Earlier than C99 */
|
||||||
#define FF_INTDEF 1
|
#define FF_INTDEF 1
|
||||||
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
|
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
|
||||||
@@ -63,29 +58,28 @@ typedef WORD WCHAR; /* UTF-16 character type */
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Type of file size and LBA variables */
|
/* Definitions of volume management */
|
||||||
|
|
||||||
#if FF_FS_EXFAT
|
#if FF_MULTI_PARTITION /* Multiple partition configuration */
|
||||||
#if FF_INTDEF != 2
|
typedef struct {
|
||||||
#error exFAT feature wants C99 or later
|
BYTE pd; /* Physical drive number */
|
||||||
|
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
|
||||||
|
} PARTITION;
|
||||||
|
extern PARTITION VolToPart[]; /* Volume - Partition mapping table */
|
||||||
#endif
|
#endif
|
||||||
typedef QWORD FSIZE_t;
|
|
||||||
#if FF_LBA64
|
#if FF_STR_VOLUME_ID
|
||||||
typedef QWORD LBA_t;
|
#ifndef FF_VOLUME_STRS
|
||||||
#else
|
extern const char* VolumeStr[FF_VOLUMES]; /* User defied volume ID */
|
||||||
typedef DWORD LBA_t;
|
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
#if FF_LBA64
|
|
||||||
#error exFAT needs to be enabled when enable 64-bit LBA
|
|
||||||
#endif
|
|
||||||
typedef DWORD FSIZE_t;
|
|
||||||
typedef DWORD LBA_t;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Type of path name strings on FatFs API (TCHAR) */
|
/* Type of path name strings on FatFs API */
|
||||||
|
|
||||||
|
#ifndef _INC_TCHAR
|
||||||
|
#define _INC_TCHAR
|
||||||
|
|
||||||
#if FF_USE_LFN && FF_LFN_UNICODE == 1 /* Unicode in UTF-16 encoding */
|
#if FF_USE_LFN && FF_LFN_UNICODE == 1 /* Unicode in UTF-16 encoding */
|
||||||
typedef WCHAR TCHAR;
|
typedef WCHAR TCHAR;
|
||||||
@@ -107,22 +101,28 @@ typedef char TCHAR;
|
|||||||
#define _TEXT(x) x
|
#define _TEXT(x) x
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Definitions of volume management */
|
|
||||||
|
|
||||||
#if FF_MULTI_PARTITION /* Multiple partition configuration */
|
|
||||||
typedef struct {
|
|
||||||
BYTE pd; /* Physical drive number */
|
|
||||||
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
|
|
||||||
} PARTITION;
|
|
||||||
extern PARTITION VolToPart[]; /* Volume - Partition mapping table */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if FF_STR_VOLUME_ID
|
|
||||||
#ifndef FF_VOLUME_STRS
|
|
||||||
extern const char* VolumeStr[FF_VOLUMES]; /* User defied volume ID */
|
/* Type of file size and LBA variables */
|
||||||
|
|
||||||
|
#if FF_FS_EXFAT
|
||||||
|
#if FF_INTDEF != 2
|
||||||
|
#error exFAT feature wants C99 or later
|
||||||
#endif
|
#endif
|
||||||
|
typedef QWORD FSIZE_t;
|
||||||
|
#if FF_LBA64
|
||||||
|
typedef QWORD LBA_t;
|
||||||
|
#else
|
||||||
|
typedef DWORD LBA_t;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#if FF_LBA64
|
||||||
|
#error exFAT needs to be enabled when enable 64-bit LBA
|
||||||
|
#endif
|
||||||
|
typedef DWORD FSIZE_t;
|
||||||
|
typedef DWORD LBA_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/ FatFs Functional Configurations
|
/ FatFs Functional Configurations
|
||||||
/---------------------------------------------------------------------------*/
|
/---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#define FFCONF_DEF 86631 /* Revision ID */
|
#define FFCONF_DEF 80196 /* Revision ID */
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------/
|
/*---------------------------------------------------------------------------/
|
||||||
/ Function Configurations
|
/ Function Configurations
|
||||||
@@ -25,6 +25,14 @@
|
|||||||
/ 3: f_lseek() function is removed in addition to 2. */
|
/ 3: f_lseek() function is removed in addition to 2. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_USE_STRFUNC 1
|
||||||
|
/* This option switches string functions, f_gets(), f_putc(), f_puts() and f_printf().
|
||||||
|
/
|
||||||
|
/ 0: Disable string functions.
|
||||||
|
/ 1: Enable without LF-CRLF conversion.
|
||||||
|
/ 2: Enable with LF-CRLF conversion. */
|
||||||
|
|
||||||
|
|
||||||
#define FF_USE_FIND 1
|
#define FF_USE_FIND 1
|
||||||
/* This option switches filtered directory read functions, f_findfirst() and
|
/* This option switches filtered directory read functions, f_findfirst() and
|
||||||
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
|
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
|
||||||
@@ -56,30 +64,6 @@
|
|||||||
/* This option switches f_forward() function. (0:Disable or 1:Enable) */
|
/* This option switches f_forward() function. (0:Disable or 1:Enable) */
|
||||||
|
|
||||||
|
|
||||||
#define FF_USE_STRFUNC 1
|
|
||||||
#define FF_PRINT_LLI 0
|
|
||||||
#define FF_PRINT_FLOAT 0
|
|
||||||
#define FF_STRF_ENCODE 0
|
|
||||||
/* FF_USE_STRFUNC switches string functions, f_gets(), f_putc(), f_puts() and
|
|
||||||
/ f_printf().
|
|
||||||
/
|
|
||||||
/ 0: Disable. FF_PRINT_LLI, FF_PRINT_FLOAT and FF_STRF_ENCODE have no effect.
|
|
||||||
/ 1: Enable without LF-CRLF conversion.
|
|
||||||
/ 2: Enable with LF-CRLF conversion.
|
|
||||||
/
|
|
||||||
/ FF_PRINT_LLI = 1 makes f_printf() support long long argument and FF_PRINT_FLOAT = 1/2
|
|
||||||
makes f_printf() support floating point argument. These features want C99 or later.
|
|
||||||
/ When FF_LFN_UNICODE >= 1 with LFN enabled, string functions convert the character
|
|
||||||
/ encoding in it. FF_STRF_ENCODE selects assumption of character encoding ON THE FILE
|
|
||||||
/ to be read/written via those functions.
|
|
||||||
/
|
|
||||||
/ 0: ANSI/OEM in current CP
|
|
||||||
/ 1: Unicode in UTF-16LE
|
|
||||||
/ 2: Unicode in UTF-16BE
|
|
||||||
/ 3: Unicode in UTF-8
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------/
|
/*---------------------------------------------------------------------------/
|
||||||
/ Locale and Namespace Configurations
|
/ Locale and Namespace Configurations
|
||||||
/---------------------------------------------------------------------------*/
|
/---------------------------------------------------------------------------*/
|
||||||
@@ -153,6 +137,19 @@
|
|||||||
/ on character encoding. When LFN is not enabled, these options have no effect. */
|
/ on character encoding. When LFN is not enabled, these options have no effect. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_STRF_ENCODE 3
|
||||||
|
/* When FF_LFN_UNICODE >= 1 with LFN enabled, string I/O functions, f_gets(),
|
||||||
|
/ f_putc(), f_puts and f_printf() convert the character encoding in it.
|
||||||
|
/ This option selects assumption of character encoding ON THE FILE to be
|
||||||
|
/ read/written via those functions.
|
||||||
|
/
|
||||||
|
/ 0: ANSI/OEM in current CP
|
||||||
|
/ 1: Unicode in UTF-16LE
|
||||||
|
/ 2: Unicode in UTF-16BE
|
||||||
|
/ 3: Unicode in UTF-8
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define FF_FS_RPATH 2
|
#define FF_FS_RPATH 2
|
||||||
/* This option configures support for relative path.
|
/* This option configures support for relative path.
|
||||||
/
|
/
|
||||||
@@ -197,7 +194,7 @@
|
|||||||
#define FF_MAX_SS 512
|
#define FF_MAX_SS 512
|
||||||
/* This set of options configures the range of sector size to be supported. (512,
|
/* This set of options configures the range of sector size to be supported. (512,
|
||||||
/ 1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and
|
/ 1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and
|
||||||
/ harddisk, but a larger value may be required for on-board flash memory and some
|
/ harddisk. But a larger value may be required for on-board flash memory and some
|
||||||
/ type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured
|
/ type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured
|
||||||
/ for variable sector size mode and disk_ioctl() function needs to implement
|
/ for variable sector size mode and disk_ioctl() function needs to implement
|
||||||
/ GET_SECTOR_SIZE command. */
|
/ GET_SECTOR_SIZE command. */
|
||||||
@@ -231,7 +228,7 @@
|
|||||||
/ buffer in the filesystem object (FATFS) is used for the file data transfer. */
|
/ buffer in the filesystem object (FATFS) is used for the file data transfer. */
|
||||||
|
|
||||||
|
|
||||||
#define FF_FS_EXFAT 1
|
#define FF_FS_EXFAT 0
|
||||||
/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
|
/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
|
||||||
/ To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)
|
/ To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)
|
||||||
/ Note that enabling exFAT discards ANSI C (C89) compatibility. */
|
/ Note that enabling exFAT discards ANSI C (C89) compatibility. */
|
||||||
|
@@ -65,19 +65,11 @@
|
|||||||
#define BEEPER_RCC_MASK RCC_AHB1ENR_GPIOBEN
|
#define BEEPER_RCC_MASK RCC_AHB1ENR_GPIOBEN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enable all clocks and setup pins in default setting.
|
* @brief Enable all clocks and setup pins in default setting
|
||||||
* @warning This function uses @ref rcc_manager_enable_clock to enable the clocks. Therefore, it must not be called
|
* @warning This function uses @ref rcc_manager_enable_clock to enable the clocks. Therefore, it must not be called
|
||||||
* multiple times.
|
* multiple times.
|
||||||
* @note Calls @ref digio_set_default_values() internally.
|
|
||||||
*/
|
*/
|
||||||
void digio_init(void);
|
void digio_setup_default_all(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Setup or restore the default DIGIO settings.
|
|
||||||
*
|
|
||||||
* This function can be called multiple times.
|
|
||||||
*/
|
|
||||||
void digio_set_default_values(void);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set up a DIGIO pin.
|
* @brief Set up a DIGIO pin.
|
||||||
@@ -154,7 +146,7 @@ int led_get(uint8_t num);
|
|||||||
#define LOUDSPEAKER_PIN 1
|
#define LOUDSPEAKER_PIN 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The loudpseaker requires a frequency signal instead of a simple on/off signal.
|
* @brief The loudpseaker requires a frequncy signal instead of a simple on/off signal.
|
||||||
*/
|
*/
|
||||||
#define LOUDSPEAKER_MULTIFREQ 1
|
#define LOUDSPEAKER_MULTIFREQ 1
|
||||||
|
|
||||||
@@ -170,14 +162,7 @@ void loudspeaker_setup(void);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the loudspeaker value
|
* @brief Set the loudspeaker value
|
||||||
*
|
* @param val Value
|
||||||
* Zero turns off the beeper. 1 is a special value
|
|
||||||
* and will set the @ref LOUDSPEAKER_MULTIFREQ_DEFAULT value.
|
|
||||||
*
|
|
||||||
* If @ref LOUDSPEAKER_MULTIFREQ is 0, then no actual frequency is produced.
|
|
||||||
* Instead any @p val unequal to zero turns the output pin high and 0 will turn it low.
|
|
||||||
*
|
|
||||||
* @param val Value.
|
|
||||||
*/
|
*/
|
||||||
void loudspeaker_set(uint16_t val);
|
void loudspeaker_set(uint16_t val);
|
||||||
|
|
||||||
|
@@ -57,7 +57,6 @@ enum hw_revision {
|
|||||||
HW_REV_ERROR = 1, /**< @brief The hardware revision could not be detected due to an internal error */
|
HW_REV_ERROR = 1, /**< @brief The hardware revision could not be detected due to an internal error */
|
||||||
HW_REV_V1_2 = 120, /**< @brief Hardware Revision v1.2 */
|
HW_REV_V1_2 = 120, /**< @brief Hardware Revision v1.2 */
|
||||||
HW_REV_V1_3 = 130, /**< @brief Hardware Revision v1.3 */
|
HW_REV_V1_3 = 130, /**< @brief Hardware Revision v1.3 */
|
||||||
HW_REV_V1_3_1 = 131, /**< @brief Hardware revision v1.3.1 */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,7 +70,6 @@ enum hw_revision {
|
|||||||
* The function returns the HW revision as an enum hw_revision.
|
* The function returns the HW revision as an enum hw_revision.
|
||||||
* For v1.2 the return value is 120 (HW_REV_V1_2).
|
* For v1.2 the return value is 120 (HW_REV_V1_2).
|
||||||
* For v1.3 the return value is 130 (HW_REV_V1_3).
|
* For v1.3 the return value is 130 (HW_REV_V1_3).
|
||||||
* For v1.3.1 the return value is 131 (HW_REV_V1_3_1).
|
|
||||||
*
|
*
|
||||||
* Other return values are not defined yet.
|
* Other return values are not defined yet.
|
||||||
*
|
*
|
||||||
|
@@ -18,34 +18,15 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup main-cycle-counter Main Cycle Counter
|
|
||||||
* The main cycle counter is incremented after every loop run of the main loop in main.c
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __MAIN_CYCLE_COUNTER_H__
|
#ifndef __MAIN_CYCLE_COUNTER_H__
|
||||||
#define __MAIN_CYCLE_COUNTER_H__
|
#define __MAIN_CYCLE_COUNTER_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialize/Reset the main cycle counter to 0.
|
|
||||||
* This function can be called multiple times.
|
|
||||||
*/
|
|
||||||
void main_cycle_counter_init(void);
|
void main_cycle_counter_init(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Increment the main cycle counter by 1
|
|
||||||
*/
|
|
||||||
void main_cycle_counter_inc(void);
|
void main_cycle_counter_inc(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the current main cycle counter value
|
|
||||||
* @return Value
|
|
||||||
*/
|
|
||||||
uint64_t main_cycle_counter_get(void);
|
uint64_t main_cycle_counter_get(void);
|
||||||
|
|
||||||
#endif /* __MAIN_CYCLE_COUNTER_H__ */
|
#endif /* __MAIN_CYCLE_COUNTER_H__ */
|
||||||
|
|
||||||
/** @} */
|
|
||||||
|
@@ -21,93 +21,32 @@
|
|||||||
#ifndef __OVEN_DRIVER_H__
|
#ifndef __OVEN_DRIVER_H__
|
||||||
#define __OVEN_DRIVER_H__
|
#define __OVEN_DRIVER_H__
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup oven-driver Oven SSR Driver and PID Controller
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <reflow-controller/pid-controller.h>
|
#include <reflow-controller/pid-controller.h>
|
||||||
|
|
||||||
/**
|
enum oven_pid_status {OVEN_PID_DEACTIVATED,
|
||||||
* @brief Status of the PID controlling the oven
|
OVEN_PID_RUNNING,
|
||||||
*/
|
OVEN_PID_ABORTED};
|
||||||
enum oven_pid_status {
|
|
||||||
OVEN_PID_DEACTIVATED, /**< @brief The PID of the oven is deactivated. */
|
|
||||||
OVEN_PID_RUNNING, /**< @brief The PID of the oven is currently active and running. */
|
|
||||||
OVEN_PID_ABORTED, /**< @brief The PID of the oven has been aborted due to an error and is not running. */
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialize the oven driver.
|
|
||||||
*
|
|
||||||
* This will initialize the Timer for the PWM output to the SSR.
|
|
||||||
* If the hardware revision is >= v1.3 the SSR safety enable line will also be initialized.
|
|
||||||
*/
|
|
||||||
void oven_driver_init(void);
|
void oven_driver_init(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set a power level on the oven control output
|
|
||||||
* @param power Power level between 0 to 100
|
|
||||||
* @note This will not actually set the output. For this, @ref oven_driver_apply_power_level() has to be called.
|
|
||||||
* It will be called in the main loop.
|
|
||||||
*/
|
|
||||||
void oven_driver_set_power(uint8_t power);
|
void oven_driver_set_power(uint8_t power);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the oven driver.
|
|
||||||
*
|
|
||||||
* This shuts down the oven driver timer and the corresponding clocks.
|
|
||||||
*/
|
|
||||||
void oven_driver_disable(void);
|
void oven_driver_disable(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialize the PID controller for the oven output
|
|
||||||
* @param PID controller holding the settings
|
|
||||||
*/
|
|
||||||
void oven_pid_init(struct pid_controller *controller_to_copy);
|
void oven_pid_init(struct pid_controller *controller_to_copy);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Handle the PID controller.
|
|
||||||
* This must be called cyclically. When the sampling period has passed, the function will process the PT1000
|
|
||||||
* resistance and do a PID cycluilation for this sample.
|
|
||||||
* @note This function must be called with a frequency greater or equal to the PID's sampling frequency
|
|
||||||
*/
|
|
||||||
void oven_pid_handle(void);
|
void oven_pid_handle(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Stop the oven PID controller
|
|
||||||
*/
|
|
||||||
void oven_pid_stop(void);
|
void oven_pid_stop(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Abort the oven PID controller. This is the same as oven_pid_stop() but will set the abort flag.
|
|
||||||
* @note this function is called by the safety controller to disable the PID controller in case of an error.
|
|
||||||
*/
|
|
||||||
void oven_pid_abort(void);
|
void oven_pid_abort(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the target temperature of the PID controller.
|
|
||||||
* @param temp
|
|
||||||
*/
|
|
||||||
void oven_pid_set_target_temperature(float temp);
|
void oven_pid_set_target_temperature(float temp);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Output the power level currently configured to the SSR.
|
|
||||||
*
|
|
||||||
* This function is separated from oven_driver_set_power() because it is called in the main loop after the
|
|
||||||
* safety controller has run. This ensures, that if the safety controller decides to stop the PID no glitch makes it
|
|
||||||
* out to the SSR.
|
|
||||||
*/
|
|
||||||
void oven_driver_apply_power_level(void);
|
void oven_driver_apply_power_level(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the current status of the oven's PID controller
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
enum oven_pid_status oven_pid_get_status(void);
|
enum oven_pid_status oven_pid_get_status(void);
|
||||||
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
#endif /* __OVEN_DRIVER_H__ */
|
#endif /* __OVEN_DRIVER_H__ */
|
||||||
|
@@ -25,11 +25,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* UART_DIV is 45.5625 => 115200 @ 84 MHz */
|
/* UART_DIV is 45.5625 => 115200 @ 84 MHz */
|
||||||
#define SHELL_UART_DEFAULT_DIV_FRACTION 9U /* Equals 9/16 = 0.5625 */
|
#define SHELL_UART_DIV_FRACTION 9U /* Equals 9/16 = 0.5625 */
|
||||||
#define SHELL_UART_DEFAULT_DIV_MANTISSA 45U /* Equals 45 */
|
#define SHELL_UART_DIV_MANTISSA 45U /* Equals 45 */
|
||||||
|
|
||||||
#define SHELL_UART_DEFAULT_BRR_REG_VALUE ((SHELL_UART_DEFAULT_DIV_MANTISSA<<4) | SHELL_UART_DEFAULT_DIV_FRACTION);
|
#define SHELL_UART_BRR_REG_VALUE ((SHELL_UART_DIV_MANTISSA<<4) | SHELL_UART_DIV_FRACTION);
|
||||||
|
|
||||||
#define SHELL_UART_PERIPHERAL_CLOCK (84000000UL)
|
|
||||||
|
|
||||||
#endif /* __SHELL_UART_CONFIG_H__ */
|
#endif /* __SHELL_UART_CONFIG_H__ */
|
||||||
|
@@ -122,6 +122,12 @@ enum analog_value_monitor {
|
|||||||
*/
|
*/
|
||||||
#define SAFETY_MIN_STACK_FREE 0x100
|
#define SAFETY_MIN_STACK_FREE 0x100
|
||||||
|
|
||||||
|
#define PID_CONTROLLER_ERR_CAREMASK (ERR_FLAG_STACK | ERR_FLAG_AMON_UC_TEMP | ERR_FLAG_AMON_VREF | \
|
||||||
|
ERR_FLAG_TIMING_PID | ERR_FLAG_TIMING_MEAS_ADC | ERR_FLAG_MEAS_ADC_OFF | \
|
||||||
|
ERR_FLAG_MEAS_ADC_OVERFLOW)
|
||||||
|
|
||||||
|
#define HALTING_CAREMASK (ERR_FLAG_STACK | ERR_FLAG_AMON_UC_TEMP)
|
||||||
|
|
||||||
#define SAFETY_ADC_VREF_MVOLT (2500.0f)
|
#define SAFETY_ADC_VREF_MVOLT (2500.0f)
|
||||||
#define SAFETY_ADC_VREF_TOL_MVOLT (100.0f)
|
#define SAFETY_ADC_VREF_TOL_MVOLT (100.0f)
|
||||||
#define SAFETY_ADC_TEMP_LOW_LIM (0.0f)
|
#define SAFETY_ADC_TEMP_LOW_LIM (0.0f)
|
||||||
|
@@ -25,8 +25,7 @@
|
|||||||
* @brief Convert PT1000 resistance to temperature in degrees celsius
|
* @brief Convert PT1000 resistance to temperature in degrees celsius
|
||||||
* @param resistance PT1000 resistance value
|
* @param resistance PT1000 resistance value
|
||||||
* @param[out] temp_out Temperature output
|
* @param[out] temp_out Temperature output
|
||||||
* @return 0 if ok, -1 if value is below conversion range, 1 if value is above conversion range,
|
* @return 0 if ok, -1 if value is below conversion range, 1 if value is above conversion range,-1000 in case of pointer error
|
||||||
* -1000 in case of pointer error
|
|
||||||
*/
|
*/
|
||||||
int temp_converter_convert_resistance_to_temp(float resistance, float *temp_out);
|
int temp_converter_convert_resistance_to_temp(float resistance, float *temp_out);
|
||||||
|
|
||||||
|
@@ -44,9 +44,9 @@ enum tpe_status {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The execution state of the temperature profile
|
* @brief The current execution state of the temperature profile
|
||||||
*/
|
*/
|
||||||
struct tpe_exec_state {
|
struct tpe_current_state {
|
||||||
enum tpe_status status; /**< @brief Execution status */
|
enum tpe_status status; /**< @brief Execution status */
|
||||||
float setpoint; /**< @brief Temperature setpoint in degrees Celsius */
|
float setpoint; /**< @brief Temperature setpoint in degrees Celsius */
|
||||||
uint64_t start_timestamp; /**< @brief The millisicend tick timestamp, the profile execution was started */
|
uint64_t start_timestamp; /**< @brief The millisicend tick timestamp, the profile execution was started */
|
||||||
@@ -78,7 +78,7 @@ int temp_profile_executer_handle(void);
|
|||||||
* @warning The returned state structure is static and used internally. You must not modify it.
|
* @warning The returned state structure is static and used internally. You must not modify it.
|
||||||
* @return Execution state
|
* @return Execution state
|
||||||
*/
|
*/
|
||||||
const struct tpe_exec_state *temp_profile_executer_status(void);
|
const struct tpe_current_state *temp_profile_executer_status(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Stop the temperature profile execution.
|
* @brief Stop the temperature profile execution.
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup temp-profile Temperature Profile Parser and Executer
|
* @addtogroup temp-profile
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -41,9 +41,6 @@ enum pl_command_type {
|
|||||||
PL_LOUDSPEAKER_SET, /**< @brief Set the loudspeaker/beeper */
|
PL_LOUDSPEAKER_SET, /**< @brief Set the loudspeaker/beeper */
|
||||||
PL_OFF, /**< @brief Disable the temperature output and shutdown the PID controller */
|
PL_OFF, /**< @brief Disable the temperature output and shutdown the PID controller */
|
||||||
PL_CLEAR_FLAGS, /**< @brief Try clear all flags */
|
PL_CLEAR_FLAGS, /**< @brief Try clear all flags */
|
||||||
PL_DIGIO_CONF, /**< @brief Configure a DIGIO pin */
|
|
||||||
PL_DIGIO_SET, /**< @brief Set a DIGIO pin */
|
|
||||||
PL_DIGIO_WAIT, /**< @brief Wait until a DIGIO pin is set to the specified level */
|
|
||||||
_PL_NUM_CMDS, /**< @brief Sentinel to determine the total amount of commands */
|
_PL_NUM_CMDS, /**< @brief Sentinel to determine the total amount of commands */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -59,7 +56,7 @@ enum pl_ret_val {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Maximum parameter count of a command.
|
* @brief Maximum parameter count of a command
|
||||||
*/
|
*/
|
||||||
#define PROFILE_LANG_MAX_NUM_ARGS (8)
|
#define PROFILE_LANG_MAX_NUM_ARGS (8)
|
||||||
|
|
||||||
@@ -92,7 +89,7 @@ enum pl_ret_val temp_profile_parse_from_file(const char *filename,
|
|||||||
uint32_t *cmds_parsed);
|
uint32_t *cmds_parsed);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fully free a comamnd list including hte stored command structures.
|
* @brief Fully free a comamnd list including hte sotred command structures.
|
||||||
*
|
*
|
||||||
* \p list's destination is set to NULL to indicate the empty list.
|
* \p list's destination is set to NULL to indicate the empty list.
|
||||||
*
|
*
|
||||||
|
@@ -22,7 +22,6 @@
|
|||||||
#define _GUI_H_
|
#define _GUI_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handle the reflow controller's LCD Menu
|
* @brief Handle the reflow controller's LCD Menu
|
||||||
@@ -30,39 +29,10 @@
|
|||||||
*/
|
*/
|
||||||
int gui_handle(void);
|
int gui_handle(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialize the GUI (LCD, button, and rotary encoder)
|
|
||||||
*/
|
|
||||||
void gui_init(void);
|
void gui_init(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set a overlay message displayed on top of the root menu
|
|
||||||
* @param heading Heading of the overlay message (1st line)
|
|
||||||
* @param text Text of the overlay (the two bottom lines, 2 times 16 chars)
|
|
||||||
*/
|
|
||||||
void gui_root_menu_message_set(const char *heading, const char *text);
|
void gui_root_menu_message_set(const char *heading, const char *text);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Directly write to the LCD
|
|
||||||
*
|
|
||||||
* This function writes directly to the LCD and doesn't use the handling FSM in the
|
|
||||||
* background. Therefore, the function will block until all data is written to the LCD.
|
|
||||||
*
|
|
||||||
* @param line line to write to. Starts at 0
|
|
||||||
* @param text Text to write to the line
|
|
||||||
*/
|
|
||||||
void gui_lcd_write_direct_blocking(uint8_t line, const char *text);
|
void gui_lcd_write_direct_blocking(uint8_t line, const char *text);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the vertical size of the display
|
|
||||||
* @return Count of rows
|
|
||||||
*/
|
|
||||||
size_t gui_get_line_count(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Return the const char disp[][21] array contianing all display rows
|
|
||||||
* @note This directly returns the working buffer pointer. Do not change it!
|
|
||||||
*/
|
|
||||||
const char (*gui_get_current_display_content(void))[21];
|
|
||||||
|
|
||||||
#endif /* _GUI_H_ */
|
#endif /* _GUI_H_ */
|
||||||
|
@@ -1,51 +0,0 @@
|
|||||||
/* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __SHELL_UART_H__
|
|
||||||
|
|
||||||
#include <shellmatta.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configure the UART for the shellmatta shell.
|
|
||||||
*
|
|
||||||
* This will configure the UART for use with a DMA ring buffer.
|
|
||||||
* @param uart
|
|
||||||
*/
|
|
||||||
void shell_uart_setup(void);
|
|
||||||
|
|
||||||
shellmatta_retCode_t shell_uart_write_callback(const char *data, uint32_t len);
|
|
||||||
|
|
||||||
int shell_uart_receive_data_with_dma(const char **data, size_t *len);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configure a new connection speed.
|
|
||||||
* @param new_baud Baudrate. E.g: 115200
|
|
||||||
* @return Error in permille (1/1000). A return value of 2 means a baudrate error of: 0.002 or 0.2%.
|
|
||||||
* Return value is negative in case of a hard error.
|
|
||||||
*/
|
|
||||||
int32_t shell_uart_reconfig_baud(uint32_t new_baud);
|
|
||||||
|
|
||||||
uint32_t shell_uart_get_current_baudrate(void);
|
|
||||||
|
|
||||||
#define __SHELL_UART_H__
|
|
||||||
|
|
||||||
#endif /* __SHELL_UART_H__ */
|
|
@@ -1,45 +0,0 @@
|
|||||||
/* 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 _OPTION_BYTES_H_
|
|
||||||
#define _OPTION_BYTES_H_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
struct option_bytes {
|
|
||||||
/* Word 1 */
|
|
||||||
uint32_t read_protection;// : 8;
|
|
||||||
uint32_t nrst_standby;// : 1;
|
|
||||||
uint32_t nrst_stop;// : 1;
|
|
||||||
uint32_t wdg_sw;// : 1;
|
|
||||||
uint32_t brown_out_level;// : 2;
|
|
||||||
/* Word 2 */
|
|
||||||
uint32_t nwrpi;// : 12;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Read out the option bytes to structs
|
|
||||||
* @param opts
|
|
||||||
*/
|
|
||||||
void stm_option_bytes_read(struct option_bytes *opts);
|
|
||||||
|
|
||||||
int stm_option_bytes_program(const struct option_bytes *opts);
|
|
||||||
|
|
||||||
#endif /* _OPTION_BYTES_H_ */
|
|
@@ -50,8 +50,6 @@ int uart_init(struct stm_uart *uart);
|
|||||||
|
|
||||||
void uart_change_brr(struct stm_uart *uart, uint32_t brr);
|
void uart_change_brr(struct stm_uart *uart, uint32_t brr);
|
||||||
|
|
||||||
uint32_t uart_get_brr(struct stm_uart *uart);
|
|
||||||
|
|
||||||
void uart_disable(struct stm_uart *uart);
|
void uart_disable(struct stm_uart *uart);
|
||||||
|
|
||||||
void uart_send_char(struct stm_uart *uart, char c);
|
void uart_send_char(struct stm_uart *uart, char c);
|
||||||
|
@@ -29,8 +29,6 @@
|
|||||||
* @param mid mid word of ID
|
* @param mid mid word of ID
|
||||||
* @param low low word of ID
|
* @param low low word of ID
|
||||||
*/
|
*/
|
||||||
void stm_unique_id_get(uint32_t *high, uint32_t *mid, uint32_t *low);
|
void unique_id_get(uint32_t *high, uint32_t *mid, uint32_t *low);
|
||||||
|
|
||||||
void stm_dev_rev_id_get(uint32_t *device_id, uint32_t *revision_id);
|
|
||||||
|
|
||||||
#endif /* __UNIQUE_ID_H__ */
|
#endif /* __UNIQUE_ID_H__ */
|
||||||
|
@@ -18,19 +18,9 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @addtogroup main-cycle-counter
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <reflow-controller/main-cycle-counter.h>
|
#include <reflow-controller/main-cycle-counter.h>
|
||||||
#include <helper-macros/helper-macros.h>
|
#include <helper-macros/helper-macros.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Variable storing the main cycle counter.
|
|
||||||
* @note This variable should not be accessed directly.
|
|
||||||
* Use the main_cycle_counter_get() or main_cycle_counter_inc() functions.
|
|
||||||
*/
|
|
||||||
static uint64_t IN_SECTION(.ccm.bss) main_cycle_counter;
|
static uint64_t IN_SECTION(.ccm.bss) main_cycle_counter;
|
||||||
|
|
||||||
void main_cycle_counter_init(void)
|
void main_cycle_counter_init(void)
|
||||||
@@ -47,5 +37,3 @@ uint64_t main_cycle_counter_get(void)
|
|||||||
{
|
{
|
||||||
return main_cycle_counter;
|
return main_cycle_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @} */
|
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include <setup/system_stm32f4xx.h>
|
#include <setup/system_stm32f4xx.h>
|
||||||
#include <reflow-controller/systick.h>
|
#include <reflow-controller/systick.h>
|
||||||
#include <reflow-controller/adc-meas.h>
|
#include <reflow-controller/adc-meas.h>
|
||||||
|
#include <reflow-controller/shell.h>
|
||||||
#include <reflow-controller/digio.h>
|
#include <reflow-controller/digio.h>
|
||||||
#include "fatfs/shimatta_sdio_driver/shimatta_sdio.h"
|
#include "fatfs/shimatta_sdio_driver/shimatta_sdio.h"
|
||||||
#include <stm-periph/stm32-gpio-macros.h>
|
#include <stm-periph/stm32-gpio-macros.h>
|
||||||
@@ -40,8 +41,6 @@
|
|||||||
#include <reflow-controller/oven-driver.h>
|
#include <reflow-controller/oven-driver.h>
|
||||||
#include <fatfs/ff.h>
|
#include <fatfs/ff.h>
|
||||||
#include <reflow-controller/ui/gui.h>
|
#include <reflow-controller/ui/gui.h>
|
||||||
#include <reflow-controller/ui/shell.h>
|
|
||||||
#include <reflow-controller/ui/shell-uart.h>
|
|
||||||
#include <reflow-controller/safety/safety-controller.h>
|
#include <reflow-controller/safety/safety-controller.h>
|
||||||
#include <reflow-controller/settings/settings.h>
|
#include <reflow-controller/settings/settings.h>
|
||||||
#include <reflow-controller/safety/safety-memory.h>
|
#include <reflow-controller/safety/safety-memory.h>
|
||||||
@@ -50,7 +49,6 @@
|
|||||||
#include <reflow-controller/temp-profile/temp-profile-executer.h>
|
#include <reflow-controller/temp-profile/temp-profile-executer.h>
|
||||||
#include <reflow-controller/settings/spi-eeprom.h>
|
#include <reflow-controller/settings/spi-eeprom.h>
|
||||||
#include <reflow-controller/main-cycle-counter.h>
|
#include <reflow-controller/main-cycle-counter.h>
|
||||||
#include <stm-periph/option-bytes.h>
|
|
||||||
|
|
||||||
static void setup_nvic_priorities(void)
|
static void setup_nvic_priorities(void)
|
||||||
{
|
{
|
||||||
@@ -69,13 +67,13 @@ static void setup_nvic_priorities(void)
|
|||||||
FATFS fs;
|
FATFS fs;
|
||||||
#define fs_ptr (&fs)
|
#define fs_ptr (&fs)
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configure UART GPIOs
|
|
||||||
* In case the application is build in debug mode, use the TX/RX Pins on the debug header
|
|
||||||
* else the Pins on the DIGIO header are configured in the digio module and this function does nothing.
|
|
||||||
*/
|
|
||||||
static inline void uart_gpio_config(void)
|
static inline void uart_gpio_config(void)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* In case the application is build in debug mode, use the TX/RX Pins on the debug header
|
||||||
|
* else the Pins on the DIGIO header are configured in the digio module
|
||||||
|
*/
|
||||||
|
|
||||||
#if defined(DEBUGBUILD) || defined(UART_ON_DEBUG_HEADER)
|
#if defined(DEBUGBUILD) || defined(UART_ON_DEBUG_HEADER)
|
||||||
rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(SHELL_UART_PORT_RCC_MASK));
|
rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(SHELL_UART_PORT_RCC_MASK));
|
||||||
SHELL_UART_PORT->MODER &= MODER_DELETE(SHELL_UART_TX_PIN) & MODER_DELETE(SHELL_UART_RX_PIN);
|
SHELL_UART_PORT->MODER &= MODER_DELETE(SHELL_UART_TX_PIN) & MODER_DELETE(SHELL_UART_RX_PIN);
|
||||||
@@ -88,11 +86,39 @@ static inline void uart_gpio_config(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Mount the SD card if available and not already mounted
|
static char shell_uart_tx_buff[256];
|
||||||
* @param mounted The current mounting state of the SD card
|
static char shell_uart_rx_buff[48];
|
||||||
* @return true if mounted, false if an error occured or the SD is not inserted and cannot be mounted
|
struct stm_uart shell_uart;
|
||||||
*/
|
|
||||||
|
static shellmatta_retCode_t write_shell_callback(const char *data, uint32_t len)
|
||||||
|
{
|
||||||
|
uart_send_array_with_dma(&shell_uart, data, len);
|
||||||
|
return SHELLMATTA_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void setup_shell_uart(struct stm_uart *uart)
|
||||||
|
{
|
||||||
|
uart->rx = 1;
|
||||||
|
uart->tx = 1;
|
||||||
|
uart->brr_val = SHELL_UART_BRR_REG_VALUE;
|
||||||
|
uart->rcc_reg = &SHELL_UART_RCC_REG;
|
||||||
|
uart->rcc_bit_no = BITMASK_TO_BITNO(SHELL_UART_RCC_MASK);
|
||||||
|
uart->uart_dev = SHELL_UART_PERIPH;
|
||||||
|
uart->dma_rx_buff = shell_uart_rx_buff;
|
||||||
|
uart->dma_tx_buff = shell_uart_tx_buff;
|
||||||
|
uart->rx_buff_count = sizeof(shell_uart_rx_buff);
|
||||||
|
uart->tx_buff_count = sizeof(shell_uart_tx_buff);
|
||||||
|
uart->base_dma_num = 2;
|
||||||
|
uart->dma_rx_stream = SHELL_UART_RECEIVE_DMA_STREAM;
|
||||||
|
uart->dma_tx_stream = SHELL_UART_SEND_DMA_STREAM;
|
||||||
|
uart->dma_rx_trigger_channel = SHELL_UART_RX_DMA_TRIGGER;
|
||||||
|
uart->dma_tx_trigger_channel = SHELL_UART_TX_DMA_TRIGGER;
|
||||||
|
|
||||||
|
uart_init(uart);
|
||||||
|
NVIC_EnableIRQ(DMA2_Stream7_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
static bool mount_sd_card_if_avail(bool mounted)
|
static bool mount_sd_card_if_avail(bool mounted)
|
||||||
{
|
{
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
@@ -122,13 +148,6 @@ static bool mount_sd_card_if_avail(bool mounted)
|
|||||||
return mounted;
|
return mounted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Process the boot status structure in the safety (backup) RAM
|
|
||||||
* Depending on the flags set there, this function will:
|
|
||||||
* - Reboot into the ram code for reflashing
|
|
||||||
* - Display the PANIC message
|
|
||||||
* - Display if the flash has been successfully updated
|
|
||||||
*/
|
|
||||||
static inline void handle_boot_status(void)
|
static inline void handle_boot_status(void)
|
||||||
{
|
{
|
||||||
struct safety_memory_boot_status status;
|
struct safety_memory_boot_status status;
|
||||||
@@ -164,101 +183,34 @@ static inline void handle_boot_status(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Read out the option bytes of the STM32 and program them to the desired values.
|
|
||||||
*
|
|
||||||
* - This function currently forces the brown out level to Level 3.
|
|
||||||
*/
|
|
||||||
static void check_and_program_opt_bytes(void)
|
|
||||||
{
|
|
||||||
struct option_bytes opts;
|
|
||||||
int err;
|
|
||||||
|
|
||||||
/** - Read option bytes */
|
|
||||||
stm_option_bytes_read(&opts);
|
|
||||||
|
|
||||||
|
|
||||||
if (opts.brown_out_level != 0) {
|
|
||||||
/* Set the brown out level to level 3 => highest brown out limit. */
|
|
||||||
opts.brown_out_level = 0;
|
|
||||||
/** - Program the option bytes if brown out level was not set correctly */
|
|
||||||
err = stm_option_bytes_program(&opts);
|
|
||||||
|
|
||||||
/** - If programming failes, enter panic mode */
|
|
||||||
if (err)
|
|
||||||
panic_mode();
|
|
||||||
|
|
||||||
/** - If programming is successful, reset the system to apply new settings */
|
|
||||||
NVIC_SystemReset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Setup the system.
|
|
||||||
*
|
|
||||||
* This function does all basic initializations of the MCU and its peripherals
|
|
||||||
*/
|
|
||||||
static inline void setup_system(void)
|
static inline void setup_system(void)
|
||||||
{
|
{
|
||||||
float tmp;
|
float tmp;
|
||||||
|
|
||||||
/** - Read the option bytes and if necessary program them to the desired values */
|
|
||||||
check_and_program_opt_bytes();
|
|
||||||
|
|
||||||
/** - Setup the NVIC priorities of the core peripherals using interrupts */
|
|
||||||
setup_nvic_priorities();
|
setup_nvic_priorities();
|
||||||
|
|
||||||
/** - Init safety controller and safety memory */
|
/* Init safety controller and safety memory */
|
||||||
safety_controller_init();
|
safety_controller_init();
|
||||||
|
|
||||||
/** - Setup the systick module generating the 100us tick fort the GUI and
|
|
||||||
* the 1ms tick for the global systick timestamp
|
|
||||||
*/
|
|
||||||
systick_setup();
|
systick_setup();
|
||||||
|
|
||||||
/** - Initialize the oven output driver outputting the wavepacket control signal for the SSR and */
|
|
||||||
oven_driver_init();
|
oven_driver_init();
|
||||||
|
digio_setup_default_all();
|
||||||
/** - Initialize all DIGIO Pins to their default state and pin functions */
|
|
||||||
digio_init();
|
|
||||||
|
|
||||||
/** - Set-up the LED outputs */
|
|
||||||
led_setup();
|
led_setup();
|
||||||
|
|
||||||
/** - Set-up the loudspeaker / beeper output */
|
|
||||||
loudspeaker_setup();
|
loudspeaker_setup();
|
||||||
|
|
||||||
/** - Initialize the GUI */
|
|
||||||
gui_init();
|
gui_init();
|
||||||
|
|
||||||
/** - Initialize the pins for the uart interface. */
|
|
||||||
uart_gpio_config();
|
uart_gpio_config();
|
||||||
|
|
||||||
/** - Set-up the settings module */
|
|
||||||
settings_setup();
|
settings_setup();
|
||||||
|
|
||||||
/** - Load the overtemperature limit from eeprom if available. Otherwise the default value will be used */
|
/* Load the overtemperature limit from eeprom if available. Otherwise the default value will be used */
|
||||||
if (settings_load_overtemp_limit(&tmp) == SETT_LOAD_SUCCESS)
|
if (settings_load_overtemp_limit(&tmp) == SETT_LOAD_SUCCESS)
|
||||||
safety_controller_set_overtemp_limit(tmp);
|
safety_controller_set_overtemp_limit(tmp);
|
||||||
|
|
||||||
/** - Handle the boot status struct in the safety memory */
|
|
||||||
handle_boot_status();
|
handle_boot_status();
|
||||||
|
|
||||||
/** - Initialize the shell UART */
|
setup_shell_uart(&shell_uart);
|
||||||
shell_uart_setup();
|
|
||||||
|
|
||||||
/** - Enable the ADC for PT1000 measurement */
|
|
||||||
adc_pt1000_setup_meas();
|
adc_pt1000_setup_meas();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Handle the input for the shell instance.
|
|
||||||
*
|
|
||||||
* This function will check if the RX ring buffer of the UART contains data.
|
|
||||||
* If so, it will prowvide it to the shellmatta shell.
|
|
||||||
*
|
|
||||||
* @param shell_handle Handle to the shellmatta instance
|
|
||||||
*/
|
|
||||||
static void handle_shell_uart_input(shellmatta_handle_t shell_handle)
|
static void handle_shell_uart_input(shellmatta_handle_t shell_handle)
|
||||||
{
|
{
|
||||||
int uart_receive_status;
|
int uart_receive_status;
|
||||||
@@ -266,15 +218,11 @@ static void handle_shell_uart_input(shellmatta_handle_t shell_handle)
|
|||||||
size_t uart_input_len;
|
size_t uart_input_len;
|
||||||
|
|
||||||
/* Handle UART input for shell */
|
/* Handle UART input for shell */
|
||||||
uart_receive_status = shell_uart_receive_data_with_dma(&uart_input, &uart_input_len);
|
uart_receive_status = uart_receive_data_with_dma(&shell_uart, &uart_input, &uart_input_len);
|
||||||
if (uart_receive_status >= 0)
|
if (uart_receive_status >= 0)
|
||||||
shell_handle_input(shell_handle, uart_input, uart_input_len);
|
shell_handle_input(shell_handle, uart_input, uart_input_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is the main function containing the initilizations and the cyclic main loop
|
|
||||||
* @return Don't care. This function will never return. We're on an embedded device...
|
|
||||||
*/
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
bool cal_active;
|
bool cal_active;
|
||||||
@@ -287,30 +235,21 @@ int main(void)
|
|||||||
int menu_wait_request;
|
int menu_wait_request;
|
||||||
uint64_t quarter_sec_timestamp = 0ULL;
|
uint64_t quarter_sec_timestamp = 0ULL;
|
||||||
|
|
||||||
/** - Setup all the peripherals and external componets like LCD, EEPROM etc. and the safety controller */
|
/* Setup all the peripherals and external componets like LCD, EEPROM etc. and the safety controller */
|
||||||
setup_system();
|
setup_system();
|
||||||
|
|
||||||
/** - Try load the calibration. This will only succeed if there's an EEPROM */
|
/* Try load the calibration. This will only succeed if there's an EEPROM */
|
||||||
status = settings_load_calibration(&sens, &offset);
|
status = settings_load_calibration(&sens, &offset);
|
||||||
if (!status)
|
if (!status)
|
||||||
adc_pt1000_set_resistance_calibration(offset, sens, true);
|
adc_pt1000_set_resistance_calibration(offset, sens, true);
|
||||||
|
|
||||||
/** - Initialize the shellmatta shell */
|
shell_handle = shell_init(write_shell_callback);
|
||||||
shell_handle = shell_init(shell_uart_write_callback);
|
|
||||||
|
|
||||||
/** - Print motd to shell */
|
|
||||||
shell_print_motd(shell_handle);
|
shell_print_motd(shell_handle);
|
||||||
|
|
||||||
/** - Set the main cycle counter to 0 */
|
|
||||||
main_cycle_counter_init();
|
main_cycle_counter_init();
|
||||||
|
|
||||||
/** - Do a loop over the following */
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
/** - If 250 ms have passed since the last time this step was reached, we try to initialize the
|
|
||||||
* SD card. If the card has been mounted and there is no current resistance calibration,
|
|
||||||
* it is tried to load it from SD card.
|
|
||||||
*/
|
|
||||||
if (systick_ticks_have_passed(quarter_sec_timestamp, 250)) {
|
if (systick_ticks_have_passed(quarter_sec_timestamp, 250)) {
|
||||||
led_set(1, 0);
|
led_set(1, 0);
|
||||||
sd_old = sd_card_mounted;
|
sd_old = sd_card_mounted;
|
||||||
@@ -328,48 +267,43 @@ int main(void)
|
|||||||
quarter_sec_timestamp = systick_get_global_tick();
|
quarter_sec_timestamp = systick_get_global_tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** - Handle the GUI */
|
|
||||||
menu_wait_request = gui_handle();
|
menu_wait_request = gui_handle();
|
||||||
|
|
||||||
/** - Handle the uart input for the shell */
|
|
||||||
handle_shell_uart_input(shell_handle);
|
handle_shell_uart_input(shell_handle);
|
||||||
|
|
||||||
/** - Execute current profile step, if a profile is active */
|
/* Execute current profile step, if a profile is active */
|
||||||
temp_profile_executer_handle();
|
temp_profile_executer_handle();
|
||||||
|
|
||||||
/** - Handle the safety controller. This must be called! Otherwise a watchdog reset will occur */
|
|
||||||
safety_controller_handle();
|
safety_controller_handle();
|
||||||
|
|
||||||
/** - If the Oven PID controller is running, we handle its sample function */
|
|
||||||
if (oven_pid_get_status() == OVEN_PID_RUNNING)
|
if (oven_pid_get_status() == OVEN_PID_RUNNING)
|
||||||
oven_pid_handle();
|
oven_pid_handle();
|
||||||
|
|
||||||
/** - Apply the power level of the oven driver */
|
|
||||||
oven_driver_apply_power_level();
|
oven_driver_apply_power_level();
|
||||||
|
|
||||||
/** - Report the main loop timing to the timing monitor to detect a slowed down main loop */
|
|
||||||
safety_controller_report_timing(ERR_TIMING_MAIN_LOOP);
|
safety_controller_report_timing(ERR_TIMING_MAIN_LOOP);
|
||||||
|
|
||||||
/** - If the menu requests a directly following loop run, the main loop will continue.
|
|
||||||
* Otherwise it will wait for the next interrupt
|
|
||||||
*/
|
|
||||||
if (menu_wait_request)
|
if (menu_wait_request)
|
||||||
__WFI();
|
__WFI();
|
||||||
else
|
else
|
||||||
__NOP();
|
__NOP();
|
||||||
/** - Increment the main cycle counter */
|
|
||||||
main_cycle_counter_inc();
|
main_cycle_counter_inc();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Callback function for the SDIO driver to wait \p ms milliseconds
|
|
||||||
* @param ms
|
|
||||||
* @warning This function relies on the systick and must not be used in interrupt context.
|
|
||||||
*/
|
|
||||||
void sdio_wait_ms(uint32_t ms)
|
void sdio_wait_ms(uint32_t ms)
|
||||||
{
|
{
|
||||||
systick_wait_ms(ms);
|
systick_wait_ms(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Handles the TX of UART1 (Shellmatta)
|
||||||
|
*/
|
||||||
|
void DMA2_Stream7_IRQHandler(void)
|
||||||
|
{
|
||||||
|
uint32_t hisr = DMA2->HISR & (0x3F << 22);
|
||||||
|
|
||||||
|
DMA2->HIFCR = hisr;
|
||||||
|
|
||||||
|
if (hisr & DMA_HISR_TCIF7)
|
||||||
|
uart_tx_dma_complete_int_callback(&shell_uart);
|
||||||
|
}
|
||||||
|
@@ -18,11 +18,6 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @addtogroup oven-driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <reflow-controller/oven-driver.h>
|
#include <reflow-controller/oven-driver.h>
|
||||||
#include <reflow-controller/periph-config/oven-driver-hwcfg.h>
|
#include <reflow-controller/periph-config/oven-driver-hwcfg.h>
|
||||||
#include <stm-periph/rcc-manager.h>
|
#include <stm-periph/rcc-manager.h>
|
||||||
@@ -33,42 +28,13 @@
|
|||||||
#include <reflow-controller/safety/safety-controller.h>
|
#include <reflow-controller/safety/safety-controller.h>
|
||||||
#include <reflow-controller/hw-version-detect.h>
|
#include <reflow-controller/hw-version-detect.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief PID controller instance of the oven driver
|
|
||||||
*/
|
|
||||||
static struct pid_controller IN_SECTION(.ccm.bss) oven_pid;
|
static struct pid_controller IN_SECTION(.ccm.bss) oven_pid;
|
||||||
|
static bool oven_pid_running;
|
||||||
/**
|
static bool oven_pid_aborted;
|
||||||
* @brief Oven PID is currently running
|
|
||||||
*/
|
|
||||||
static bool IN_SECTION(.ccm.bss) oven_pid_running;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Oven PID has been aborted / abnormally stopped.
|
|
||||||
*/
|
|
||||||
static bool IN_SECTION(.ccm.bss) oven_pid_aborted;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Power level [0..100] of the oven to be applied
|
|
||||||
*/
|
|
||||||
static uint8_t IN_SECTION(.ccm.bss) oven_driver_power_level;
|
static uint8_t IN_SECTION(.ccm.bss) oven_driver_power_level;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Current target temperature of the oven PID controller in degC
|
|
||||||
*/
|
|
||||||
static float IN_SECTION(.ccm.bss) target_temp;
|
static float IN_SECTION(.ccm.bss) target_temp;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The millisecond timestamp of the last run of the PID controller
|
|
||||||
*/
|
|
||||||
static uint64_t IN_SECTION(.ccm.bss) timestamp_last_run;
|
static uint64_t IN_SECTION(.ccm.bss) timestamp_last_run;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable or disable the safety enable line of the oven control relay.
|
|
||||||
* @param enable
|
|
||||||
* @note This function is only working for hardware revisions >= v1.3. Below,
|
|
||||||
* the safety enable is unavailable.
|
|
||||||
*/
|
|
||||||
static void ssr_safety_en(bool enable)
|
static void ssr_safety_en(bool enable)
|
||||||
{
|
{
|
||||||
if (get_pcb_hardware_version() >= HW_REV_V1_3) {
|
if (get_pcb_hardware_version() >= HW_REV_V1_3) {
|
||||||
@@ -199,5 +165,3 @@ enum oven_pid_status oven_pid_get_status(void)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @} */
|
|
||||||
|
@@ -24,12 +24,6 @@
|
|||||||
#include <reflow-controller/safety/safety-memory.h>
|
#include <reflow-controller/safety/safety-memory.h>
|
||||||
#include <helper-macros/helper-macros.h>
|
#include <helper-macros/helper-macros.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Handler for hard faults.
|
|
||||||
*
|
|
||||||
* This hard fault handler will turn of the oven output and go to panic mode.
|
|
||||||
* @note Depending on the fault condition some of the things done here could fail.
|
|
||||||
*/
|
|
||||||
void HardFault_Handler(void)
|
void HardFault_Handler(void)
|
||||||
{
|
{
|
||||||
/* This is a non recoverable fault. Stop the oven */
|
/* This is a non recoverable fault. Stop the oven */
|
||||||
@@ -44,26 +38,11 @@ void HardFault_Handler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Overwrite default handler. Go to panic mode */
|
/* Overwrite default handler. Go to panic mode */
|
||||||
/**
|
|
||||||
* @brief Default interrupt handler. This will trigger a panic.
|
|
||||||
* @note This function should never be called during normal operation.
|
|
||||||
*/
|
|
||||||
void __int_default_handler(void)
|
void __int_default_handler(void)
|
||||||
{
|
{
|
||||||
panic_mode();
|
panic_mode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Put the device into panic mode.
|
|
||||||
*
|
|
||||||
* This function can be used when a irrecoverable error is encountered.
|
|
||||||
* The function will:
|
|
||||||
* - Disable the oven output
|
|
||||||
* - Set the panic flag in the safety memory
|
|
||||||
* - Hang and wait for the watchdog to trigger a system reset.
|
|
||||||
*
|
|
||||||
* The panic state will be entered after the reset due to the set panic flag in the safety memory
|
|
||||||
*/
|
|
||||||
void panic_mode(void)
|
void panic_mode(void)
|
||||||
{
|
{
|
||||||
/* This variable is static, because I don't want it to be on the stack */
|
/* This variable is static, because I don't want it to be on the stack */
|
||||||
|
@@ -31,22 +31,8 @@
|
|||||||
#include <reflow-controller/safety/safety-controller.h>
|
#include <reflow-controller/safety/safety-controller.h>
|
||||||
|
|
||||||
static const uint8_t safety_adc_channels[SAFETY_ADC_NUM_OF_CHANNELS] = {SAFETY_ADC_CHANNELS};
|
static const uint8_t safety_adc_channels[SAFETY_ADC_NUM_OF_CHANNELS] = {SAFETY_ADC_CHANNELS};
|
||||||
|
static volatile uint8_t safety_adc_conversion_complete;
|
||||||
/**
|
static volatile uint8_t safety_adc_triggered;
|
||||||
* @brief Safety ADC conversion complete. Set in interrupt.
|
|
||||||
*/
|
|
||||||
static volatile uint8_t IN_SECTION(.ccm.bss) safety_adc_conversion_complete;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Safety ADC has been started. It will perform all specified conversions and
|
|
||||||
* set @ref safety_adc_conversion_complete afterwards
|
|
||||||
*/
|
|
||||||
static volatile uint8_t IN_SECTION(.ccm.bss) safety_adc_triggered;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Safety ADC conversion storage. This is filled by DMA.
|
|
||||||
* @note Do not move this to CCM RAM as the DMA won't be able to access it.
|
|
||||||
*/
|
|
||||||
static volatile uint16_t safety_adc_conversions[SAFETY_ADC_NUM_OF_CHANNELS];
|
static volatile uint16_t safety_adc_conversions[SAFETY_ADC_NUM_OF_CHANNELS];
|
||||||
|
|
||||||
void safety_adc_init(void)
|
void safety_adc_init(void)
|
||||||
|
@@ -67,13 +67,6 @@ int watchdog_setup(uint8_t prescaler)
|
|||||||
else
|
else
|
||||||
prescaler_reg_val = 6UL;
|
prescaler_reg_val = 6UL;
|
||||||
|
|
||||||
/** - (De)activate the watchdog during debug access according to @ref WATCHDOG_HALT_DEBUG */
|
|
||||||
if (WATCHDOG_HALT_DEBUG) {
|
|
||||||
DBGMCU->APB1FZ |= DBGMCU_APB1_FZ_DBG_IWDG_STOP;
|
|
||||||
} else {
|
|
||||||
DBGMCU->APB1FZ &= ~DBGMCU_APB1_FZ_DBG_IWDG_STOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** - Unlock registers */
|
/** - Unlock registers */
|
||||||
IWDG->KR = STM32_WATCHDOG_REGISTER_ACCESS_KEY;
|
IWDG->KR = STM32_WATCHDOG_REGISTER_ACCESS_KEY;
|
||||||
|
|
||||||
|
@@ -57,7 +57,7 @@ static bool check_eeprom_header(void)
|
|||||||
static void settings_eeprom_zero()
|
static void settings_eeprom_zero()
|
||||||
{
|
{
|
||||||
settings_eeprom_save_calibration(0.0f, 0.0f, false);
|
settings_eeprom_save_calibration(0.0f, 0.0f, false);
|
||||||
settings_eeprom_save_overtemp_limit(0.0f, false);
|
settings_eeprom_save_overtemp_limit(0.0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool settings_eeprom_detect_and_prepare(void)
|
bool settings_eeprom_detect_and_prepare(void)
|
||||||
|
@@ -38,7 +38,7 @@ static void get_controller_folder_path(char *path, size_t size)
|
|||||||
if (!path)
|
if (!path)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
stm_unique_id_get(&high, &mid, &low);
|
unique_id_get(&high, &mid, &low);
|
||||||
|
|
||||||
snprintf(path, size, "/%08X-%08X-%08X",
|
snprintf(path, size, "/%08X-%08X-%08X",
|
||||||
(unsigned int)high, (unsigned int)mid, (unsigned int)low);
|
(unsigned int)high, (unsigned int)mid, (unsigned int)low);
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <stm32/stm32f4xx.h>
|
#include <stm32/stm32f4xx.h>
|
||||||
#include <cmsis/core_cm4.h>
|
#include <cmsis/core_cm4.h>
|
||||||
#include <reflow-controller/ui/shell.h>
|
#include <reflow-controller/shell.h>
|
||||||
#include <stm-periph/uart.h>
|
#include <stm-periph/uart.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <reflow-controller/adc-meas.h>
|
#include <reflow-controller/adc-meas.h>
|
||||||
@@ -45,10 +45,6 @@
|
|||||||
#include <reflow-controller/temp-profile/temp-profile-executer.h>
|
#include <reflow-controller/temp-profile/temp-profile-executer.h>
|
||||||
#include <reflow-controller/updater/updater.h>
|
#include <reflow-controller/updater/updater.h>
|
||||||
#include <reflow-controller/main-cycle-counter.h>
|
#include <reflow-controller/main-cycle-counter.h>
|
||||||
#include <stm-periph/option-bytes.h>
|
|
||||||
#include <reflow-controller/ui/gui.h>
|
|
||||||
#include <reflow-controller/ui/shell-uart.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifndef GIT_VER
|
#ifndef GIT_VER
|
||||||
@@ -68,13 +64,10 @@ static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
|
|||||||
uint32_t low_id;
|
uint32_t low_id;
|
||||||
uint32_t mid_id;
|
uint32_t mid_id;
|
||||||
uint32_t high_id;
|
uint32_t high_id;
|
||||||
uint32_t stm_rev_id;
|
|
||||||
uint32_t stm_dev_id;
|
|
||||||
const char *hw_rev_str;
|
const char *hw_rev_str;
|
||||||
enum hw_revision pcb_rev;
|
enum hw_revision pcb_rev;
|
||||||
|
|
||||||
stm_unique_id_get(&high_id, &mid_id, &low_id);
|
unique_id_get(&high_id, &mid_id, &low_id);
|
||||||
stm_dev_rev_id_get(&stm_dev_id, &stm_rev_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");
|
||||||
@@ -88,17 +81,11 @@ static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
|
|||||||
case HW_REV_V1_3:
|
case HW_REV_V1_3:
|
||||||
hw_rev_str = "Hardware: v1.3";
|
hw_rev_str = "Hardware: v1.3";
|
||||||
break;
|
break;
|
||||||
case HW_REV_V1_3_1:
|
|
||||||
hw_rev_str = "Hardware: v1.3.1";
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
hw_rev_str = "Hardware: Unknown Revision. You might have to update the firmware!";
|
hw_rev_str = "Hardware: Unknown Revision. You might have to update the firmware!";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
shellmatta_printf(handle, "%s\r\n", hw_rev_str);
|
shellmatta_printf(handle, "%s", hw_rev_str);
|
||||||
|
|
||||||
shellmatta_printf(handle, "STM Device ID: 0x%04X\r\n", stm_dev_id);
|
|
||||||
shellmatta_printf(handle, "STM Revision ID: 0x%04X\r\n", stm_rev_id);
|
|
||||||
|
|
||||||
return SHELLMATTA_OK;
|
return SHELLMATTA_OK;
|
||||||
}
|
}
|
||||||
@@ -486,11 +473,6 @@ static shellmatta_retCode_t shell_cmd_ui_emulation(const shellmatta_handle_t han
|
|||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
char *buff;
|
char *buff;
|
||||||
uint8_t row;
|
|
||||||
uint8_t col;
|
|
||||||
bool disp_content_differs = false;
|
|
||||||
static char IN_SECTION(.ccm.bss) display_buffer[4][21] = {0};
|
|
||||||
const char (*current_display)[21];
|
|
||||||
|
|
||||||
shellmatta_read(handle, &buff, &len);
|
shellmatta_read(handle, &buff, &len);
|
||||||
|
|
||||||
@@ -519,39 +501,6 @@ static shellmatta_retCode_t shell_cmd_ui_emulation(const shellmatta_handle_t han
|
|||||||
case 'R':
|
case 'R':
|
||||||
button_override_event(BUTTON_LONG_RELEASED);
|
button_override_event(BUTTON_LONG_RELEASED);
|
||||||
break;
|
break;
|
||||||
case '\x03':
|
|
||||||
/* CTRL-C received. Delete the display buffer so it will be updated the next time
|
|
||||||
* This function is called.
|
|
||||||
* Otherwise the diplay might not be printed to the console if nothing has changed
|
|
||||||
*/
|
|
||||||
display_buffer[0][0] = 0;
|
|
||||||
display_buffer[1][0] = 0;
|
|
||||||
display_buffer[2][0] = 0;
|
|
||||||
display_buffer[3][0] = 0;
|
|
||||||
return SHELLMATTA_OK;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
current_display = gui_get_current_display_content();
|
|
||||||
|
|
||||||
for (row = 0; row < 4; row++) {
|
|
||||||
for (col = 0; col < 21; col++) {
|
|
||||||
if (current_display[row][col] != display_buffer[row][col]) {
|
|
||||||
display_buffer[row][col] = current_display[row][col];
|
|
||||||
disp_content_differs = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
display_buffer[row][20] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (disp_content_differs) {
|
|
||||||
/* Clear the display */
|
|
||||||
shellmatta_printf(handle, "\e[2J\e[H");
|
|
||||||
|
|
||||||
/* Print out the rows of the LCD to console */
|
|
||||||
for (row = 0; row < 4; row++) {
|
|
||||||
shellmatta_printf(handle, "%s\r\n", &display_buffer[row][0]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -768,7 +717,7 @@ shellmatta_retCode_t shell_cmd_overtemp_cfg(const shellmatta_handle_t handle, co
|
|||||||
shellmatta_retCode_t shell_cmd_execute(const shellmatta_handle_t handle, const char *args, uint32_t len)
|
shellmatta_retCode_t shell_cmd_execute(const shellmatta_handle_t handle, const char *args, uint32_t len)
|
||||||
{
|
{
|
||||||
enum pl_ret_val res;
|
enum pl_ret_val res;
|
||||||
const struct tpe_exec_state *state;
|
const struct tpe_current_state *state;
|
||||||
static bool running = false;
|
static bool running = false;
|
||||||
char *data;
|
char *data;
|
||||||
uint32_t dlen;
|
uint32_t dlen;
|
||||||
@@ -928,75 +877,6 @@ shellmatta_retCode_t shell_cmd_filter_alpha(const shellmatta_handle_t handle, co
|
|||||||
return SHELLMATTA_OK;
|
return SHELLMATTA_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
shellmatta_retCode_t shell_cmd_print_opt_bytes(const shellmatta_handle_t handle,
|
|
||||||
const char *args, uint32_t len)
|
|
||||||
{
|
|
||||||
(void)args;
|
|
||||||
(void)len;
|
|
||||||
struct option_bytes opts;
|
|
||||||
|
|
||||||
stm_option_bytes_read(&opts);
|
|
||||||
|
|
||||||
shellmatta_printf(handle, "Brown-out Level: 0x%x\r\n", opts.brown_out_level);
|
|
||||||
shellmatta_printf(handle, "nRST Standby: 0x%x\r\n", opts.nrst_standby);
|
|
||||||
shellmatta_printf(handle, "nRST Stop: 0x%x\r\n", opts.nrst_stop);
|
|
||||||
shellmatta_printf(handle, "Write Protection: 0x%x\r\n", opts.nwrpi);
|
|
||||||
shellmatta_printf(handle, "Read Protection: 0x%x\r\n", opts.read_protection);
|
|
||||||
shellmatta_printf(handle, "SW Watchdog: 0x%x\r\n", opts.wdg_sw);
|
|
||||||
|
|
||||||
return SHELLMATTA_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
shellmatta_retCode_t shell_cmd_set_baud(const shellmatta_handle_t handle, const char *args, uint32_t len)
|
|
||||||
{
|
|
||||||
|
|
||||||
shellmatta_retCode_t opt_stat;
|
|
||||||
char option;
|
|
||||||
char *argument;
|
|
||||||
uint32_t arg_len;
|
|
||||||
char *baud_string = NULL;
|
|
||||||
uint32_t baud;
|
|
||||||
(void)len;
|
|
||||||
(void)args;
|
|
||||||
|
|
||||||
const shellmatta_opt_long_t options[] = {
|
|
||||||
{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 '\0':
|
|
||||||
baud_string = argument;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
shellmatta_printf(handle, "Current baudrate: %u\r\n", (unsigned int)shell_uart_get_current_baudrate());
|
|
||||||
|
|
||||||
if (!baud_string) {
|
|
||||||
shellmatta_printf(handle, "Please specify a baudrate\r\n");
|
|
||||||
return SHELLMATTA_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
baud = strtoul(baud_string, NULL, 0);
|
|
||||||
if (baud < 38400) {
|
|
||||||
shellmatta_printf(handle, "38400 is the minimum recommended baudrate!\r\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
shellmatta_printf(handle, "Setting baud to: %u\r\n", (unsigned int)baud);
|
|
||||||
|
|
||||||
if (shell_uart_reconfig_baud(baud) < 0) {
|
|
||||||
shellmatta_printf(handle,"Setting baudrate not possible. Error greater than 2%%\r\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return SHELLMATTA_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
//typedef struct shellmatta_cmd
|
//typedef struct shellmatta_cmd
|
||||||
//{
|
//{
|
||||||
// char *cmd; /**< command name */
|
// char *cmd; /**< command name */
|
||||||
@@ -1006,7 +886,7 @@ shellmatta_retCode_t shell_cmd_set_baud(const shellmatta_handle_t handle, const
|
|||||||
// shellmatta_cmdFct_t cmdFct; /**< pointer to the cmd callack function */
|
// shellmatta_cmdFct_t cmdFct; /**< pointer to the cmd callack function */
|
||||||
// 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[25] = {
|
static shellmatta_cmd_t cmd[24] = {
|
||||||
{
|
{
|
||||||
.cmd = "version",
|
.cmd = "version",
|
||||||
.cmdAlias = "ver",
|
.cmdAlias = "ver",
|
||||||
@@ -1190,25 +1070,8 @@ static shellmatta_cmd_t cmd[25] = {
|
|||||||
.helpText = "Sets the filter constant",
|
.helpText = "Sets the filter constant",
|
||||||
.usageText = "filter-alpha <alpha>",
|
.usageText = "filter-alpha <alpha>",
|
||||||
.cmdFct = shell_cmd_filter_alpha,
|
.cmdFct = shell_cmd_filter_alpha,
|
||||||
.next = &cmd[23],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.cmd = "print-option-bytes",
|
|
||||||
.cmdAlias = "opt-bytes",
|
|
||||||
.helpText = "Print the currently set option bytes of the STM32",
|
|
||||||
.usageText = "",
|
|
||||||
.cmdFct = shell_cmd_print_opt_bytes,
|
|
||||||
.next = &cmd[24],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.cmd = "baudrate",
|
|
||||||
.cmdAlias = "opt-bytes",
|
|
||||||
.helpText = "Set a new temporary baudrate for the UART",
|
|
||||||
.usageText = "baudrate <new baud>",
|
|
||||||
.cmdFct = shell_cmd_set_baud,
|
|
||||||
.next = NULL,
|
.next = NULL,
|
||||||
},
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
shellmatta_handle_t shell_init(shellmatta_write_t write_func)
|
shellmatta_handle_t shell_init(shellmatta_write_t write_func)
|
@@ -1,90 +0,0 @@
|
|||||||
/* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stm-periph/option-bytes.h>
|
|
||||||
#include <stm32/stm32f4xx.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief First key for unlocking hte option byte write access
|
|
||||||
*/
|
|
||||||
#define FLASH_OPTION_KEY1 (0x08192A3BUL)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Second key for unlocking hte option byte write access
|
|
||||||
*/
|
|
||||||
#define FLASH_OPTION_KEY2 (0x4C5D6E7FUL)
|
|
||||||
|
|
||||||
void stm_option_bytes_read(struct option_bytes *opts)
|
|
||||||
{
|
|
||||||
uint32_t opt_reg;
|
|
||||||
|
|
||||||
if (!opts)
|
|
||||||
return;
|
|
||||||
|
|
||||||
opt_reg = FLASH->OPTCR;
|
|
||||||
opts->brown_out_level = (opt_reg & FLASH_OPTCR_BOR_LEV) >> 2;
|
|
||||||
opts->nrst_standby = (opt_reg & FLASH_OPTCR_nRST_STDBY) >> 7;
|
|
||||||
opts->nrst_stop = (opt_reg & FLASH_OPTCR_nRST_STOP) >> 6;
|
|
||||||
opts->nwrpi = (opt_reg & FLASH_OPTCR_nWRP) >> 16;
|
|
||||||
opts->read_protection = (opt_reg & FLASH_OPTCR_RDP) >> 8;
|
|
||||||
opts->wdg_sw = (opt_reg & FLASH_OPTCR_WDG_SW) >> 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
int stm_option_bytes_program(const struct option_bytes *opts)
|
|
||||||
{
|
|
||||||
uint32_t reg;
|
|
||||||
|
|
||||||
FLASH->OPTKEYR = FLASH_OPTION_KEY1;
|
|
||||||
FLASH->OPTKEYR = FLASH_OPTION_KEY2;
|
|
||||||
|
|
||||||
__DSB();
|
|
||||||
|
|
||||||
if (FLASH->OPTCR & FLASH_OPTCR_OPTLOCK) {
|
|
||||||
/* Unlocking failed */
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
reg = FLASH->OPTCR;
|
|
||||||
reg &= ~FLASH_OPTCR_BOR_LEV;
|
|
||||||
reg &= ~FLASH_OPTCR_nRST_STDBY;
|
|
||||||
reg &= ~FLASH_OPTCR_nRST_STOP;
|
|
||||||
reg &= ~FLASH_OPTCR_nWRP;
|
|
||||||
reg &= ~FLASH_OPTCR_RDP;
|
|
||||||
reg &= ~FLASH_OPTCR_WDG_SW;
|
|
||||||
|
|
||||||
reg |= (opts->brown_out_level << 2) & FLASH_OPTCR_BOR_LEV;
|
|
||||||
reg |= (opts->nrst_standby << 7) & FLASH_OPTCR_nRST_STDBY;
|
|
||||||
reg |= (opts->nrst_stop << 6) & FLASH_OPTCR_nRST_STOP;
|
|
||||||
reg |= (opts->nwrpi << 16) & FLASH_OPTCR_nWRP;
|
|
||||||
reg |= (opts->read_protection << 8) & FLASH_OPTCR_RDP;
|
|
||||||
reg |= (opts->wdg_sw << 5) & FLASH_OPTCR_WDG_SW;
|
|
||||||
|
|
||||||
while (FLASH->SR & FLASH_SR_BSY);
|
|
||||||
|
|
||||||
FLASH->OPTCR = reg;
|
|
||||||
FLASH->OPTCR |= FLASH_OPTCR_OPTSTRT;
|
|
||||||
__DSB();
|
|
||||||
while (FLASH->SR & FLASH_SR_BSY);
|
|
||||||
|
|
||||||
FLASH->OPTCR |= FLASH_OPTCR_OPTLOCK;
|
|
||||||
|
|
||||||
__DSB();
|
|
||||||
return 0;
|
|
||||||
}
|
|
@@ -95,14 +95,6 @@ void uart_change_brr(struct stm_uart *uart, uint32_t brr)
|
|||||||
uart->uart_dev->BRR = brr;
|
uart->uart_dev->BRR = brr;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t uart_get_brr(struct stm_uart *uart)
|
|
||||||
{
|
|
||||||
if (!uart || !uart->uart_dev)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return uart->brr_val;
|
|
||||||
}
|
|
||||||
|
|
||||||
void uart_disable(struct stm_uart *uart)
|
void uart_disable(struct stm_uart *uart)
|
||||||
{
|
{
|
||||||
if (!uart)
|
if (!uart)
|
||||||
|
@@ -19,13 +19,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stm-periph/unique-id.h>
|
#include <stm-periph/unique-id.h>
|
||||||
#include <stm32/stm32f4xx.h>
|
|
||||||
|
|
||||||
#define LOW_WORD_ADDR (0x1FFF7A10UL)
|
#define LOW_WORD_ADDR (0x1FFF7A10UL)
|
||||||
#define MID_WORD_ADDR (LOW_WORD_ADDR+4U)
|
#define MID_WORD_ADDR (LOW_WORD_ADDR+4U)
|
||||||
#define HIGH_WORD_ADDR (LOW_WORD_ADDR+8U)
|
#define HIGH_WORD_ADDR (LOW_WORD_ADDR+8U)
|
||||||
|
|
||||||
void stm_unique_id_get(uint32_t *high, uint32_t *mid, uint32_t *low)
|
void unique_id_get(uint32_t *high, uint32_t *mid, uint32_t *low)
|
||||||
{
|
{
|
||||||
if (!high || !mid || !low)
|
if (!high || !mid || !low)
|
||||||
return;
|
return;
|
||||||
@@ -34,12 +33,3 @@ void stm_unique_id_get(uint32_t *high, uint32_t *mid, uint32_t *low)
|
|||||||
*mid = *((uint32_t *)MID_WORD_ADDR);
|
*mid = *((uint32_t *)MID_WORD_ADDR);
|
||||||
*high = *((uint32_t *)HIGH_WORD_ADDR);
|
*high = *((uint32_t *)HIGH_WORD_ADDR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void stm_dev_rev_id_get(uint32_t *device_id, uint32_t *revision_id)
|
|
||||||
{
|
|
||||||
if (device_id)
|
|
||||||
*device_id = DBGMCU->IDCODE & DBGMCU_IDCODE_DEV_ID;
|
|
||||||
if (revision_id)
|
|
||||||
*revision_id = (DBGMCU->IDCODE & DBGMCU_IDCODE_REV_ID) >> 16;
|
|
||||||
}
|
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include <reflow-controller/safety/safety-controller.h>
|
#include <reflow-controller/safety/safety-controller.h>
|
||||||
|
|
||||||
static struct tpe_exec_state IN_SECTION(.ccm.data) current_state = {
|
static struct tpe_current_state IN_SECTION(.ccm.data) state = {
|
||||||
.status = TPE_OFF,
|
.status = TPE_OFF,
|
||||||
.start_timestamp = 0,
|
.start_timestamp = 0,
|
||||||
};
|
};
|
||||||
@@ -46,7 +46,7 @@ static SlList *command_list = NULL;
|
|||||||
static void tpe_abort(void)
|
static void tpe_abort(void)
|
||||||
{
|
{
|
||||||
temp_profile_executer_stop();
|
temp_profile_executer_stop();
|
||||||
current_state.status = TPE_ABORT;
|
state.status = TPE_ABORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum pl_ret_val temp_profile_executer_start(const char *filename)
|
enum pl_ret_val temp_profile_executer_start(const char *filename)
|
||||||
@@ -54,16 +54,16 @@ enum pl_ret_val temp_profile_executer_start(const char *filename)
|
|||||||
uint32_t parsed_count = 0;
|
uint32_t parsed_count = 0;
|
||||||
enum pl_ret_val res;
|
enum pl_ret_val res;
|
||||||
|
|
||||||
current_state.setpoint = 0.0f;
|
state.setpoint = 0.0f;
|
||||||
current_state.start_timestamp = 0ULL;
|
state.start_timestamp = 0ULL;
|
||||||
current_state.setpoint = 0.0f;
|
state.setpoint = 0.0f;
|
||||||
current_state.step = 0;
|
state.step = 0;
|
||||||
current_state.profile_steps = 0;
|
state.profile_steps = 0;
|
||||||
|
|
||||||
oven_pid_stop();
|
oven_pid_stop();
|
||||||
pid_should_run = false;
|
pid_should_run = false;
|
||||||
current_state.status = TPE_OFF;
|
state.status = TPE_OFF;
|
||||||
current_state.profile_steps = 0;
|
state.profile_steps = 0;
|
||||||
cmd_continue = false;
|
cmd_continue = false;
|
||||||
|
|
||||||
/* This should never happen... But who knows */
|
/* This should never happen... But who knows */
|
||||||
@@ -73,9 +73,9 @@ enum pl_ret_val temp_profile_executer_start(const char *filename)
|
|||||||
|
|
||||||
res = temp_profile_parse_from_file(filename, &command_list, MAX_PROFILE_LENGTH, &parsed_count);
|
res = temp_profile_parse_from_file(filename, &command_list, MAX_PROFILE_LENGTH, &parsed_count);
|
||||||
if (res == PL_RET_SUCCESS) {
|
if (res == PL_RET_SUCCESS) {
|
||||||
current_state.profile_steps = parsed_count;
|
state.profile_steps = parsed_count;
|
||||||
current_state.status = TPE_RUNNING;
|
state.status = TPE_RUNNING;
|
||||||
current_state.start_timestamp = systick_get_global_tick();
|
state.start_timestamp = systick_get_global_tick();
|
||||||
} else {
|
} else {
|
||||||
if (command_list)
|
if (command_list)
|
||||||
temp_profile_free_command_list(&command_list);
|
temp_profile_free_command_list(&command_list);
|
||||||
@@ -132,7 +132,7 @@ static bool cmd_set_temp(struct pl_command *cmd)
|
|||||||
{
|
{
|
||||||
reactivate_pid_if_suspended();
|
reactivate_pid_if_suspended();
|
||||||
oven_pid_set_target_temperature(cmd->params[0]);
|
oven_pid_set_target_temperature(cmd->params[0]);
|
||||||
current_state.setpoint = cmd->params[0];
|
state.setpoint = cmd->params[0];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,21 +146,21 @@ static bool cmd_ramp(struct pl_command *cmd, bool cmd_continue)
|
|||||||
|
|
||||||
if (!cmd_continue) {
|
if (!cmd_continue) {
|
||||||
/* Init of command */
|
/* Init of command */
|
||||||
start_temp = current_state.setpoint;
|
start_temp = state.setpoint;
|
||||||
slope = (cmd->params[0] - start_temp) / cmd->params[1];
|
slope = (cmd->params[0] - start_temp) / cmd->params[1];
|
||||||
reactivate_pid_if_suspended();
|
reactivate_pid_if_suspended();
|
||||||
oven_pid_set_target_temperature(start_temp);
|
oven_pid_set_target_temperature(start_temp);
|
||||||
start_timestamp = systick_get_global_tick();
|
start_timestamp = systick_get_global_tick();
|
||||||
} else {
|
} else {
|
||||||
secs_passed = ((float)(systick_get_global_tick() - start_timestamp)) / 1000.0f;
|
secs_passed = ((float)(systick_get_global_tick() - start_timestamp)) / 1000.0f;
|
||||||
if ((current_state.setpoint <= cmd->params[0] && start_temp < cmd->params[0]) ||
|
if ((state.setpoint <= cmd->params[0] && start_temp < cmd->params[0]) ||
|
||||||
(current_state.setpoint >= cmd->params[0] && start_temp > cmd->params[0])) {
|
(state.setpoint >= cmd->params[0] && start_temp > cmd->params[0])) {
|
||||||
current_state.setpoint = start_temp + secs_passed * slope;
|
state.setpoint = start_temp + secs_passed * slope;
|
||||||
} else {
|
} else {
|
||||||
current_state.setpoint = cmd->params[0];
|
state.setpoint = cmd->params[0];
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
oven_pid_set_target_temperature(current_state.setpoint);
|
oven_pid_set_target_temperature(state.setpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -185,36 +185,6 @@ static void cmd_ack_flags(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_digio_conf(uint8_t digio_num, uint8_t mode)
|
|
||||||
{
|
|
||||||
uint8_t pin_mode;
|
|
||||||
uint8_t alt_func = 0;
|
|
||||||
|
|
||||||
if (mode == 0 || mode == 1) {
|
|
||||||
pin_mode = mode;
|
|
||||||
} else if (mode >= 0x80 && mode <= 0x87) {
|
|
||||||
/* Alternate function */
|
|
||||||
pin_mode = 2;
|
|
||||||
alt_func = mode - 0x80;
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
digio_setup_pin(digio_num, pin_mode, alt_func);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cmd_digio_wait(uint8_t digio_num, uint8_t digio_state)
|
|
||||||
{
|
|
||||||
bool advance = false;
|
|
||||||
int res;
|
|
||||||
|
|
||||||
res = digio_get(digio_num);
|
|
||||||
if (res < 0 || (uint8_t)res == digio_state)
|
|
||||||
advance = true;
|
|
||||||
|
|
||||||
return advance;
|
|
||||||
}
|
|
||||||
|
|
||||||
int temp_profile_executer_handle(void)
|
int temp_profile_executer_handle(void)
|
||||||
{
|
{
|
||||||
struct pl_command *current_cmd;
|
struct pl_command *current_cmd;
|
||||||
@@ -225,7 +195,7 @@ int temp_profile_executer_handle(void)
|
|||||||
|
|
||||||
|
|
||||||
/* Return if no profile is currently executed */
|
/* Return if no profile is currently executed */
|
||||||
if (current_state.status != TPE_RUNNING)
|
if (state.status != TPE_RUNNING)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Abort profile execution if oven PID is aborted. This is most likely due to some error flags */
|
/* Abort profile execution if oven PID is aborted. This is most likely due to some error flags */
|
||||||
@@ -239,8 +209,8 @@ int temp_profile_executer_handle(void)
|
|||||||
if (!systick_ticks_have_passed(last_tick, 100))
|
if (!systick_ticks_have_passed(last_tick, 100))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
current_cmd = (struct pl_command *)sl_list_nth(command_list, current_state.step)->data;
|
current_cmd = (struct pl_command *)sl_list_nth(command_list, state.step)->data;
|
||||||
next_step = current_state.step;
|
next_step = state.step;
|
||||||
|
|
||||||
switch (current_cmd->cmd) {
|
switch (current_cmd->cmd) {
|
||||||
case PL_WAIT_FOR_TIME:
|
case PL_WAIT_FOR_TIME:
|
||||||
@@ -280,17 +250,6 @@ int temp_profile_executer_handle(void)
|
|||||||
cmd_ack_flags();
|
cmd_ack_flags();
|
||||||
advance = true;
|
advance = true;
|
||||||
break;
|
break;
|
||||||
case PL_DIGIO_CONF:
|
|
||||||
advance = true;
|
|
||||||
cmd_digio_conf((uint8_t)current_cmd->params[0], (uint8_t)current_cmd->params[1]);
|
|
||||||
break;
|
|
||||||
case PL_DIGIO_SET:
|
|
||||||
digio_set((uint8_t)current_cmd->params[0], current_cmd->params[1] ? 1u : 0u);
|
|
||||||
advance = true;
|
|
||||||
break;
|
|
||||||
case PL_DIGIO_WAIT:
|
|
||||||
advance = cmd_digio_wait((uint8_t)current_cmd->params[0], current_cmd->params[1] ? 1u : 0u);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
tpe_abort();
|
tpe_abort();
|
||||||
advance = true;
|
advance = true;
|
||||||
@@ -300,9 +259,9 @@ int temp_profile_executer_handle(void)
|
|||||||
if (advance)
|
if (advance)
|
||||||
next_step++;
|
next_step++;
|
||||||
|
|
||||||
if (next_step != current_state.step) {
|
if (next_step != state.step) {
|
||||||
current_state.step = next_step;
|
state.step = next_step;
|
||||||
if (next_step >= current_state.profile_steps) {
|
if (next_step >= state.profile_steps) {
|
||||||
(void)temp_profile_executer_stop();
|
(void)temp_profile_executer_stop();
|
||||||
} else {
|
} else {
|
||||||
cmd_continue = false;
|
cmd_continue = false;
|
||||||
@@ -315,15 +274,15 @@ int temp_profile_executer_handle(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct tpe_exec_state *temp_profile_executer_status(void)
|
const struct tpe_current_state *temp_profile_executer_status(void)
|
||||||
{
|
{
|
||||||
return ¤t_state;
|
return &state;
|
||||||
}
|
}
|
||||||
|
|
||||||
int temp_profile_executer_stop(void)
|
int temp_profile_executer_stop(void)
|
||||||
{
|
{
|
||||||
if (current_state.status == TPE_RUNNING) {
|
if (state.status == TPE_RUNNING) {
|
||||||
current_state.status = TPE_OFF;
|
state.status = TPE_OFF;
|
||||||
oven_pid_stop();
|
oven_pid_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,9 +290,7 @@ int temp_profile_executer_stop(void)
|
|||||||
if (command_list)
|
if (command_list)
|
||||||
temp_profile_free_command_list(&command_list);
|
temp_profile_free_command_list(&command_list);
|
||||||
|
|
||||||
/* Reset loudspeaker and reset default state of DIGIO channels */
|
|
||||||
loudspeaker_set(0);
|
loudspeaker_set(0);
|
||||||
digio_set_default_values();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -48,9 +48,6 @@ static const struct pl_command_list_map cmd_list_map[_PL_NUM_CMDS] = {
|
|||||||
{PL_LOUDSPEAKER_SET, "beep", 1u},
|
{PL_LOUDSPEAKER_SET, "beep", 1u},
|
||||||
{PL_OFF, "temp_off", 0u},
|
{PL_OFF, "temp_off", 0u},
|
||||||
{PL_CLEAR_FLAGS, "clear_flags", 0u},
|
{PL_CLEAR_FLAGS, "clear_flags", 0u},
|
||||||
{PL_DIGIO_CONF, "digio_conf", 2u},
|
|
||||||
{PL_DIGIO_SET, "digio_set", 2u},
|
|
||||||
{PL_DIGIO_WAIT, "digio_wait", 2u},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,13 +108,6 @@ static const struct pl_command_list_map *string_to_command(const char *str)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Parse a line in the temperature profile to a command.
|
|
||||||
* @param line Line to parse
|
|
||||||
* @param[out] cmd Command parsed
|
|
||||||
* @return negative in case of an error (Invalid command, invalid line);
|
|
||||||
* 1 in case the line is an empty line.
|
|
||||||
*/
|
|
||||||
static int parse_line(char *line, struct pl_command *cmd)
|
static int parse_line(char *line, struct pl_command *cmd)
|
||||||
{
|
{
|
||||||
uint8_t token_idx = 0;
|
uint8_t token_idx = 0;
|
||||||
@@ -133,10 +123,7 @@ static int parse_line(char *line, struct pl_command *cmd)
|
|||||||
token = strtok(line, delim);
|
token = strtok(line, delim);
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
/* Empty line.
|
/* Empty line or command line */
|
||||||
* Note: The comments in the lines are already filteed out before calling this function.
|
|
||||||
* Therefore, the empty line case covers lines containing just a comment
|
|
||||||
*/
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,10 +131,6 @@ static int parse_line(char *line, struct pl_command *cmd)
|
|||||||
switch (token_idx) {
|
switch (token_idx) {
|
||||||
case 0:
|
case 0:
|
||||||
map = string_to_command(token);
|
map = string_to_command(token);
|
||||||
if (!map) {
|
|
||||||
/* No valid command found */
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
c.cmd = map->command;
|
c.cmd = map->command;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -179,23 +162,12 @@ static int parse_line(char *line, struct pl_command *cmd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Append a command to a singly linked list.
|
|
||||||
*
|
|
||||||
* The the list item is newly allocated and the command is copied. Therefore, \p cmd can be overwritten after
|
|
||||||
* a call to this function.
|
|
||||||
*
|
|
||||||
* @param list List to add the command to
|
|
||||||
* @param cmd Command to add to list
|
|
||||||
* @return The new head of the list. If an error occured */
|
|
||||||
static SlList *copy_and_append_command_to_list(SlList *list, const struct pl_command *cmd)
|
static SlList *copy_and_append_command_to_list(SlList *list, const struct pl_command *cmd)
|
||||||
{
|
{
|
||||||
struct pl_command *alloced_cmd;
|
struct pl_command *alloced_cmd;
|
||||||
|
|
||||||
alloced_cmd = (struct pl_command *)malloc(sizeof(struct pl_command));
|
alloced_cmd = (struct pl_command *)malloc(sizeof(struct pl_command));
|
||||||
memcpy(alloced_cmd, cmd, sizeof(struct pl_command));
|
memcpy(alloced_cmd, cmd, sizeof(struct pl_command));
|
||||||
|
|
||||||
/* This will go catastrophically wrong, if the heap is full... just saying. */
|
|
||||||
list = sl_list_append(list, alloced_cmd);
|
list = sl_list_append(list, alloced_cmd);
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@@ -263,10 +235,6 @@ exit:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Free an allocated pl_command structure
|
|
||||||
* @param cmd command struct. Tolerates NULL.
|
|
||||||
*/
|
|
||||||
static void delete_pl_command(void *cmd)
|
static void delete_pl_command(void *cmd)
|
||||||
{
|
{
|
||||||
if (cmd)
|
if (cmd)
|
||||||
|
@@ -53,7 +53,6 @@ void button_init()
|
|||||||
enum button_state button_read_event()
|
enum button_state button_read_event()
|
||||||
{
|
{
|
||||||
uint64_t time_delta;
|
uint64_t time_delta;
|
||||||
uint64_t activation_stmp;
|
|
||||||
enum button_state temp_state;
|
enum button_state temp_state;
|
||||||
|
|
||||||
if (override_state != BUTTON_IDLE) {
|
if (override_state != BUTTON_IDLE) {
|
||||||
@@ -67,13 +66,7 @@ enum button_state button_read_event()
|
|||||||
int_state = BUTTON_IDLE;
|
int_state = BUTTON_IDLE;
|
||||||
return temp_state;
|
return temp_state;
|
||||||
} else {
|
} else {
|
||||||
/* Unfortunately I don't jave a better idea for now to ensure,
|
time_delta = systick_get_global_tick() - to_active_timestamp;
|
||||||
* that to_active_timestamp is read atomically
|
|
||||||
*/
|
|
||||||
__disable_irq();
|
|
||||||
activation_stmp = to_active_timestamp;
|
|
||||||
__enable_irq();
|
|
||||||
time_delta = systick_get_global_tick() - activation_stmp;
|
|
||||||
if (time_delta >= BUTTON_LONG_ON_TIME_MS)
|
if (time_delta >= BUTTON_LONG_ON_TIME_MS)
|
||||||
return BUTTON_LONG;
|
return BUTTON_LONG;
|
||||||
else if (time_delta >= BUTTON_SHORT_ON_TIME_MS)
|
else if (time_delta >= BUTTON_SHORT_ON_TIME_MS)
|
||||||
|
@@ -189,7 +189,7 @@ static void gui_menu_about(struct lcd_menu *menu, enum menu_entry_func_entry ent
|
|||||||
if (last_page == 3)
|
if (last_page == 3)
|
||||||
break;
|
break;
|
||||||
last_page = 3;
|
last_page = 3;
|
||||||
stm_unique_id_get(&ser1, &ser2, &ser3);
|
unique_id_get(&ser1, &ser2, &ser3);
|
||||||
|
|
||||||
menu_lcd_outputf(menu, 0, "Serial: %08X", ser1);
|
menu_lcd_outputf(menu, 0, "Serial: %08X", ser1);
|
||||||
menu_lcd_outputf(menu, 1, " %08X", ser2);
|
menu_lcd_outputf(menu, 1, " %08X", ser2);
|
||||||
@@ -414,7 +414,7 @@ static SlList *load_file_list_from_sdcard(int *error, const char *file_pattern)
|
|||||||
static void gui_menu_temp_profile_execute(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void* parent)
|
static void gui_menu_temp_profile_execute(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void* parent)
|
||||||
{
|
{
|
||||||
static void *my_parent;
|
static void *my_parent;
|
||||||
const struct tpe_exec_state *state;
|
const struct tpe_current_state *state;
|
||||||
static uint64_t last_tick;
|
static uint64_t last_tick;
|
||||||
float temperature;
|
float temperature;
|
||||||
float resistance;
|
float resistance;
|
||||||
@@ -663,26 +663,21 @@ static void gui_update_firmware(struct lcd_menu *menu, enum menu_entry_func_entr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list_length) {
|
if (entry_type == MENU_ENTRY_FIRST_ENTER ||
|
||||||
if (entry_type == MENU_ENTRY_FIRST_ENTER ||
|
previously_selected_file != currently_selected_file) {
|
||||||
previously_selected_file != currently_selected_file) {
|
fname = sl_list_nth(file_list, currently_selected_file)->data;
|
||||||
fname = sl_list_nth(file_list, currently_selected_file)->data;
|
menu_lcd_output(menu, 0, "Select File:");
|
||||||
menu_lcd_output(menu, 0, "Select File:");
|
if (fname)
|
||||||
if (fname)
|
menu_lcd_output(menu, 1, fname);
|
||||||
menu_lcd_output(menu, 1, fname);
|
|
||||||
}
|
|
||||||
if (button == BUTTON_SHORT_RELEASED) {
|
|
||||||
fname = sl_list_nth(file_list, currently_selected_file)->data;
|
|
||||||
menu_display_clear(menu);
|
|
||||||
updater_update_from_file(fname);
|
|
||||||
/* This code is here for completeness. It will never be reached! */
|
|
||||||
sl_list_free_full(file_list, delete_file_list_entry);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
menu_lcd_output(menu, 0, "No files!");
|
|
||||||
}
|
}
|
||||||
|
if (button == BUTTON_SHORT_RELEASED) {
|
||||||
if (button == BUTTON_LONG) {
|
fname = sl_list_nth(file_list, currently_selected_file)->data;
|
||||||
|
menu_display_clear(menu);
|
||||||
|
file_list = NULL;
|
||||||
|
updater_update_from_file(fname);
|
||||||
|
/* This code is here for completeness. It will never be reached! */
|
||||||
|
sl_list_free_full(file_list, delete_file_list_entry);
|
||||||
|
} else if (button == BUTTON_LONG) {
|
||||||
sl_list_free_full(file_list, delete_file_list_entry);
|
sl_list_free_full(file_list, delete_file_list_entry);
|
||||||
file_list = NULL;
|
file_list = NULL;
|
||||||
menu_entry_dropback(menu, my_parent);
|
menu_entry_dropback(menu, my_parent);
|
||||||
@@ -796,7 +791,7 @@ static void gui_menu_root_entry(struct lcd_menu *menu, enum menu_entry_func_entr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int gui_handle(void)
|
int gui_handle()
|
||||||
{
|
{
|
||||||
int32_t rot_delta;
|
int32_t rot_delta;
|
||||||
enum button_state button;
|
enum button_state button;
|
||||||
@@ -818,18 +813,12 @@ int gui_handle(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gui_init(void)
|
void gui_init()
|
||||||
{
|
{
|
||||||
/** - Setup the rotary encoder input */
|
|
||||||
rotary_encoder_setup();
|
rotary_encoder_setup();
|
||||||
|
|
||||||
/** - Setup the push button */
|
|
||||||
button_init();
|
button_init();
|
||||||
|
|
||||||
/** - Setup the LCD */
|
|
||||||
lcd_init();
|
lcd_init();
|
||||||
|
|
||||||
/** - If an overlay has been previously set, clear it */
|
|
||||||
if (overlay_heading)
|
if (overlay_heading)
|
||||||
free(overlay_heading);
|
free(overlay_heading);
|
||||||
if (overlay_text)
|
if (overlay_text)
|
||||||
@@ -838,7 +827,6 @@ void gui_init(void)
|
|||||||
overlay_heading = NULL;
|
overlay_heading = NULL;
|
||||||
overlay_text = NULL;
|
overlay_text = NULL;
|
||||||
|
|
||||||
/** - Init the GUI menu */
|
|
||||||
menu_init(reflow_menu_ptr, gui_menu_root_entry, update_display_buffer);
|
menu_init(reflow_menu_ptr, gui_menu_root_entry, update_display_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -865,13 +853,3 @@ void gui_lcd_write_direct_blocking(uint8_t line, const char *text)
|
|||||||
lcd_setcursor(0, line);
|
lcd_setcursor(0, line);
|
||||||
lcd_string(text);
|
lcd_string(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t gui_get_line_count(void)
|
|
||||||
{
|
|
||||||
return (size_t)LCD_ROW_COUNT;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char (*gui_get_current_display_content(void))[21]
|
|
||||||
{
|
|
||||||
return display_buffer;
|
|
||||||
}
|
|
||||||
|
@@ -1,130 +0,0 @@
|
|||||||
/* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <reflow-controller/ui/shell-uart.h>
|
|
||||||
#include <reflow-controller/periph-config/shell-uart-config.h>
|
|
||||||
#include <stm-periph/stm32-gpio-macros.h>
|
|
||||||
#include <stm-periph/uart.h>
|
|
||||||
#include <helper-macros/helper-macros.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief TX buffer for the shell's uart
|
|
||||||
*/
|
|
||||||
static char shell_uart_tx_buff[4096];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief RX buffer for the shell's uart
|
|
||||||
*/
|
|
||||||
static char shell_uart_rx_buff[128];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The uart instance handling the shellmatta shell.
|
|
||||||
*/
|
|
||||||
struct stm_uart shell_uart;
|
|
||||||
|
|
||||||
void shell_uart_setup(void)
|
|
||||||
{
|
|
||||||
struct stm_uart *uart = &shell_uart;
|
|
||||||
|
|
||||||
uart->rx = 1;
|
|
||||||
uart->tx = 1;
|
|
||||||
uart->brr_val = SHELL_UART_DEFAULT_BRR_REG_VALUE;
|
|
||||||
uart->rcc_reg = &SHELL_UART_RCC_REG;
|
|
||||||
uart->rcc_bit_no = BITMASK_TO_BITNO(SHELL_UART_RCC_MASK);
|
|
||||||
uart->uart_dev = SHELL_UART_PERIPH;
|
|
||||||
uart->dma_rx_buff = shell_uart_rx_buff;
|
|
||||||
uart->dma_tx_buff = shell_uart_tx_buff;
|
|
||||||
uart->rx_buff_count = sizeof(shell_uart_rx_buff);
|
|
||||||
uart->tx_buff_count = sizeof(shell_uart_tx_buff);
|
|
||||||
uart->base_dma_num = 2;
|
|
||||||
uart->dma_rx_stream = SHELL_UART_RECEIVE_DMA_STREAM;
|
|
||||||
uart->dma_tx_stream = SHELL_UART_SEND_DMA_STREAM;
|
|
||||||
uart->dma_rx_trigger_channel = SHELL_UART_RX_DMA_TRIGGER;
|
|
||||||
uart->dma_tx_trigger_channel = SHELL_UART_TX_DMA_TRIGGER;
|
|
||||||
|
|
||||||
uart_init(uart);
|
|
||||||
NVIC_EnableIRQ(DMA2_Stream7_IRQn);
|
|
||||||
}
|
|
||||||
|
|
||||||
shellmatta_retCode_t shell_uart_write_callback(const char *data, uint32_t len)
|
|
||||||
{
|
|
||||||
uart_send_array_with_dma(&shell_uart, data, len);
|
|
||||||
return SHELLMATTA_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int shell_uart_receive_data_with_dma(const char **data, size_t *len)
|
|
||||||
{
|
|
||||||
return uart_receive_data_with_dma(&shell_uart, data, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t shell_uart_reconfig_baud(uint32_t new_baud)
|
|
||||||
{
|
|
||||||
uint32_t brr_val_floor;
|
|
||||||
uint32_t brr_val_remainder;
|
|
||||||
uint32_t error_permille;
|
|
||||||
int64_t actual_baud;
|
|
||||||
|
|
||||||
/* Calculate the new BRR register value */
|
|
||||||
brr_val_floor = SHELL_UART_PERIPHERAL_CLOCK / new_baud;
|
|
||||||
brr_val_remainder = SHELL_UART_PERIPHERAL_CLOCK % new_baud;
|
|
||||||
|
|
||||||
/* Round to the nearest value */
|
|
||||||
if (brr_val_remainder > (new_baud / 2u)) {
|
|
||||||
brr_val_floor++;
|
|
||||||
brr_val_remainder = new_baud - brr_val_remainder;
|
|
||||||
}
|
|
||||||
|
|
||||||
actual_baud = (1000U *(int64_t)SHELL_UART_PERIPHERAL_CLOCK) / brr_val_floor;
|
|
||||||
error_permille = (ABS(actual_baud - 1000U * (int64_t)new_baud)) / (int64_t)new_baud;
|
|
||||||
|
|
||||||
|
|
||||||
if (error_permille < 20u) {
|
|
||||||
uart_change_brr(&shell_uart, brr_val_floor);
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int32_t)error_permille;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t shell_uart_get_current_baudrate(void)
|
|
||||||
{
|
|
||||||
uint32_t brr;
|
|
||||||
|
|
||||||
brr = uart_get_brr(&shell_uart);
|
|
||||||
if (brr == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return (SHELL_UART_PERIPHERAL_CLOCK) / brr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Handles the TX of UART1 (Shellmatta)
|
|
||||||
*/
|
|
||||||
void DMA2_Stream7_IRQHandler(void)
|
|
||||||
{
|
|
||||||
uint32_t hisr = DMA2->HISR & (0x3F << 22);
|
|
||||||
|
|
||||||
DMA2->HIFCR = hisr;
|
|
||||||
|
|
||||||
if (hisr & DMA_HISR_TCIF7)
|
|
||||||
uart_tx_dma_complete_int_callback(&shell_uart);
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -26,7 +26,7 @@ void flash_writer_perform_mass_erase(void)
|
|||||||
flash_writer_enable_access();
|
flash_writer_enable_access();
|
||||||
while (flash_op_busy());
|
while (flash_op_busy());
|
||||||
|
|
||||||
FLASH->CR = FLASH_CR_PSIZE_1;
|
FLASH->CR = DMA_SxCR_PSIZE_1;
|
||||||
FLASH->CR |= FLASH_CR_MER;
|
FLASH->CR |= FLASH_CR_MER;
|
||||||
FLASH->CR |= FLASH_CR_STRT;
|
FLASH->CR |= FLASH_CR_STRT;
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
/*----------------------------------------------------------------------------/
|
/*----------------------------------------------------------------------------/
|
||||||
/ FatFs - Generic FAT Filesystem module R0.14b /
|
/ FatFs - Generic FAT Filesystem module R0.14 /
|
||||||
/-----------------------------------------------------------------------------/
|
/-----------------------------------------------------------------------------/
|
||||||
/
|
/
|
||||||
/ Copyright (C) 2021, ChaN, all right reserved.
|
/ Copyright (C) 2019, ChaN, all right reserved.
|
||||||
/
|
/
|
||||||
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
||||||
/ source and binary forms, with or without modification, are permitted provided
|
/ source and binary forms, with or without modification, are permitted provided
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifndef FF_DEFINED
|
#ifndef FF_DEFINED
|
||||||
#define FF_DEFINED 86631 /* Revision ID */
|
#define FF_DEFINED 86606 /* Revision ID */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -35,14 +35,10 @@ extern "C" {
|
|||||||
|
|
||||||
/* Integer types used for FatFs API */
|
/* Integer types used for FatFs API */
|
||||||
|
|
||||||
#if defined(_WIN32) /* Windows VC++ (for development only) */
|
#if defined(_WIN32) /* Main development platform */
|
||||||
#define FF_INTDEF 2
|
#define FF_INTDEF 2
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
typedef unsigned __int64 QWORD;
|
typedef unsigned __int64 QWORD;
|
||||||
#include <float.h>
|
|
||||||
#define isnan(v) _isnan(v)
|
|
||||||
#define isinf(v) (!_finite(v))
|
|
||||||
|
|
||||||
#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) /* C99 or later */
|
#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) /* C99 or later */
|
||||||
#define FF_INTDEF 2
|
#define FF_INTDEF 2
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -52,7 +48,6 @@ typedef uint16_t WORD; /* 16-bit unsigned integer */
|
|||||||
typedef uint32_t DWORD; /* 32-bit unsigned integer */
|
typedef uint32_t DWORD; /* 32-bit unsigned integer */
|
||||||
typedef uint64_t QWORD; /* 64-bit unsigned integer */
|
typedef uint64_t QWORD; /* 64-bit unsigned integer */
|
||||||
typedef WORD WCHAR; /* UTF-16 character type */
|
typedef WORD WCHAR; /* UTF-16 character type */
|
||||||
|
|
||||||
#else /* Earlier than C99 */
|
#else /* Earlier than C99 */
|
||||||
#define FF_INTDEF 1
|
#define FF_INTDEF 1
|
||||||
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
|
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
|
||||||
@@ -63,29 +58,28 @@ typedef WORD WCHAR; /* UTF-16 character type */
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Type of file size and LBA variables */
|
/* Definitions of volume management */
|
||||||
|
|
||||||
#if FF_FS_EXFAT
|
#if FF_MULTI_PARTITION /* Multiple partition configuration */
|
||||||
#if FF_INTDEF != 2
|
typedef struct {
|
||||||
#error exFAT feature wants C99 or later
|
BYTE pd; /* Physical drive number */
|
||||||
|
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
|
||||||
|
} PARTITION;
|
||||||
|
extern PARTITION VolToPart[]; /* Volume - Partition mapping table */
|
||||||
#endif
|
#endif
|
||||||
typedef QWORD FSIZE_t;
|
|
||||||
#if FF_LBA64
|
#if FF_STR_VOLUME_ID
|
||||||
typedef QWORD LBA_t;
|
#ifndef FF_VOLUME_STRS
|
||||||
#else
|
extern const char* VolumeStr[FF_VOLUMES]; /* User defied volume ID */
|
||||||
typedef DWORD LBA_t;
|
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
#if FF_LBA64
|
|
||||||
#error exFAT needs to be enabled when enable 64-bit LBA
|
|
||||||
#endif
|
|
||||||
typedef DWORD FSIZE_t;
|
|
||||||
typedef DWORD LBA_t;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Type of path name strings on FatFs API (TCHAR) */
|
/* Type of path name strings on FatFs API */
|
||||||
|
|
||||||
|
#ifndef _INC_TCHAR
|
||||||
|
#define _INC_TCHAR
|
||||||
|
|
||||||
#if FF_USE_LFN && FF_LFN_UNICODE == 1 /* Unicode in UTF-16 encoding */
|
#if FF_USE_LFN && FF_LFN_UNICODE == 1 /* Unicode in UTF-16 encoding */
|
||||||
typedef WCHAR TCHAR;
|
typedef WCHAR TCHAR;
|
||||||
@@ -107,22 +101,28 @@ typedef char TCHAR;
|
|||||||
#define _TEXT(x) x
|
#define _TEXT(x) x
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Definitions of volume management */
|
|
||||||
|
|
||||||
#if FF_MULTI_PARTITION /* Multiple partition configuration */
|
|
||||||
typedef struct {
|
|
||||||
BYTE pd; /* Physical drive number */
|
|
||||||
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
|
|
||||||
} PARTITION;
|
|
||||||
extern PARTITION VolToPart[]; /* Volume - Partition mapping table */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if FF_STR_VOLUME_ID
|
|
||||||
#ifndef FF_VOLUME_STRS
|
|
||||||
extern const char* VolumeStr[FF_VOLUMES]; /* User defied volume ID */
|
/* Type of file size and LBA variables */
|
||||||
|
|
||||||
|
#if FF_FS_EXFAT
|
||||||
|
#if FF_INTDEF != 2
|
||||||
|
#error exFAT feature wants C99 or later
|
||||||
#endif
|
#endif
|
||||||
|
typedef QWORD FSIZE_t;
|
||||||
|
#if FF_LBA64
|
||||||
|
typedef QWORD LBA_t;
|
||||||
|
#else
|
||||||
|
typedef DWORD LBA_t;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#if FF_LBA64
|
||||||
|
#error exFAT needs to be enabled when enable 64-bit LBA
|
||||||
|
#endif
|
||||||
|
typedef DWORD FSIZE_t;
|
||||||
|
typedef DWORD LBA_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -345,6 +345,10 @@ TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the fil
|
|||||||
#define f_rmdir(path) f_unlink(path)
|
#define f_rmdir(path) f_unlink(path)
|
||||||
#define f_unmount(path) f_mount(0, path, 0)
|
#define f_unmount(path) f_mount(0, path, 0)
|
||||||
|
|
||||||
|
#ifndef EOF
|
||||||
|
#define EOF (-1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/ FatFs Functional Configurations
|
/ FatFs Functional Configurations
|
||||||
/---------------------------------------------------------------------------*/
|
/---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#define FFCONF_DEF 86631 /* Revision ID */
|
#define FFCONF_DEF 86606 /* Revision ID */
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------/
|
/*---------------------------------------------------------------------------/
|
||||||
/ Function Configurations
|
/ Function Configurations
|
||||||
@@ -25,7 +25,15 @@
|
|||||||
/ 3: f_lseek() function is removed in addition to 2. */
|
/ 3: f_lseek() function is removed in addition to 2. */
|
||||||
|
|
||||||
|
|
||||||
#define FF_USE_FIND 1
|
#define FF_USE_STRFUNC 1
|
||||||
|
/* This option switches string functions, f_gets(), f_putc(), f_puts() and f_printf().
|
||||||
|
/
|
||||||
|
/ 0: Disable string functions.
|
||||||
|
/ 1: Enable without LF-CRLF conversion.
|
||||||
|
/ 2: Enable with LF-CRLF conversion. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_USE_FIND 0
|
||||||
/* This option switches filtered directory read functions, f_findfirst() and
|
/* This option switches filtered directory read functions, f_findfirst() and
|
||||||
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
|
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
|
||||||
|
|
||||||
@@ -56,30 +64,6 @@
|
|||||||
/* This option switches f_forward() function. (0:Disable or 1:Enable) */
|
/* This option switches f_forward() function. (0:Disable or 1:Enable) */
|
||||||
|
|
||||||
|
|
||||||
#define FF_USE_STRFUNC 1
|
|
||||||
#define FF_PRINT_LLI 0
|
|
||||||
#define FF_PRINT_FLOAT 0
|
|
||||||
#define FF_STRF_ENCODE 0
|
|
||||||
/* FF_USE_STRFUNC switches string functions, f_gets(), f_putc(), f_puts() and
|
|
||||||
/ f_printf().
|
|
||||||
/
|
|
||||||
/ 0: Disable. FF_PRINT_LLI, FF_PRINT_FLOAT and FF_STRF_ENCODE have no effect.
|
|
||||||
/ 1: Enable without LF-CRLF conversion.
|
|
||||||
/ 2: Enable with LF-CRLF conversion.
|
|
||||||
/
|
|
||||||
/ FF_PRINT_LLI = 1 makes f_printf() support long long argument and FF_PRINT_FLOAT = 1/2
|
|
||||||
makes f_printf() support floating point argument. These features want C99 or later.
|
|
||||||
/ When FF_LFN_UNICODE >= 1 with LFN enabled, string functions convert the character
|
|
||||||
/ encoding in it. FF_STRF_ENCODE selects assumption of character encoding ON THE FILE
|
|
||||||
/ to be read/written via those functions.
|
|
||||||
/
|
|
||||||
/ 0: ANSI/OEM in current CP
|
|
||||||
/ 1: Unicode in UTF-16LE
|
|
||||||
/ 2: Unicode in UTF-16BE
|
|
||||||
/ 3: Unicode in UTF-8
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------/
|
/*---------------------------------------------------------------------------/
|
||||||
/ Locale and Namespace Configurations
|
/ Locale and Namespace Configurations
|
||||||
/---------------------------------------------------------------------------*/
|
/---------------------------------------------------------------------------*/
|
||||||
@@ -153,6 +137,19 @@
|
|||||||
/ on character encoding. When LFN is not enabled, these options have no effect. */
|
/ on character encoding. When LFN is not enabled, these options have no effect. */
|
||||||
|
|
||||||
|
|
||||||
|
#define FF_STRF_ENCODE 3
|
||||||
|
/* When FF_LFN_UNICODE >= 1 with LFN enabled, string I/O functions, f_gets(),
|
||||||
|
/ f_putc(), f_puts and f_printf() convert the character encoding in it.
|
||||||
|
/ This option selects assumption of character encoding ON THE FILE to be
|
||||||
|
/ read/written via those functions.
|
||||||
|
/
|
||||||
|
/ 0: ANSI/OEM in current CP
|
||||||
|
/ 1: Unicode in UTF-16LE
|
||||||
|
/ 2: Unicode in UTF-16BE
|
||||||
|
/ 3: Unicode in UTF-8
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define FF_FS_RPATH 0
|
#define FF_FS_RPATH 0
|
||||||
/* This option configures support for relative path.
|
/* This option configures support for relative path.
|
||||||
/
|
/
|
||||||
@@ -197,7 +194,7 @@
|
|||||||
#define FF_MAX_SS 512
|
#define FF_MAX_SS 512
|
||||||
/* This set of options configures the range of sector size to be supported. (512,
|
/* This set of options configures the range of sector size to be supported. (512,
|
||||||
/ 1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and
|
/ 1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and
|
||||||
/ harddisk, but a larger value may be required for on-board flash memory and some
|
/ harddisk. But a larger value may be required for on-board flash memory and some
|
||||||
/ type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured
|
/ type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured
|
||||||
/ for variable sector size mode and disk_ioctl() function needs to implement
|
/ for variable sector size mode and disk_ioctl() function needs to implement
|
||||||
/ GET_SECTOR_SIZE command. */
|
/ GET_SECTOR_SIZE command. */
|
||||||
@@ -208,8 +205,8 @@
|
|||||||
/ To enable the 64-bit LBA, also exFAT needs to be enabled. (FF_FS_EXFAT == 1) */
|
/ To enable the 64-bit LBA, also exFAT needs to be enabled. (FF_FS_EXFAT == 1) */
|
||||||
|
|
||||||
|
|
||||||
#define FF_MIN_GPT 0x10000000
|
#define FF_MIN_GPT 0x100000000
|
||||||
/* Minimum number of sectors to switch GPT as partitioning format in f_mkfs and
|
/* Minimum number of sectors to switch GPT format to create partition in f_mkfs and
|
||||||
/ f_fdisk function. 0x100000000 max. This option has no effect when FF_LBA64 == 0. */
|
/ f_fdisk function. 0x100000000 max. This option has no effect when FF_LBA64 == 0. */
|
||||||
|
|
||||||
|
|
||||||
@@ -231,7 +228,7 @@
|
|||||||
/ buffer in the filesystem object (FATFS) is used for the file data transfer. */
|
/ buffer in the filesystem object (FATFS) is used for the file data transfer. */
|
||||||
|
|
||||||
|
|
||||||
#define FF_FS_EXFAT 1
|
#define FF_FS_EXFAT 0
|
||||||
/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
|
/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
|
||||||
/ To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)
|
/ To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)
|
||||||
/ Note that enabling exFAT discards ANSI C (C89) compatibility. */
|
/ Note that enabling exFAT discards ANSI C (C89) compatibility. */
|
||||||
@@ -240,7 +237,7 @@
|
|||||||
#define FF_FS_NORTC 0
|
#define FF_FS_NORTC 0
|
||||||
#define FF_NORTC_MON 1
|
#define FF_NORTC_MON 1
|
||||||
#define FF_NORTC_MDAY 1
|
#define FF_NORTC_MDAY 1
|
||||||
#define FF_NORTC_YEAR 2020
|
#define FF_NORTC_YEAR 2019
|
||||||
/* The option FF_FS_NORTC switches timestamp functiton. If the system does not have
|
/* The option FF_FS_NORTC switches timestamp functiton. If the system does not have
|
||||||
/ any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable
|
/ any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable
|
||||||
/ the timestamp function. Every object modified by FatFs will have a fixed timestamp
|
/ the timestamp function. Every object modified by FatFs will have a fixed timestamp
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
void uart_init(void)
|
void uart_init(void)
|
||||||
{
|
{
|
||||||
SHELL_UART_RCC_REG |= SHELL_UART_RCC_MASK;
|
SHELL_UART_RCC_REG |= SHELL_UART_RCC_MASK;
|
||||||
SHELL_UART_PERIPH->BRR = SHELL_UART_DEFAULT_BRR_REG_VALUE;
|
SHELL_UART_PERIPH->BRR = SHELL_UART_BRR_REG_VALUE;
|
||||||
SHELL_UART_PERIPH->CR2 = 0;
|
SHELL_UART_PERIPH->CR2 = 0;
|
||||||
SHELL_UART_PERIPH->CR3 = 0;
|
SHELL_UART_PERIPH->CR3 = 0;
|
||||||
SHELL_UART_PERIPH->CR1 = USART_CR1_TE | USART_CR1_UE;
|
SHELL_UART_PERIPH->CR1 = USART_CR1_TE | USART_CR1_UE;
|
||||||
|
@@ -1,43 +0,0 @@
|
|||||||
LEXER := flex
|
|
||||||
YACC := bison
|
|
||||||
CC := gcc
|
|
||||||
|
|
||||||
YACC_FLAGS := -yd
|
|
||||||
LEXER_FLAGS :=
|
|
||||||
|
|
||||||
LANG_NAME := lang
|
|
||||||
|
|
||||||
|
|
||||||
ifneq ($(VERBOSE),true)
|
|
||||||
QUIET=@
|
|
||||||
else
|
|
||||||
QUIET=
|
|
||||||
endif
|
|
||||||
|
|
||||||
default: test
|
|
||||||
|
|
||||||
y.tab.c: $(LANG_NAME).yacc
|
|
||||||
$(QUIET)echo "[$(YACC)] $@"
|
|
||||||
$(QUIET)$(YACC) $(YACC_FLAGS) $<
|
|
||||||
|
|
||||||
lex.yy.c: $(LANG_NAME).lex
|
|
||||||
$(QUIET)echo "[$(LEXER)] $@"
|
|
||||||
$(QUIET)$(LEXER) $^
|
|
||||||
|
|
||||||
test: y.tab.c lex.yy.c
|
|
||||||
$(QUIET)echo "[CC] $@"
|
|
||||||
$(QUIET)$(CC) -o $@ $^
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: clean run
|
|
||||||
|
|
||||||
run: test
|
|
||||||
./test
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(QUIET)echo "Clean up..."
|
|
||||||
$(QUIET)rm -f *.c *.o y.tab.h test
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -1,45 +0,0 @@
|
|||||||
%{
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "y.tab.h"
|
|
||||||
%}
|
|
||||||
|
|
||||||
/*
|
|
||||||
static const struct pl_command_list_map cmd_list_map[_PL_NUM_CMDS] = {
|
|
||||||
{PL_PID_CONF, "pid_conf", 6u},
|
|
||||||
{PL_SET_TEMP, "temp_set", 1u},
|
|
||||||
{PL_WAIT_FOR_TEMP, "wait_temp", 1u},
|
|
||||||
{PL_WAIT_FOR_TIME, "wait_time", 1u},
|
|
||||||
{PL_SET_RAMP, "temp_ramp", 2u},
|
|
||||||
{PL_LOUDSPEAKER_SET, "beep", 1u},
|
|
||||||
{PL_OFF, "temp_off", 0u},
|
|
||||||
{PL_CLEAR_FLAGS, "clear_flags", 0u},
|
|
||||||
{PL_DIGIO_CONF, "digio_conf", 2u},
|
|
||||||
{PL_DIGIO_SET, "digio_set", 2u},
|
|
||||||
{PL_DIGIO_WAIT, "digio_wait", 2u},
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
%option yylineno
|
|
||||||
|
|
||||||
%%
|
|
||||||
|
|
||||||
#[^\n]* return COMMENT;
|
|
||||||
pid_conf return PL_PID_CONF;
|
|
||||||
temp_set return PL_SET_TEMP;
|
|
||||||
wait_temp return PL_WAIT_FOR_TEMP;
|
|
||||||
wait_time return PL_WAIT_FOR_TIME;
|
|
||||||
temp_ramp return PL_SET_RAMP;
|
|
||||||
beep return PL_LOUDSPEAKER_SET;
|
|
||||||
temp_off return PL_OFF;
|
|
||||||
clear_flags return PL_CLEAR_FLAGS;
|
|
||||||
digio_conf return PL_DIGIO_CONF;
|
|
||||||
digio_set return PL_DIGIO_SET;
|
|
||||||
digio_wait return PL_DIGIO_WAIT;
|
|
||||||
[+-]?[0-9]+ yylval.int_value=atoi(yytext); return INT_NUMBER;
|
|
||||||
[+-]?[0-9]+[.]?[0-9]* yylval.float_value=atof(yytext); return NUMBER;
|
|
||||||
[ \t]+ /* Ignore whitespaces */;
|
|
||||||
[\r]?\n return NEWLINE;
|
|
||||||
|
|
||||||
[^\t\n #]+ return LITERAL;
|
|
||||||
|
|
||||||
%%
|
|
@@ -1,137 +0,0 @@
|
|||||||
%{
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
extern int yylineno;
|
|
||||||
extern int yylex();
|
|
||||||
extern int yyparse();
|
|
||||||
|
|
||||||
void yyerror(const char *str)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Error: %s, line %d\n", str, yylineno);
|
|
||||||
}
|
|
||||||
|
|
||||||
int yywrap()
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
yyparse();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
%}
|
|
||||||
|
|
||||||
%locations
|
|
||||||
|
|
||||||
%token COMMENT PL_PID_CONF PL_SET_TEMP PL_WAIT_FOR_TEMP PL_WAIT_FOR_TIME PL_SET_RAMP PL_LOUDSPEAKER_SET PL_OFF PL_CLEAR_FLAGS PL_DIGIO_CONF PL_DIGIO_SET PL_DIGIO_WAIT NEWLINE LITERAL
|
|
||||||
%token <float_value> NUMBER
|
|
||||||
%token <int_value> INT_NUMBER
|
|
||||||
|
|
||||||
%type <float_value> any_num
|
|
||||||
|
|
||||||
%union
|
|
||||||
{
|
|
||||||
int int_value;
|
|
||||||
float float_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
%%
|
|
||||||
|
|
||||||
program: /* empty */
|
|
||||||
| program command
|
|
||||||
| program NEWLINE
|
|
||||||
| program cmt_line
|
|
||||||
;
|
|
||||||
|
|
||||||
command:
|
|
||||||
command_core NEWLINE
|
|
||||||
|
|
|
||||||
command_core cmt_line
|
|
||||||
;
|
|
||||||
|
|
||||||
command_core:
|
|
||||||
pid_conf | temp_set | wait_time | wait_temp | temp_ramp | beep | temp_off | clear_flags | digio_conf | digio_set | digio_wait;
|
|
||||||
|
|
||||||
pid_conf: PL_PID_CONF any_num any_num any_num any_num any_num any_num
|
|
||||||
{
|
|
||||||
printf("PID Config\n");
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
temp_set: PL_SET_TEMP any_num
|
|
||||||
{
|
|
||||||
printf("Target temp set: %f\n", $2);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
wait_time: PL_WAIT_FOR_TIME any_num
|
|
||||||
{
|
|
||||||
printf("Wait for %f seconds\n", $2);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
wait_temp: PL_WAIT_FOR_TEMP any_num
|
|
||||||
{
|
|
||||||
printf("Wait for temperature %f\n", $2);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
temp_ramp: PL_SET_RAMP any_num any_num
|
|
||||||
{
|
|
||||||
printf("Temperature ramp. Target %f, duration: %f\n", $2, $3);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
cmt_line: COMMENT NEWLINE
|
|
||||||
{
|
|
||||||
printf("Comment line detected\n");
|
|
||||||
};
|
|
||||||
|
|
||||||
beep: PL_LOUDSPEAKER_SET INT_NUMBER
|
|
||||||
{
|
|
||||||
printf("Beep: %d\n", $2);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
PL_LOUDSPEAKER_SET NUMBER
|
|
||||||
{
|
|
||||||
printf("Warning: Float value casted to int!\n");
|
|
||||||
printf("Beep %u\n", (unsigned int)$2);
|
|
||||||
};
|
|
||||||
|
|
||||||
temp_off: PL_OFF
|
|
||||||
{
|
|
||||||
printf("Turn off oven\n");
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
clear_flags: PL_CLEAR_FLAGS
|
|
||||||
{
|
|
||||||
printf("Clear flags\n");
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
digio_conf: PL_DIGIO_CONF INT_NUMBER INT_NUMBER
|
|
||||||
{
|
|
||||||
printf("Configure digio pin\n");
|
|
||||||
};
|
|
||||||
|
|
||||||
digio_set: PL_DIGIO_SET INT_NUMBER INT_NUMBER
|
|
||||||
{
|
|
||||||
printf("Configure digio pin\n");
|
|
||||||
};
|
|
||||||
|
|
||||||
digio_wait: PL_DIGIO_WAIT INT_NUMBER INT_NUMBER
|
|
||||||
{
|
|
||||||
printf("Configure digio pin\n");
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Matches any number format that can be interpreted as float */
|
|
||||||
any_num : NUMBER | INT_NUMBER
|
|
||||||
{
|
|
||||||
$$ = (float)$1;
|
|
||||||
};
|
|
||||||
%%
|
|
||||||
|
|
Reference in New Issue
Block a user