]> git.ayabusa.dev Git - numworks-zeta-os.git/commitdiff
Documentation and clean up
authorayabusa <lebgpub@gmail.com>
Fri, 5 Apr 2024 18:59:57 +0000 (20:59 +0200)
committerayabusa <lebgpub@gmail.com>
Fri, 5 Apr 2024 18:59:57 +0000 (20:59 +0200)
22 files changed:
.vscode/settings.json
numworks_port/README.md
numworks_port/build/Laplace/gpio_helper.o
numworks_port/build/Laplace/keyboard.o
numworks_port/build/Laplace/laplace.o
numworks_port/build/Laplace/led.o
numworks_port/build/Laplace/time.o
numworks_port/build/main.bin
numworks_port/build/main.elf
numworks_port/build/main.o
numworks_port/src/Laplace/gpio_helper.c
numworks_port/src/Laplace/gpio_helper.h
numworks_port/src/Laplace/keyboard.c
numworks_port/src/Laplace/keyboard.h
numworks_port/src/Laplace/laplace.c
numworks_port/src/Laplace/laplace.h
numworks_port/src/Laplace/led.c
numworks_port/src/Laplace/led.h
numworks_port/src/Laplace/time.c
numworks_port/src/Laplace/time.h
numworks_port/src/main.c
numworks_port/src/main.h

index 02bb9b31f428ba696cab40e6973e7c4155c33722..90879a8d26724668467db26caf8214f50c49c984 100644 (file)
@@ -21,6 +21,7 @@
         "led.h": "c",
         "stm32f730xx.h": "c",
         "keyboard.h": "c",
-        "gpio_helper.h": "c"
+        "gpio_helper.h": "c",
+        "stdint.h": "c"
     }
 }
\ No newline at end of file
index e3da20bd9a92b6e37f20c8adf8145662e89fa64b..6957788659b46d6622f5dabd4b7d5a37f391b267 100644 (file)
@@ -17,6 +17,9 @@ This is a bare metal os attempt on the numworks n0110
     - [ ] adapt ms_wait() and us_wait()
 - [ ] Screen interface
 - [ ] UI toolkit
+    - [ ] set pixel
     - [ ] text display
     - [ ] fill rect
-    - [ ] image display
\ No newline at end of file
+    - [ ] image display
+- [ ] File system
+    - [ ] Plan what to do
\ No newline at end of file
index 3a0b9593130df5230eac96cd64a07e52e0efe777..d291bcf6117a92650ea23a68cdafd67ab8a507d3 100644 (file)
Binary files a/numworks_port/build/Laplace/gpio_helper.o and b/numworks_port/build/Laplace/gpio_helper.o differ
index c52184b921b47e6b53f093e8b83454084295a78e..84570ffd4694a6a632a17e4dd4d8e653bdef95e6 100644 (file)
Binary files a/numworks_port/build/Laplace/keyboard.o and b/numworks_port/build/Laplace/keyboard.o differ
index ac299558d1d9bdb813dced3616511ecd3827d8c3..699b906f65a7176356a540c00ae2e416cce4287f 100644 (file)
Binary files a/numworks_port/build/Laplace/laplace.o and b/numworks_port/build/Laplace/laplace.o differ
index 6284c5539b2b0ef408aceed1f119977b0c054081..0fcbf308745087be2750774bdd0ed5cb26e976b4 100644 (file)
Binary files a/numworks_port/build/Laplace/led.o and b/numworks_port/build/Laplace/led.o differ
index 1c566c504e5209921bc030acf4aa8150ec28e4e0..bc8f70a863612ac4be5d55b4e984dddd28553826 100644 (file)
Binary files a/numworks_port/build/Laplace/time.o and b/numworks_port/build/Laplace/time.o differ
index 632f485714454486df4580b1082569772c62405b..e7aefdb6bf149dc676765304599d73dc28122c7e 100755 (executable)
Binary files a/numworks_port/build/main.bin and b/numworks_port/build/main.bin differ
index e8a3275eed6d41a53a8dcc5bf2dba654a365dc8a..3051e3e479e8a7f69d3aeaa78006702983b83cc1 100755 (executable)
Binary files a/numworks_port/build/main.elf and b/numworks_port/build/main.elf differ
index 1f8ae0c3c6114f7c38137bc92b93604388ac6eba..1d3f27abf7148116d338a9df95a76981f101dd83 100644 (file)
Binary files a/numworks_port/build/main.o and b/numworks_port/build/main.o differ
index d5ba4c2bf16be747daf320d5b67fde54109a0c86..7d844b989aba9527db034caee966c854e7508bc4 100644 (file)
@@ -6,6 +6,9 @@ uint8_t GPIOC_state = 0;
 uint8_t GPIOD_state = 0;
 uint8_t GPIOE_state = 0;
 
