Compare commits
8 Commits
ba8072c21d
...
v0.3
Author | SHA1 | Date | |
---|---|---|---|
00b8d1f48e | |||
8ac1d52240 | |||
3e82cf69b4 | |||
62b256fd18 | |||
74111826a0 | |||
69d7724c8f | |||
48f69d0fb5 | |||
8fd924829e |
@@ -37,10 +37,11 @@
|
|||||||
* If the pointer is invalid, the function using this macro will return with
|
* If the pointer is invalid, the function using this macro will return with
|
||||||
* CONFIG_PARSER_PARAM_ERR
|
* CONFIG_PARSER_PARAM_ERR
|
||||||
*/
|
*/
|
||||||
#define config_parser_check_handle(handle) do { if (!(handle) || \
|
#define config_parser_check_handle(handle) do { \
|
||||||
((struct config_parser *)(handle))->magic != CONFIG_PARSER_MAGIC) \
|
if (!(handle) || \
|
||||||
return CONFIG_PARSER_PARAM_ERR; \
|
((struct config_parser *)(handle))->magic != CONFIG_PARSER_MAGIC) \
|
||||||
} while (0)
|
return CONFIG_PARSER_PARAM_ERR; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
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)
|
||||||
@@ -92,17 +93,17 @@ 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 */
|
||||||
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;
|
||||||
}
|
|
||||||
entry->type = CONFIG_PARSER_TYPE_UINT;
|
entry->type = CONFIG_PARSER_TYPE_UINT;
|
||||||
goto exit;
|
goto exit;
|
||||||
} else {
|
} else {
|
||||||
/* Try parsing as int */
|
/* Try parsing as int */
|
||||||
entry->value.int_val = strtod(value_start_token, &endptr);
|
entry->value.int_val = strtod(value_start_token, &endptr);
|
||||||
if (endptr == value_start_token) {
|
if (endptr == value_start_token)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
entry->type = CONFIG_PARSER_TYPE_INT;
|
entry->type = CONFIG_PARSER_TYPE_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,14 +111,16 @@ exit:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
struct config_parser *p;
|
struct config_parser *p;
|
||||||
config_parser_check_handle(handle);
|
|
||||||
p = CONFIG_PARSER(handle);
|
|
||||||
char *token;
|
char *token;
|
||||||
int token_round = 0;
|
int token_round = 0;
|
||||||
|
|
||||||
|
config_parser_check_handle(handle);
|
||||||
|
p = CONFIG_PARSER(handle);
|
||||||
|
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return CONFIG_PARSER_PARAM_ERR;
|
return CONFIG_PARSER_PARAM_ERR;
|
||||||
|
|
||||||
@@ -131,8 +134,7 @@ enum config_parser_ret config_parser_get_line(config_parser_handle_t handle, str
|
|||||||
if (token[0] == '#') {
|
if (token[0] == '#') {
|
||||||
if (token_round == 0)
|
if (token_round == 0)
|
||||||
return CONFIG_PARSER_LINE_COMMENT;
|
return CONFIG_PARSER_LINE_COMMENT;
|
||||||
else
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (token_round) {
|
switch (token_round) {
|
||||||
@@ -140,9 +142,8 @@ enum config_parser_ret config_parser_get_line(config_parser_handle_t handle, str
|
|||||||
entry->name = token;
|
entry->name = token;
|
||||||
break;
|
break;
|
||||||
case 1: /* = Symbol */
|
case 1: /* = Symbol */
|
||||||
if (strcmp(token, "=")) {
|
if (strcmp(token, "="))
|
||||||
return CONFIG_PARSER_LINE_MALFORM;
|
return CONFIG_PARSER_LINE_MALFORM;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 2: /* VALUE */
|
case 2: /* VALUE */
|
||||||
if (parse_value(entry, token))
|
if (parse_value(entry, token))
|
||||||
@@ -172,6 +173,7 @@ enum config_parser_ret config_parser_reset_to_start(config_parser_handle_t handl
|
|||||||
{
|
{
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
struct config_parser *p;
|
struct config_parser *p;
|
||||||
|
|
||||||
config_parser_check_handle(handle);
|
config_parser_check_handle(handle);
|
||||||
p = CONFIG_PARSER(handle);
|
p = CONFIG_PARSER(handle);
|
||||||
|
|
||||||
@@ -194,6 +196,7 @@ enum config_parser_ret config_parser_close_file(config_parser_handle_t handle)
|
|||||||
{
|
{
|
||||||
struct config_parser *p;
|
struct config_parser *p;
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
|
|
||||||
config_parser_check_handle(handle);
|
config_parser_check_handle(handle);
|
||||||
p = CONFIG_PARSER(handle);
|
p = CONFIG_PARSER(handle);
|
||||||
|
|
||||||
|
@@ -28,12 +28,12 @@
|
|||||||
* @brief Initialize the SPI for the eeprom.
|
* @brief Initialize the SPI for the eeprom.
|
||||||
* @return 0 if succesful
|
* @return 0 if succesful
|
||||||
*/
|
*/
|
||||||
int spi_eeprom_init();
|
int spi_eeprom_init(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Uninitialize the SPI EEPROM
|
* @brief Uninitialize the SPI EEPROM
|
||||||
*/
|
*/
|
||||||
void spi_eeprom_deinit();
|
void spi_eeprom_deinit(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read from SPI EEPROM
|
* @brief Read from SPI EEPROM
|
||||||
|
@@ -1,22 +1,22 @@
|
|||||||
/* Reflow Oven Controller
|
/* Reflow Oven Controller
|
||||||
*
|
*
|
||||||
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
||||||
*
|
*
|
||||||
* This file is part of the Reflow Oven Controller Project.
|
* This file is part of the Reflow Oven Controller Project.
|
||||||
*
|
*
|
||||||
* The reflow oven controller is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with the reflow oven controller project.
|
* along with the reflow oven controller project.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <reflow-controller/safety/stack-check.h>
|
#include <reflow-controller/safety/stack-check.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
extern char __ld_top_of_stack;
|
extern char __ld_top_of_stack;
|
||||||
extern char __ld_end_stack;
|
extern char __ld_end_stack;
|
||||||
|
|
||||||
int32_t stack_check_get_usage()
|
int32_t stack_check_get_usage(void)
|
||||||
{
|
{
|
||||||
uint32_t stack_top;
|
uint32_t stack_top;
|
||||||
uint32_t stack_ptr;
|
uint32_t stack_ptr;
|
||||||
@@ -37,7 +37,7 @@ int32_t stack_check_get_usage()
|
|||||||
return stack_top - stack_ptr;
|
return stack_top - stack_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t stack_check_get_free()
|
int32_t stack_check_get_free(void)
|
||||||
{
|
{
|
||||||
uint32_t upper_heap_boundary;
|
uint32_t upper_heap_boundary;
|
||||||
uint32_t stack_ptr;
|
uint32_t stack_ptr;
|
||||||
@@ -102,9 +102,6 @@ int stack_check_corruption_detect_area(void)
|
|||||||
&__ld_start_stack_corruption_detect_area;
|
&__ld_start_stack_corruption_detect_area;
|
||||||
crc_unit_reset();
|
crc_unit_reset();
|
||||||
crc_unit_input_array(&__ld_start_stack_corruption_detect_area, area_size_in_words);
|
crc_unit_input_array(&__ld_start_stack_corruption_detect_area, area_size_in_words);
|
||||||
if (crc_unit_get_crc() == 0UL) {
|
|
||||||
return 0;
|
return crc_unit_get_crc() == 0UL ? 0 : -1;
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,22 +1,22 @@
|
|||||||
/* Reflow Oven Controller
|
/* Reflow Oven Controller
|
||||||
*
|
*
|
||||||
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
||||||
*
|
*
|
||||||
* This file is part of the Reflow Oven Controller Project.
|
* This file is part of the Reflow Oven Controller Project.
|
||||||
*
|
*
|
||||||
* The reflow oven controller is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with the reflow oven controller project.
|
* along with the reflow oven controller project.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup watchdog
|
* @addtogroup watchdog
|
||||||
@@ -50,7 +50,8 @@ int watchdog_setup(uint8_t prescaler)
|
|||||||
RCC->CSR |= RCC_CSR_LSION;
|
RCC->CSR |= RCC_CSR_LSION;
|
||||||
__DSB();
|
__DSB();
|
||||||
/** - Wait for the oscillator to be ready */
|
/** - Wait for the oscillator to be ready */
|
||||||
while (!(RCC->CSR & RCC_CSR_LSIRDY));
|
while (!(RCC->CSR & RCC_CSR_LSIRDY))
|
||||||
|
;
|
||||||
|
|
||||||
if (prescaler == 4U)
|
if (prescaler == 4U)
|
||||||
prescaler_reg_val = 0UL;
|
prescaler_reg_val = 0UL;
|
||||||
@@ -68,23 +69,24 @@ int watchdog_setup(uint8_t prescaler)
|
|||||||
prescaler_reg_val = 6UL;
|
prescaler_reg_val = 6UL;
|
||||||
|
|
||||||
/** - (De)activate the watchdog during debug access according to @ref WATCHDOG_HALT_DEBUG */
|
/** - (De)activate the watchdog during debug access according to @ref WATCHDOG_HALT_DEBUG */
|
||||||
if (WATCHDOG_HALT_DEBUG) {
|
if (WATCHDOG_HALT_DEBUG)
|
||||||
DBGMCU->APB1FZ |= DBGMCU_APB1_FZ_DBG_IWDG_STOP;
|
DBGMCU->APB1FZ |= DBGMCU_APB1_FZ_DBG_IWDG_STOP;
|
||||||
} else {
|
else
|
||||||
DBGMCU->APB1FZ &= ~DBGMCU_APB1_FZ_DBG_IWDG_STOP;
|
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;
|
||||||
|
|
||||||
/** - Wait until prescaler can be written */
|
/** - Wait until prescaler can be written */
|
||||||
while (IWDG->SR & IWDG_SR_PVU);
|
while (IWDG->SR & IWDG_SR_PVU)
|
||||||
|
;
|
||||||
|
|
||||||
/** - Write prescaler value */
|
/** - Write prescaler value */
|
||||||
IWDG->PR = prescaler_reg_val;
|
IWDG->PR = prescaler_reg_val;
|
||||||
|
|
||||||
/* - Wait until reload value can be written */
|
/* - Wait until reload value can be written */
|
||||||
while (IWDG->SR & IWDG_SR_RVU);
|
while (IWDG->SR & IWDG_SR_RVU)
|
||||||
|
;
|
||||||
|
|
||||||
/** - Set reload value fixed to 0xFFF */
|
/** - Set reload value fixed to 0xFFF */
|
||||||
IWDG->RLR = 0xFFFU;
|
IWDG->RLR = 0xFFFU;
|
||||||
|
@@ -1,22 +1,22 @@
|
|||||||
/* Reflow Oven Controller
|
/* Reflow Oven Controller
|
||||||
*
|
*
|
||||||
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
||||||
*
|
*
|
||||||
* This file is part of the Reflow Oven Controller Project.
|
* This file is part of the Reflow Oven Controller Project.
|
||||||
*
|
*
|
||||||
* The reflow oven controller is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with the reflow oven controller project.
|
* along with the reflow oven controller project.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <reflow-controller/settings/settings-eeprom.h>
|
#include <reflow-controller/settings/settings-eeprom.h>
|
||||||
#include <reflow-controller/settings/spi-eeprom.h>
|
#include <reflow-controller/settings/spi-eeprom.h>
|
||||||
@@ -37,6 +37,7 @@ struct eeprom_calibration_settings {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define EEPROM_OVER_TEMP_CONFIG_BASE_ADDR (EEPROM_CALIBRATION_BASE_ADDR + sizeof(struct eeprom_calibration_settings))
|
#define EEPROM_OVER_TEMP_CONFIG_BASE_ADDR (EEPROM_CALIBRATION_BASE_ADDR + sizeof(struct eeprom_calibration_settings))
|
||||||
|
|
||||||
struct eeprom_over_temp_config {
|
struct eeprom_over_temp_config {
|
||||||
float over_temperature;
|
float over_temperature;
|
||||||
uint32_t over_temp_crc;
|
uint32_t over_temp_crc;
|
||||||
@@ -54,7 +55,7 @@ static bool check_eeprom_header(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void settings_eeprom_zero()
|
static void settings_eeprom_zero(void)
|
||||||
{
|
{
|
||||||
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.0f, false);
|
||||||
@@ -62,7 +63,7 @@ static void settings_eeprom_zero()
|
|||||||
|
|
||||||
bool settings_eeprom_detect_and_prepare(void)
|
bool settings_eeprom_detect_and_prepare(void)
|
||||||
{
|
{
|
||||||
bool eeprom_ready = false;;
|
bool eeprom_ready = false;
|
||||||
|
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
@@ -77,7 +78,10 @@ bool settings_eeprom_detect_and_prepare(void)
|
|||||||
if (check_eeprom_header() == false) {
|
if (check_eeprom_header() == false) {
|
||||||
/* Try to write a new header and check it again */
|
/* Try to write a new header and check it again */
|
||||||
spi_eeprom_write(0, expected_header, sizeof(expected_header));
|
spi_eeprom_write(0, expected_header, sizeof(expected_header));
|
||||||
while (spi_eeprom_write_in_progress());
|
|
||||||
|
while (spi_eeprom_write_in_progress())
|
||||||
|
;
|
||||||
|
|
||||||
if (check_eeprom_header() == false) {
|
if (check_eeprom_header() == false) {
|
||||||
goto ret_deinit_crc;
|
goto ret_deinit_crc;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -1,22 +1,22 @@
|
|||||||
/* Reflow Oven Controller
|
/* Reflow Oven Controller
|
||||||
*
|
*
|
||||||
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
||||||
*
|
*
|
||||||
* This file is part of the Reflow Oven Controller Project.
|
* This file is part of the Reflow Oven Controller Project.
|
||||||
*
|
*
|
||||||
* The reflow oven controller is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with the reflow oven controller project.
|
* along with the reflow oven controller project.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <reflow-controller/settings/settings-sd-card.h>
|
#include <reflow-controller/settings/settings-sd-card.h>
|
||||||
#include <stm-periph/unique-id.h>
|
#include <stm-periph/unique-id.h>
|
||||||
@@ -72,18 +72,12 @@ static int create_controller_folder(void)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
filesystem_result = f_mkdir(foldername);
|
filesystem_result = f_mkdir(foldername);
|
||||||
if (filesystem_result == FR_OK) {
|
ret = filesystem_result == FR_OK ? 1 : -1;
|
||||||
ret = 1;
|
|
||||||
} else {
|
|
||||||
ret = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int sd_card_settings_save_calibration(float sens_deviation, float offset, bool active)
|
int sd_card_settings_save_calibration(float sens_deviation, float offset, bool active)
|
||||||
{
|
{
|
||||||
char path[200];
|
char path[200];
|
||||||
|
@@ -1,22 +1,22 @@
|
|||||||
/* Reflow Oven Controller
|
/* Reflow Oven Controller
|
||||||
*
|
*
|
||||||
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
||||||
*
|
*
|
||||||
* This file is part of the Reflow Oven Controller Project.
|
* This file is part of the Reflow Oven Controller Project.
|
||||||
*
|
*
|
||||||
* The reflow oven controller is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with the reflow oven controller project.
|
* along with the reflow oven controller project.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <reflow-controller/settings/settings.h>
|
#include <reflow-controller/settings/settings.h>
|
||||||
#include <reflow-controller/settings/settings-sd-card.h>
|
#include <reflow-controller/settings/settings-sd-card.h>
|
||||||
@@ -39,7 +39,7 @@ int settings_load_calibration(float *sens_dev, float *offset)
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (settings_use_eeprom) {
|
if (settings_use_eeprom) {
|
||||||
res =settings_eeprom_load_calibration(sens_dev, offset, &active);
|
res = settings_eeprom_load_calibration(sens_dev, offset, &active);
|
||||||
if (!res && !active)
|
if (!res && !active)
|
||||||
res = -1;
|
res = -1;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -1,22 +1,22 @@
|
|||||||
/* Reflow Oven Controller
|
/* Reflow Oven Controller
|
||||||
*
|
*
|
||||||
* Copyright (C) 2021 Mario Hüttel <mario.huettel@gmx.net>
|
* Copyright (C) 2021 Mario Hüttel <mario.huettel@gmx.net>
|
||||||
*
|
*
|
||||||
* This file is part of the Reflow Oven Controller Project.
|
* This file is part of the Reflow Oven Controller Project.
|
||||||
*
|
*
|
||||||
* The reflow oven controller is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with the reflow oven controller project.
|
* along with the reflow oven controller project.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <reflow-controller/settings/spi-eeprom.h>
|
#include <reflow-controller/settings/spi-eeprom.h>
|
||||||
#include <stm-periph/spi.h>
|
#include <stm-periph/spi.h>
|
||||||
@@ -52,7 +52,7 @@ static void eeprom_cs_deactivate(void)
|
|||||||
SPI_EEPROM_SPI_PORT->ODR |= (1<<SPI_EEPROM_CS_PIN);
|
SPI_EEPROM_SPI_PORT->ODR |= (1<<SPI_EEPROM_CS_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_eeprom_init()
|
int spi_eeprom_init(void)
|
||||||
{
|
{
|
||||||
static struct stm_spi_dev spi_dev;
|
static struct stm_spi_dev spi_dev;
|
||||||
struct stm_spi_settings settings;
|
struct stm_spi_settings settings;
|
||||||
@@ -61,7 +61,8 @@ int spi_eeprom_init()
|
|||||||
|
|
||||||
SPI_EEPROM_SPI_PORT->MODER &= MODER_DELETE(SPI_EEPROM_CS_PIN) & MODER_DELETE(SPI_EEPROM_MISO_PIN) &
|
SPI_EEPROM_SPI_PORT->MODER &= MODER_DELETE(SPI_EEPROM_CS_PIN) & MODER_DELETE(SPI_EEPROM_MISO_PIN) &
|
||||||
MODER_DELETE(SPI_EEPROM_MOSI_PIN) & MODER_DELETE(SPI_EEPROM_SCK_PIN);
|
MODER_DELETE(SPI_EEPROM_MOSI_PIN) & MODER_DELETE(SPI_EEPROM_SCK_PIN);
|
||||||
SPI_EEPROM_SPI_PORT->MODER |= ALTFUNC(SPI_EEPROM_MISO_PIN) | ALTFUNC(SPI_EEPROM_SCK_PIN) | ALTFUNC(SPI_EEPROM_MOSI_PIN);
|
SPI_EEPROM_SPI_PORT->MODER |= ALTFUNC(SPI_EEPROM_MISO_PIN) | ALTFUNC(SPI_EEPROM_SCK_PIN) |
|
||||||
|
ALTFUNC(SPI_EEPROM_MOSI_PIN);
|
||||||
SPI_EEPROM_SPI_PORT->MODER |= OUTPUT(SPI_EEPROM_CS_PIN);
|
SPI_EEPROM_SPI_PORT->MODER |= OUTPUT(SPI_EEPROM_CS_PIN);
|
||||||
|
|
||||||
SETAF(SPI_EEPROM_SPI_PORT, SPI_EEPROM_MISO_PIN, SPI_EEPROM_SPI_ALTFUNC_NO);
|
SETAF(SPI_EEPROM_SPI_PORT, SPI_EEPROM_MISO_PIN, SPI_EEPROM_SPI_ALTFUNC_NO);
|
||||||
@@ -85,7 +86,7 @@ int spi_eeprom_init()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void spi_eeprom_deinit()
|
void spi_eeprom_deinit(void)
|
||||||
{
|
{
|
||||||
spi_deinit(eeprom_spi_handle);
|
spi_deinit(eeprom_spi_handle);
|
||||||
|
|
||||||
@@ -166,7 +167,8 @@ static void spi_eeprom_do_write_page(uint32_t addr, const uint8_t *data, uint8_t
|
|||||||
uint8_t cmd[2];
|
uint8_t cmd[2];
|
||||||
|
|
||||||
/* Wait for the previous write to finish */
|
/* Wait for the previous write to finish */
|
||||||
while (spi_eeprom_write_in_progress());
|
while (spi_eeprom_write_in_progress())
|
||||||
|
;
|
||||||
/* Set the write enable latch */
|
/* Set the write enable latch */
|
||||||
spi_eeprom_set_write_enable_latch(true);
|
spi_eeprom_set_write_enable_latch(true);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user