Fix #10: Moved static and global variablöes that are 0 initialized to CCMRAM in order to make room and increase performance.

This commit is contained in:
Mario Hüttel 2020-08-18 19:57:13 +02:00
parent 64ef7b4a3c
commit 60e990632b
9 changed files with 25 additions and 21 deletions

View File

@ -28,25 +28,26 @@
#include <cmsis/core_cm4.h> #include <cmsis/core_cm4.h>
#include <stm-periph/stm32-gpio-macros.h> #include <stm-periph/stm32-gpio-macros.h>
#include <stdlib.h> #include <stdlib.h>
#include <helper-macros/helper-macros.h>
#include <stm-periph/clock-enable-manager.h> #include <stm-periph/clock-enable-manager.h>
#include <reflow-controller/safety/safety-controller.h> #include <reflow-controller/safety/safety-controller.h>
static float pt1000_offset; static float IN_SECTION(.ccmram) pt1000_offset;
static float pt1000_sens_dev; static float IN_SECTION(.ccmram) pt1000_sens_dev;
static bool calibration_active; static bool IN_SECTION(.ccmram) calibration_active;
static float filter_alpha; static float IN_SECTION(.ccmram) filter_alpha;
/** /**
* @brief Filtered PT1000 resistance value. * @brief Filtered PT1000 resistance value.
* @note This value is not yet calibrated. Use @ref adc_pt1000_get_current_resistance to get this value with calibration. * @note This value is not yet calibrated. Use @ref adc_pt1000_get_current_resistance to get this value with calibration.
*/ */
static volatile float pt1000_res_raw_lf; static volatile float IN_SECTION(.ccmram) pt1000_res_raw_lf;
static volatile int * volatile streaming_flag_ptr = NULL; static volatile int * volatile streaming_flag_ptr = NULL;
static uint32_t filter_startup_cnt; static uint32_t IN_SECTION(.ccmram) filter_startup_cnt;
static volatile float adc_pt1000_raw_reading_hf; static volatile float IN_SECTION(.ccmram) adc_pt1000_raw_reading_hf;
static volatile uint16_t dma_sample_buffer[ADC_PT1000_DMA_AVG_SAMPLES]; static volatile uint16_t dma_sample_buffer[ADC_PT1000_DMA_AVG_SAMPLES];
static volatile uint32_t adc_watchdog_counter = 0UL; static volatile uint32_t IN_SECTION(.ccmram) adc_watchdog_counter = 0UL;
volatile float * volatile stream_buffer = NULL; volatile float * volatile stream_buffer = NULL;
volatile uint32_t stream_count; volatile uint32_t stream_count;

View File

@ -23,11 +23,12 @@
#include <stm-periph/stm32-gpio-macros.h> #include <stm-periph/stm32-gpio-macros.h>
#include <stm-periph/clock-enable-manager.h> #include <stm-periph/clock-enable-manager.h>
#include <stdint.h> #include <stdint.h>
#include <helper-macros/helper-macros.h>
#include <cmsis/core_cm4.h> #include <cmsis/core_cm4.h>
#include <reflow-controller/systick.h> #include <reflow-controller/systick.h>
static volatile uint64_t to_active_timestamp; static volatile uint64_t IN_SECTION(.ccmram) to_active_timestamp;
static volatile enum button_state int_state; static volatile enum button_state IN_SECTION(.ccmram) int_state;
void button_init() void button_init()
{ {

View File

@ -38,4 +38,6 @@
#define is_power_of_two(num) ((num) && !((num) & ((num) - 1))) #define is_power_of_two(num) ((num) && !((num) & ((num) - 1)))
#define IN_SECTION(sec) __attribute__((section(#sec)))
#endif /* __HELPER_MACROS_H__ */ #endif /* __HELPER_MACROS_H__ */

View File

@ -115,7 +115,7 @@ static inline void setup_shell_uart(struct stm_uart *uart)
static bool mount_sd_card_if_avail(bool mounted) static bool mount_sd_card_if_avail(bool mounted)
{ {
FRESULT res; FRESULT res;
static uint8_t inserted_counter = 0; static uint8_t IN_SECTION(.ccmram) inserted_counter = 0;
if (sdio_check_inserted() && mounted) { if (sdio_check_inserted() && mounted) {
memset(fs_ptr, 0, sizeof(FATFS)); memset(fs_ptr, 0, sizeof(FATFS));

View File

@ -24,12 +24,13 @@
#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/temp-converter.h> #include <reflow-controller/temp-converter.h>
#include <helper-macros/helper-macros.h>
#include <reflow-controller/safety/safety-controller.h> #include <reflow-controller/safety/safety-controller.h>
static struct pid_controller oven_pid; static struct pid_controller IN_SECTION(.ccmram) oven_pid;
static bool oven_pid_running = false; static bool oven_pid_running = false;
static bool oven_pid_aborted = false; static bool oven_pid_aborted = false;
static uint8_t oven_driver_power_level = 0U; static uint8_t IN_SECTION(.ccmram) oven_driver_power_level = 0U;
void oven_driver_init() void oven_driver_init()
{ {

View File

@ -34,8 +34,8 @@
#include <string.h> #include <string.h>
#include <inttypes.h> #include <inttypes.h>
static char __attribute__((section(".ccmram"))) display_buffer[4][21] = {0}; static char IN_SECTION(.ccmram) display_buffer[4][21] = {0};
static struct lcd_menu reflow_menu; static struct lcd_menu IN_SECTION(.ccmram) reflow_menu;
static struct lcd_menu * const reflow_menu_ptr = &reflow_menu; static struct lcd_menu * const reflow_menu_ptr = &reflow_menu;
static void update_display_buffer(uint8_t row, const char *data) static void update_display_buffer(uint8_t row, const char *data)

View File

@ -55,8 +55,6 @@ float safety_adc_convert_channel(enum safety_adc_meas_channel channel, uint16_t
{ {
float converted_val; float converted_val;
switch (channel) { switch (channel) {
case SAFETY_ADC_MEAS_TEMP: case SAFETY_ADC_MEAS_TEMP:
converted_val = (((float)analog_value / 4095.0f * 2500.0f - SAFETY_ADC_TEMP_NOM_MV) / converted_val = (((float)analog_value / 4095.0f * 2500.0f - SAFETY_ADC_TEMP_NOM_MV) /

View File

@ -45,7 +45,7 @@
extern struct stm_uart shell_uart; extern struct stm_uart shell_uart;
static shellmatta_instance_t shell; static shellmatta_instance_t shell;
static char shell_buffer[512]; static char shell_buffer[512];
static char history_buffer[600]; static char IN_SECTION(.ccmram) history_buffer[600];
static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle, static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
const char *arguments, const char *arguments,

View File

@ -23,12 +23,13 @@
*/ */
#include <reflow-controller/systick.h> #include <reflow-controller/systick.h>
#include <helper-macros/helper-macros.h>
#include <stm32/stm32f4xx.h> #include <stm32/stm32f4xx.h>
#include <cmsis/core_cm4.h> #include <cmsis/core_cm4.h>
volatile uint32_t wait_tick_ms = 0UL; volatile uint32_t IN_SECTION(.ccmram) wait_tick_ms = 0UL;
volatile uint64_t global_tick_ms = 0ULL; volatile uint64_t IN_SECTION(.ccmram) global_tick_ms = 0ULL;
volatile uint32_t lcd_tick_100us = 0UL; volatile uint32_t IN_SECTION(.ccmram) lcd_tick_100us = 0UL;
void systick_setup(void) void systick_setup(void)
{ {