NavHAL 0.1.0
NAVRobotec's architecture-agnostic HAL for embedded systems.
Loading...
Searching...
No Matches
startup.c File Reference
#include <stdint.h>
Include dependency graph for startup.c:

Macros

#define WEAK_ALIAS   __attribute__((weak, alias("Default_Handler")))
 Weak aliases for all interrupt handlers to Default_Handler.

Functions

int main (void)
 Main entry point.
void Default_Handler (void)
 Default handler used for all unimplemented interrupts.
void Reset_Handler (void)
 Reset handler called at MCU startup.
void NMI_Handler (void)
 Vector table placed in .isr_vector section.

Variables

uint32_t _sidata
uint32_t _sdata
uint32_t _edata
uint32_t _sbss
uint32_t _ebss
uint32_t _estack

Macro Definition Documentation

◆ WEAK_ALIAS

#define WEAK_ALIAS   __attribute__((weak, alias("Default_Handler")))

Weak aliases for all interrupt handlers to Default_Handler.

Function Documentation

◆ Default_Handler()

void Default_Handler ( void )

Default handler used for all unimplemented interrupts.

◆ main()

int main ( void )
extern

Main entry point.

Initializes GPIOA pin 5 as output and toggles it in an infinite loop. Typically connected to an LED (e.g., onboard LED on Nucleo boards).

Main entry point.

  • Initializes system clock using PLL.
  • Configures SysTick timer.
  • Initializes UART2 for console output.
  • Configures multiple timers with interrupts and attaches callbacks.
  • Enters infinite loop with optional debug prints.

< Initialize SysTick with 1 ms tick

< Initialize UART2 at 9600 baud

< Send string over UART2

< Wait for 1 second

< Buffer to hold timer count as string

< Initialize SysTick with 1 ms tick

< Initialize UART2 at 9600 baud

< Initialize TIM5 with auto-reload 1e9

< Convert timer value to string

< Print label

< Print TIM5 counter value

< Newline and carriage return

< Initialize system clock with PLL

< Initialize SysTick with 1 ms tick

< Initialize UART2 at 9600 baud

Initialize TIM2, enable interrupt, attach callback

Initialize TIM3, enable interrupt, attach callback

Initialize TIM4, enable interrupt, attach callback

Initialize TIM5, enable interrupt, attach callback

Initialize TIM9, enable interrupt, attach callback

Optional debug prints uart2_write("SysTicks: "); uart2_write(hal_get_tick()); uart2_write(", Millis: "); uart2_write(timer_get_count(TIM5)); uart2_write("\n\r");

< Optional 1-second delay

< Initialize SysTick with 40 µs tick

< Initialize UART2 at 9600 baud

< Configure PA05 as output

< Initialize TIM5 with prescaler 0 and auto-reload 1e9

< Set PA05 HIGH

< Delay 500 ms

< Set PA05 LOW

< Delay 500 ms

< Print label

< Print system millis

< Newline and carriage return

< Initialize SysTick with 40 µs tick

< Initialize UART2 at 9600 baud

< Set PB10 as alternate function

< AF1 for TIM2_CH3

< Initialize PWM handle on TIM2, channel 3

< Init PWM at 15 kHz, 10% duty cycle

< Start PWM output

< Variable for duty cycle update

< Update PWM duty cycle

< Increment duty cycle by 1%

< Reset to 0% after 100%

< Print current duty cycle over UART2

< Newline and carriage return

< Delay 10 ms

< Initialize system clock with PLL

< Initialize SysTick with 40 µs tick

< Initialize UART2 at 9600 baud

< Print SYSCLK label

< Print system clock

< Print APB1CLK label

< Print APB1 clock

< Print APB2CLK label

< Print APB2 clock

< Print AHBCLK label

< Print AHB clock

< Newline

< Wait 1 second

< Initialize SysTick for delays

< Initialize UART2 at 9600 baud

< Stop execution if I2C init fails

< Wait for conversion (~4.5 ms for temperature)

< Assumes uart2_write_int exists

< Wait 1 second before next measurement

◆ NMI_Handler()

void NMI_Handler ( void )

Vector table placed in .isr_vector section.

◆ Reset_Handler()

void Reset_Handler ( void )

Reset handler called at MCU startup.

Reset handler for Cortex-M4.

Initializes the .data and .bss sections, enables interrupts, and calls the main application.

Variable Documentation

◆ _ebss

uint32_t _ebss
extern

◆ _edata

uint32_t _edata
extern

◆ _estack

uint32_t _estack
extern

◆ _sbss

uint32_t _sbss
extern

◆ _sdata

uint32_t _sdata
extern

◆ _sidata

uint32_t _sidata
extern