Compare commits

..

4 Commits

9 changed files with 130 additions and 27 deletions

View File

@ -42,13 +42,13 @@ CFILES += stm-periph/unique-id.c
CFILES += calibration.c
CFILES += temp-converter.c
CFILES += rotary-encoder.c button.c
CFILES += ui/lcd.c ui/menu.c reflow-menu.c
CFILES += ui/lcd.c ui/menu.c ui/gui.c
CFILES += fatfs/diskio.c fatfs/ff.c fatfs/ffsystem.c fatfs/ffunicode.c fatfs/shimatta_sdio_driver/shimatta_sdio.c
CFILES += pid-controller.c oven-driver.c
CFILES += settings/settings.c settings/settings-sd-card.c
CFILES += stm-periph/crc-unit.c
CFILES += safety/safety-adc.c safety/safety-controller.c safety/watchdog.c safety/fault.c safety/safety-memory.c safety/stack-check.c
CFILES += hw-version-detect.c
CFILES += config-parser/config-parser.c
INCLUDEPATH += -Iconfig-parser/include

View File

@ -188,4 +188,15 @@ enum config_parser_ret config_parser_close_file(config_parser_handle_t handle)
return (res == FR_OK ? CONFIG_PARSER_OK : CONFIG_PARSER_IOERR);
}
bool config_parser_ret_is_abort_condition(enum config_parser_ret return_val)
{
if (return_val == CONFIG_PARSER_END_REACHED ||
return_val == CONFIG_PARSER_GENERIC_ERR ||
return_val == CONFIG_PARSER_IOERR ||
return_val == CONFIG_PARSER_PARAM_ERR)
return true;
return false;
}
/** @} */

View File

@ -90,6 +90,8 @@ enum config_parser_ret config_parser_write_entry(config_parser_handle_t handle,
enum config_parser_ret config_parser_close_file(config_parser_handle_t handle);
bool config_parser_ret_is_abort_condition(enum config_parser_ret return_val);
#endif /* _CONFIG_PARSER_H_ */
/** @} */

View File

@ -0,0 +1,48 @@
#include <reflow-controller/hw-version-detect.h>
#include <stm-periph/clock-enable-manager.h>
#include <stm32/stm32f4xx.h>
#define HW_REV_DETECT_GPIO GPIOE
#define HW_REV_DETECT_RCC_FIELD RCC_AHB1ENR_GPIOEEN
#define HW_REV_DETECT_PIN_LOW (8U)
#define HW_REV_DETECT_PIN_HIGH (15U)
enum hw_revision get_pcb_hardware_version(void)
{
uint8_t current_pin;
uint16_t port_bitmask = 0U;
static enum hw_revision revision = HW_REV_NOT_DETECTED;
if (revision != HW_REV_NOT_DETECTED)
return revision;
rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(HW_REV_DETECT_RCC_FIELD));
/* Setup the pins as input with pull up */
for (current_pin = HW_REV_DETECT_PIN_LOW; current_pin <= HW_REV_DETECT_PIN_HIGH; current_pin++) {
HW_REV_DETECT_GPIO->MODER &= MODER_DELETE(current_pin);
HW_REV_DETECT_GPIO->PUPDR &= PUPDR_DELETE(current_pin);
HW_REV_DETECT_GPIO->PUPDR |= PULLUP(current_pin);
}
/* Loop again and read in the pin mask */
for (current_pin = HW_REV_DETECT_PIN_LOW; current_pin <= HW_REV_DETECT_PIN_HIGH; current_pin++) {
port_bitmask <<= 1;
port_bitmask |= (HW_REV_DETECT_GPIO->IDR & (1 << current_pin)) ? 0x0 : 0x1;
}
switch (port_bitmask) {
case 0U:
revision = HW_REV_V1_2;
break;
case 1U:
revision = HW_REV_V1_3;
break;
default:
revision = HW_REV_ERROR;
}
rcc_manager_disable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(HW_REV_DETECT_RCC_FIELD));
return revision;
}

View File

@ -0,0 +1,31 @@
#ifndef _HW_VERSION_DETECT_H_
#define _HW_VERSION_DETECT_H_
#include <stdint.h>
enum hw_revision {
HW_REV_NOT_DETECTED = 0,
HW_REV_ERROR = 1,
HW_REV_V1_2 = 120,
HW_REV_V1_3 = 130,
};
/**
* @brief This function returns the hardware version of the PCB.
*
* This is used to
* determine the feature set of the hardware. So this firmware can be used on all hardwares.
*
* The first hardware revision supported, is: v1.2
*
* 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.3 the return value is 130 (HW_REV_V1_3).
*
* Other return values are not defined yet.
*
* @return Harware revision
*/
enum hw_revision get_pcb_hardware_version(void);
#endif /* _HW_VERSION_DETECT_H_ */

View File

@ -18,15 +18,15 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __REFLOW_MENU_H__
#define __REFLOW_MENU_H__
#ifndef _GUI_H_
#define _GUI_H_
/**
* @brief Handle the reflow controller's LCD Menu
* @return 0 if no delay is requested, 1 if delay is requested
*/
int reflow_menu_handle(void);
int gui_handle(void);
void reflow_menu_init(void);
void gui_init(void);
#endif /* __REFLOW_MENU_H__ */
#endif /* _GUI_H_ */

