diff options
Diffstat (limited to 'VexRiscvSocSoftware/libs')
-rwxr-xr-x | VexRiscvSocSoftware/libs/gpio.h | 15 | ||||
-rw-r--r-- | VexRiscvSocSoftware/libs/interrupt.h | 17 | ||||
-rw-r--r-- | VexRiscvSocSoftware/libs/prescaler.h | 16 | ||||
-rw-r--r-- | VexRiscvSocSoftware/libs/timer.h | 20 | ||||
-rwxr-xr-x | VexRiscvSocSoftware/libs/uart.h | 42 | ||||
-rw-r--r-- | VexRiscvSocSoftware/libs/vga.h | 78 |
6 files changed, 188 insertions, 0 deletions
diff --git a/VexRiscvSocSoftware/libs/gpio.h b/VexRiscvSocSoftware/libs/gpio.h new file mode 100755 index 0000000..34348fe --- /dev/null +++ b/VexRiscvSocSoftware/libs/gpio.h @@ -0,0 +1,15 @@ +#ifndef GPIO_H_ +#define GPIO_H_ + + +typedef struct +{ + volatile uint32_t INPUT; + volatile uint32_t OUTPUT; + volatile uint32_t OUTPUT_ENABLE; +} Gpio_Reg; + + +#endif /* GPIO_H_ */ + + diff --git a/VexRiscvSocSoftware/libs/interrupt.h b/VexRiscvSocSoftware/libs/interrupt.h new file mode 100644 index 0000000..23b7d27 --- /dev/null +++ b/VexRiscvSocSoftware/libs/interrupt.h @@ -0,0 +1,17 @@ +#ifndef INTERRUPTCTRL_H_ +#define INTERRUPTCTRL_H_ + +#include <stdint.h> + +typedef struct +{ + volatile uint32_t PENDINGS; + volatile uint32_t MASKS; +} InterruptCtrl_Reg; + +static void interruptCtrl_init(InterruptCtrl_Reg* reg){ + reg->MASKS = 0; + reg->PENDINGS = 0xFFFFFFFF; +} + +#endif /* INTERRUPTCTRL_H_ */ diff --git a/VexRiscvSocSoftware/libs/prescaler.h b/VexRiscvSocSoftware/libs/prescaler.h new file mode 100644 index 0000000..6bd9694 --- /dev/null +++ b/VexRiscvSocSoftware/libs/prescaler.h @@ -0,0 +1,16 @@ +#ifndef PRESCALERCTRL_H_ +#define PRESCALERCTRL_H_ + +#include <stdint.h> + + +typedef struct +{ + volatile uint32_t LIMIT; +} Prescaler_Reg; + +static void prescaler_init(Prescaler_Reg* reg){ + +} + +#endif /* PRESCALERCTRL_H_ */ diff --git a/VexRiscvSocSoftware/libs/timer.h b/VexRiscvSocSoftware/libs/timer.h new file mode 100644 index 0000000..1577535 --- /dev/null +++ b/VexRiscvSocSoftware/libs/timer.h @@ -0,0 +1,20 @@ +#ifndef TIMERCTRL_H_ +#define TIMERCTRL_H_ + +#include <stdint.h> + + +typedef struct +{ + volatile uint32_t CLEARS_TICKS; + volatile uint32_t LIMIT; + volatile uint32_t VALUE; +} Timer_Reg; + +static void timer_init(Timer_Reg *reg){ + reg->CLEARS_TICKS = 0; + reg->VALUE = 0; +} + + +#endif /* TIMERCTRL_H_ */ diff --git a/VexRiscvSocSoftware/libs/uart.h b/VexRiscvSocSoftware/libs/uart.h new file mode 100755 index 0000000..c3a30a5 --- /dev/null +++ b/VexRiscvSocSoftware/libs/uart.h @@ -0,0 +1,42 @@ +#ifndef UART_H_ +#define UART_H_ + + +typedef struct +{ + volatile uint32_t DATA; + volatile uint32_t STATUS; + volatile uint32_t CLOCK_DIVIDER; + volatile uint32_t FRAME_CONFIG; +} Uart_Reg; + +enum UartParity {NONE = 0,EVEN = 1,ODD = 2}; +enum UartStop {ONE = 0,TWO = 1}; + +typedef struct { + uint32_t dataLength; + enum UartParity parity; + enum UartStop stop; + uint32_t clockDivider; +} Uart_Config; + +static uint32_t uart_writeAvailability(Uart_Reg *reg){ + return (reg->STATUS >> 16) & 0xFF; +} +static uint32_t uart_readOccupancy(Uart_Reg *reg){ + return reg->STATUS >> 24; +} + +static void uart_write(Uart_Reg *reg, uint32_t data){ + while(uart_writeAvailability(reg) == 0); + reg->DATA = data; +} + +static void uart_applyConfig(Uart_Reg *reg, Uart_Config *config){ + reg->CLOCK_DIVIDER = config->clockDivider; + reg->FRAME_CONFIG = ((config->dataLength-1) << 0) | (config->parity << 8) | (config->stop << 16); +} + +#endif /* UART_H_ */ + + diff --git a/VexRiscvSocSoftware/libs/vga.h b/VexRiscvSocSoftware/libs/vga.h new file mode 100644 index 0000000..182b968 --- /dev/null +++ b/VexRiscvSocSoftware/libs/vga.h @@ -0,0 +1,78 @@ +/* + * vga.h + * + * Created on: Jul 8, 2017 + * Author: spinalvm + */ + +#ifndef VGA_H_ +#define VGA_H_ +#include <stdint.h> + +typedef struct { + uint32_t hSyncStart ,hSyncEnd; + uint32_t hColorStart,hColorEnd; + + uint32_t vSyncStart ,vSyncEnd; + uint32_t vColorStart,vColorEnd; +}Vga_Timing; + +static const Vga_Timing vga_h640_v480_r60 = { + .hSyncStart = 96, + .hSyncEnd = 800, + .hColorStart = 96 + 16, + .hColorEnd = 800 - 48, + .vSyncStart = 2, + .vSyncEnd = 525, + .vColorStart = 2 + 10, + .vColorEnd = 525 - 33 +}; + +static const Vga_Timing vga_simRes = { + .hSyncStart = 8, + .hSyncEnd = 70, + .hColorStart = 16, + .hColorEnd = 64, + .vSyncStart = 2, + .vSyncEnd = 48, + .vColorStart = 8, + .vColorEnd = 40 +}; + +static const Vga_Timing vga_simRes_h160_v120 = { + .hSyncStart = 8, + .hSyncEnd = 24+160, + .hColorStart = 16, + .hColorEnd = 16+160, + .vSyncStart = 2, + .vSyncEnd = 10+120, + .vColorStart = 6, + .vColorEnd = 6+120 +}; + +typedef struct +{ + volatile uint32_t STATUS; + volatile uint32_t FRAME_SIZE; + volatile uint32_t FRAME_BASE; + volatile uint32_t DUMMY0[13]; + volatile Vga_Timing TIMING; +} Vga_Reg; + +static uint32_t vga_isBusy(Vga_Reg *reg){ + return (reg->STATUS & 2) != 0; +} + +static void vga_run(Vga_Reg *reg){ + reg->STATUS = 1; +} + +static void vga_stop(Vga_Reg *reg){ + reg->STATUS = 0; + while(vga_isBusy(reg)); +} + + +#endif /* VGA_H_ */ + + |