]> git.ayabusa.dev Git - numworks-zeta-os.git/commitdiff
the led is finally working
authorayabusa <lebgpub@gmail.com>
Sun, 31 Mar 2024 13:47:23 +0000 (15:47 +0200)
committerayabusa <lebgpub@gmail.com>
Sun, 31 Mar 2024 13:47:23 +0000 (15:47 +0200)
.vscode/settings.json
numworks_port/build/main.bin
numworks_port/build/main.elf
numworks_port/build/rt0.o
numworks_port/build/vector_table.o
numworks_port/src/linker.ld
numworks_port/src/rt0.cpp
numworks_port/src/vector_table.cpp

index 0ab8f978d6c91884ca080b1686abee2d5d8d4e4d..8d5cb5703fbc5d1bd108aad2f7f813554fa489d6 100644 (file)
@@ -16,6 +16,7 @@
         "stdexcept": "cpp",
         "streambuf": "cpp",
         "system_error": "cpp",
-        "tuple": "cpp"
+        "tuple": "cpp",
+        "main.h": "c"
     }
 }
\ No newline at end of file
index ff6161c8de4664554ae050ddf173b5f199ed26f4..5f5d8c7b5d32c3b846b864e4bbf9ee31a6cffd9e 100755 (executable)
Binary files a/numworks_port/build/main.bin and b/numworks_port/build/main.bin differ
index 056273f9f478682c6b0a7103230c90dc814284fc..3e81d598c56d43ad8bcbe7fba3d2ecdb79dbddf0 100755 (executable)
Binary files a/numworks_port/build/main.elf and b/numworks_port/build/main.elf differ
index 298d4c8d694085c8053b188eb70ec24c3df33b9b..86c4d359a45ebdcdae070266ad28bfd9eb8145ae 100644 (file)
Binary files a/numworks_port/build/rt0.o and b/numworks_port/build/rt0.o differ
index b635bd6adc7e3f34cdad90cc5f76ad1afafda539..95f70dbe1345892e2dc63bed5543e55fe136029c 100644 (file)
Binary files a/numworks_port/build/vector_table.o and b/numworks_port/build/vector_table.o differ
index c083a1ad51511d00a86e091205c116b5b430c286..b2e35449614de735f990ea275bd2c95ec1ea417a 100644 (file)
@@ -2,7 +2,6 @@
 /*ENTRY(reset_handler)*/
 /* End of RAM / Start of stack */
 /* (4KB SRAM) */
-_estack = 0x20262144;
 
 /* epsilon stuff */
 STACK_SIZE = 32K;
@@ -85,6 +84,13 @@ SECTIONS
     *(.rodata.*)
   } >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
    * things like variables, which can change. */
   .data : {
index 948a356d2a10106af92acd773356af47427cf683..2d3ffeebd38bee10c644a3da0514e7bc8bc17c95 100644 (file)
@@ -1,5 +1,9 @@
 #include "vector_table.h"
 #include <stddef.h>
+#include <stdint.h>
+#include "device/stm32f730xx.h"
+
+#define LED_PIN    (4) // PC0
 
 typedef void (*cxx_constructor)();
 
@@ -52,8 +56,19 @@ void __attribute__((noinline)) start() {
   size_t bssSectionLength = (&_bss_section_end_ram - &_bss_section_start_ram);
   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)
   {
-    /* code */
+    GPIOB->ODR = (1 << LED_PIN);
   }
 }
\ No newline at end of file
index 8b875a943c57818e12426a98739da6334b342f1f..948a363aa81891d5b2eefc684f7d041abed96591 100644 (file)
@@ -1,5 +1,5 @@
 #include "vector_table.h"
-extern const void * _estack;
+extern const void * _stack_start;
 
 /* Interrupt Service Routines are void->void functions */
 typedef void(*ISR)(void);
@@ -16,7 +16,7 @@ ISR InitialisationVector[INITIALISATION_VECTOR_SIZE]
   __attribute__((section(".isr_vector_table")))
   __attribute__((used))
   = {
-  (ISR)&_estack, // Stack start
+  (ISR)&_stack_start, // Stack start
   start, // Reset service routine,
   0, // NMI service routine,
   0, // HardFault service routine,