]> git.ayabusa.dev Git - numworks-zeta-os.git/commitdiff
started working on clock control, not working
authorayabusa <lebgpub@gmail.com>
Wed, 17 Apr 2024 18:10:01 +0000 (20:10 +0200)
committerayabusa <lebgpub@gmail.com>
Wed, 17 Apr 2024 18:10:01 +0000 (20:10 +0200)
12 files changed:
numworks_port/build/Laplace/clock.o [new file with mode: 0644]
numworks_port/build/Laplace/keyboard.o
numworks_port/build/Laplace/laplace.o
numworks_port/build/main.bin
numworks_port/build/main.elf
numworks_port/build/main.o
numworks_port/src/Laplace/clock.c [new file with mode: 0644]
numworks_port/src/Laplace/clock.h [new file with mode: 0644]
numworks_port/src/Laplace/laplace.c
numworks_port/src/Laplace/laplace.h
numworks_port/src/device/stm32f730xx.h
numworks_port/src/main.c

diff --git a/numworks_port/build/Laplace/clock.o b/numworks_port/build/Laplace/clock.o
new file mode 100644 (file)
index 0000000..a3dec50
Binary files /dev/null and b/numworks_port/build/Laplace/clock.o differ
index 7962349cca4579b6435d2b41eaf9f6e47cbaea08..b8cdc077345fce4e7314ac2a5fc6c59fe89abb86 100644 (file)
Binary files a/numworks_port/build/Laplace/keyboard.o and b/numworks_port/build/Laplace/keyboard.o differ
index 699b906f65a7176356a540c00ae2e416cce4287f..489fd842e5990d22e4d15b67513ff9584aeb5065 100644 (file)
Binary files a/numworks_port/build/Laplace/laplace.o and b/numworks_port/build/Laplace/laplace.o differ
index 90cc9f1a85de47aa0f9fcdca4a42f73854b3e667..d02b2206ec633b92b2412fab7fa72e431f3779f7 100755 (executable)
Binary files a/numworks_port/build/main.bin and b/numworks_port/build/main.bin differ
index b2b547f9d0e96d9cf2bf20ec90f7e1c6c40ef5d7..0eff4a1e40d7e3aae3a90ca6a645a3c31bb3c724 100755 (executable)
Binary files a/numworks_port/build/main.elf and b/numworks_port/build/main.elf differ
index e6051ad8b9f98d5b3cfe510564595d68b3da1454..a89f7cbc9b9894c74907c3a5e3a271d9da42fe86 100644 (file)
Binary files a/numworks_port/build/main.o and b/numworks_port/build/main.o differ
diff --git a/numworks_port/src/Laplace/clock.c b/numworks_port/src/Laplace/clock.c
new file mode 100644 (file)
index 0000000..4d5e0e7
--- /dev/null
@@ -0,0 +1,32 @@
+#include "clock.h"
+
+/* This should set the speed to 216MHz intead of just 48MHz */
+void init_clock(){
+    // ACR means flash Access control register
+    FLASH->ACR |=  (FLASH_ACR_LATENCY_7WS | // 7 wait states
+                  FLASH_ACR_PRFTEN |        // prefetch on
+                  FLASH_ACR_ARTEN);         // ART on
+
+    // enables HSE and wait for it to be ready
+    RCC->CR    |=  (RCC_CR_HSEON);
+    while (!(RCC->CR & RCC_CR_HSERDY)) {};
+
+    // clear the specified bit
+
+    // (8/4)*108 = 216MHz
+    /*
+    RCC->PLLCFGR  |=  (RCC_PLLCFGR_PLLSRC_HSE | // HSE: 8MHz
+                  RCC_PLLCFGR_PLLN_108 |        // *108
+                  RCC_PLLCFGR_PLLM_25);          // /4
+    */
+    RCC->PLLCFGR  =  0b00001000010000100110000000001000; // HSE: 8MHz*/
+
+    // enable the RCC clock and wait for it to be ready
+    RCC->CR    |=  (RCC_CR_PLLON);
+    while (!(RCC->CR & RCC_CR_PLLRDY)) {};
+
+    // set it as the system clock source
+    RCC->CFGR  &= ~(RCC_CFGR_SW);
+    RCC->CFGR  |=  (RCC_CFGR_SW_PLL);
+    while (!(RCC->CFGR & RCC_CFGR_SWS_PLL)) {};
+}
\ No newline at end of file
diff --git a/numworks_port/src/Laplace/clock.h b/numworks_port/src/Laplace/clock.h
new file mode 100644 (file)
index 0000000..9120586
--- /dev/null
@@ -0,0 +1,25 @@
+/** @file clock.h
+ * 
+ * @brief Handle clock init and all
+ *
+ */ 
+
+#ifndef CLOCK_H
+#define CLOCK_H
+
+#include "stdint.h"
+#include "../device/stm32f730xx.h"
+
+#define PLL_N 384
+#define PLL_M 8
+#define PLL_P 2
+#define PLL_Q 8
+
+/*
+RCC->PLLCFGR  |=  0b00001000010000100110000000001000; // HSE: 8MHz*/
+    //0b0000/*<-null*/1000/*<-PLLQ*/0/*<-null*/1/*<-PLLPSRC(HSE)*/0000/*<-null*/10/*<-PLLP*/0/*<-null*/110000000/*<-PLLN*/001000/*<-PLLM*/
+
+
+void init_clock();
+
+#endif
\ No newline at end of file
index 03f9459bfb38fd460278bfd3accb9ac250b52c8a..abc4c1b9bcf488774c94d7bfc4120f9011c131ef 100644 (file)
@@ -10,4 +10,5 @@ void laplace_init(){
     enable_gpio_x_rcc(GPIO_C); //column (in)
     enable_gpio_x_rcc(GPIO_A); //row (out)
     keyboard_init();
+    init_clock();
 }
