the led is finally working

This commit is contained in:
ayabusa 2024-03-31 15:47:23 +02:00
parent 70d807180e
commit e9d949748b
8 changed files with 27 additions and 5 deletions

View File

@ -16,6 +16,7 @@
"stdexcept": "cpp", "stdexcept": "cpp",
"streambuf": "cpp", "streambuf": "cpp",
"system_error": "cpp", "system_error": "cpp",
"tuple": "cpp" "tuple": "cpp",
"main.h": "c"
} }
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,6 @@
/*ENTRY(reset_handler)*/ /*ENTRY(reset_handler)*/
/* End of RAM / Start of stack */ /* End of RAM / Start of stack */
/* (4KB SRAM) */ /* (4KB SRAM) */
_estack = 0x20262144;
/* epsilon stuff */ /* epsilon stuff */
STACK_SIZE = 32K; STACK_SIZE = 32K;
@ -85,6 +84,13 @@ SECTIONS
*(.rodata.*) *(.rodata.*)
} >FLASH } >FLASH
.init_array : {
. = ALIGN(4);
_init_array_start = .;
KEEP (*(.init_array*))
_init_array_end = .;
} >FLASH
/* The 'data' section is space set aside in RAM for /* The 'data' section is space set aside in RAM for
* things like variables, which can change. */ * things like variables, which can change. */
.data : { .data : {

View File

@ -1,5 +1,9 @@
#include "vector_table.h" #include "vector_table.h"
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include "device/stm32f730xx.h"
#define LED_PIN (4) // PC0
typedef void (*cxx_constructor)(); typedef void (*cxx_constructor)();
@ -52,8 +56,19 @@ void __attribute__((noinline)) start() {
size_t bssSectionLength = (&_bss_section_end_ram - &_bss_section_start_ram); size_t bssSectionLength = (&_bss_section_end_ram - &_bss_section_start_ram);
memset_custom(&_bss_section_start_ram, 0, bssSectionLength); memset_custom(&_bss_section_start_ram, 0, bssSectionLength);
// Enable the GPIOa and GPIOC peripheral in RCC.
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN ;
// C0 is connected to the LED.
// It should be set to push-pull low-speed output.
GPIOB->MODER &= ~(0x3 << (LED_PIN*2));
GPIOB->MODER |= (0x1 << (LED_PIN*2));
GPIOB->OTYPER &= ~(1 << LED_PIN);
GPIOB->ODR = (1 << LED_PIN);
while (0) while (0)
{ {
/* code */ GPIOB->ODR = (1 << LED_PIN);
} }
} }

View File

@ -1,5 +1,5 @@
#include "vector_table.h" #include "vector_table.h"
extern const void * _estack; extern const void * _stack_start;
/* Interrupt Service Routines are void->void functions */ /* Interrupt Service Routines are void->void functions */
typedef void(*ISR)(void); typedef void(*ISR)(void);
@ -16,7 +16,7 @@ ISR InitialisationVector[INITIALISATION_VECTOR_SIZE]
__attribute__((section(".isr_vector_table"))) __attribute__((section(".isr_vector_table")))
__attribute__((used)) __attribute__((used))
= { = {
(ISR)&_estack, // Stack start (ISR)&_stack_start, // Stack start
start, // Reset service routine, start, // Reset service routine,
0, // NMI service routine, 0, // NMI service routine,
0, // HardFault service routine, 0, // HardFault service routine,