diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/clock.h | 17 | ||||
-rw-r--r-- | include/display.h | 41 | ||||
-rw-r--r-- | include/display_draw.h | 15 | ||||
-rw-r--r-- | include/flash.h | 38 | ||||
-rw-r--r-- | include/gpio.h | 15 | ||||
-rw-r--r-- | include/heap.h | 15 | ||||
-rw-r--r-- | include/initrd.h | 25 | ||||
-rw-r--r-- | include/keypad.h | 32 | ||||
-rw-r--r-- | include/lcd.h | 15 | ||||
-rw-r--r-- | include/random.h | 15 | ||||
-rw-r--r-- | include/script.h | 17 | ||||
-rw-r--r-- | include/serial.h | 15 | ||||
-rw-r--r-- | include/stdlib.h | 43 | ||||
-rw-r--r-- | include/task.h | 24 |
14 files changed, 314 insertions, 13 deletions
diff --git a/include/clock.h b/include/clock.h index c12c41e..7446dd1 100644 --- a/include/clock.h +++ b/include/clock.h @@ -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); diff --git a/include/display.h b/include/display.h index 55f6974..b8afe38 100644 --- a/include/display.h +++ b/include/display.h @@ -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_ @@ -19,6 +34,11 @@ #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. * @param r red value, 0-255 @@ -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_ diff --git a/include/display_draw.h b/include/display_draw.h index 9d86437..8db3e2c 100644 --- a/include/display_draw.h +++ b/include/display_draw.h @@ -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_ diff --git a/include/flash.h b/include/flash.h index 26fffd3..47daf8e 100644 --- a/include/flash.h +++ b/include/flash.h @@ -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_ diff --git a/include/gpio.h b/include/gpio.h index 46a8e15..58ebaa7 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -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_ diff --git a/include/heap.h b/include/heap.h index e8cd9c1..593ce09 100644 --- a/include/heap.h +++ b/include/heap.h @@ -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_ diff --git a/include/initrd.h b/include/initrd.h index de730f2..7bc34bb 100644 --- a/include/initrd.h +++ b/include/initrd.h @@ -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; /** diff --git a/include/keypad.h b/include/keypad.h index 5eec1fc..2e5fa9c 100644 --- a/include/keypad.h +++ b/include/keypad.h @@ -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_ @@ -16,9 +36,21 @@ #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_ diff --git a/include/lcd.h b/include/lcd.h index 378aac4..c13ff97 100644 --- a/include/lcd.h +++ b/include/lcd.h @@ -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_ diff --git a/include/random.h b/include/random.h index a1868f6..efb3726 100644 --- a/include/random.h +++ b/include/random.h @@ -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_ diff --git a/include/script.h b/include/script.h index ab5fa7e..971cccf 100644 --- a/include/script.h +++ b/include/script.h @@ -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); diff --git a/include/serial.h b/include/serial.h index 7192e17..b943c33 100644 --- a/include/serial.h +++ b/include/serial.h @@ -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_ diff --git a/include/stdlib.h b/include/stdlib.h index c2658d6..ada39cd 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -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_ diff --git a/include/task.h b/include/task.h index 6456bdc..555a470 100644 --- a/include/task.h +++ b/include/task.h @@ -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_ @@ -8,10 +23,13 @@ #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; /** |