]> code.bitgloo.com Git - clyne/calculator.git/commitdiff
added licensing
authorClyne Sullivan <tullivan99@gmail.com>
Mon, 26 Mar 2018 01:16:33 +0000 (21:16 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Mon, 26 Mar 2018 01:16:33 +0000 (21:16 -0400)
44 files changed:
LICENSE
Makefile
README.md
include/clock.h
include/display.h
include/display_draw.h
include/flash.h
include/gpio.h
include/heap.h
include/initrd.h
include/keypad.h
include/lcd.h
include/random.h
include/script.h
include/serial.h
include/stdlib.h
include/task.h
initrd/init2 [deleted file]
initrd/init3 [deleted file]
initrd/keys [new file with mode: 0644]
initrd/lines [new file with mode: 0644]
libinterp.a
link.ld
run.sh
src/clock.c
src/display.c
src/display_draw.c
src/flash.c
src/flash.c.bak [new file with mode: 0644]
src/gpio.c
src/heap.c
src/initrd.c
src/keypad.c
src/keypad.c.bak
src/lcd.c.bak
src/main.c
src/random.c
src/script.c
src/serial.c
src/startup_stm32l476xx.s
src/stdlib.c
src/task.c
xinitrd/init [deleted file]
xinitrd/init2 [deleted file]

diff --git a/LICENSE b/LICENSE
index 94a9ed024d3859793618152ea559a168bbcbb5e2..53d1f3d01864c35841739c55aeba9700657627b7 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -1,7 +1,7 @@
                     GNU GENERAL PUBLIC LICENSE
                        Version 3, 29 June 2007
 
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
@@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 Also add information on how to contact you by electronic and paper mail.
 
@@ -664,11 +664,12 @@ might be different; for a GUI interface, you would use an "about box".
   You should also get your employer (if you work as a programmer) or school,
 if any, to sign a "copyright disclaimer" for the program, if necessary.
 For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
+<https://www.gnu.org/licenses/>.
 
   The GNU General Public License does not permit incorporating your program
 into proprietary programs.  If your program is a subroutine library, you
 may consider it more useful to permit linking proprietary applications with
 the library.  If this is what you want to do, use the GNU Lesser General
 Public License instead of this License.  But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+<https://www.gnu.org/licenses/why-not-lgpl.html>.
+
index b5b2f2147dc8600a88ee0c71b22f4fa763f01ebe..0b9e19ab7394e9f028f64105f8c60e783943a291 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,23 @@
+##
+# @file Makefile
+# Script to build source files
+#
+# Copyright (C) 2018 Clyne Sullivan
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+#
+
 CROSS = arm-none-eabi-
 CC = gcc
 AS = as
index f2e4a048523ec50287121d91a9a2108d03df935e..60b714dd71f1d642203d5a4098713b492ea7fa08 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,7 +1,10 @@
 # calculator
-An OS for an STM32-based calculator  
+A from-scratch operating system for a graphing calculator.  
   
-Trying to make an operating system for a calculator based on the STM32L476RG, using its associated Nucleo board. Starting from scratch because it's fun.  
+The goal of this project is to design a functional operating system for a
+graphing calculator based on the STM32L476RG processor. This OS has been
+designed from scratch to optimize for speed and code size, targeting the
+features necessary for a graphing calculator application.  
   
 Required packages:
 * arm-none-eabi toolchain
@@ -10,4 +13,10 @@ Required packages:
   
 Use ```run.sh``` to upload the final output to the processor.  
   
-To make an initrd, add files to ```initrd/``` and then run ```./mkinitrd.sh```.
+  
+## design overview
+The core of the operating system is written entirely in C and assembly. This
+project is paired with the [interpreter project](https://code.bitgloo.com/clyne/interpreter)
+(licensed under the GPL),
+which parses script from C strings. The operating system exposes calls to the
+script parser, and then loads the text file at ```initrd/init```. 
index c12c41effc55486482f0ceb5d8bdf4a693e840a4..7446dd11ad40da3d56b153d6e9816a4170cdc800 100644 (file)
@@ -1,6 +1,21 @@
 /**
  * @file clock.h
  * Basic clock utilities
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef CLOCK_H_
@@ -9,7 +24,7 @@
 #include <stdint.h>
 
 /**
- * Sets HCLK (system clock) to 80MHz, the maximum.
+ * Initializes clocks, setting HCLK (system clock) to 80MHz, the maximum.
  */
 extern void clock_init(void);
 
index 55f69746f65311de3930fa6280555de10ff76c36..b8afe38f94bbe6428a82abb2e1eea57d363c70fd 100644 (file)
@@ -1,6 +1,21 @@
 /*
  * @file display.h
- * Display library for ILI9481 display.
+ * Display library for ILI9481 display
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef DISPLAY_H_
  */
 #define LCD_HEIGHT 320
 
+/**
+ * Initializes the display. Must be called before other display use.
+ */
+void dsp_init(void);
+
 /**
  * Returns the color integer for the given RGB values.
  * Converts 8RGB to 5-6-5.
@@ -52,9 +72,24 @@ void dsp_write_data(uint8_t data);
  */
 uint8_t dsp_read_data(void);
 
+/**
+ * Selects the area of pixels to draw to, from (x1, y1) inclusive to (x2, y2)
+ * exclusive.
+ * @param x1 starting x coordinate
+ * @param y1 starting y coordinate
+ * @param x2 ending x coordinate
+ * @param y2 ending y coordinate
+ */
 void dsp_set_addr(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
-void dsp_set_addr_read(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
 
-void dsp_init(void);
+/**
+ * Selects the area of pixels to read from, in the range (x1, y1) inclusive to
+ * (x2, y2) exclusive.
+ * @param x1 starting x coordinate
+ * @param y1 starting y coordinate
+ * @param x2 ending x coordinate
+ * @param y2 ending y coordinate
+ */
+void dsp_set_addr_read(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
 
 #endif // DISPLAY_H_
index 9d86437f84d69b7014def59d85381afaf7ae2742..8db3e2ce22c4d259328e14e4951e442b59acc0a5 100644 (file)
@@ -1,6 +1,21 @@
 /**
  * @file display_draw.h
  * Provides functions for drawing to the display
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef DISPLAY_DRAW_H_
index 26fffd37003294904c3df5209a5fbfa098cc562a..47daf8e1215cacb7d9c0aafe820461458554a293 100644 (file)
@@ -1,11 +1,49 @@
+/**
+ * @file flash.h
+ * Provides functionality for using an external SPI flash 
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #ifndef FLASH_H_
 #define FLASH_H_
 
 #include <stdint.h>
 
+/**
+ * Initializes GPIO ports and variables for flash IO. Must be called before
+ * any reads or writes.
+ */
 void flash_init(void);
 
+/**
+ * Does a blocking read of the flash chip into a pre-allocated buffer.
+ * @param buf the buffer to read in to
+ * @param addr the address to read from in the flash chip
+ * @param count the number of bytes to read from the chip
+ */
 void flash_read(char *buf, uint32_t addr, unsigned int count);
+
+/**
+ * Does a blocking write to the flash chip using data from a pre-allocated
+ * buffer.
+ * @param buf the buffer to read data from
+ * @param addr the address to write to in the flash chip
+ * @param count the number of bytes to write to the chip
+ */
 void flash_write(const char *buf, uint32_t addr, unsigned int count);
 
 #endif // FLASH_H_
index 46a8e15428bcf501023919082316aac491116e69..58ebaa7b6ff312c77f9b23261fc9063cad34d644 100644 (file)
@@ -1,6 +1,21 @@
 /**
  * @file gpio.h
  * Abstracts gpio access, makes things easier
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef GPIO_H_
index e8cd9c1e204d56d9e2ddf9b783fde736cef3cf9b..593ce095861c59e2197a46e3c6c9282dd20b1789 100644 (file)
@@ -1,6 +1,21 @@
 /**
  * @file heap.h
  * A basic memory manager
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef HEAP_H_
index de730f27a5b273eebc89c71ea961ee0b800beac2..7bc34bbcc0db1c77ae04c7f81394d4c8df628940 100644 (file)
@@ -4,6 +4,21 @@
  * An archive file (made with ar) can be linked into the final executable to
  * allow files to be loaded in memory on boot. See mkinitrd.sh or the Makefile
  * for more info.
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef INITRD_H_
@@ -16,7 +31,7 @@
  */
 typedef struct
 {
-       char signature[8]; /**< The archive's signature. */
+       char signature[8]; /**< The archive's signature */
 } __attribute__ ((packed)) initrd_header;
 
 /**
@@ -24,10 +39,10 @@ typedef struct
  */
 typedef struct 
 {
-       char name[16];      /**< The name of the file. */
-       uint8_t unused[32]; /**< Unused information. */
-       char size[10];      /**< The file's size in bytes (as string). */
-       char sig[2];        /**< A signature to start file data. */
+       char name[16];      /**< The name of the file */
+       uint8_t unused[32]; /**< Unused information */
+       char size[10];      /**< The file's size in bytes (as string) */
+       char sig[2];        /**< A signature to start file data */
 } __attribute__ ((packed)) initrd_file;
 
 /**
index 5eec1fcaf0d78e7d75c64d614205da5f62c19b38..2e5fa9cacc316b01c88cc0468843cf0cdcacc7d5 100644 (file)
@@ -1,3 +1,23 @@
+/**
+ * @file keypad.h
+ * Manages the GPIO keypad
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #ifndef KEYPAD_H_
 #define KEYPAD_H_
 
 #define KS (uint16_t)(1 << 10)
 #define KP (uint16_t)(1 << 11)
 
+/**
+ * Initializes GPIO for the keypad. Must be called before any keypad reading.
+ */
 void keypad_init(void);
 
+/**
+ * Reads the state of the keypad and returns it.
+ * @return the keypad's state
+ */
 uint16_t keypad_get(void);
+
+/**
+ * Tests if the given key is currently pressed, returning non-zero if it is.
+ * @return non-zero if pressed
+ */
 uint8_t keypad_isdown(uint16_t);
 
 #endif // KEYPAD_H_
index 378aac4c80f0155733cc7983a89a22745be9e35d..c13ff97b8df01faab5b7df06e1a306a1c7bcb95f 100644 (file)
@@ -1,6 +1,21 @@
 /**
  * @file lcd.h
  * A basic library for writing a 16x2 text LCD.
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef LCD_H_
index a1868f677257f36e90af5f24a7fd2ff1ee660987..efb3726f52c33c6ed8ca4c4eafc0c36137bb5348 100644 (file)
@@ -1,6 +1,21 @@
 /**
  * @file random.h
  * Provides true random number generation functionality
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef RANDOM_H_
index ab5fa7e3f6b77f67fe778ed7bacea3106dd641c0..971cccf30b8b7c8cdc9e77da342ce0b439f0b101 100644 (file)
@@ -1,6 +1,21 @@
 /**
  * @file script.h
  * Provides script library for using calculator hardware
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef SCRIPT_H_
@@ -9,7 +24,7 @@
 #include <parser.h>
 
 /**
- * Loads the library for the given interpreter.
+ * Loads the library for the given interpreter instance.
  * @param it the interpreter to use
  */
 void script_loadlib(instance *it);
index 7192e171cee3605425f875760b36d7b1c0ac5549..b943c33164d1b32df61aae1ab9f36c006d5dff3e 100644 (file)
@@ -1,6 +1,21 @@
 /**
  * @file serial.h
  * Provides basic serial IO (through STM debug stuff)
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef SERIAL_H_
index c2658d6077e4aa6da2d212b5d69a939e3b347e9c..ada39cdd6d30417a6b20a4d9ce670c818a7458a8 100644 (file)
@@ -1,8 +1,51 @@
+/**
+ * @file stdlib.h
+ * Provides missing C standard library functions
+ * The newlib versions of these calls are not being used due to dependence on
+ * unsupported system calls.
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #ifndef STDLIB_H_
 #define STDLIB_H_
 
+/**
+ * Parses a formatted string, storing the result in the given buffer.
+ * @param buf the buffer to print the parsed string to
+ * @param max the maximum number of bytes to write to the buffer
+ * @param format the format string
+ * @return a pointer to the buffer
+ */
 char *snprintf(char *buf, unsigned int max, const char *format, ...);
+
+/**
+ * Attempts to convert the given string to a float.
+ * @param s the string to convert
+ * @param endptr if not-null, set to the address of the character after the
+ * number
+ * @return the resulting float, or zero if an error occurred
+ */
 float strtof(const char *s, char **endptr);
+
+/**
+ * Attempts to convert the given string to an integer.
+ * @param s the string to convert
+ * @return the resulting integer, or zero if an error occurred
+ */
 int atoi(const char *s);
 
 #endif // STDLIB_H_
index 6456bdc23c48a675caad2bce41588c58a44acfd4..555a470d7f33eb4811c153cbc0361fa53d2c902d 100644 (file)
@@ -1,6 +1,21 @@
 /**
  * @file task.h
  * Provides multitasking functionality
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef TASK_H_
 
 #include <stdint.h>
 
+/**
+ * A structure to contain task data.
+ */
 typedef struct {
-       void *next;
-       uint32_t *stack;
-       uint32_t *sp;
+       void *next;      /**< pointer to the next task_t instance */
+       uint32_t *stack; /**< pointer to the task's stack */
+       uint32_t *sp;    /**< pointer to the task's last sp register value */
 } task_t;
 
 /**
diff --git a/initrd/init2 b/initrd/init2
deleted file mode 100644 (file)
index 47dbae1..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-do
-       getkey > input
-       print input
-       delay 1000
-while (1)
-
-#do
-#      getkey > input
-#      if (input & 4)
-#              rand 479 > x
-#              rand 319 > y
-#              rand 479 > i
-#              rand 319 > j
-#              rand 32767 > purple
-#              
-#              line x y i j purple
-#      end
-#while (1)
-#
-#print "done"
-
diff --git a/initrd/init3 b/initrd/init3
deleted file mode 100644 (file)
index 4351743..0000000
+++ /dev/null
@@ -1 +0,0 @@
-print "Hello, world!"
diff --git a/initrd/keys b/initrd/keys
new file mode 100644 (file)
index 0000000..47dbae1
--- /dev/null
@@ -0,0 +1,21 @@
+do
+       getkey > input
+       print input
+       delay 1000
+while (1)
+
+#do
+#      getkey > input
+#      if (input & 4)
+#              rand 479 > x
+#              rand 319 > y
+#              rand 479 > i
+#              rand 319 > j
+#              rand 32767 > purple
+#              
+#              line x y i j purple
+#      end
+#while (1)
+#
+#print "done"
+
diff --git a/initrd/lines b/initrd/lines
new file mode 100644 (file)
index 0000000..f6b2a82
--- /dev/null
@@ -0,0 +1,29 @@
+print("Hello.\n")
+
+fg = 32767
+
+# draw bg, lines
+rect(50, 50, 380, 220, 6375)
+line(50, 160, 430, 160, fg)
+line(240, 50, 240, 270, fg)
+
+x = 50
+while (x <= 430) {
+       line(x, 170, x, 150, fg)
+       x = x + 20
+}
+
+y = 50
+while (y <= 270) {
+       line(230, y, 250, y, fg)
+       y = y + 20
+}
+
+while (1) {
+       x = rand(379) + 50
+       y = rand(219) + 50
+       i = 50 + rand(379)
+       j = 50 + rand(219)
+
+       line(x, y, i, j, 511)
+}
index 08b52ec23cbc7f0e5e674450c45c3f684d5dd819..123d9f418c141931bf4de8feec44f22e84b421e5 100644 (file)
Binary files a/libinterp.a and b/libinterp.a differ
diff --git a/link.ld b/link.ld
index 4819a3cbf17289e6484edd271b5986d90f641df7..be1c5236340034df4d3082ed52ca161bb74b5660 100644 (file)
--- a/link.ld
+++ b/link.ld
-/*\r
-*****************************************************************************\r
-**\r
-\r
-**  File        : LinkerScript.ld\r
-**\r
-**  Abstract    : Linker script for STM32L476RGTx Device with\r
-**                1024KByte FLASH, 96KByte RAM\r
-**\r
-**                Set heap size, stack size and stack location according\r
-**                to application requirements.\r
-**\r
-**                Set memory bank area and size if external memory is used.\r
-**\r
-**  Target      : STMicroelectronics STM32\r
-**\r
-**\r
-**  Distribution: The file is distributed as is, without any warranty\r
-**                of any kind.\r
-**\r
-**  (c)Copyright Ac6.\r
-**  You may use this file as-is or modify it according to the needs of your\r
-**  project. Distribution of this file (unmodified or modified) is not\r
-**  permitted. Ac6 permit registered System Workbench for MCU users the\r
-**  rights to distribute the assembled, compiled & linked contents of this\r
-**  file as part of an application binary file, provided that it is built\r
-**  using the System Workbench for MCU toolchain.\r
-**\r
-*****************************************************************************\r
-*/\r
-\r
-/* Entry Point */\r
-ENTRY(Reset_Handler)\r
-\r
-/* Highest address of the user mode stack */\r
-_estack = 0x20018000;    /* end of RAM */\r
-\r
-/* Specify the memory areas */\r
-MEMORY\r
-{\r
-       FLASH (rx)      : ORIGIN = 0x8000000,   LENGTH = 1024K\r
-       RAM   (xrw)     : ORIGIN = 0x20000000,  LENGTH = 96K\r
-}\r
-\r
-/* Define output sections */\r
-SECTIONS\r
-{\r
-  /* The startup code goes first into FLASH */\r
-  .isr_vector :\r
-  {\r
-    . = ALIGN(8);\r
-    KEEP(*(.isr_vector)) /* Startup code */\r
-    . = ALIGN(8);\r
-  } >FLASH\r
-\r
-  /* The program code and other data goes into FLASH */\r
-  .text :\r
-  {\r
-    . = ALIGN(8);\r
-    *(.text)           /* .text sections (code) */\r
-    *(.text*)          /* .text* sections (code) */\r
-    *(.glue_7)         /* glue arm to thumb code */\r
-    *(.glue_7t)        /* glue thumb to arm code */\r
-    *(.eh_frame)\r
-\r
-    KEEP (*(.init))\r
-    KEEP (*(.fini))\r
-\r
-    . = ALIGN(8);\r
-    _etext = .;        /* define a global symbols at end of code */\r
-  } >FLASH\r
-\r
-  /* Constant data goes into FLASH */\r
-  .rodata :\r
-  {\r
-    . = ALIGN(8);\r
-    *(.rodata)         /* .rodata sections (constants, strings, etc.) */\r
-    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */\r
-    . = ALIGN(8);\r
-  } >FLASH\r
-\r
-  .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH\r
-  .ARM : {\r
-    __exidx_start = .;\r
-    *(.ARM.exidx*)\r
-    __exidx_end = .;\r
-  } >FLASH\r
-\r
-  .preinit_array :\r
-  {\r
-    PROVIDE_HIDDEN (__preinit_array_start = .);\r
-    KEEP (*(.preinit_array*))\r
-    PROVIDE_HIDDEN (__preinit_array_end = .);\r
-  } >FLASH\r
-  .init_array :\r
-  {\r
-    PROVIDE_HIDDEN (__init_array_start = .);\r
-    KEEP (*(SORT(.init_array.*)))\r
-    KEEP (*(.init_array*))\r
-    PROVIDE_HIDDEN (__init_array_end = .);\r
-  } >FLASH\r
-  .fini_array :\r
-  {\r
-    PROVIDE_HIDDEN (__fini_array_start = .);\r
-    KEEP (*(SORT(.fini_array.*)))\r
-    KEEP (*(.fini_array*))\r
-    PROVIDE_HIDDEN (__fini_array_end = .);\r
-  } >FLASH\r
-\r
-  /* used by the startup to initialize data */\r
-  _sidata = LOADADDR(.data);\r
-\r
-  /* Initialized data sections goes into RAM, load LMA copy after code */\r
-  .data : \r
-  {\r
-    . = ALIGN(8);\r
-    _sdata = .;        /* create a global symbol at data start */\r
-    *(.data)           /* .data sections */\r
-    *(.data*)          /* .data* sections */\r
-\r
-    . = ALIGN(8);\r
-    _edata = .;        /* define a global symbol at data end */\r
-  } >RAM AT> FLASH\r
-\r
-  \r
-  /* Uninitialized data section */\r
-  . = ALIGN(4);\r
-  .bss :\r
-  {\r
-    /* This is used by the startup in order to initialize the .bss secion */\r
-    _sbss = .;         /* define a global symbol at bss start */\r
-    __bss_start__ = _sbss;\r
-    *(.bss)\r
-    *(.bss*)\r
-    *(COMMON)\r
-\r
-    . = ALIGN(4);\r
-    _ebss = .;         /* define a global symbol at bss end */\r
-    __bss_end__ = _ebss;\r
-  } >RAM\r
-\r
-  /* User_heap_stack section, used to check that there is enough RAM left */\r
-  ._user_heap_stack :\r
-  {\r
-    . = ALIGN(8);\r
-    *(._user_heap_stack)\r
-    . = ALIGN(8);\r
-  } >RAM\r
-\r
-  \r
-\r
-  /* Remove information from the standard libraries */\r
-  /DISCARD/ :\r
-  {\r
-    libc.a ( * )\r
-    libm.a ( * )\r
-    libgcc.a ( * )\r
-  }\r
-\r
-  .ARM.attributes 0 : { *(.ARM.attributes) }\r
-}\r
-\r
+/**
+ * @file linker.ld
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+/* enter at the reset handler */
+ENTRY(Reset_Handler)
+
+/* description of memory regions */
+MEMORY {
+       FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
+       RAM (rwx)  : ORIGIN = 0x20000000,  LENGTH = 96K
+}
+
+/* description of ELF sections */
+SECTIONS {
+       /* keep startup code at beginning */
+       .isr_vector : {
+               . = ALIGN(8);
+               KEEP(*(.isr_vector))
+               . = ALIGN(8);
+       } > FLASH
+
+       /* code sections */
+       .text : {
+               . = ALIGN(8);
+               *(.text)
+               . = ALIGN(8);
+       } > FLASH
+
+       /* readonly data */
+       .rodata : {
+               . = ALIGN(8);
+               *(.rodata)
+               . = ALIGN(8);
+       } > FLASH
+
+       /* init_array/fini_array (TODO understand this) */
+       .init_array : {
+               PROVIDE_HIDDEN(__init_array_start = .);
+               KEEP(*(.init_array))
+               PROVIDE_HIDDEN(__init_array_end = .);
+       } > FLASH
+
+       .fini_array : {
+               PROVIDE_HIDDEN(__fini_array_start = .);
+               KEEP(*(.fini_array))
+               PROVIDE_HIDDEN(__fini_array_end = .);
+       } > FLASH
+
+       /* initialized data */
+       _sidata = LOADADDR(.data);
+       .data : {
+               . = ALIGN(8);
+               _sdata = .;
+               *(.data)
+               . = ALIGN(8);
+               _edata = .;
+       } > RAM AT > FLASH
+
+       /* uninitialized data */
+       .bss : {
+               . = ALIGN(8);
+               __bss_start__ = .;
+               *(.bss)
+               __bss_end__ = .;
+       } > RAM
+}
diff --git a/run.sh b/run.sh
index f628d56ee02880936dd51501d0b143f70f3e8a33..79b7c7e9934758c8625a2398712331785ca9da84 100755 (executable)
--- a/run.sh
+++ b/run.sh
@@ -1,4 +1,23 @@
 #!/bin/bash
+#
+# @file run.sh
+# Starts openocd and connects gdb to the target, for programming/debugging
+#
+# Copyright (C) 2018 Clyne Sullivan
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+#
 
 openocd -f /usr/share/openocd/scripts/board/st_nucleo_l476rg.cfg > /dev/null &
 gdb-multiarch -iex "target remote localhost:3333" out/main.elf
index 0c8ca7cdf92e2cb68c16d4de99593df82aeba528..284573c94879809c46719496826ab30ef4ae163c 100644 (file)
@@ -1,3 +1,23 @@
+/**
+ * @file clock.c
+ * Basic clock utilities
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #include <clock.h>
 #include <stm32l476xx.h>
 
index 163a742503ae21df5c21e43638ca21cfb3e8deb3..e9612999010ac5e906dd1fb6db5ebe1b92e8d0ea 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * @file display.c
+ * Display library for ILI9481 display
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #include <display.h>
 
 #include <clock.h>
index f58dda77b5aa3d66277194b66b3c4c802e7130e7..269f76ce0a059172c8083786cae19528e02e77d3 100644 (file)
@@ -1,3 +1,23 @@
+/**
+ * @file display_draw.c
+ * Provides functions for drawing to the display
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #include <display_draw.h>
 #include <display.h>
 #include <task.h>
@@ -41,6 +61,7 @@ void dsp_putchar(int c)
                        dsp_rect(0, 0, LCD_WIDTH, LCD_HEIGHT, 0);
                        cury = 0;
                }
+               UNLOCK;
                return;
        } else if (c == '\b') {
                if (curx > 0)
index 6b3ee0043a638f637900be85ae523513f9bb761b..e3de42000a35691d3621740b72ab2b33abf38848 100644 (file)
@@ -1,3 +1,23 @@
+/**
+ * @file flash.c
+ * Provides functionality for using an external SPI flash 
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #include <stm32l476xx.h>
 #include <gpio.h>
 #include <clock.h>
diff --git a/src/flash.c.bak b/src/flash.c.bak
new file mode 100644 (file)
index 0000000..037eeae
--- /dev/null
@@ -0,0 +1,110 @@
+#include <stm32l476xx.h>
+#include <gpio.h>
+#include <clock.h>
+
+#define READ  0x03
+#define WRITE 0x02
+#define WREN  0x06
+#define WRDS  0x04
+
+#define SCK GPIO_PORT(C, 9)
+#define SI  GPIO_PORT(B, 8)
+#define SO  GPIO_PORT(B, 9)
+#define CS  GPIO_PORT(C, 4)
+
+void flash_out(uint8_t);
+uint8_t flash_in(void);
+
+void flash_init(void)
+{
+       gpio_mode(SCK, OUTPUT);
+       gpio_mode(SI, OUTPUT);
+       gpio_mode(CS, OUTPUT);
+       gpio_mode(SO, OUTPUT);
+       gpio_dout(SO, 0);
+       gpio_mode(SO, INPUT);
+       gpio_dout(CS, 1);
+       gpio_dout(SCK, 0);
+       gpio_dout(SI, 0);
+
+       //RCC->AHB3ENR |= RCC_AHB3ENR_QSPIEN;
+
+       //// 10MHz operation, per datasheet
+       //QUADSPI->CR &= ~(0xFF << QUADSPI_CR_PRESCALER_Pos);
+       //QUADSPI->CR |= 7 << QUADSPI_CR_PRESCALER_Pos;
+
+       //// pick FSEL! 0=1, 1=2
+
+       //// FSIZE = 16, 2^17 bits = 1Mb
+       //QUADSPI->DCR = (16 << QUADSPI_DCR_FSIZE_Pos);
+
+       //// Memmap mode, single-spi
+       //QUADSPI->CCR = (3 << QUADSPI_CCR_FMODE_Pos) | (1 << QUADSPI_CCR_DMODE_Pos)
+       //      | (2 << QUADSPI_CCR_ADSIZE_Pos) | (1 << QUADSPI_CCR_ADMODE_Pos)
+       //      | (1 << QUADSPI_CCR_IMODE_Pos);
+       //// TODO CCR also takes instruction byte
+       //QUADSPI->CCR |= (READ << QUADSPI_CCR_INSTRUCTION_Pos);
+
+       //QUADSPI->CR |= QUADSPI_CR_EN;
+}
+
+void flash_out(uint8_t byte)
+{
+       for (uint8_t i = 0; i < 8; i++) {
+               gpio_dout(SI, (byte & (1 << (7 - i))));
+               gpio_dout(SCK, 1);
+               gpio_dout(SCK, 0);
+       }
+}
+
+void flash_addr(uint32_t addr)
+{
+       for (uint8_t i = 0; i < 24; i++) {
+               gpio_dout(SI, (addr & (1 << (23 - i))));
+               gpio_dout(SCK, 1);
+               gpio_dout(SCK, 0);
+       }
+}
+
+uint8_t flash_in(void)
+{
+       uint8_t byte = 0;
+       for (uint8_t i = 0; i < 8; i++) {
+               gpio_dout(SCK, 1);
+               gpio_dout(SCK, 0);
+               if (gpio_din(SO))
+                       byte |= (1 << (7 - i));
+       }
+       return byte;
+}
+
+void flash_read(char *buf, uint32_t addr, unsigned int count)
+{
+       if (buf == 0)
+               return;
+       gpio_dout(CS, 0);
+       flash_out(READ);
+       flash_addr(addr);
+       for (unsigned int i = 0; i < count; i++)
+               buf[i] = flash_in();
+       gpio_dout(CS, 1);
+}
+
+void flash_write(const char *buf, uint32_t addr, unsigned int count)
+{
+       if (buf == 0)
+               return;
+       gpio_dout(CS, 0);
+       flash_out(WREN);
+       gpio_dout(CS, 1);
+       gpio_dout(CS, 0);
+       flash_out(WRITE);
+       flash_addr(addr);
+       for (unsigned int i = 0; i < count; i++)
+               flash_out(buf[i]);
+       gpio_dout(CS, 1);
+       delay(100);
+       //gpio_dout(CS, 0);
+       //flash_out(WRDS);
+       //gpio_dout(CS, 1);
+}
index 900a3f1c1f80ca84fcb5b14daa9cc2db8058fd56..2e50e8826846da6ce158439d15a45b1220c5b5f2 100644 (file)
@@ -1,3 +1,23 @@
+/**
+ * @file gpio.c
+ * Abstracts gpio access, makes things easier
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #include <gpio.h>
 
 void gpio_init(void)
index 9a11cba271f9b25fffb71e523f2734349ba77179..c2293fa14e3e83b3394148bb3c9c1d4ef3e4d1cc 100644 (file)
@@ -1,3 +1,23 @@
+/**
+ * @file heap.c
+ * A basic memory manager
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #include <heap.h>
 
 #define HEAP_ALIGN 4
index 948811fb44db4a757680085237b9b6a369b3ae1c..37e3764f778917107dc045022b90e37a5edffc05 100644 (file)
@@ -1,3 +1,26 @@
+/**
+ * @file initrd.c
+ * Initrd image support
+ * An archive file (made with ar) can be linked into the final executable to
+ * allow files to be loaded in memory on boot. See mkinitrd.sh or the Makefile
+ * for more info.
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #include <initrd.h>
 
 extern uint8_t _binary_initrd_img_start[];
index 06e0b6a33ebeb172e36bc95601908ad6ad371e16..fad774a895c99907be3cb3fe01affdfa44ea55b5 100644 (file)
@@ -1,3 +1,23 @@
+/**
+ * @file keypad.c
+ * Manages the GPIO keypad
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #include <keypad.h>
 #include <gpio.h>
 
index f25d46fb6fcbba21c6940067b99c741bcb3b1c84..2fbefff0cd2779ffe547d8552dfee65ea55eaed1 100644 (file)
@@ -1,3 +1,23 @@
+/**
+ * @file keypad.c
+ * Manages the GPIO keypad using IO expanders
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #include <stm32l476xx.h>
 #include <gpio.h>
 
index a2a8ca79cc15a728347b990605fe5ad84a20eec4..8229041d2f77f9a326c0ffe3ab25e1a9d52becbc 100644 (file)
@@ -1,3 +1,23 @@
+/**
+ * @file lcd.c
+ * A basic library for writing a 16x2 text LCD.
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #include <lcd.h>
 #include <clock.h>
 #include <gpio.h>
index fc64edd30bd619dea10ba1b201efca6ffd210c80..98441996a8b8b32729460b0c0c1797cb893b43fa 100644 (file)
@@ -1,3 +1,23 @@
+/**\r
+ * @file main.c\r
+ * Entry point for operating system\r
+ *\r
+ * Copyright (C) 2018 Clyne Sullivan\r
+ *\r
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.\r
+ */\r
+\r
 #include <stm32l476xx.h>\r
 #include <clock.h>\r
 #include <heap.h>\r
@@ -15,7 +35,7 @@
 #include <keypad.h>\r
 #include <flash.h>\r
 \r
-extern uint8_t _ebss;\r
+extern uint8_t __bss_end__;\r
 extern char *itoa(int, char *, int);\r
 \r
 void kmain(void);\r
@@ -32,7 +52,7 @@ int main(void)
        FLASH->ACR |= FLASH_ACR_LATENCY_4WS;\r
 \r
        clock_init();\r
-       heap_init(&_ebss);\r
+       heap_init(&__bss_end__);\r
        gpio_init();\r
        keypad_init();\r
        serial_init();\r
index 9c1e0d1321e79b07396fd581e3c63d73aa2f9c21..002b86297d8b672d5734e82bb30c6d578f2b0780 100644 (file)
@@ -1,3 +1,23 @@
+/**
+ * @file random.c
+ * Provides true random number generation functionality
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #include <random.h>
 
 #include <stm32l476xx.h>
index b69b02367b05ac85889ac4854dfde9b5ab996ed7..be0fa3769e63799f0fead5ef2b225c99d6269ea7 100644 (file)
@@ -1,3 +1,23 @@
+/**
+ * @file script.c
+ * Provides script library for using calculator hardware
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #include <script.h>
 
 #include <builtins.h>
@@ -24,19 +44,41 @@ int script_color(instance *it);
 int script_rand(instance *it);
 int script_getkey(instance *it);
 int script_pixel(instance *it);
+int script_menu(instance *it);
 
 void script_loadlib(instance *it)
 {
        inew_cfunc(it, "print", script_puts);
        inew_cfunc(it, "gets", script_gets);
-       inew_cfunc(it, "delay", script_delay);
-       inew_cfunc(it, "rect", script_rect);
+       inew_cfunc(it, "getkey", script_getkey);
        inew_cfunc(it, "ppos", script_ppos);
+
+       inew_cfunc(it, "pixel", script_pixel);
        inew_cfunc(it, "line", script_line);
+       inew_cfunc(it, "rect", script_rect);
        inew_cfunc(it, "color", script_color);
+
        inew_cfunc(it, "rand", script_rand);
-       inew_cfunc(it, "getkey", script_getkey);
-       inew_cfunc(it, "pixel", script_pixel);
+       inew_cfunc(it, "delay", script_delay);
+
+       inew_cfunc(it, "menu", script_menu);
+}
+
+int script_menu(instance *it)
+{
+       char listbuf[4];
+       int nargs = igetarg_integer(it, 0);
+       float *resps = (float *)calloc(nargs, sizeof(float));
+       strncpy(listbuf, " : \0", 4);
+       for (int i = 0; i < nargs; i++) {
+               listbuf[0] = i + '0';
+               dsp_puts(listbuf);
+               dsp_puts((char *)igetarg(it, 1 + i * 2)->value.p);
+               dsp_puts("\n");
+               resps[i] = igetarg(it, 2 + i * 2)->value.f;
+       }
+       free(resps);
+       return 0;
 }
 
 int script_puts(instance *it)
@@ -125,7 +167,7 @@ int script_rand(instance *it)
 {
        unsigned int mod = igetarg_integer(it, 0);
        unsigned int val = random_get();
-       variable *v = make_varf(0, (float)(mod % val));
+       variable *v = make_varf(0, (float)(val % mod));
        ipush(it, (uint32_t)v);
        return 0;
 }
index de28275b1a423841fdd7e0544dd91ba73b95f46a..31c7744074c124c6f66c64aa9c71fcb0131e87d1 100644 (file)
@@ -1,3 +1,23 @@
+/**
+ * @file serial.c
+ * Provides basic serial IO (through STM debug stuff)
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #include <stm32l476xx.h>
 #include <gpio.h>
 #include <clock.h>
index f7e18a4a111f7d477704c684bf478a127063123b..b26ced5cf1aacc3fc917be2c2af05f8d80f9f661 100644 (file)
@@ -57,10 +57,8 @@ defined in linker script */
 .word  _sdata\r
 /* end address for the .data section. defined in linker script */\r
 .word  _edata\r
-/* start address for the .bss section. defined in linker script */\r
-.word  _sbss\r
-/* end address for the .bss section. defined in linker script */\r
-.word  _ebss\r
+\r
+.equ _estack, 0x20018000\r
 \r
 .equ  BootRAM,        0xF1E0F85F\r
 /**\r
@@ -94,7 +92,7 @@ LoopCopyDataInit:
        adds    r2, r0, r1\r
        cmp     r2, r3\r
        bcc     CopyDataInit\r
-       ldr     r2, =_sbss\r
+       ldr     r2, =__bss_start__\r
        b       LoopFillZerobss\r
 /* Zero fill the bss segment. */\r
 FillZerobss:\r
@@ -102,7 +100,7 @@ FillZerobss:
        str     r3, [r2], #4\r
 \r
 LoopFillZerobss:\r
-       ldr     r3, = _ebss\r
+       ldr     r3, = __bss_end__\r
        cmp     r2, r3\r
        bcc     FillZerobss\r
 \r
index e34d2a0f5e2b69898ac0a0745e2ef5136f37ce9c..f5f9cc8e34d7eda887b1c120635a995578f81db5 100644 (file)
@@ -1,3 +1,25 @@
+/**
+ * @file stdlib.c
+ * Provides missing C standard library functions
+ * The newlib versions of these calls are not being used due to dependence on
+ * unsupported system calls.
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #include <stdlib.h>
 
 #include <ctype.h>
index 537785d2c444a7d63168251ac5d29fd3e2775544..9e99ab65c06e3f7d90b8144dbda13fc4382eddae 100644 (file)
@@ -1,3 +1,23 @@
+/**
+ * @file task.c
+ * Provides multitasking functionality
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
 #include <task.h>
 #include <heap.h>
 #include <stm32l476xx.h>
diff --git a/xinitrd/init b/xinitrd/init
deleted file mode 100644 (file)
index 4fd74dd..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-print "Hello."
-
-set fg 32767
-
-# draw bg, lines
-rect 50 50 380 220 6375
-line 50 160 430 160 fg
-line 240 50 240 270 fg
-
-set x 50
-do
-       line x 170 x 150 fg
-       set x (x + 20)
-while (x < 431)
-
-set y 50
-do
-       line 230 y 250 y fg
-       set y (y + 20)
-while (y < 271)
-
-do
-       rand 379 > x
-       rand 219 > y
-       rand 379 > i
-       rand 219 > j
-       set x (x + 50)
-       set y (y + 50)
-       set i (i + 50)
-       set j (j + 50)
-
-       line x y i j 511
-while (1)
diff --git a/xinitrd/init2 b/xinitrd/init2
deleted file mode 100644 (file)
index 47dbae1..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-do
-       getkey > input
-       print input
-       delay 1000
-while (1)
-
-#do
-#      getkey > input
-#      if (input & 4)
-#              rand 479 > x
-#              rand 319 > y
-#              rand 479 > i
-#              rand 319 > j
-#              rand 32767 > purple
-#              
-#              line x y i j purple
-#      end
-#while (1)
-#
-#print "done"
-