STM32 Bootloader
Customizable Bootloader for STM32 microcontrollers

Macros

#define LED_GREEN1_GPIO_PORT   GPIOB
 
#define LED_GREEN1_GPIO_PIN   GPIO_PIN_13
 
#define LED_GREEN1_GPIO_ACTIVE_STATE   GPIO_PIN_RESET
 
#define LED_GREEN1_GPIO_INACTIVE_STATE   GPIO_PIN_SET
 
#define LED_GREEN2_GPIO_PORT   GPIOA
 
#define LED_GREEN2_GPIO_PIN   GPIO_PIN_5
 
#define LED_GREEN2_GPIO_ACTIVE_STATE   GPIO_PIN_SET
 
#define LED_GREEN2_GPIO_INACTIVE_STATE   GPIO_PIN_RESET
 
#define BUTTON_GPIO_PORT   GPIOC
 
#define BUTTON_GPIO_PIN   GPIO_PIN_13
 
#define BUTTON_GPIO_PRESSED_STATE   GPIO_PIN_SET
 
#define SDMMC_INIT_MAX_TRIES   5U
 
#define SDMMC_IRQ_PRIORITY   1U
 
#define SDMMC_DMA_IRQ_PRIORITY   2U
 
#define SDMMC_TRANSFER_TIMEOUT   500U
 
#define SDMMC_GPIO_D0_PORT   GPIOC
 
#define SDMMC_GPIO_D0_PIN   GPIO_PIN_8
 
#define SDMMC_GPIO_D1_PORT   GPIOC
 
#define SDMMC_GPIO_D1_PIN   GPIO_PIN_9
 
#define SDMMC_GPIO_D2_PORT   GPIOC
 
#define SDMMC_GPIO_D2_PIN   GPIO_PIN_10
 
#define SDMMC_GPIO_D3_PORT   GPIOC
 
#define SDMMC_GPIO_D3_PIN   GPIO_PIN_11
 
#define SDMMC_GPIO_CLK_PORT   GPIOC
 
#define SDMMC_GPIO_CLK_PIN   GPIO_PIN_12
 
#define SDMMC_GPIO_CMD_PORT   GPIOD
 
#define SDMMC_GPIO_CMD_PIN   GPIO_PIN_2
 
#define SDMMC_GPIO_AF   GPIO_AF12_SDMMC1
 
#define SYSTICK_IRQ_PRIORITY   0U
 
#define VCP_UART_BUFFER_SIZE   80U
 
#define VCP_UART_TX_TIMEOUT   100U
 
#define VCP_UART_INSTANCE   USART2
 
#define VCP_UART_BAUDRATE   115200U
 
#define VCP_UART_GPIO_TX_PORT   GPIOD
 
#define VCP_UART_GPIO_TX_PIN   GPIO_PIN_6
 
#define VCP_UART_GPIO_RX_PORT   GPIOA
 
#define VCP_UART_GPIO_RX_PIN   GPIO_PIN_2
 
#define VCP_UART_GPIO_AF   GPIO_AF7_USART2
 

Functions

void BoardInit (void)
 Initialize the board hardware and peripherals. More...
 
void BoardDeInit (void)
 De-initialize the board hardware and peripherals. More...
 
void SetVectorTableLocation (const uint32_t address)
 Set the vector table location to the specified address. More...
 
static void PinoutInit (void)
 Initialize the board GPIO pinout including button, LEDs, UART, and SDMMC pins.
 
static void PinoutDeInit (void)
 De-initialize all board GPIO pins and disable the GPIO port clocks.
 
static void SystemClockConfig (void)
 Configure the system clock, PLL, and peripheral clocks.
 

Detailed Description

Macro Definition Documentation

◆ BUTTON_GPIO_PIN

#define BUTTON_GPIO_PIN   GPIO_PIN_13

GPIO pin of the joystick center button.

Definition at line 80 of file board.h.

◆ BUTTON_GPIO_PORT

#define BUTTON_GPIO_PORT   GPIOC

GPIO port of the joystick center button.

Definition at line 77 of file board.h.

◆ BUTTON_GPIO_PRESSED_STATE