\ No newline at end of file
index 860f3700c0a1f43455d0da65dfdbdc971c3d20ac..e66addd0b67085ff163fb55920f63e8c1233891b 100644 (file)
@@ -10,6 +10,7 @@
 #include "gpio_helper.h"
 #include "led.h"
 #include "keyboard.h"
+#include "clock.h"
 
 /* Initialize all needed peripherals, should be called early in your program */
 void laplace_init();
index 235c758c727845ef1ec190938b7b03b8505b7062..a40cfda255cb40523fcf425b217df6e8145b83f8 100644 (file)
@@ -9403,6 +9403,7 @@ typedef struct
 #define RCC_PLLCFGR_PLLN_6                 (0x040UL << RCC_PLLCFGR_PLLN_Pos)    /*!< 0x00001000 */\r
 #define RCC_PLLCFGR_PLLN_7                 (0x080UL << RCC_PLLCFGR_PLLN_Pos)    /*!< 0x00002000 */\r
 #define RCC_PLLCFGR_PLLN_8                 (0x100UL << RCC_PLLCFGR_PLLN_Pos)    /*!< 0x00004000 */\r
+#define RCC_PLLCFGR_PLLN_384               (0x180UL << RCC_PLLCFGR_PLLN_Pos)    /*!< ? */\r
 #define RCC_PLLCFGR_PLLP_Pos               (16U)\r
 #define RCC_PLLCFGR_PLLP_Msk               (0x3UL << RCC_PLLCFGR_PLLP_Pos)      /*!< 0x00030000 */\r
 #define RCC_PLLCFGR_PLLP                   RCC_PLLCFGR_PLLP_Msk\r
index 241d613674d34f8ac8b7e8708aacbaf20aeb0717..079e576e1df82a98eb1cc488a7b8909e96c5da1e 100644 (file)
@@ -4,7 +4,6 @@
 void main_entry(){
     // init all the peripherals
     laplace_init();
-    ms_wait(2000);
 
     // infinite loop
     while (1){
@@ -27,12 +26,17 @@ void main_entry(){
                 }
             }
         }*/
-
+    /*
         if(get_key('G', 3)){
             set_led_red(true);
         }else{
             set_led_red(false);
-        }
+        }*/
+
+        set_led_red(true);
+        ms_wait(5000);
+        set_led_red(false);
+        ms_wait(5000);
     }
     
 }
\ No newline at end of file