diff options
Diffstat (limited to 'eindopdracht-progh2-vitis')
9 files changed, 717 insertions, 0 deletions
diff --git a/eindopdracht-progh2-vitis/.gitignore b/eindopdracht-progh2-vitis/.gitignore new file mode 100644 index 0000000..9b16e22 --- /dev/null +++ b/eindopdracht-progh2-vitis/.gitignore @@ -0,0 +1,17 @@ +# Ignore build output directory +/build + + +# Ignore object files and dependent files +.o +.d + +#Ignore logs folder and log files +/logs +.log + +#Ignore lock files +.lock + +.bin +.pdi
\ No newline at end of file diff --git a/eindopdracht-progh2-vitis/app_component/.gitignore b/eindopdracht-progh2-vitis/app_component/.gitignore new file mode 100644 index 0000000..9b16e22 --- /dev/null +++ b/eindopdracht-progh2-vitis/app_component/.gitignore @@ -0,0 +1,17 @@ +# Ignore build output directory +/build + + +# Ignore object files and dependent files +.o +.d + +#Ignore logs folder and log files +/logs +.log + +#Ignore lock files +.lock + +.bin +.pdi
\ No newline at end of file diff --git a/eindopdracht-progh2-vitis/app_component/src/CMakeLists.txt b/eindopdracht-progh2-vitis/app_component/src/CMakeLists.txt new file mode 100644 index 0000000..15509f6 --- /dev/null +++ b/eindopdracht-progh2-vitis/app_component/src/CMakeLists.txt @@ -0,0 +1,77 @@ +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +# SPDX-License-Identifier: MIT +cmake_minimum_required(VERSION 3.16) + +include(${CMAKE_SOURCE_DIR}/Empty_applicationExample.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/UserConfig.cmake) +set(APP_NAME app_component) +project(${APP_NAME}) + +find_package(common) +enable_language(C ASM CXX) +collect(PROJECT_LIB_DEPS xilstandalone) +collect(PROJECT_LIB_DEPS xil) +collect(PROJECT_LIB_DEPS xiltimer) + + + + + + + + + + + + + + + + + + + + + + + + + +collect(PROJECT_LIB_DEPS gcc) +collect(PROJECT_LIB_DEPS c) + +aux_source_directory(${CMAKE_SOURCE_DIR} _sources) +foreach (source ${_sources}) + get_filename_component(ext ${source} EXT) + list(APPEND src_ext ${ext}) +endforeach() + +find_project_type ("${src_ext}" PROJECT_TYPE) + +if("${PROJECT_TYPE}" STREQUAL "c++") +collect(PROJECT_LIB_DEPS stdc++) +endif() +collector_list (_deps PROJECT_LIB_DEPS) +list (APPEND _deps ${USER_LINK_LIBRARIES}) + +if("${PROJECT_TYPE}" STREQUAL "c++") +string (REPLACE ";" ",-l" _deps "${_deps}") +endif() +if(CMAKE_EXPORT_COMPILE_COMMANDS) + set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}) + set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}) +endif() +linker_gen("${CMAKE_SOURCE_DIR}/linker_files/") +string(APPEND CMAKE_C_FLAGS ${USER_COMPILE_OPTIONS}) +string(APPEND CMAKE_CXX_FLAGS ${USER_COMPILE_OPTIONS}) +string(APPEND CMAKE_C_LINK_FLAGS ${USER_LINK_OPTIONS}) +string(APPEND CMAKE_CXX_LINK_FLAGS ${USER_LINK_OPTIONS}) +if(NOT "${_sources}" STREQUAL "") +set_source_files_properties(${_sources} OBJECT_DEPENDS "${CMAKE_LIBRARY_PATH}/*.a") +add_executable(${APP_NAME}.elf ${_sources}) +set_target_properties(${APP_NAME}.elf PROPERTIES LINK_DEPENDS ${CMAKE_SOURCE_DIR}/lscript.ld) +target_link_libraries(${APP_NAME}.elf -Wl,-T -Wl,\"${CMAKE_SOURCE_DIR}/lscript.ld\" -L\"${CMAKE_SOURCE_DIR}/\" -L\"${CMAKE_LIBRARY_PATH}/\" -L\"${USER_LINK_DIRECTORIES}/\" -Wl,--start-group,-l${_deps} -Wl,--end-group) +target_compile_definitions(${APP_NAME}.elf PUBLIC ${USER_COMPILE_DEFINITIONS}) +target_include_directories(${APP_NAME}.elf PUBLIC ${USER_INCLUDE_DIRECTORIES}) +print_elf_size(CMAKE_SIZE ${APP_NAME}) +endif() diff --git a/eindopdracht-progh2-vitis/app_component/src/Empty_applicationExample.cmake b/eindopdracht-progh2-vitis/app_component/src/Empty_applicationExample.cmake new file mode 100644 index 0000000..7aa8be4 --- /dev/null +++ b/eindopdracht-progh2-vitis/app_component/src/Empty_applicationExample.cmake @@ -0,0 +1,9 @@ +set(DDR lmb_bram_0) +set(lmb_bram_0 "0x50;0x7fb0") +set(TOTAL_MEM_CONTROLLERS "lmb_bram_0") +set(MEMORY_SECTION "MEMORY +{ + lmb_bram_0 : ORIGIN = 0x50, LENGTH = 0x7fb0 +}") +set(STACK_SIZE 0x400) +set(HEAP_SIZE 0x400) diff --git a/eindopdracht-progh2-vitis/app_component/src/UserConfig.cmake b/eindopdracht-progh2-vitis/app_component/src/UserConfig.cmake new file mode 100644 index 0000000..58cc778 --- /dev/null +++ b/eindopdracht-progh2-vitis/app_component/src/UserConfig.cmake @@ -0,0 +1,157 @@ +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +# SPDX-License-Identifier: MIT +cmake_minimum_required(VERSION 3.16) + +### USER SETTINGS START ### +# Below settings can be customized +# User need to edit it manually as per their needs. +### DO NOT ADD OR REMOVE VARIABLES FROM THIS SECTION ### +# ----------------------------------------- +# Add any compiler definitions, they will be added as extra definitions +# Example adding VERBOSE=1 will pass -DVERBOSE=1 to the compiler. +set(USER_COMPILE_DEFINITIONS +"" +) + +# Undefine any previously specified compiler definitions, either built in or provided with a -D option +# Example adding MY_SYMBOL will pass -UMY_SYMBOL to the compiler. +set(USER_UNDEFINED_SYMBOLS +"__clang__" +) + + +# Add any directories below, they will be added as extra include directories. +# Example 1: Adding /proj/data/include will pass -I/proj/data/include +# Example 2: Adding ../../common/include will consider the path as relative to this component directory. +# Example 3: Adding ${CMAKE_SOURCE_DIR}/data/include to add data/include from this project. + +set(USER_INCLUDE_DIRECTORIES +) + +# ----------------------------------------- + +# Turn on all optional warnings (-Wall) +set(USER_COMPILE_WARNINGS_ALL -Wall) + +# Enable extra warning flags (-Wextra) +set(USER_COMPILE_WARNINGS_EXTRA -Wextra) + +# Make all warnings into hard errors (-Werror) +set(USER_COMPILE_WARNINGS_AS_ERRORS ) + +# Check the code for syntax errors, but don't do anything beyond that. (-fsyntax-only) +set(USER_COMPILE_WARNINGS_CHECK_SYNTAX_ONLY ) + +# Issue all the mandatory diagnostics listed in the C standard (-pedantic) +set(USER_COMPILE_WARNINGS_PEDANTIC ) + +# Issue all the mandatory diagnostics, and make all mandatory diagnostics into errors. (-pedantic-errors) +set(USER_COMPILE_WARNINGS_PEDANTIC_AS_ERRORS ) + +# Suppress all warnings (-w) +set(USER_COMPILE_WARNINGS_INHIBIT_ALL ) + +# ----------------------------------------- + +# Optimization level "-O0" [None] , "-O1" [Optimize] , "-O2" [Optimize More], "-O3" [Optimize Most] or "-Os" [Optimize Size] +set(USER_COMPILE_OPTIMIZATION_LEVEL -O0) + +# Other flags related to optimization +set(USER_COMPILE_OPTIMIZATION_OTHER_FLAGS ) + +# ----------------------------------------- + +# Debug level "" [None], "-g1" [Minimum], "g2" [Default], "g3" [Maximim] +set(USER_COMPILE_DEBUG_LEVEL -g3) + +# Other flags releated to debugging +set(USER_COMPILE_DEBUG_OTHER_FLAGS ) + +# ----------------------------------------- + +# Enable Profiling (-pg) (This feature is not supported currently) +# set(USER_COMPILE_PROFILING_ENABLE ) + +# ----------------------------------------- + +# Verbose (-v) +set(USER_COMPILE_VERBOSE ) + +# Support ANSI_PROGRAM (-ansi) +set(USER_COMPILE_ANSI ) + +# Add any compiler options that are not covered by the above variables, they will be added as extra compiler options +# To enable profiling -pg [ for gprof ] or -p [ for prof information ] +set(USER_COMPILE_OTHER_FLAGS ) + +# ----------------------------------------- + +# Linker options +# Do not use the standard system startup files when linking. +# The standard system libraries are used normally, unless -nostdlib or -nodefaultlibs is used. (-nostartfiles) +set(USER_LINK_NO_START_FILES ) + +# Do not use the standard system libraries when linking. (-nodefaultlibs) +set(USER_LINK_NO_DEFAULT_LIBS ) + +# Do not use the standard system startup files or libraries when linking. (-nostdlib) +set(USER_LINK_NO_STDLIB ) + +# Omit all symbol information (-s) +set(USER_LINK_OMIT_ALL_SYMBOL_INFO ) + + +# ----------------------------------------- + +# Add any libraries to be linked below, they will be added as extra libraries. +# User need to update USER_LINK_DIRECTORIES below with these library paths. +set(USER_LINK_LIBRARIES +) + +# Add any directories to look for the libraries to be linked. +# Example 1: Adding /proj/compression/lib will pass -L/proj/compression/lib to the linker. +# Example adding Adding ../../common/lib will consider the path as relative to this directory. and will pass the path to -L option. +set(USER_LINK_DIRECTORIES +) + +# ----------------------------------------- + +set(USER_LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/lscript.ld") + +# Add linker options to be passed, they will be added as extra linker options +# Example : adding -s will pass -s to the linker. +set(USER_LINK_OTHER_FLAGS +) + +# ----------------------------------------- + +### END OF USER SETTINGS SECTION ### +### DO NOT EDIT BEYOND THIS LINE ### + +set(USER_COMPILE_OPTIONS + " ${USER_COMPILE_WARNINGS_ALL}" + " ${USER_COMPILE_WARNINGS_EXTRA}" + " ${USER_COMPILE_WARNINGS_AS_ERRORS}" + " ${USER_COMPILE_WARNINGS_CHECK_SYNTAX_ONLY}" + " ${USER_COMPILE_WARNINGS_PEDANTIC}" + " ${USER_COMPILE_WARNINGS_PEDANTIC_AS_ERRORS}" + " ${USER_COMPILE_WARNINGS_INHIBIT_ALL}" + " ${USER_COMPILE_OPTIMIZATION_LEVEL}" + " ${USER_COMPILE_OPTIMIZATION_OTHER_FLAGS}" + " ${USER_COMPILE_DEBUG_LEVEL}" + " ${USER_COMPILE_DEBUG_OTHER_FLAGS}" + " ${USER_COMPILE_VERBOSE}" + " ${USER_COMPILE_ANSI}" + " ${USER_COMPILE_OTHER_FLAGS}" +) +foreach(entry ${USER_UNDEFINED_SYMBOLS}) + list(APPEND USER_COMPILE_OPTIONS " -U${entry}") +endforeach() + +set(USER_LINK_OPTIONS + " ${USER_LINKER_NO_START_FILES}" + " ${USER_LINKER_NO_DEFAULT_LIBS}" + " ${USER_LINKER_NO_STDLIB}" + " ${USER_LINKER_OMIT_ALL_SYMBOL_INFO}" + " ${USER_LINK_OTHER_FLAGS}" +) diff --git a/eindopdracht-progh2-vitis/app_component/src/app.yaml b/eindopdracht-progh2-vitis/app_component/src/app.yaml new file mode 100644 index 0000000..7b2cb3b --- /dev/null +++ b/eindopdracht-progh2-vitis/app_component/src/app.yaml @@ -0,0 +1,3 @@ +domain_path: /home/loek/docs/repos/progh-huiswerk/eindopdracht-progh2-vitis/platform/export/platform/sw/standalone_microblaze_0 +app_src_dir: /mnt/e/Xilinx/Vitis/2023.2/data/embeddedsw/lib/sw_apps/empty_application +template: empty_application diff --git a/eindopdracht-progh2-vitis/app_component/src/lscript.ld b/eindopdracht-progh2-vitis/app_component/src/lscript.ld new file mode 100644 index 0000000..0e0fce6 --- /dev/null +++ b/eindopdracht-progh2-vitis/app_component/src/lscript.ld @@ -0,0 +1,211 @@ +/****************************************************************************** +* Copyright (C) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ + +_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x400; +_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x400; + +MEMORY +{ + lmb_bram_0 : ORIGIN = 0x50, LENGTH = 0x7fb0 +} + +/* Specify the default entry point to the program */ + +ENTRY(_start) + +/* Define the sections, and where they are mapped in memory */ + +SECTIONS +{ +.vectors.reset 0x0 : { + KEEP (*(.vectors.reset)) +} + +.vectors.sw_exception 0x8 : { + KEEP (*(.vectors.sw_exception)) +} + +.vectors.interrupt 0x10 : { + KEEP (*(.vectors.interrupt)) +} + +.vectors.hw_exception 0x20 : { + KEEP (*(.vectors.hw_exception)) +} + +.text : { + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) + *(.note.gnu.build-id) +} > lmb_bram_0 + +.init : { + KEEP (*(.init)) +} > lmb_bram_0 + +.fini : { + KEEP (*(.fini)) +} > lmb_bram_0 + +.ctors : { + __CTOR_LIST__ = .; + ___CTORS_LIST___ = .; + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __CTOR_END__ = .; + ___CTORS_END___ = .; +} > lmb_bram_0 + +.dtors : { + __DTOR_LIST__ = .; + ___DTORS_LIST___ = .; + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + PROVIDE(__DTOR_END__ = .); + PROVIDE(___DTORS_END___ = .); +} > lmb_bram_0 + +.drvcfg_sec : { + . = ALIGN(8); + __drvcfgsecdata_start = .; + KEEP (*(.drvcfg_sec)) + __drvcfgsecdata_end = .; + __drvcfgsecdata_size = __drvcfgsecdata_end - __drvcfgsecdata_start; +} > lmb_bram_0 + +.rodata : { + __rodata_start = .; + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + __rodata_end = .; +} > lmb_bram_0 + +.sdata2 : { + . = ALIGN(8); + __sdata2_start = .; + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + . = ALIGN(8); + __sdata2_end = .; +} > lmb_bram_0 + +.sbss2 : { + __sbss2_start = .; + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + __sbss2_end = .; +} > lmb_bram_0 + +.data : { + . = ALIGN(4); + __data_start = .; + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + __data_end = .; +} > lmb_bram_0 + +.got : { + *(.got) +} > lmb_bram_0 + +.got1 : { + *(.got1) +} > lmb_bram_0 + +.got2 : { + *(.got2) +} > lmb_bram_0 + +.eh_frame : { + *(.eh_frame) +} > lmb_bram_0 + +.jcr : { + *(.jcr) +} > lmb_bram_0 + +.gcc_except_table : { + *(.gcc_except_table) +} > lmb_bram_0 + +.sdata : { + . = ALIGN(8); + __sdata_start = .; + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + __sdata_end = .; +} > lmb_bram_0 + +.sbss (NOLOAD) : { + . = ALIGN(4); + __sbss_start = .; + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + . = ALIGN(8); + __sbss_end = .; +} > lmb_bram_0 + +.tdata : { + __tdata_start = .; + *(.tdata) + *(.tdata.*) + *(.gnu.linkonce.td.*) + __tdata_end = .; +} > lmb_bram_0 + +.tbss : { + __tbss_start = .; + *(.tbss) + *(.tbss.*) + *(.gnu.linkonce.tb.*) + __tbss_end = .; +} > lmb_bram_0 + +.bss (NOLOAD) : { + . = ALIGN(4); + __bss_start = .; + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + __bss_end = .; +} > lmb_bram_0 + +_SDA_BASE_ = __sdata_start + ((__sbss_end - __sdata_start) / 2 ); + +_SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2 ); + +/* Generate Stack and Heap definitions */ + +.heap (NOLOAD) : { + . = ALIGN(8); + _heap = .; + _heap_start = .; + . += _HEAP_SIZE; + _heap_end = .; +} > lmb_bram_0 + +.stack (NOLOAD) : { + _stack_end = .; + . += _STACK_SIZE; + . = ALIGN(8); + _stack = .; + __stack = _stack; +} > lmb_bram_0 + +_end = .; +} diff --git a/eindopdracht-progh2-vitis/app_component/src/main.c b/eindopdracht-progh2-vitis/app_component/src/main.c new file mode 100644 index 0000000..5055611 --- /dev/null +++ b/eindopdracht-progh2-vitis/app_component/src/main.c @@ -0,0 +1,208 @@ +// #include <sys/_types.h> +#include <sys/_types.h> +#include <xgpio.h> +#include <xil_printf.h> +#include <xil_types.h> +#include <xil_exception.h> +#include <xintc_l.h> +#include <xstatus.h> +#include <xparameters.h> +#include <xintc.h> + +#include <stdbool.h> +#include <stdint.h> +#include <stdlib.h> + +#define NOTE_ID XPAR_AXI_GPIO_AUX_OUT_BASEADDR +#define PS2_ID XPAR_AXI_GPIO_PS2_IN_BASEADDR +#define AUX_CHANNEL 1 +#define PS2_CHANNEL 1 +#define AUX_MASK 0xff +#define PS2_MASK 0xff + +#define LOWER_NOTE_INDEX 0 +#define UPPER_NOTE_INDEX 7 + +#define NOTE_F 0 +#define NOTE_G 1 +#define NOTE_A 2 +#define NOTE_B 3 +#define NOTE_C 4 +#define NOTE_D 5 +#define NOTE_E 6 +#define NOTE_F_HIGH 7 + +#define KEYCODE_F 0x2b +#define KEYCODE_G 0x34 +#define KEYCODE_A 0x1c +#define KEYCODE_B 0x32 +#define KEYCODE_C 0x21 +#define KEYCODE_D 0x23 +#define KEYCODE_E 0x24 +#define KEYCODE_UP 0xf0 + +#define TIMER_AANTAL 2 +#define PlayNoteTimer 0 +#define WrongNoteTimer 1 + +XIntc int_ctrl; +XGpio note_device, ps2_device; + +// game state +bool game_continue = true; +bool correct_note = false; +uint32_t target_note = 0; + +// quick 'n dirty delay +void sleep(unsigned long millis) { + unsigned arbitary_multiplier = 1000; + xil_printf("%lums delay ...", millis); + for (unsigned long i = 0; i < millis * arbitary_multiplier; i++) + asm("nop"); + xil_printf(" done\r\n"); +} + +// top.vhd NOTE_IDX +#define NOTE_IDX_MASK ((uint32_t) (0x000f)) +// top.vhd NOTE_PLAY +#define NOTE_PLAY_BIT ((uint32_t) (1 << 4)) +// top.vhd NOTE_WRONG +#define NOTE_WRONG_BIT ((uint32_t) (1 << 5)) + +uint32_t note_output = 0; +void _set_note_idx(uint32_t idx) { + note_output &= ~NOTE_IDX_MASK; + note_output |= (idx & NOTE_IDX_MASK); +} +void _set_note_play(bool play) { + note_output &= ~NOTE_PLAY_BIT; + if (play) note_output |= NOTE_PLAY_BIT; +} +void _set_note_wrong(bool wrong) { + note_output &= ~NOTE_WRONG_BIT; + if (wrong) note_output |= NOTE_WRONG_BIT; +} +void _note_flush() { + XGpio_DiscreteWrite(¬e_device, AUX_CHANNEL, note_output); +} + +void note_play(uint8_t note) { + _set_note_idx(note); + _set_note_play(true); + _set_note_wrong(false); + _note_flush(); +} +void note_wrong() { + _set_note_wrong(true); + _set_note_play(true); + _note_flush(); +} +void note_stop() { + _set_note_play(false); + _note_flush(); +} + +uint32_t note_to_key() { + if (target_note == NOTE_C) return KEYCODE_C; + if (target_note == NOTE_D) return KEYCODE_D; + if (target_note == NOTE_E) return KEYCODE_E; + if (target_note == NOTE_F) return KEYCODE_F; + if (target_note == NOTE_F_HIGH) return KEYCODE_F; + if (target_note == NOTE_G) return KEYCODE_G; + if (target_note == NOTE_A) return KEYCODE_A; + if (target_note == NOTE_B) return KEYCODE_B; + return KEYCODE_F; +} + +bool valid_key(uint8_t ps2_input) { + if (ps2_input == KEYCODE_C) return true; + if (ps2_input == KEYCODE_D) return true; + if (ps2_input == KEYCODE_E) return true; + if (ps2_input == KEYCODE_F) return true; + if (ps2_input == KEYCODE_G) return true; + if (ps2_input == KEYCODE_A) return true; + if (ps2_input == KEYCODE_B) return true; + return false; +} + +void handle_key(uint8_t ps2_input) { + xil_printf("ps2 0x%02x", ps2_input); + + // only react to keycodes for note names + if (!valid_key(ps2_input)) { + xil_printf(" (not a note)\r\n"); + return; + } + + if (game_continue) { + xil_printf(" (ignored, game running)\r\n"); + return; + } + + correct_note = ps2_input == note_to_key(); + xil_printf(" %s\r\n", correct_note ? "CORRECT" : "INCORRECT"); + game_continue = true; +} + +void ps2_int() { + static int ignore_cnt = 0; + + if (ignore_cnt > 0) { + ignore_cnt--; + return; + } + + uint32_t ps2_input = XGpio_DiscreteRead(&ps2_device, PS2_CHANNEL) & PS2_MASK; + + // ignore 0xf0 and next scancode (key up) + if (ps2_input == 0xf0) { + ignore_cnt = 1; + return; + } + + handle_key(ps2_input); +} + +int main() { + srand(6643); + + XGpio_Config *cfg_ptr; + + cfg_ptr = XGpio_LookupConfig(NOTE_ID); + XGpio_CfgInitialize(¬e_device, cfg_ptr, cfg_ptr->BaseAddress); + cfg_ptr = XGpio_LookupConfig(PS2_ID); + XGpio_CfgInitialize(&ps2_device, cfg_ptr, cfg_ptr->BaseAddress); + XGpio_SetDataDirection(&ps2_device, PS2_CHANNEL, PS2_MASK); + XGpio_SetDataDirection(¬e_device, AUX_CHANNEL, 0); + + // ps2 interrupt + XIntc_Initialize(&int_ctrl, XPAR_XINTC_0_BASEADDR); + XIntc_Connect(&int_ctrl, 0x0U, (XInterruptHandler) ps2_int, NULL); + XIntc_Start(&int_ctrl, XIN_REAL_MODE); + XIntc_Enable(&int_ctrl, 0x0U); + Xil_ExceptionInit(); + Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler)XIntc_InterruptHandler, &int_ctrl); + Xil_ExceptionEnable(); + + xil_printf("boot'd!\r\n"); + + // game loop + // game_continue is set from the key handler because the interrupt should return asap to prevent repeated calls + while (1) { + if (!game_continue) continue; + + if (!correct_note) { + note_wrong(); + sleep(500); + } + + target_note = (rand() % (UPPER_NOTE_INDEX - LOWER_NOTE_INDEX + 1)) + LOWER_NOTE_INDEX; + xil_printf("chose new note: %d\r\n", target_note); + note_play(target_note); + sleep(2000); + note_stop(); + + game_continue = false; + + } +} diff --git a/eindopdracht-progh2-vitis/app_component/vitis-comp.json b/eindopdracht-progh2-vitis/app_component/vitis-comp.json new file mode 100644 index 0000000..6a813cb --- /dev/null +++ b/eindopdracht-progh2-vitis/app_component/vitis-comp.json @@ -0,0 +1,18 @@ +{ + "name": "app_component", + "type": "HOST", + "platform": "/home/loek/docs/repos/progh-huiswerk/eindopdracht-progh2-vitis/platform/export/platform/platform.xpfm", + "domain": "standalone_microblaze_0", + "cpuInstance": "microblaze_0", + "cpuType": "microblaze", + "os": "standalone", + "configuration": { + "componentType": "HOST", + "hostToolchainConfigurations": [] + }, + "domainRealName": "standalone_microblaze_0", + "applicationFlow": "EMBEDDED", + "previousBuildStatusMap": { + "hw": "SUCCESS" + } +}
\ No newline at end of file |