#define BUTTON_GPIO_PRESSED_STATE   GPIO_PIN_SET

Pressed state of the joystick center button.

Definition at line 83 of file board.h.

◆ LED_GREEN1_GPIO_ACTIVE_STATE

#define LED_GREEN1_GPIO_ACTIVE_STATE   GPIO_PIN_RESET

Active pin state of the 1st green LED.

Definition at line 57 of file board.h.

◆ LED_GREEN1_GPIO_INACTIVE_STATE

#define LED_GREEN1_GPIO_INACTIVE_STATE   GPIO_PIN_SET

Inactive pin state of the 1st green LED.

Definition at line 60 of file board.h.

◆ LED_GREEN1_GPIO_PIN

#define LED_GREEN1_GPIO_PIN   GPIO_PIN_13

GPIO pin of the 1st green LED.

Definition at line 54 of file board.h.

◆ LED_GREEN1_GPIO_PORT

#define LED_GREEN1_GPIO_PORT   GPIOB

GPIO port of the 1st green LED.

Definition at line 51 of file board.h.

◆ LED_GREEN2_GPIO_ACTIVE_STATE

#define LED_GREEN2_GPIO_ACTIVE_STATE   GPIO_PIN_SET

Active pin state of the 2nd green LED.

Definition at line 70 of file board.h.

◆ LED_GREEN2_GPIO_INACTIVE_STATE

#define LED_GREEN2_GPIO_INACTIVE_STATE   GPIO_PIN_RESET

Inactive pin state of the 2nd green LED.

Definition at line 73 of file board.h.

◆ LED_GREEN2_GPIO_PIN

#define LED_GREEN2_GPIO_PIN   GPIO_PIN_5

GPIO pin of the 2nd green LED.

Definition at line 67 of file board.h.

◆ LED_GREEN2_GPIO_PORT

#define LED_GREEN2_GPIO_PORT   GPIOA

GPIO port of the 2nd green LED.

Definition at line 64 of file board.h.

◆ SDMMC_DMA_IRQ_PRIORITY

#define SDMMC_DMA_IRQ_PRIORITY   2U

SDMMC DMA interrupt priority.

Definition at line 90 of file board.h.

◆ SDMMC_GPIO_AF

#define SDMMC_GPIO_AF   GPIO_AF12_SDMMC1

GPIO alternate function for the SDMMC peripheral.

Definition at line 144 of file board.h.

◆ SDMMC_GPIO_CLK_PIN

#define SDMMC_GPIO_CLK_PIN   GPIO_PIN_12

GPIO pin of the SDMMC clock line.

Definition at line 132 of file board.h.

◆ SDMMC_GPIO_CLK_PORT

#define SDMMC_GPIO_CLK_PORT   GPIOC

GPIO port of the SDMMC clock line.

Definition at line 128 of file board.h.

◆ SDMMC_GPIO_CMD_PIN

#define SDMMC_GPIO_CMD_PIN   GPIO_PIN_2

GPIO pin of the SDMMC command line.

Definition at line 140 of file board.h.

◆ SDMMC_GPIO_CMD_PORT

#define SDMMC_GPIO_CMD_PORT   GPIOD

GPIO port of the SDMMC command line.

Definition at line 136 of file board.h.

◆ SDMMC_GPIO_D0_PIN

#define SDMMC_GPIO_D0_PIN   GPIO_PIN_8

GPIO pin of the SDMMC data line 0.

Definition at line 100 of file board.h.

◆ SDMMC_GPIO_D0_PORT

#define SDMMC_GPIO_D0_PORT   GPIOC

GPIO port of the SDMMC data line 0.

Definition at line 96 of file board.h.

◆ SDMMC_GPIO_D1_PIN

#define SDMMC_GPIO_D1_PIN   GPIO_PIN_9

GPIO pin of the SDMMC data line 1.

Definition at line 108 of file board.h.

◆ SDMMC_GPIO_D1_PORT

#define SDMMC_GPIO_D1_PORT   GPIOC

GPIO port of the SDMMC data line 1.

Definition at line 104 of file board.h.

◆ SDMMC_GPIO_D2_PIN

