diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/clock.h | 9 | ||||
-rw-r--r-- | include/display.h | 6 | ||||
-rw-r--r-- | include/display_draw.h | 6 | ||||
-rw-r--r-- | include/heap.h | 10 | ||||
-rw-r--r-- | include/initrd.h | 40 | ||||
-rw-r--r-- | include/lcd.h | 50 | ||||
-rw-r--r-- | include/serial.h | 23 | ||||
-rw-r--r-- | include/task.h | 15 |
8 files changed, 143 insertions, 16 deletions
diff --git a/include/clock.h b/include/clock.h index 9d4b17a..77ab7e9 100644 --- a/include/clock.h +++ b/include/clock.h @@ -1,3 +1,8 @@ +/** + * @file clock.h + * Basic clock utilities + */ + #ifndef CLOCK_H_ #define CLOCK_H_ @@ -5,11 +10,13 @@ /** * Sets HCLK (system clock) to 80MHz, the maximum. + * @param none */ extern void clock_init(void); /** - * Sleeps for given milliseconds. + * Sleeps for given amount of milliseconds. + * @param ms number of milliseconds to sleep for */ void delay(uint32_t ms); diff --git a/include/display.h b/include/display.h index fb808c6..6004f19 100644 --- a/include/display.h +++ b/include/display.h @@ -9,9 +9,15 @@ #define COLOR_MAX 31 uint16_t dsp_color(uint8_t r, uint8_t g, uint8_t b); + +void dsp_dmode(int mode); void dsp_write_cmd(uint8_t data); void dsp_write_data(uint8_t data); +uint8_t dsp_read_data(void); + 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); #endif // DISPLAY_H_ diff --git a/include/display_draw.h b/include/display_draw.h index 1030d45..5ed4224 100644 --- a/include/display_draw.h +++ b/include/display_draw.h @@ -1,9 +1,15 @@ #ifndef DISPLAY_DRAW_H_ #define DISPLAY_DRAW_H_ +#include <stdint.h> + +void dsp_cursoron(void); + +void dsp_line(int x, int y, int i, int j, uint16_t color); void dsp_rect(int x, int y, int w, int h, uint16_t color); void dsp_cpos(int x, int y); +void dsp_coff(int x, int y); void dsp_puts(const char *s); #endif // DISPLAY_DRAW_H_ diff --git a/include/heap.h b/include/heap.h index 9625771..c93eb8e 100644 --- a/include/heap.h +++ b/include/heap.h @@ -1,12 +1,12 @@ #ifndef HEAP_H_ #define HEAP_H_ -//#include <stdint.h> +#include <stdint.h> -//uint32_t heap_available(void); +void heap_init(void *buf); -//void *malloc(uint32_t size); -//void *calloc(uint32_t count, uint32_t size); -//void free(void *buf); +void *malloc(uint32_t size); +void *calloc(uint32_t count, uint32_t size); +void free(void *buf); #endif // HEAP_H_ diff --git a/include/initrd.h b/include/initrd.h index 9c7a9de..de730f2 100644 --- a/include/initrd.h +++ b/include/initrd.h @@ -1,23 +1,53 @@ +/** + * @file initrd.h + * 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. + */ + #ifndef INITRD_H_ #define INITRD_H_ #include <stdint.h> +/** + * Structure for the archive's header. + */ typedef struct { - char signature[8]; + char signature[8]; /**< The archive's signature. */ } __attribute__ ((packed)) initrd_header; +/** + * Structure for a file entry in the archive. + */ typedef struct { - char name[16]; - uint8_t unused[32]; - char size[10]; - char sig[2]; + 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; +/** + * Confirms the initrd image is loaded and valid. + * @return non-zero if valid image found + */ uint8_t initrd_validate(void); + +/** + * Gets contents of the given file. + * @param name the file's name + * @return pointer to file data, null if not found + */ char *initrd_getfile(const char *name); + +/** + * Gets the size of the given file. + * @param name the file's name + * @return the file's size, in bytes + */ uint32_t initrd_getfilesize(const char *name); #endif // INITRD_H_ diff --git a/include/lcd.h b/include/lcd.h index 441d463..378aac4 100644 --- a/include/lcd.h +++ b/include/lcd.h @@ -1,23 +1,63 @@ +/** + * @file lcd.h + * A basic library for writing a 16x2 text LCD. + */ + #ifndef LCD_H_ #define LCD_H_ #include <stdint.h> /** - * Direct access + * A handler/task to manage asyncronous LCD writes. + */ +void lcd_handler(void); + +/** + * Writes a string asyncronously to the LCD. + * The lcd_handler task must be running for the string to actually be printed. + * @param s the string to write + */ +void lcd_put(const char *s); + +// +// The following functions do not support asyncronous calls. +// + +/** + * Initializes the LCD. */ void lcd_init(void); +/** + * Writes a string to the LCD. + * A cursor position is kept internally. When the end of the screen is reached, + * writing resumes at the first position. + * @param s the string to write + */ void lcd_puts(const char *s); + +/** + * Writes a base 10 integer to the screen. + * @param i the integer to print + */ void lcd_puti(int i); + +/** + * Writes a base 16 integer to the screen. + * @param h the integer to print + */ void lcd_puth(int h); + +/** + * Writes a byte in binary to the screen. + * @param b the byte to print + */ void lcd_putb(uint8_t b); -void lcd_clear(void); /** - * Buffered/async access + * Clears the LCD. */ -void lcd_handler(void); -void lcd_put(const char *s); +void lcd_clear(void); #endif // LCD_H_ diff --git a/include/serial.h b/include/serial.h index 9cb9d24..7192e17 100644 --- a/include/serial.h +++ b/include/serial.h @@ -1,10 +1,33 @@ +/** + * @file serial.h + * Provides basic serial IO (through STM debug stuff) + */ + #ifndef SERIAL_H_ #define SERIAL_H_ +/** + * Initializes the serial device. + */ void serial_init(void); + +/** + * Puts the given character through serial. + * @param c the character to send + */ void serial_put(int c); +/** + * Gets a character from serial. + * @return the character + */ char serial_get(void); + +/** + * Gets a string from serial, cut off by a newline. + * @param buf the initialized buffer to fill + * @param max the max amount of bytes to write to the buffer + */ void serial_gets(char *buf, int max); #endif // SERIAL_H_ diff --git a/include/task.h b/include/task.h index c57b2c0..eda2dcd 100644 --- a/include/task.h +++ b/include/task.h @@ -1,10 +1,25 @@ +/** + * @file task.h + * Provides multitasking functionality + */ + #ifndef TASK_H_ #define TASK_H_ #include <stdint.h> +/** + * Enters multitasking mode. The given function acts as the initial thread. + * This task is given a 4kb stack. + * @param init the initial thread to run + */ void task_init(void (*init)(void)); +/** + * Starts a new task. + * @param task the code to run + * @param stackSize how many bytes of stack to give the thread + */ void task_start(void (*task)(void), uint16_t stackSize); #endif // TASK_H_ |