+/* Set a pin High (true) or Low (false) ie:
+   set_output_pin(GPIO_B, 2, true);
+   this sets the pin B2 to high */
 void set_output_pin(uint8_t gpio_x, uint8_t pin, bool state){
     switch (gpio_x)
     {
@@ -59,6 +62,9 @@ void set_output_pin(uint8_t gpio_x, uint8_t pin, bool state){
     }
 }
 
+/* Read the value of an input pin, it returns High (true) or Low (false) ie:
+   bool state = read_input_pin(GPIO_C, 3);
+   This stores the state of the pin C3 */
 bool read_input_pin(uint8_t gpio_x, uint8_t pin){
     // Invert the IDR register since '0' means 'pressed'.
     uint8_t idr_val = 0;
@@ -87,6 +93,7 @@ bool read_input_pin(uint8_t gpio_x, uint8_t pin){
     return idr_val & (1 << pin);
 }
 
+/* Enable the specified GPIO */
 void enable_gpio_x_rcc(uint8_t gpio_x){
     switch (gpio_x)
     {
index a09f88fc8884a3f688ed994e8063901ade9a0a7f..8f40c8ea3dee4ee76536f4c1a46743f9c3b37fb5 100644 (file)
 #define GPIO_D 3
 #define GPIO_E 4
 
+/* Set a pin High (true) or Low (false) ie:
+   set_output_pin(GPIO_B, 2, true);
+   this sets the pin B2 to high */
 void set_output_pin(uint8_t gpio_x, uint8_t pin, bool state);
+
+/* Read the value of an input pin, it returns High (true) or Low (false) ie:
+   bool state = read_input_pin(GPIO_C, 3);
+   This stores the state of the pin C3 */
 bool read_input_pin(uint8_t gpio_x, uint8_t pin);
+
+/* Enable the specified GPIO */
 void enable_gpio_x_rcc(uint8_t gpio_x);
 
 #endif
\ No newline at end of file
index ced4e4969a2c2e56110c33861f601092b97dfbac..5d4563b3e92624771643ac757f2e9f747b4b894c 100644 (file)
@@ -43,6 +43,8 @@ const uint8_t number_of_rows = 9;
 const uint8_t number_of_columns = 6;
 const char row_list[9] = {'B', 'A', 'C', 'D', 'E', 'F', 'G', 'H', 'I'};
 
+/* This should be called before accessing any other keyboard related feature
+   as it sets up all keyboard related peripherals */
 void keyboard_init(){
     for (int i = 0; i < number_of_rows; i++){
         // setup rows (output open drain)
@@ -58,7 +60,8 @@ void keyboard_init(){
     }
 }
 
-
+/* This disable the all the row except for the specified one
+   It is usefull to test if a specific key is pressed */
 void activate_row(uint8_t row_nb){
     // set all row to 0 and then reenable selected row
     for(int i =0; i < number_of_rows; i++){
@@ -68,6 +71,8 @@ void activate_row(uint8_t row_nb){
     us_wait(100);
 }
 
+/* Scans the current state of the keyboard and returns an array of buttons struct
+   You can find the button struct definition in keyboard.h */
 struct button* keyboard_scan(){
     static struct button result_button_list[54] = {};
     uint8_t i = 0;
index a06b45b5f671b2f9fb5c9be78bb6b8278dafec37..35be241c603f945b8a4e0af0eb3eb7203bacd6f4 100644 (file)
 #include "gpio_helper.h"
 
 struct button{
-       uint8_t column;
-       char row;
-       bool state;
+       uint8_t column; // ie: 2
+       char row; // ie: 'A'
+       bool state; // true is pressed and false released
 };
 
-
+/* This should be called before accessing any other keyboard related feature
+   as it sets up all keyboard related peripherals */
 void keyboard_init();
+
+/* Scans the current state of the keyboard and returns an array of buttons struct
+   You can find the button struct definition in keyboard.h */
 struct button* keyboard_scan();
 
 #endif
\ No newline at end of file
index deb4ae356af921a2cacdbe653bc5c1d17a03f95c..03f9459bfb38fd460278bfd3accb9ac250b52c8a 100644 (file)
@@ -1,12 +1,13 @@
 #include "laplace.h"
 
+/* Initialize all needed peripherals, should be called early in your program */
 void laplace_init(){
-    // Enable the GPIO peripheral in RCC.
+    /* led init */
     enable_gpio_x_rcc(GPIO_B);
     led_init();
-    //col (in)
-    enable_gpio_x_rcc(GPIO_C);
-    //row (out)
-    enable_gpio_x_rcc(GPIO_A);
+
+    /* keyboard init */
+    enable_gpio_x_rcc(GPIO_C); //column (in)
+    enable_gpio_x_rcc(GPIO_A); //row (out)
     keyboard_init();
 }
\ No newline at end of file
index 626bf7e1b70bb33201dccaae9d4536e2884537cb..860f3700c0a1f43455d0da65dfdbdc971c3d20ac 100644 (file)
@@ -11,6 +11,7 @@
 #include "led.h"
 #include "keyboard.h"
 
+/* Initialize all needed peripherals, should be called early in your program */
 void laplace_init();
 
 #endif
\ No newline at end of file
index db8ac592c31565c3e9ee80fd7fc0958725fc9ee6..0c796edd11ce271321a487afa898fcd052abc296 100644 (file)
@@ -3,6 +3,8 @@
 // GPIOB for all the leds
 uint8_t gpio_b = GPIO_B;
 
+/* This should be called before accessing any other led related feature
+   as it sets up all led related peripherals */
 void led_init(){
     // It should be set to push-pull low-speed output.
 
@@ -22,18 +24,30 @@ void led_init(){
     GPIOB->OTYPER &= ~(1 << BLUE_LED_PIN);
 }
 
+/* Set the status of the red led
+   true  -> ON
+   false -> OFF */
 void set_led_red(bool state){
     set_output_pin(gpio_b, RED_LED_PIN, state);
 }
 
+/* Set the status of the green led
+   true  -> ON
+   false -> OFF */
 void set_led_green(bool state){
     set_output_pin(gpio_b, GREEN_LED_PIN, state);
 }
 
+/* Set the status of the blue led
+   true  -> ON
+   false -> OFF */
 void set_led_blue(bool state){
     set_output_pin(gpio_b, BLUE_LED_PIN, state);
 }
 
+/* Set the status of all 3 leds at the same time
+   true  -> ON
+   false -> OFF */
 void set_led_all(bool state){
     set_output_pin(gpio_b, RED_LED_PIN, state);
     set_output_pin(gpio_b, GREEN_LED_PIN, state);
index 2be3080c6798722159c1fab8e123e255c85739dd..72f5e0b5151a9713365ff1c4aac4a79e1f5145d9 100644 (file)
 #include "../device/stm32f730xx.h"
 #include "gpio_helper.h"
 
+/* This should be called before accessing any other led related feature
+   as it sets up all led related peripherals */
 void led_init();
+
+/* Set the status of the red led
+   true  -> ON
+   false -> OFF */
 void set_led_red(bool state);
+
+/* Set the status of the green led
+   true  -> ON
+   false -> OFF */
 void set_led_green(bool state);
+
+/* Set the status of the blue led
+   true  -> ON
+   false -> OFF */
 void set_led_blue(bool state);
+
+/* Set the status of all 3 leds at the same time
+   true  -> ON
+   false -> OFF */
 void set_led_all(bool state);
 
 #endif
\ No newline at end of file
index c257d1899aea31d63b5dd18baa2f50ac95f34154..3df54ba99e96f0b4073b91e193c6e8821e4c2fbf 100644 (file)
@@ -1,11 +1,13 @@
 #include "time.h"
 
+/* Pause the os for x micro seconds */
 void us_wait(uint8_t micro_seconds) {
   for (volatile uint32_t i=0; i<loops_per_microsecond*micro_seconds; i++) {
     __asm volatile("nop");
   }
 }
 
+/* Pause the os for x milli seconds */
 void ms_wait(uint16_t milli_seconds) {
   for (volatile uint32_t i=0; i<loops_per_millisecond*milli_seconds; i++) {
     __asm volatile("nop");
index ed59cc8d1b69f9ad2ce155a5bd1e03c119d24eb9..99c1af2990c8edcf6e10285aded8e1633cbc5bdb 100644 (file)
@@ -12,7 +12,9 @@
 
 #include "stdint.h"
 
+/* Pause the os for x micro seconds */
 void us_wait(uint8_t micro_seconds);
+/* Pause the os for x milli seconds */
 void ms_wait(uint16_t milli_seconds);
 
 #endif
\ No newline at end of file
index 9bf2e4ebbe050eeff9ece22e1e1a9c85692e3ae0..9c8401d834e613e383ac6bf10c804a60fb577d62 100644 (file)
@@ -6,17 +6,32 @@ void main_entry(){
     laplace_init();
     ms_wait(2000);
     set_led_green(true);
-    while (1)
-    {
+
+    // infinite loop
+    while (1){
         struct button * keyboard_state = keyboard_scan();
+        
         for(int i =0; i < 54; i++){
             if(keyboard_state[i].column == 4 && keyboard_state[i].row == 'H'){
+                if(keyboard_state[i].state){
+                    set_led_blue(true);
+                }else{
+                    set_led_blue(false);
+                }
+            }
+            if(keyboard_state[i].column == 3 && keyboard_state[i].row == 'H'){
                 if(keyboard_state[i].state){
                     set_led_green(true);
                 }else{
                     set_led_green(false);
                 }
-                break;
+            }
+            if(keyboard_state[i].column == 2 && keyboard_state[i].row == 'H'){
+                if(keyboard_state[i].state){
+                    set_led_red(true);
+                }else{
+                    set_led_red(false);
+                }
             }
         }
     }
index 85c894f9ed3f1d12feec5fd9ca12bd91b11be37e..8626abb891800dcd51f9a658bd3c5494726e788f 100644 (file)
@@ -1,6 +1,6 @@
-/** @file led.h
+/** @file main.h
  * 
- * @brief Control the led
+ * @brief The main programm
  *
  */ 
 
@@ -12,6 +12,7 @@
 #include "Laplace/keyboard.h"
 #include "Laplace/time.h"
 
+/* our main function */
 void main_entry();
 
 #endif
\ No newline at end of file