#define SDMMC_GPIO_D2_PIN   GPIO_PIN_10

GPIO pin of the SDMMC data line 2.

Definition at line 116 of file board.h.

◆ SDMMC_GPIO_D2_PORT

#define SDMMC_GPIO_D2_PORT   GPIOC

GPIO port of the SDMMC data line 2.

Definition at line 112 of file board.h.

◆ SDMMC_GPIO_D3_PIN

#define SDMMC_GPIO_D3_PIN   GPIO_PIN_11

GPIO pin of the SDMMC data line 3.

Definition at line 124 of file board.h.

◆ SDMMC_GPIO_D3_PORT

#define SDMMC_GPIO_D3_PORT   GPIOC

GPIO port of the SDMMC data line 3.

Definition at line 120 of file board.h.

◆ SDMMC_INIT_MAX_TRIES

#define SDMMC_INIT_MAX_TRIES   5U

Maximum number of SDMMC initialization attempts.

Definition at line 86 of file board.h.

◆ SDMMC_IRQ_PRIORITY

#define SDMMC_IRQ_PRIORITY   1U

SDMMC interrupt priority.

Definition at line 88 of file board.h.

◆ SDMMC_TRANSFER_TIMEOUT

#define SDMMC_TRANSFER_TIMEOUT   500U

SDMMC transfer timeout in milliseconds.

Definition at line 92 of file board.h.

◆ SYSTICK_IRQ_PRIORITY

#define SYSTICK_IRQ_PRIORITY   0U

SysTick interrupt priority.

Definition at line 147 of file board.h.

◆ VCP_UART_BAUDRATE

#define VCP_UART_BAUDRATE   115200U

UART baud rate for the VCP connection.

Definition at line 159 of file board.h.

◆ VCP_UART_BUFFER_SIZE

#define VCP_UART_BUFFER_SIZE   80U

Size of the buffer used for logging.

Definition at line 150 of file board.h.

◆ VCP_UART_GPIO_AF

#define VCP_UART_GPIO_AF   GPIO_AF7_USART2

GPIO alternate function of UART.

Definition at line 179 of file board.h.

◆ VCP_UART_GPIO_RX_PIN

#define VCP_UART_GPIO_RX_PIN   GPIO_PIN_2

GPIO pin of the UART RX GPIO.

Definition at line 175 of file board.h.

◆ VCP_UART_GPIO_RX_PORT

#define VCP_UART_GPIO_RX_PORT   GPIOA

GPIO port of the UART RX GPIO connected to the on-board ST-Link VCP.

Definition at line 171 of file board.h.

◆ VCP_UART_GPIO_TX_PIN

#define VCP_UART_GPIO_TX_PIN   GPIO_PIN_6

GPIO pin of the UART TX GPIO connected to the on-board ST-Link VCP.

Definition at line 167 of file board.h.

◆ VCP_UART_GPIO_TX_PORT

#define VCP_UART_GPIO_TX_PORT   GPIOD

GPIO port of the UART TX GPIO connected to the on-board ST-Link VCP.

Definition at line 163 of file board.h.

◆ VCP_UART_INSTANCE

#define VCP_UART_INSTANCE   USART2

UART peripheral instance connected to the on-board ST-Link VCP.

Definition at line 156 of file board.h.

◆ VCP_UART_TX_TIMEOUT

#define VCP_UART_TX_TIMEOUT   100U

UART transmit timeout in milliseconds.

Definition at line 152 of file board.h.

Function Documentation

◆ BoardDeInit()

void BoardDeInit ( void  )

De-initialize the board hardware and peripherals.

Resets the peripherals and GPIOs to their default state before jumping to the user application or the system memory bootloader.

Definition at line 65 of file board.c.

◆ BoardInit()

void BoardInit ( void  )

Initialize the board hardware and peripherals.

Configures the system clock, GPIOs, LEDs, button, UART, and other peripherals required by the bootloader.

Definition at line 55 of file board.c.

◆ SetVectorTableLocation()

void SetVectorTableLocation ( const uint32_t  address)

Set the vector table location to the specified address.

Parameters
addressBase address of the vector table.

Definition at line 79 of file board.c.