Skip to content

Commit

Permalink
Merge pull request #3 from kasper201/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
kasper201 authored Mar 10, 2024
2 parents a937e78 + 6ece903 commit 1dd98d2
Show file tree
Hide file tree
Showing 1,070 changed files with 578,058 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Ignore node_modules directory
node_modules/

# Ignore build output
build/

# Ignore IDE and editor specific files
.vscode/
.idea/
*.sublime-project
*.sublime-workspace

# Ignore logs and other generated files
logs/
*.log
*.exe

# Ignore environment specific files
.env

# Ignore dependencies lock files
package-lock.json
yarn.lock
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# How to install and run the project will be put here:

## How to update images

Updating images is done by replacing the .coe files in the vivado project.

### How to convert png's to .coe files
1. locate the file you want to convert
2. download [matlab](https://www.mathworks.com/products/matlab.html)
3. open matlab
4. download the [converter]()
41 changes: 41 additions & 0 deletions Release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# What's changed

## Sprites
- Added enemy: angy wall-E
- Added enemy: CleaningRobot
- Added enemy: Evil Eve
- Added plant: moneyplant (sunflower like)
- Added plant: Pineapple
- Added plant: crazyPear
- Added plant: peashooterRO

## Game logic

### location handling
- Added location handling
- Added the ability to move enemies
- Added the ability to detect plants and stop moving
- Added the ability to change entity information based on location

### STM32
- Added the ability to read a button press

## GPU
- Added the ability to draw a sprite
- Added the ability to draw the background
- Added the ability to "green screen" the sprites

## Other
- Added the ability to use UART to communicate at 230400 baud

# Known bugs

## Sprites
- Borders have green artifacts

## Game logic
- There are currently no known bugs

## GPU
- Line on the left of the sprite
- improper border handling
7 changes: 7 additions & 0 deletions STM32/TestBenchForFPGA/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files.associations": {
"computercom.h": "c",
"uart.h": "c",
"string.h": "c"
}
}
14 changes: 14 additions & 0 deletions STM32/TestBenchForFPGA/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
set(DTS_OVERLAY_FILE ${CMAKE_SOURCE_DIR}/board/nucleo_f091rc.overlay)
project(TestBenchForFPGA)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})

# Add the path to the directory containing the missing header file
include_directories(
header/
)
2 changes: 2 additions & 0 deletions STM32/TestBenchForFPGA/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Uart toegevoegd aan de button sample
Kan een led aan en uit zetten op een fpga met de bijhoorende vhdl code
19 changes: 19 additions & 0 deletions STM32/TestBenchForFPGA/boards/nucleo_f030r8.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
&usart1{
pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
pinctrl-names = "default";
current-speed = <230400>;
status = "okay";
};

&usart2{
pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>;
pinctrl-names = "default";
current-speed = <115200>;
status = "okay";
};

/ {
aliases {
usart = &usart1;
};
};
19 changes: 19 additions & 0 deletions STM32/TestBenchForFPGA/boards/nucleo_f091rc.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
&usart1{
pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
pinctrl-names = "default";
current-speed = <115200>;
status = "okay";
};

&usart2{
pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>;
pinctrl-names = "default";
current-speed = <115200>;
status = "okay";
};

/ {
aliases {
usart = &usart1;
};
};
5 changes: 5 additions & 0 deletions STM32/TestBenchForFPGA/header/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifndef MAIN_H_
#define MAIN_H_


#endif //MAIN_H_
9 changes: 9 additions & 0 deletions STM32/TestBenchForFPGA/header/uart.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef UART_H_
#define UART_H_

extern struct k_msgq uart_msgq; // Declare uart_msgq here

int uartSetup(void);
void print_uart(char *buf);

#endif //UART_H_
3 changes: 3 additions & 0 deletions STM32/TestBenchForFPGA/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_GPIO=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_STDOUT_CONSOLE=y
158 changes: 158 additions & 0 deletions STM32/TestBenchForFPGA/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*
* Copyright (c) 2016 Open-RnD Sp. z o.o.
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*
* Connect pin 2 to A14 and pin 8 to A15
*/

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/printk.h>
#include <inttypes.h>
#include <string.h>

#include "uart.h"
#include "main.h"

#define SLEEP_TIME_MS 10

/*
* Get button configuration from the devicetree sw0 alias. This is mandatory.
*/
#define SW0_NODE DT_ALIAS(sw0)
#if !DT_NODE_HAS_STATUS(SW0_NODE, okay)
#error "Unsupported board: sw0 devicetree alias is not defined"
#endif
static const struct gpio_dt_spec button = GPIO_DT_SPEC_GET_OR(SW0_NODE, gpios,
{0});
static struct gpio_callback button_cb_data;

/*
* The led0 devicetree alias is optional. If present, we'll use it
* to turn on the LED whenever the button is pressed.
*/
static struct gpio_dt_spec led = GPIO_DT_SPEC_GET_OR(DT_ALIAS(led0), gpios,
{0});

void button_pressed(const struct device *dev, struct gpio_callback *cb,
uint32_t pins)
{
// printk("Button pressed at %" PRIu32 "\n", k_cycle_get_32());
}

int main(void)
{
int ret;

if (!gpio_is_ready_dt(&button))
{
printk("Error: button device %s is not ready\n",
button.port->name);
return 0;
}

ret = gpio_pin_configure_dt(&button, GPIO_INPUT);
if (ret != 0)
{
printk("Error %d: failed to configure %s pin %d\n",
ret, button.port->name, button.pin);
return 0;
}

ret = gpio_pin_interrupt_configure_dt(&button,
GPIO_INT_EDGE_TO_ACTIVE);
if (ret != 0)
{
printk("Error %d: failed to configure interrupt on %s pin %d\n",
ret, button.port->name, button.pin);
return 0;
}

gpio_init_callback(&button_cb_data, button_pressed, BIT(button.pin));
gpio_add_callback(button.port, &button_cb_data);
printk("Set up button at %s pin %d\n", button.port->name, button.pin);

if (led.port && !gpio_is_ready_dt(&led))
{
printk("Error %d: LED device %s is not ready; ignoring it\n",
ret, led.port->name);
led.port = NULL;
}
if (led.port)
{
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT);
if (ret != 0)
{
printk("Error %d: failed to configure LED device %s pin %d\n",
ret, led.port->name, led.pin);
led.port = NULL;
}
else
{
printk("Set up LED at %s pin %d\n", led.port->name, led.pin);
}
}

uartSetup();
int buttonPressed = 0;
int ledState = 0;
int ledActivated = 0;
char outToFpga;

printk("Start\n");
if (led.port)
{
while (1)
{
/* If we have an LED, match its state to the button's. */
int val = gpio_pin_get_dt(&button);

if (val >= 1 && buttonPressed <= 0)
{
if (ledState == 1)
{
ledState = 0;
}
else
{
ledState = 1;
}
buttonPressed = 1;
}
else if (val == 0 && buttonPressed >= 1)
{
buttonPressed = 0;
}

if (ledState == 1)
{
gpio_pin_set_dt(&led, 1);
if (ledActivated == 0)
{
outToFpga = 0x11;
print_uart(&outToFpga);
printk("Send 00010001\n");
ledActivated = 1;
}
}
else
{
gpio_pin_set_dt(&led, 0);
if (ledActivated == 1)
{
outToFpga = 0x88;
print_uart(&outToFpga);
printk("Send 10001000\n");
ledActivated = 0;
}
}

k_msleep(SLEEP_TIME_MS);
}
}
return 0;
}
Loading

0 comments on commit 1dd98d2

Please sign in to comment.