Skip to content

Commit

Permalink
Now pindef address also changes with flash size
Browse files Browse the repository at this point in the history
  • Loading branch information
jsphuebner committed Jun 2, 2021
1 parent 06d7477 commit 0a36ff3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion stm32_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
9 changes: 5 additions & 4 deletions stm32_loader.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#ifndef STM32_LOADER_H_INCLUDED
#define STM32_LOADER_H_INCLUDED

/*
* This file is part of the tumanako_vc project.
*
Expand All @@ -19,9 +16,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef STM32_LOADER_H_INCLUDED
#define STM32_LOADER_H_INCLUDED

#include <stdint.h>

#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
Expand Down

0 comments on commit 0a36ff3

Please sign in to comment.