From 0a36ff309c7bb8cb8dd7d4bf03d5faac39892af9 Mon Sep 17 00:00:00 2001 From: jsphuebner Date: Wed, 2 Jun 2021 17:48:14 +0200 Subject: [PATCH] Now pindef address also changes with flash size --- stm32_loader.c | 4 +++- stm32_loader.h | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/stm32_loader.c b/stm32_loader.c index e53f156..d1258df 100644 --- a/stm32_loader.c +++ b/stm32_loader.c @@ -112,7 +112,9 @@ static void dma_setup(void *data, uint32_t len) static void initialize_pins() { - const struct pincommands* pincommands = (struct pincommands*)PINDEF_ADDRESS; + uint32_t flashSize = desig_get_flash_size(); + uint32_t pindefAddr = FLASH_BASE + flashSize * 1024 - PINDEF_BLKNUM * PINDEF_BLKSIZE; + const struct pincommands* pincommands = (struct pincommands*)pindefAddr; uint32_t crc = crc_calculate_block(((uint32_t*)pincommands), PINDEF_NUMWORDS); diff --git a/stm32_loader.h b/stm32_loader.h index 4e75121..b73219a 100644 --- a/stm32_loader.h +++ b/stm32_loader.h @@ -1,6 +1,3 @@ -#ifndef STM32_LOADER_H_INCLUDED -#define STM32_LOADER_H_INCLUDED - /* * This file is part of the tumanako_vc project. * @@ -19,9 +16,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +#ifndef STM32_LOADER_H_INCLUDED +#define STM32_LOADER_H_INCLUDED + #include -#define PINDEF_ADDRESS 0x0801F400 +#define PINDEF_BLKNUM 3 //3rd to last flash page +#define PINDEF_BLKSIZE 1024 #define NUM_PIN_COMMANDS 10 #define PIN_IN 0 #define PIN_OUT 1