View File

@ -149,10 +149,7 @@ int sd_card_settings_try_load_calibration(float *sens_deviation, float *offset)
}
}
} while (res != CONFIG_PARSER_END_REACHED &&
res != CONFIG_PARSER_GENERIC_ERR &&
res != CONFIG_PARSER_IOERR &&
res != CONFIG_PARSER_PARAM_ERR);
} while (!config_parser_ret_is_abort_condition(res));
config_parser_close_file(p);
@ -202,10 +199,7 @@ enum settings_load_result sd_card_settings_load_pid_oven_parameters(struct oven_
}
}
} while (parse_result != CONFIG_PARSER_END_REACHED &&
parse_result != CONFIG_PARSER_GENERIC_ERR &&
parse_result != CONFIG_PARSER_IOERR &&
parse_result != CONFIG_PARSER_PARAM_ERR);
} while (!config_parser_ret_is_abort_condition(parse_result));
if (kp_loaded && kd_loaded && ki_loaded && t_sample && int_max_loaded)

View File

@ -40,6 +40,7 @@
#include <reflow-controller/button.h>
#include <reflow-controller/safety/fault.h>
#include <reflow-controller/safety/safety-memory.h>
#include <reflow-controller/hw-version-detect.h>
#ifndef GIT_VER
#define GIT_VER "VERSION NOT SET"
@ -81,12 +82,28 @@ static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
uint32_t low_id;
uint32_t mid_id;
uint32_t high_id;
const char *hw_rev_str;
enum hw_revision pcb_rev;
unique_id_get(&high_id, &mid_id, &low_id);
shellmatta_printf(handle, "Reflow Oven Controller Firmware " xstr(GIT_VER) "\r\n"
"Compiled: " __DATE__ " at " __TIME__ "\r\n");
shellmatta_printf(handle, "Serial: %08X-%08X-%08X", high_id, mid_id, low_id);
shellmatta_printf(handle, "Serial: %08X-%08X-%08X\r\n", high_id, mid_id, low_id);
pcb_rev = get_pcb_hardware_version();
switch (pcb_rev) {
case HW_REV_V1_2:
hw_rev_str = "Hardware: v1.2";
break;
case HW_REV_V1_3:
hw_rev_str = "Hardware: v1.3";
break;
default:
hw_rev_str = "Hardware: Unknown Revision. You might have to update the firmware!";
break;
}
shellmatta_printf(handle, "%s", hw_rev_str);
return SHELLMATTA_OK;
}

View File

@ -18,7 +18,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <reflow-controller/reflow-menu.h>
#include <reflow-controller/ui/gui.h>
#include <reflow-controller/ui/menu.h>
#include <reflow-controller/ui/lcd.h>
#include <reflow-controller/rotary-encoder.h>
@ -54,7 +54,7 @@ static void update_display_buffer(uint8_t row, const char *data)
display_buffer[row][i] = 0;
}
static void reflow_menu_monitor(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent)
static void gui_menu_monitor(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent)
{
static void *my_parent;
static uint64_t my_timestamp = 0;
@ -104,7 +104,7 @@ static void reflow_menu_monitor(struct lcd_menu *menu, enum menu_entry_func_entr
}
}
static void reflow_menu_about(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent)
static void gui_menu_about(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent)
{
static void *my_parent;
static int page = 0;
@ -217,7 +217,7 @@ static void reflow_menu_about(struct lcd_menu *menu, enum menu_entry_func_entry
}
}
static void reflow_menu_err_flags(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent)
static void gui_menu_err_flags(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent)
{
static void *my_parent = NULL;
static uint8_t offset;
@ -297,7 +297,7 @@ static void reflow_menu_err_flags(struct lcd_menu *menu, enum menu_entry_func_en
timestamp = systick_get_global_tick();
}
static void reflow_menu_root_entry(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent)
static void gui_menu_root_entry(struct lcd_menu *menu, enum menu_entry_func_entry entry_type, void *parent)
{
(void)parent;
static struct menu_list list;
@ -309,9 +309,9 @@ static void reflow_menu_root_entry(struct lcd_menu *menu, enum menu_entry_func_e
NULL
};
static const menu_func_t root_entry_funcs[] = {
reflow_menu_about,
reflow_menu_monitor,
reflow_menu_err_flags,
gui_menu_about,
gui_menu_monitor,
gui_menu_err_flags,
};
enum button_state push_button;
int16_t rot_delta;
@ -352,7 +352,7 @@ static void reflow_menu_root_entry(struct lcd_menu *menu, enum menu_entry_func_e
menu_list_display(&list, 1, 3);
}
int reflow_menu_handle()
int gui_handle()
{
int32_t rot_delta;
enum button_state button;
@ -374,11 +374,11 @@ int reflow_menu_handle()
return 1;
}
void reflow_menu_init()
void gui_init()
{
rotary_encoder_setup();
button_init();
lcd_init();
menu_init(reflow_menu_ptr, reflow_menu_root_entry, update_display_buffer);
menu_init(reflow_menu_ptr, gui_menu_root_entry, update_display_buffer);
}